Warrior_EA/AI/ArrayLayer.mqh

43 lines
1.7 KiB
MQL5
Raw Permalink Normal View History

refactor(AI): split 8 self-contained classes out of the Network.mqh god-file AI/Network.mqh was 5,805 lines / 18 classes in one file. Investigation found method implementations for several classes (CNeuronBase/Pool/Conv, CNeuronBaseOCL) hand-interleaved across thousands of lines - not safe to split without risky manual reassembly. But 8 classes turned out to be genuinely self-contained (declaration + every method body physically contiguous, and only ever depended upon, never depending on anything declared later): CConnection/CArrayCon, CNeuron, CDirectMLMy (+ its WarriorDML.dll/WarriorCPU.dll #import blocks), CArrayLayer, CLayerDescription, CBufferDouble, and CNeuronConvOCL/CNeuronPoolOCL. Extracted each verbatim, via exact line-range extraction (not manual retyping) to eliminate transcription risk, into its own AI/*.mqh file, included from Network.mqh at the exact point each class used to sit - preserving original declaration order exactly. Mathematically verified byte-for-byte: reconstructing the original file from the 7 new files' bodies + Network.mqh's remaining segments is line-for-line identical to the pre-split git history. Compiled clean (MetaEditor, 0 errors/0 warnings) both before and after. The remaining tangled classes (CNeuronBase, CNeuronPool, CNeuronConv, CNet, CNeuronLSTM, CNeuronBaseOCL, CNeuronConvOCL/PoolOCL's shared base, CNeuronLSTMOCL, COpenCLMy) stay in Network.mqh (now ~4,450 lines) - splitting those safely needs deliberate per-method surgery, deferred to a future dedicated pass rather than rushed into this one. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-07-18 16:13:03 -04:00
//+------------------------------------------------------------------+
//| ArrayLayer.mqh |
//| AnimateDread |
//| https://www.mql5.com |
//+------------------------------------------------------------------+
//| CArrayLayer - array-of-CLayer container, CNet's own topology |
//| storage. Needs CLayer (AI\Network.mqh) already declared - |
//| included from Network.mqh at the exact point this class used to |
//| sit (right after CLayer), so ordering matches the original file. |
//| Extracted verbatim (SOLID cleanup) - no logic changes. |
//+------------------------------------------------------------------+
class CArrayLayer : public CArrayObj
{
public:
CArrayLayer(void) {};
~CArrayLayer(void) {};
//---
virtual bool CreateElement(uint neurons, uint outputs);
virtual int Type(void) const { return defArrayLayer; }
};
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
bool CArrayLayer::CreateElement(uint neurons, uint outputs)
{
if(neurons <= 0)
return false;
//---
CLayer *layer = new CLayer(outputs);
if(CheckPointer(layer) == POINTER_INVALID)
return false;
//---
if(!layer.Reserve(neurons + 1))
return false;
for(uint i = 0; i <= neurons; i++)
{
if(!layer.CreateElement(i))
return false;
layer.IncreaseTotal();
}
//---
return (Add(layer));
}