00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef EVONET_H
00025 #define EVONET_H
00026
00027 #include "experimentsconfig.h"
00028 #include "parametersettable.h"
00029 #include <stdio.h>
00030 #include <math.h>
00031 #include <string.h>
00032 #include <iostream>
00033 #include <stdlib.h>
00034 #include <QString>
00035 #include <QStringList>
00036 #include <QColor>
00037 #include <QDebug>
00038 #include <QObject>
00039
00040 namespace farsa {
00041
00048 class FARSA_EXPERIMENTS_API Evonet : public QObject, public ParameterSettableWithConfigureFunction {
00049 Q_OBJECT
00050
00051 friend class NetworkDialog;
00052 friend class RendNetwork;
00053 signals:
00057 void evonetUpdated();
00058 public:
00060 static const int MAXSTOREDACTIVATIONS = 100;
00062 static const int MAXN = 1000;
00064 static const float DEFAULT_VALUE;
00075 void configure(ConfigurationParameters& params, QString prefix);
00085 void save(ConfigurationParameters& params, QString prefix);
00089 static void describe( QString type );
00095 void create_net_block( int inputNeuronType, int hiddenNeuronType, int outputNeuronType, bool recurrentHiddens, bool inputOutputConnections, bool recurrentOutputs, bool biasOnHidden, bool biasOnOutput );
00101 int load_net_blocks(const char *filename, int mode);
00102 void save_net_blocks(const char *filename, int mode);
00103 void readNewPheLine(QStringList, float*, float*);
00104 void readOldPheLine(QStringList, float*, float*);
00105 void updateNet();
00106 void computeParameters();
00107 int setInput(int inp, float value);
00108 float getOutput(int out);
00109 float getInput(int in);
00110 float getHidden(int h);
00111 void resetNet();
00112 int freeParameters();
00113 void getParameters(const int* dt);
00114 void getMutations(float* mut);
00115 void copyPheParameters(int* pheGene);
00116 void printIO();
00117 int getParamBias(int nbias);
00118 float getWrange();
00119 void injectHidden(int nh, float val);
00120 float logistic(float f);
00121 void printBlocks();
00122 int getNoInputs();
00123 int getNoHiddens();
00124 int getNoOutputs();
00125 int getNoNeurons();
00126 float getNeuron(int in);
00127 bool pheFileLoaded();
00128 Evonet();
00129 char neuronl[MAXN][10];
00130 int neurondisplay[MAXN];
00131 double neuronrange[MAXN][2];
00132 QColor neurondcolor[MAXN];
00133 bool neuronlesion[MAXN];
00134 double neuronlesionVal[MAXN];
00135 void setRanges(double weight, double bias, double gain);
00146 float* getOldestStoredActivations();
00147 private:
00148 int ninputs;
00149 int nhiddens;
00150 int noutputs;
00151 int nneurons;
00152 int net_nblocks;
00153 int net_block[MAXN][5];
00154 int neuronbias[MAXN];
00155 int neurontype[MAXN];
00156 int neurongain[MAXN];
00157 int neuronxy[MAXN][2];
00158 float wrange;
00159 float grange;
00160 float brange;
00161 int nparameters;
00162 int nparambias;
00163
00164 int neuronlesions;
00165
00166
00167 float act[MAXN];
00168 float storedActivations[MAXSTOREDACTIVATIONS][MAXN];
00169 int nextStoredActivation;
00170 int firstStoredActivation;
00171 float input[MAXN];
00172 float netinput[MAXN];
00173 float *freep;
00174 float *phep;
00175 bool pheloaded;
00176 float *muts;
00177 int geneMaxValue;
00178 float **selectedp;
00179 int nselected;
00180
00181 int p;
00182 int ndata;
00183
00184 int drawnymax;
00185 int drawnxmax;
00186
00187
00188 QString netFile;
00189 };
00190
00191 }
00192
00193 #endif