00001 #ifndef MIES_
00002 #define MIES_
00003
00004 #include "global.h"
00005
00006 class Individual;
00007
00009 class MixedIntegerES
00010 {
00011 public:
00012 MixedIntegerES(unsigned n_r_, unsigned n_z_, unsigned n_d_, unsigned n_sigma_r_, unsigned n_sigma_z_, unsigned n_prob_, unsigned n_f_,
00013 unsigned mu_, unsigned rho_, unsigned kappa_, unsigned lambda_,
00014 vector<double>& lBound_r_, vector<double>& uBound_r_, vector<int>& lBound_z_, vector<int>& uBound_z_,
00015 vector<int>& lBound_d_, vector<int>& uBound_d_, double prob_min_, double prob_max_,
00016 bool disRec_r_, bool disRec_z_, bool disRec_sigma_r_, bool disRec_sigma_z_, bool disRec_prob_,
00017 bool selfAdaptation_, vector<int>& direction_,
00018 unsigned evaluations_, vector<double>& optimalF_,
00019 double initialSigma_r_, double initialSigma_z_, double initialProb_,
00020 ifstream* initialPopFile_, int randomSeed_, bool feedback_);
00021 virtual ~MixedIntegerES();
00022
00024 virtual void run();
00025
00026 protected:
00027 unsigned n_r, n_z, n_d, n_sigma_r, n_sigma_z, n_prob, n_f;
00028 unsigned mu, rho, kappa, lambda;
00029 vector<double> lBound_r, uBound_r; vector<int> lBound_z, uBound_z, lBound_d, uBound_d; double prob_min, prob_max;
00030 bool disRec_r, disRec_z, disRec_sigma_r, disRec_sigma_z, disRec_prob;
00031 bool selfAdaptation; vector<double> maxSigma_r, maxSigma_z; vector<int> direction; vector<double> bestF;
00032 unsigned evaluations, generations, currGen; vector<double> optimalF;
00033 double initialSigma_r, initialSigma_z, initialProb;
00034 ifstream* initialPopFile; int randomSeed; bool feedback; bool debug; time_t id;
00035
00037 vector<Individual*> P;
00038
00040 vector<Individual*> O;
00041
00045 virtual void initialize();
00046
00048 virtual void evaluate();
00049
00051 virtual void simulate(Individual* I) = 0;
00052
00054 virtual void writePop(time_t id) = 0;
00055
00057 void increaseAge();
00058
00060 virtual void recombineMutate();
00061
00063 void recombineMutateSingleParent();
00064
00066 virtual void writeStep(time_t id) {}
00067
00068 void applyRecomb(Individual* I, vector<int>& parents);
00069
00070 void applyMut(Individual* I);
00071
00073 double transformR(double x, double a, double b);
00074
00076 int transformZ(int x, int a, int b);
00077
00079 double fixedConvergence(double x, double threshold, double varPart);
00080
00082 virtual void select() = 0;
00083
00085 virtual void writeLog(time_t elapsed, time_t id) = 0;
00086
00089 virtual bool optimumReached() = 0;
00090 };
00091
00092 class Individual
00093 {
00094 public:
00095 Individual() { feasible = true; age = 0; numDominating = 0; }
00096 Individual(unsigned n_r, unsigned n_z, unsigned n_d, unsigned n_sigma_r, unsigned n_sigma_z, unsigned n_prob, unsigned n_f,
00097 vector<double>& lBound_r, vector<double>& uBound_r, vector<int>& lBound_z, vector<int>& uBound_z,
00098 vector<int>& lBound_d, vector<int>& uBound_d, double prob_min, double prob_max,
00099 double initialSigma_r, double initialSigma_z, double initialProb);
00100 Individual(vector<double>& R_, vector<int>& Z_, vector<int>& D_,
00101 vector<double>& S_r_, vector<double>& S_z_, vector<double>& Prob_,
00102 vector<double>& F_, bool feasible_);
00103 Individual(Individual* original);
00104 ~Individual() {}
00105 void dump();
00106
00107
00108
00110 vector<double> R;
00111
00113 vector<int> Z;
00114
00116 vector<int> D;
00117
00118
00119
00121 vector<double> S_r;
00122
00124 vector<double> S_z;
00125
00127 vector<double> Prob;
00128
00130 vector<double> F;
00131
00132 bool feasible;
00133
00134 unsigned age;
00135
00137 unsigned numDominating;
00138 };
00139
00140 #endif