Main Page | Modules | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

MatrixController.h

Go to the documentation of this file.
00001 #ifndef __MATRIXCONTROLLER_H
00002 #define __MATRIXCONTROLLER_H
00003 
00004 #include "Controller.h"
00005 #include "GenotypeDecoder.h"
00006 #include "../utils/Matrix.h"
00007 #include <assert.h>
00008 #include <valarray>
00009 
00014 namespace Teem
00015 {
00020     class MatrixController : public Controller
00021     {
00022     public:
00023         Matrix<double> matrix; 
00024         std::valarray<double> bias; 
00025     
00026     public:
00028         MatrixController(unsigned inputCount, unsigned outputCount);
00030         virtual ~MatrixController() {}
00031         
00032         virtual void setInput(unsigned index, double val)
00033         {
00034             assert(index < input.size());
00035             input[index] = val;
00036         }
00037         
00038         virtual double getOutput(unsigned index)
00039         {
00040             assert(index < output.size());
00041             return output[index];
00042         }
00043         
00044         virtual void step();
00045     
00046     protected:
00047     
00049         std::valarray<double> input;
00050         
00052         std::valarray<double> output;
00053     };
00054     
00055     class Genome;
00056     
00059     class MatrixGenotypeDecoder : public GenotypeDecoder
00060     {
00061     protected:
00062         Ishtar::Variable<double> coefRange; 
00063         Ishtar::Variable<unsigned> evolveBias; 
00064         
00065     public:
00067         MatrixGenotypeDecoder(const std::string &root) :
00068             GenotypeDecoder(root),
00069             coefRange(root + ".coefRange", 1.0),
00070             evolveBias(root + ".evolveBias", 1) { }
00072         virtual ~MatrixGenotypeDecoder() { }
00073         
00074         virtual Genome* createGenome();
00075         virtual Controller* decode(Genome* genome);
00076     };
00077 }
00078 
00079 #endif

Generated on Mon Oct 24 17:38:25 2005 for Teem by  doxygen 1.4.2