00001
00025 #ifndef __NOLFINET_H__
00026 #define __NOLFINET_H__
00027
00028 #include <magic/mcoord.h>
00029 #include "annalee/nolfi.h"
00030
00031 class NolfiNet;
00032
00033
00034 namespace MagiC {
00035 class GDevice;
00036 class EPSDevice;
00037 }
00038
00039
00041
00042
00043
00044
00045
00046
00047
00049
00056 class NolfiCell : public Object {
00057 public:
00058
00059 NolfiCell () {make();}
00060 NolfiCell (const NolfiCell& other) {copy (other);}
00061
00062
00063 static void addGenesTo (Gentainer& g, int i, int types,
00064 int xsize, int ysize, const StringMap& params);
00065 void make ();
00066 void decodeFrom (const Gentainer& g, int i);
00067 void developAxon (Array<Coord2D>& result, double scale) const;
00068
00069
00070
00075 const Coord2D& pos () const {return mCoord;}
00076
00080 void setPos (const Coord2D& npos) {mCoord=npos;}
00081
00085 void setPos (double x, double y) {mCoord.moveTo (x, y);}
00086
00093 void setTipRadius (double r) {mTipRadius = r;}
00094
00099 void mapTo (int neuron) {mFinalID = neuron;}
00100
00101
00102
00103 void copy (const NolfiCell& o);
00104 OStream& operator>> (OStream& out) const;
00105
00112 void drawEPS (EPSDevice& dc, double scale) const;
00113
00115 void check () const;
00116
00117 protected:
00118
00119
00120
00121 bool mExpression;
00122 Coord2D mCoord;
00123 double mSegmentAngle;
00124 double mSegmentLength;
00125 double mWeight;
00126 double mBias;
00127 int mTypeID;
00128
00129
00130
00131 double mTipRadius;
00132 int mFinalID;
00133 int mFinalType;
00134
00135 friend class NolfiNet;
00136
00137 private:
00138 static String smAxonString;
00139 };
00140
00141 enum celltypes {CT_NONE=-1, CT_INPUT=0, CT_HIDDEN=1, CT_OUTPUT=2};
00142 enum cellids {EMPTYID=-1};
00143
00144
00146
00147
00148
00149
00150
00151
00152
00154
00158 class NolfiNet : public Object {
00159 public:
00160
00161 NolfiNet (int inputs, int hiddens, int outputs,
00162 double xsize, double ysize, double tipRadius,
00163 double axonScale);
00164
00165 virtual void decodeFrom (const Gentainer& g);
00166 virtual ANNetwork* growNet ();
00167
00168
00169
00170 virtual OStream& operator>> (OStream& out) const;
00171 String drawEPS () const;
00172
00173 protected:
00174 Array<NolfiCell> cells;
00175 double mSize;
00176 int mInputs;
00177 int mHiddens;
00178 int mMaxHidden;
00179 int mOutputs;
00180 double mXSize;
00181 double mYSize;
00182 double mInputBorder;
00183 double mOutputBorder;
00184 double mTipRadius;
00185 double mAxonScale;
00186
00187 protected:
00194 virtual bool indexCells ();
00195
00201 virtual void resolveTypes (int& inputs, int& hiddens, int& outputs);
00202
00204 virtual void indexInputs ();
00205
00207 virtual void indexHiddens (int hiddens);
00208
00210 virtual void indexOutputs (int hiddens);
00211
00213 virtual void removeDuplicates (int& rOutputs);
00214
00220 virtual int connect (ANNetwork& net) const;
00221 };
00222
00223 #endif
00224