MTK++ Latest version: 0.2.0

gaRegion.h
Go to the documentation of this file.
00001 
00033 #ifndef GAREGION_H
00034 #define GAREGION_H
00035 
00036 #include <iostream>
00037 #include <string>
00038 #include <vector>
00039 #include <stdio.h>
00040 #include <stdlib.h>
00041 
00042 #include "Utils/constants.h"
00043 
00044 namespace MTKpp
00045 {
00046 
00047 class gaWorld;
00048 class gaPopulation;
00049 class gaIndividual; //temp
00050 class gaGene;
00051 class gaOperators;
00052 class gaOutput;
00053 
00054 // ============================================================
00055 // Class : gaRegion()
00056 // ------------------------------------------------------------
00064 // ============================================================
00065 
00066 class gaRegion
00067 {
00068     friend class gaPopulation;
00069     friend class gaGene;
00070     friend class gaOperators;
00071     friend class gaOutput;
00072 public:
00073 
00078     gaRegion(gaWorld *parent = 0);
00079 
00081     virtual ~gaRegion();
00082 
00107     void setup(const int& maxInds, const int& seed, const int& maxGens, 
00108                const int& elitism, const double& selectionPressure, 
00109                const int& curPop, const int& popKeep, const int& nChild, const double& chreDiff,
00110                const double& pKeep, const double& pCrossover, 
00111                const double& pMutate, const double& pAverage,
00112                const std::string& selection, const std::string& crossover,
00113                const std::string& mutate, const std::string& average,
00114                const std::string& funcDir,
00115                std::vector<double> maxParameters, std::vector<double> minParameters,
00116                std::vector<double> stepSize);
00117 
00122     gaPopulation* addPopulation();
00123 
00128     void delPopulation(gaPopulation* pop);
00129 
00137     gaPopulation* getPopulation(const int& number, bool id, bool index);
00138 
00143     std::vector<gaPopulation*> getPopulations();
00144 
00149     int getNumPopulations();
00150 
00154     void initialize();
00155 
00159     void nextGeneration();
00160 
00161     //------------//
00162     // - get/set -//
00163     //------------//
00164 
00169     void setId(int id);
00170 
00175     int getId();
00176 
00181     void setName(std::string name);
00182 
00187     std::string getName();
00188 
00193     gaWorld* getParent();
00194 
00199     void setFitness(double d);
00200 
00205      std::vector<double> getFitness();
00206 
00211     void setMinParameters(std::vector<double> m);
00212 
00220     double getMinParameter(const int& chr, const int& gen, const int& pos);
00221 
00226     void setMaxParameters(std::vector<double> m);
00227 
00235     double getMaxParameter(const int& chr, const int& gen, const int& pos);
00236 
00241     void setStepSizes(std::vector<double> s);
00242 
00250     double getStepSize(const int& chr, const int& gen, const int& pos);
00251 
00256     int getMaxGens();
00257 
00260 
00264     void setGeneValues(std::vector<std::vector<double> > gVs);
00265 
00271     std::vector<double> getGeneValues(const int& gen);
00272 
00273 protected:
00275     typedef std::vector<gaPopulation*>::iterator populationIterator;
00276 
00278     std::vector<gaPopulation*>    itsPopulationList;
00279 
00281     gaWorld*                      pParent;
00282 
00284     gaPopulation*                 pGaPopulation;
00285 
00287     gaPopulation*                 pPreviousGaPop;
00288 
00293     gaOperators*                  pGaOperators;
00294 
00295     //-----------------------------//
00296     // - Options from Input file - //
00297     //-----------------------------//
00298 
00300     int                           maxInds;
00301 
00303     int                           seed;
00304 
00306     int                           maxGens;
00307 
00309     int                           elitism;
00310 
00319     double                        selectionPressure;
00320 
00322     int                           curPop;
00323 
00325     int                           nChild;
00326 
00328     double                        chreDiff;
00329 
00331     int                           popKeep;
00332 
00337     double                        pKeep;
00338 
00343     double                        pCrossover;
00344 
00349     double                        pMutate;
00350 
00355     double                        pAverage;
00356 
00361     std::string                   selection;
00362 
00367     std::string                   crossover;
00368 
00373     std::string                   mutate;
00374 
00379     std::string                   average;
00380 
00384     std::string                   funcDir;
00385 
00387     std::vector<double>           maxParameters;
00388 
00390     std::vector<double>           minParameters;
00391 
00393     std::vector<double>           stepSize;
00394 
00396     std::vector<std::vector<double> > geneValues;
00397 
00398     //-----------------------------//
00399     // - Options from world file - //
00400     //-----------------------------//
00401 
00403     std::string                   itsName;
00404 
00406     int                           itsId;
00407 
00409     std::vector<double>           popConv;
00410 
00411 };
00412 
00413 } // MTKpp namespace
00414 
00415 #endif // GAREGION_H

Generated on Fri Dec 23 2011 09:28:50 for MTK++ by Doxygen 1.7.5.1