soml.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef __SOML_H
00020 #define __SOML_H
00021
00022 #include <selforg/abstractcontroller.h>
00023 #include <selforg/controller_misc.h>
00024 #include <selforg/controllernet.h>
00025
00026 #include <assert.h>
00027 #include <cmath>
00028
00029 #include <selforg/matrix.h>
00030
00031
00032 struct SoMLConf {
00033 bool useHiddenContr;
00034
00035 double hiddenContrUnitsRatio;
00036 bool useHiddenModel;
00037
00038 double hiddenModelUnitsRatio;
00039 bool useS;
00040 bool initUnitMatrix;
00041
00042 bool someInternalParams;
00043 };
00044
00045
00046
00047
00048
00049 class SoML : public AbstractController {
00050
00051 public:
00052 SoML(const SoMLConf& conf = getDefaultConf());
00053
00054 static SoMLConf getDefaultConf(){
00055 SoMLConf c;
00056 c.useHiddenContr = true;
00057 c.useHiddenModel = true;
00058 c.hiddenContrUnitsRatio = 1.0;
00059 c.hiddenModelUnitsRatio = 1.0;
00060 c.someInternalParams=false;
00061 c.useS = false;
00062 c.initUnitMatrix = true;
00063 return c;
00064 }
00065
00066 virtual void init(int sensornumber, int motornumber, RandGen* randGen = 0);
00067
00068 virtual ~SoML();
00069
00070
00071 virtual int getSensorNumber() const { return number_sensors; }
00072
00073 virtual int getMotorNumber() const { return number_motors; }
00074
00075
00076
00077 virtual void step(const sensor* , int number_sensors, motor* , int number_motors);
00078
00079
00080 virtual void stepNoLearning(const sensor* , int number_sensors,
00081 motor* , int number_motors);
00082
00083
00084 virtual void motorBabblingStep(const sensor* , int number_sensors,
00085 const motor* , int number_motors);
00086
00087
00088
00089
00090 virtual bool store(FILE* f) const;
00091
00092 virtual bool restore(FILE* f);
00093
00094
00095 virtual ControllerNet* getCNet();
00096
00097 protected:
00098
00099 void control(const matrix::Matrix& x, motor* y_, int number_motors);
00100
00101
00102
00103
00104 virtual void learn(const matrix::Matrix& x, const matrix::Matrix& y);
00105
00106
00107
00108 virtual void learnModelBP(double factor);
00109
00110 protected:
00111 unsigned short number_sensors;
00112 unsigned short number_motors;
00113 static const unsigned short buffersize = 10;
00114
00115 matrix::Matrix y_buffer[buffersize];
00116 matrix::Matrix x_buffer[buffersize];
00117 ControllerNet* cNet;
00118 unsigned int numControllerLayer;
00119
00120 SoMLConf conf;
00121
00122 matrix::Matrix x;
00123 matrix::Matrix x_smooth;
00124 matrix::Matrix eta_avg;
00125 int t;
00126 double E;
00127
00128 paramval creativity;
00129 paramval epsC;
00130 paramval epsA;
00131 paramval harmony;
00132 paramval dampA;
00133 paramval discountS;
00134 paramint s4avg;
00135 paramint s4delay;
00136 paramval biasnoise;
00137 parambool loga;
00138
00139
00140
00141 };
00142
00143 #endif
00144
00145