Main Page   Class Hierarchy   Compound List   File List   Compound Members   File Members  

nolfinet.h

Go to the documentation of this file.
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 // Externals
00034 namespace MagiC {
00035     class GDevice;
00036     class EPSDevice;
00037 }
00038 
00039 
00041 //                                                                          //
00042 //                    |   |      |     o  ___        | |                    //
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     // Access functions
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     // Object handling and IO
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     // Basic model attributes
00120 
00121     bool    mExpression;    //< Existence of the neuron.
00122     Coord2D mCoord;         //< Coordinates.
00123     double  mSegmentAngle;  //< Axon segment angle.
00124     double  mSegmentLength; //< Axon segment length.
00125     double  mWeight;        //< Initial weight for all the connections.
00126     double  mBias;          //< Initial bias.
00127     int     mTypeID;        //< I/O neuron semantical identifier.
00128     
00129     // Additional attributes
00130 
00131     double  mTipRadius;     //< Connection radius from axon tips and branching points.
00132     int     mFinalID;       //< Neuron index in the final brain.
00133     int     mFinalType;     //< input, hidden, output or none.
00134 
00135     friend class NolfiNet;
00136 
00137   private:
00138     static String   smAxonString; //< Axon description string generated with a L-System
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 //                    |   |      |     o |   |                              //
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     // Implementations
00169     
00170     virtual OStream&        operator>>          (OStream& out) const;
00171     String                  drawEPS             () const;
00172     
00173   protected:
00174     Array<NolfiCell>    cells;          //< The cells in the cell space
00175     double              mSize;          //< The size of the 2d-space
00176     int                 mInputs;        //< Number of input cells in the final network
00177     int                 mHiddens;       //< Number of hidden cells in the final network
00178     int                 mMaxHidden;     //< Maximum number of hidden cells in the final network
00179     int                 mOutputs;       //< Number of output cells in the final network
00180     double              mXSize;         //< X-size of the cell space.
00181     double              mYSize;         //< Y-size of the cell space.
00182     double              mInputBorder;   //< Size of the input-portion of the cell space. Default is 0.3.
00183     double              mOutputBorder;  //< 1 - size of the output-portion of the cell space. Default is 0.75.
00184     double              mTipRadius;     //< Global axon tip radius. Default is 0.5.
00185     double              mAxonScale;     //< Axon scaling factor. Default is 1.0.
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 

Generated on Thu Feb 10 20:21:26 2005 for Annalee by doxygen1.2.18