InputGeneratorTwoClasses.hpp

Go to the documentation of this file.
00001 #ifndef __INUTGENERATORTWOCLASSES_H
00002 #define __INUTGENERATORTWOCLASSES_H
00003 
00004 #include <Random.hpp>
00005 #include "IInputGenerator.hpp"
00006 
00007 class InputGeneratorTwoClasses : public IInputGenerator
00008 {
00009 public: 
00010   InputGeneratorTwoClasses(double width, double height)
00011   {
00012     m_input.push_back(0.0);
00013     m_input.push_back(0.0);
00014     m_output.push_back(0.0);
00015     m_output.push_back(0.0);
00016     m_width = width;
00017     m_height = height;
00018     m_dimension = 2;
00019   }
00020   
00021   virtual Vector GetOutput()
00022   {
00023     return m_output;
00024   }
00025 
00029   virtual Vector GetInput()
00030   {
00031     double x = Random::Randomize();
00032     if(x < 0.0)
00033     {
00034       m_input[0] = -1.0 - x * m_width;
00035       m_output[0] = 0.0;
00036       m_output[1] = 1.0;
00037     }
00038     else
00039     {
00040       m_input[0] = 1.0 - x * m_width;
00041       m_output[0] = 1.0;
00042       m_output[1] = 0.0;
00043     }
00044 
00045     m_input[1] = Random::Randomize() * m_height;
00046     
00047     return m_input;
00048   }
00049   
00053   virtual Vector const & GetLastInput() const { return m_input; }  
00054 
00058   virtual unsigned int GetDimension() const { return m_dimension; }
00059   
00060   virtual double GetWidth() { return m_width; }
00061   virtual double GetHeight() { return m_height; }
00062 
00066   virtual GeneratorType GetGeneratorType() const { return ClassesGenerator; }
00067   
00068 protected:
00069   unsigned int m_dimension;
00070   double m_width;
00071   double m_height;
00072   Vector m_input;  
00073 };
00074 
00075 
00079 class InputRepresentationTwoClasses : public IGLInputRepresentation
00080 {
00081 public:
00082   InputRepresentationTwoClasses(InputGeneratorTwoClasses * i) : m_inputGenerator(*i) {}
00083     virtual ~InputRepresentationTwoClasses() {}
00084 
00085   virtual void GLOutputDistribution() const
00086   {
00087     double width = m_inputGenerator.GetWidth();
00088     double height = m_inputGenerator.GetHeight();
00089 
00090     double yMin = -height;
00091     double yMax = height;
00092     double xMin = -1.0 + width;
00093     double xMax = 1.0 - width;
00094 
00095     glColor4f(0.6, 0.6, 0.6, 1.0);
00096     glRectd(-1.0,yMin, xMin,yMax);  
00097     glColor4f(0.8, 0.8, 0.8, 1.0);
00098     glRectd(1.0,yMin, xMax,yMax);  
00099   }
00100   
00101   virtual void GLOutputSignal() const 
00102   {    
00103     Vector const & v = m_inputGenerator.GetLastInput();
00104     glBegin(GL_POINTS);
00105     {           
00106       glVertex2d(v[0], v[1]);
00107     }    
00108     glEnd();
00109   }
00110   
00111 private:
00112   InputGeneratorTwoClasses & m_inputGenerator;
00113 };
00114 
00115 
00116 #endif

Generated on Mon Mar 22 16:40:48 2004 for GNG_GL by doxygen 1.3.6