Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members  

SIG_GPIndividual.h

00001 #ifndef SIGEL_GP_SIG_GPINDIVIDUAL_H
00002 #define SIGEL_GP_SIG_GPINDIVIDUAL_H
00003 
00004 #include "SIGEL_Program/SIG_Program.h"
00005 #include "SIGEL_Tools/SIG_Randomizer.h"
00006 #include "SIGEL_GP/SIG_GPParameter.h"
00007 #include "SIGEL_Robot/SIG_LanguageParameters.h"
00008 #include "SIGEL_Tools/SIG_IO.h"
00009 
00010 #include <qstring.h>
00011 #include <qstringlist.h>
00012 #include <qdatetime.h>
00013 #include <qtextstream.h>
00014 #include <qfile.h>
00015 
00016 
00017 namespace SIGEL_GP
00018 {
00019 
00026 class SIG_GPIndividual{
00027 
00032  private:
00033   long age;
00034 
00039  private:
00040   QStringList history;
00041 
00046  private:
00047   SIGEL_Program::SIG_Program prog;
00048 
00053  private:
00054   QString indName;
00055 
00060  private:
00061   int poolPos;
00062 
00063 
00069  private:
00070   double fitnessValue;
00071 
00080  /*
00081  * The constructor of an individual, used for creating an individual randomly.
00082  * @pre
00083  * There must be a pool to place the individual.
00084  * @post
00085  * The individual object is created correctly, the history is updated and the individual 
00086  * is placed in the right place.
00087  * @param param
00088  * The parameter which contains the probabilities and datas about the individual.
00089  * @param random
00090  * A reference to the randomizer module.
00091  * @param name
00092  * The name of the new individual.
00093  * @param birthtime
00094  * The time of birth of the individual.
00095  * @param poolpos
00096  * The position where the individual is to place.
00097  */
00098 
00099  public:
00100  SIG_GPIndividual();
00101 
00102 
00103  public:
00104  SIG_GPIndividual( SIG_GPParameter& param, 
00105                    SIGEL_Tools::SIG_Randomizer& random, 
00106                    QString name, 
00107                    QDateTime birthtime, 
00108                    int poolpos );
00109 
00128  public:
00129  SIG_GPIndividual( SIG_GPParameter const& param, 
00130                    QStringList const& hist, 
00131                    QString name, 
00132                    QDateTime birthtime, 
00133                    int poolpos );
00134 
00135 
00142  public:
00143  SIG_GPIndividual( SIGEL_Tools::SIG_Randomizer& random );
00144 
00145  public:
00146  SIG_GPIndividual( SIGEL_Tools::SIG_Randomizer &random,
00147                    SIGEL_GP::SIG_GPParameter& param, 
00148                    SIGEL_Robot::SIG_LanguageParameters& languageP );
00149 
00170  public:
00171  SIG_GPIndividual( SIGEL_Program::SIG_Program const& prog, 
00172                    QString name, 
00173                    QString hist, 
00174                    QDateTime birthtime, 
00175                    int poolpos );
00176 
00187  public:
00188  SIG_GPIndividual(QString data);
00189 
00190 
00194  public:
00195  ~SIG_GPIndividual();
00196  
00197 
00198 
00206  public:
00207  void increaseAge();
00208 
00214  public:
00215   long getAge() const;
00216 
00226  public:
00227  void importProgram(SIGEL_Program::SIG_Program& prog );
00228 
00235  public:
00236  QString getName();
00237 
00245  public:
00246  void loadIndividual(QString data); 
00247 
00255  public:
00256  QString saveIndividual();
00257  
00264  public:
00265  void copyIndividual(SIGEL_GP::SIG_GPIndividual &cInd,int poolPos);  
00266  
00275  public:
00276  int getPoolPos() const;
00277 
00288  public:
00289  SIGEL_Program::SIG_Program const& getProgram() const;
00290  
00302  public:
00303  SIGEL_Program::SIG_Program& getProgramVar();
00304 
00305 
00306 
00307   //SIGEL_Program::SIG_Program const& SIGEL_GP::SIG_GPIndividual::getProgram() const{};
00308 
00322  public:
00323  void setFitness(double fit);
00324 
00331  public:
00332  double getFitness() const;
00333 
00339  public:
00340  QStringList getHistory() const;
00341 
00357  public:
00358  void addMutationInfo(QString name, QDateTime time, int mutpoint);
00359 
00364  public:
00365  void addMutationInfo(QString name, QDateTime time, int mutpoint, double fit);
00384  public:
00385  void addCrossOverInfo(QString name1, QString name2, QDateTime time, int xoverpnt1, int xoverpnt2);
00386 
00393  public:
00394  void SIGEL_GP::SIG_GPIndividual::addCrossOverInfo(QString name1, 
00395                                                   QString name2, 
00396                                                   QDateTime time, 
00397                                                   int xoverpnt1, 
00398                                                   int xoverpnt2,
00399                                                   double fitness1,
00400                                                   double fitness2 );
00401 
00402 
00403 
00409  public:
00410  void addLengthIncreasedInfo( QDateTime time, long lgth );
00411 
00417  public:
00418  void addLengthDecreasedInfo( QDateTime time, long lgth );
00419  
00420 
00426  public:
00427  SIG_GPIndividual( SIGEL_Program::SIG_Program const& prog, 
00428                    QString name1, 
00429                    QString name2, 
00430                    QString name3, 
00431                    QDateTime birthtime, 
00432                    int poolpos,
00433                    QStringList const& hist );
00434 
00449  public:
00450  void addReproductionInfo(QString name, QDateTime time);
00451 
00456  public:
00457  void addImportIndividualInfo(QDateTime time);
00458 
00463  public:
00464  void addImportProgramInfo(QDateTime time);
00465 
00471  public:
00472  void addPreparationOfHistoryInfo();
00473  
00481  public:
00482  bool upToDate() const;
00483 
00490  public:
00491  SIGEL_Program::SIG_Program *getProgramPointer();
00492 
00499  public:
00500  void setPoolPos(int pp);
00501 
00508  public:
00509  void setAge(long a);
00510 
00517  public:
00518  void setName(QString n);
00519 
00527  public:
00528  void writeToFile(QTextStream &file);
00529 
00537  public:
00538  void readFromFile(QString indStr);
00539  
00540 
00548  public:
00549  SIGEL_GP::SIG_GPIndividual& operator =(SIGEL_GP::SIG_GPIndividual& ind); 
00550 
00551  public:
00552  void generateRandomIndividual(SIGEL_Tools::SIG_Randomizer& random,
00553                                SIGEL_GP::SIG_GPParameter& param, 
00554                                SIGEL_Robot::SIG_LanguageParameters& languageP);
00562 public:
00563  void increaseAgeInfo();
00564 
00572 public:
00573  void setFitnessInfo();
00574 
00582 public:
00583  void setPoolPosInfo();
00584 
00592 public:
00593  void setAgeInfo();
00594 
00602 public:
00603  void setNameInfo();
00604 
00605  
00610 public:
00611  void importIndividual( QString& filename );
00612 
00617 public:
00618  void exportIndividual( QString& filename );
00619 
00625 public:
00626  void print();
00627 
00633 public:
00634  void importProgram( QString& filename );
00635 
00640 public:
00641  void exportProgram( QString& filename );
00642 
00648 public:
00649  void setHistory( QStringList hist );
00650 
00651 };
00652 }
00653 
00654 #endif // SIGEL_GP_SIG_GPINDIVIDUAL_H
00655 
00656 
00657 
00658 
00659 
00660 
00661 
00662 
00663 
00664 
00665 
00666 

Generated at Mon Sep 3 01:32:23 2001 for PG 368 - SIGEL by doxygen1.2.3 written by Dimitri van Heesch, © 1997-2000