00001 00025 #ifndef __INANNA_TOPOLOGY_H__ 00026 #define __INANNA_TOPOLOGY_H__ 00027 00028 #include "inanna/annetwork.h" 00029 00030 // Predeclarations 00031 class ANNetwork; 00032 00033 00034 00036 // _ | | | | ----- | // 00037 // / \ |\ | |\ | | -- | // 00038 // / \ | \ | | \ | | __ | ) __ | __ ___ \ | // 00039 // |---| | \| | \| | / \ |-- / \ | / \ ( \ \ | // 00040 // | | | | | | | \__/ | \__/ | \__/ ---/ \_/ // 00041 // __/ \_/ // 00043 00048 class ANNTopology { 00049 public: 00050 virtual ~ANNTopology (); 00051 00052 virtual void build (ANNetwork& network) const=0; 00053 virtual void empty ()=0; 00054 protected: 00055 }; 00056 00057 00058 00060 // _ | | | | | o // 00061 // / \ |\ | |\ | | ___ ___ _ // 00062 // / \ | \ | | \ | | ___| \ | / ) |/\ | |/ \ ___ // 00063 // |---| | \| | \| | ( | \ | |--- | | | | ( \ // 00064 // | | | | | | |____ \__| \_/ \__ | | | | ---/ // 00065 // \_/ __/ // 00067 00071 class ANNLayering : public Object { 00072 public: 00073 00078 ANNLayering (const char* description=NULL) {make (description);} 00079 virtual ~ANNLayering (); 00080 void make (const char* description); 00081 int layerIndex (int layer) const; 00082 void getPos (int i, int& layerno, int& layerpos) const; 00083 00086 int totalUnits () const { 00087 return layerIndex(mLayers.size()-1)+mLayers[mLayers.size()-1];} 00088 00090 int layers () const {return mLayers.size();} 00091 String toString () const; 00092 00099 int layerSize (int i) const {return mLayers [(i<0)?mLayers.size()+i:i];} 00100 00107 int operator[] (int i) const {return mLayers [(i<0)?mLayers.size()+i:i];} 00108 00115 int& operator[] (int i) {return mLayers [(i<0)?mLayers.size()+i:i];} 00116 00119 void empty () {mLayers.empty();} 00120 00122 void operator= (const ANNLayering& o) {mLayers=o.mLayers;} 00123 00127 void removeLayer (int i) {mLayers.removeFill(i);} 00128 00129 protected: 00130 Array<int> mLayers; 00131 }; 00132 00133 00134 00136 // | | ----- | // 00137 // | ___ ___ ___ | | -- | // 00138 // | ___| \ | / ) |/\ / ) ---| | __ | ) __ | __ ___ \ | // 00139 // | ( | \ | |--- | |--- ( | | / \ |-- / \ | / \ ( \ \ | // 00140 // |____ \__| \_/ \__ | \__ ---| | \__/ | \__/ | \__/ ---/ \_/ // 00141 // \_/ __/ \_/ // 00143 00146 class LayeredTopology : virtual public ANNTopology, public ANNLayering { 00147 public: 00148 00153 LayeredTopology (const char* description=NULL) {make (description);} 00154 virtual ~LayeredTopology (); 00155 00156 virtual void build (ANNetwork& network) const; 00157 00160 virtual void empty () {ANNLayering::empty();} 00161 00162 protected: 00163 }; 00164 00165 00170 #endif 00171