00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #ifndef MOEOITERATEDIBMOLS_H_
00014 #define MOEOITERATEDIBMOLS_H_
00015
00016 #include <eoContinue.h>
00017 #include <eoEvalFunc.h>
00018 #include <eoOp.h>
00019 #include <eoPop.h>
00020 #include <utils/rnd_generators.h>
00021 #include <moMove.h>
00022 #include <moMoveInit.h>
00023 #include <moNextMove.h>
00024 #include <algo/moeoIBMOLS.h>
00025 #include <algo/moeoLS.h>
00026 #include <archive/moeoArchive.h>
00027 #include <fitness/moeoIndicatorBasedFitnessAssignment.h>
00028 #include <move/moeoMoveIncrEval.h>
00029
00030
00031
00032
00033
00034
00035
00040 template < class MOEOT, class Move >
00041 class moeoIteratedIBMOLS : public moeoLS < MOEOT, eoPop < MOEOT > & >
00042 {
00043 public:
00044
00046 typedef typename MOEOT::ObjectiveVector ObjectiveVector;
00047
00048
00061 moeoIteratedIBMOLS(
00062 moMoveInit < Move > & _moveInit,
00063 moNextMove < Move > & _nextMove,
00064 eoEvalFunc < MOEOT > & _eval,
00065 moeoMoveIncrEval < Move > & _moveIncrEval,
00066 moeoIndicatorBasedFitnessAssignment < MOEOT > & _fitnessAssignment,
00067 eoContinue < MOEOT > & _continuator,
00068 eoMonOp < MOEOT > & _monOp,
00069 eoMonOp < MOEOT > & _randomMonOp,
00070 unsigned int _nNoiseIterations=1
00071 ) :
00072 ibmols(_moveInit, _nextMove, _eval, _moveIncrEval, _fitnessAssignment, _continuator),
00073 eval(_eval),
00074 continuator(_continuator),
00075 monOp(_monOp),
00076 randomMonOp(_randomMonOp),
00077 nNoiseIterations(_nNoiseIterations)
00078 {}
00079
00080
00086 void operator() (eoPop < MOEOT > & _pop, moeoArchive < MOEOT > & _arch)
00087 {
00088 _arch.update(_pop);
00089 ibmols(_pop, _arch);
00090 while (continuator(_arch))
00091 {
00092
00093 generateNewSolutions(_pop, _arch);
00094
00095 ibmols(_pop, _arch);
00096 }
00097 }
00098
00099
00100 private:
00101
00103 moeoIBMOLS < MOEOT, Move > ibmols;
00105 eoEvalFunc < MOEOT > & eval;
00107 eoContinue < MOEOT > & continuator;
00109 eoMonOp < MOEOT > & monOp;
00111 eoMonOp < MOEOT > & randomMonOp;
00113 unsigned int nNoiseIterations;
00114
00115
00121 void generateNewSolutions(eoPop < MOEOT > & _pop, const moeoArchive < MOEOT > & _arch)
00122 {
00123
00124 vector<unsigned int> shuffle;
00125 shuffle.resize(std::max(_pop.size(), _arch.size()));
00126
00127 for (unsigned int i=0; i<shuffle.size(); i++)
00128 {
00129 shuffle[i] = i;
00130 }
00131
00132 UF_random_generator <unsigned int> gen;
00133 std::random_shuffle(shuffle.begin(), shuffle.end(), gen);
00134
00135 for (unsigned int i=0; i<_pop.size(); i++)
00136 {
00137 if (shuffle[i] < _arch.size())
00138
00139 {
00140
00141 _pop[i] = _arch[shuffle[i]];
00142
00143 for (unsigned int j=0; j<nNoiseIterations; j++)
00144 {
00145 monOp(_pop[i]);
00146 }
00147 }
00148 else
00149
00150 {
00151
00152 randomMonOp(_pop[i]);
00153 }
00154
00155 _pop[i].invalidate();
00156 eval(_pop[i]);
00157 }
00158 }
00159
00160
00161
00162
00163
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00208
00209
00210
00211
00212
00213 };
00214
00215 #endif