Constructor revised
git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@1614 331e1502-861f-0410-8da2-ba01fb791d7f
This commit is contained in:
parent
ff211f496c
commit
348da5c52c
3 changed files with 38 additions and 21 deletions
|
|
@ -76,7 +76,7 @@ public:
|
|||
* @param _max the max size for the pop
|
||||
*/
|
||||
moeoASEEA (unsigned int _maxGen, eoEvalFunc < MOEOT > & _eval, eoQuadOp < MOEOT > & _crossover, double _pCross, eoMonOp < MOEOT > & _mutation, double _pMut, moeoArchive < MOEOT > & _archive, unsigned int _max) :
|
||||
defaultGenContinuator(_maxGen), continuator(defaultGenContinuator), eval(_eval), defaultPopEval(_eval), popEval(defaultPopEval), selectMany(_archive, _max), selectTransform(defaultSelect, defaultTransform), defaultSGAGenOp(_crossover, _pCross, _mutation, _pMut), breed (selectTransform), archive(_archive)
|
||||
defaultGenContinuator(_maxGen), continuator(defaultGenContinuator), eval(_eval), defaultPopEval(_eval), popEval(defaultPopEval), selectMany(_archive, _max), transform(_crossover, _pCross, _mutation, _pMut), selectTransform(selectMany, transform), breed (selectTransform), archive(_archive)
|
||||
{}
|
||||
|
||||
|
||||
|
|
@ -84,11 +84,15 @@ public:
|
|||
* Ctor with a eoContinue.
|
||||
* @param _continuator stopping criteria
|
||||
* @param _eval evaluation function
|
||||
* @param _crossover crossover
|
||||
* @param _pCross crossover probability
|
||||
* @param _mutation mutation
|
||||
* @param _pMut mutation probability
|
||||
* @param _archive archive
|
||||
* @param _max the max size for the pop
|
||||
*/
|
||||
moeoASEEA (eoContinue < MOEOT > & _continuator, eoEvalFunc < MOEOT > & _eval, moeoArchive < MOEOT > & _archive, unsigned int _max) :
|
||||
defaultGenContinuator(0), continuator(_continuator), eval(_eval), defaultPopEval(_eval), popEval(defaultPopEval), selectMany(_archive, _max), selectTransform(defaultSelect, defaultTransform), defaultSGAGenOp(defaultQuadOp, 1.0, defaultMonOp, 1.0), breed(selectTransform), archive(_archive)
|
||||
moeoASEEA (eoContinue < MOEOT > & _continuator, eoEvalFunc < MOEOT > & _eval, eoQuadOp < MOEOT > & _crossover, double _pCross, eoMonOp < MOEOT > & _mutation, double _pMut, moeoArchive < MOEOT > & _archive, unsigned int _max) :
|
||||
defaultGenContinuator(0), continuator(_continuator), eval(_eval), defaultPopEval(_eval), popEval(defaultPopEval), selectMany(_archive, _max), transform(_crossover, _pCross, _mutation, _pMut), selectTransform(selectMany, transform), breed(selectTransform), archive(_archive)
|
||||
{}
|
||||
|
||||
|
||||
|
|
@ -96,11 +100,15 @@ public:
|
|||
* Ctor with a eoContinue, a eoPopEval.
|
||||
* @param _continuator stopping criteria
|
||||
* @param _popEval population evaluation function
|
||||
* @param _crossover crossover
|
||||
* @param _pCross crossover probability
|
||||
* @param _mutation mutation
|
||||
* @param _pMut mutation probability
|
||||
* @param _archive archive
|
||||
* @param _max the max size for the pop
|
||||
*/
|
||||
moeoASEEA (eoContinue < MOEOT > & _continuator, eoPopEvalFunc < MOEOT > & _popEval, moeoArchive < MOEOT > & _archive, unsigned int _max) :
|
||||
defaultGenContinuator(0), continuator(_continuator), eval(defaultEval), defaultPopEval(eval), popEval(_popEval), selectMany(_archive, _max), selectTransform(defaultSelect, defaultTransform), defaultSGAGenOp(defaultQuadOp, 1.0, defaultMonOp, 1.0), breed(selectTransform), archive(_archive)
|
||||
moeoASEEA (eoContinue < MOEOT > & _continuator, eoPopEvalFunc < MOEOT > & _popEval, eoQuadOp < MOEOT > & _crossover, double _pCross, eoMonOp < MOEOT > & _mutation, double _pMut, moeoArchive < MOEOT > & _archive, unsigned int _max) :
|
||||
defaultGenContinuator(0), continuator(_continuator), eval(defaultEval), defaultPopEval(eval), popEval(_popEval), selectMany(_archive, _max), transform(_crossover, _pCross, _mutation, _pMut), selectTransform(selectMany, transform), breed(selectTransform), archive(_archive)
|
||||
{}
|
||||
|
||||
|
||||
|
|
@ -113,7 +121,7 @@ public:
|
|||
* @param _max the max size for the pop
|
||||
*/
|
||||
moeoASEEA (eoContinue < MOEOT > & _continuator, eoEvalFunc < MOEOT > & _eval, eoTransform < MOEOT > & _transform, moeoArchive < MOEOT > & _archive, unsigned int _max) :
|
||||
defaultGenContinuator(0), continuator(_continuator), eval(_eval), defaultPopEval(_eval), popEval(defaultPopEval), selectMany(_archive, _max), selectTransform(selectMany, _transform), defaultSGAGenOp(defaultQuadOp, 0.0, defaultMonOp, 0.0), breed(selectTransform), archive(_archive)
|
||||
defaultGenContinuator(0), continuator(_continuator), eval(_eval), defaultPopEval(_eval), popEval(defaultPopEval), selectMany(_archive, _max), transform(defaultQuadOp, 0.0, defaultMonOp, 0.0), selectTransform(selectMany, _transform), breed(selectTransform), archive(_archive)
|
||||
{}
|
||||
|
||||
|
||||
|
|
@ -126,7 +134,7 @@ public:
|
|||
* @param _max the max size for the pop
|
||||
*/
|
||||
moeoASEEA (eoContinue < MOEOT > & _continuator, eoPopEvalFunc < MOEOT > & _popEval, eoTransform < MOEOT > & _transform, moeoArchive < MOEOT > & _archive, unsigned int _max) :
|
||||
defaultGenContinuator(0), continuator(_continuator), eval(defaultEval), defaultPopEval(eval), popEval(_popEval), selectMany(_archive, _max), selectTransform(selectMany, _transform), defaultSGAGenOp(defaultQuadOp, 0.0, defaultMonOp, 0.0), breed(selectTransform), archive(_archive)
|
||||
defaultGenContinuator(0), continuator(_continuator), eval(defaultEval), defaultPopEval(eval), popEval(_popEval), selectMany(_archive, _max), transform(defaultQuadOp, 0.0, defaultMonOp, 0.0), selectTransform(selectMany, _transform), breed(selectTransform), archive(_archive)
|
||||
{}
|
||||
|
||||
|
||||
|
|
@ -159,12 +167,6 @@ protected:
|
|||
void operator()(MOEOT &) {}
|
||||
}defaultEval;
|
||||
|
||||
/** default select */
|
||||
class DummySelect : public eoSelect < MOEOT >{
|
||||
public :
|
||||
void operator()(const eoPop<MOEOT>&, eoPop<MOEOT>&) {}
|
||||
}defaultSelect;
|
||||
|
||||
/** default transform */
|
||||
class DummyTransform : public eoTransform < MOEOT >{
|
||||
public :
|
||||
|
|
@ -183,6 +185,8 @@ protected:
|
|||
eoPopEvalFunc < MOEOT > & popEval;
|
||||
/** default select many */
|
||||
moeoDetArchiveSelect < MOEOT > selectMany; // A REMPLACER !!!!!!!!!!! => add/moeoDetArchiveSelect.h
|
||||
/** eoTransform */
|
||||
eoSGATransform < MOEOT > transform;
|
||||
/** select transform */
|
||||
eoSelectTransform < MOEOT > selectTransform;
|
||||
/** a default crossover */
|
||||
|
|
@ -190,7 +194,9 @@ protected:
|
|||
/** a default mutation */
|
||||
eoMonCloneOp < MOEOT > defaultMonOp;
|
||||
/** an object for genetic operators (used as default) */
|
||||
eoSGAGenOp < MOEOT > defaultSGAGenOp;
|
||||
//eoSGAGenOp < MOEOT > defaultSGAGenOp;
|
||||
/** an object for genetic operators (used as default) */
|
||||
//eoSGAGenOp < MOEOT >& genOp;
|
||||
/** breeder */
|
||||
eoBreed < MOEOT > & breed;
|
||||
/**archive */
|
||||
|
|
|
|||
|
|
@ -57,15 +57,16 @@ class moeoDetArchiveSelect : public eoSelect<MOEOT>
|
|||
* @param _source compatibility parameter, not used
|
||||
* @param _dest destination population, selected from archive
|
||||
*/
|
||||
virtual void operator()(const eoPop < MOEOT > & _source, eoPop < MOEOT > & _dest)
|
||||
void operator()(const eoPop < MOEOT > & _source, eoPop < MOEOT > & _dest)
|
||||
{
|
||||
if(max < min){
|
||||
std::cout << "Warning! moeoDetArchiveSelect: min value > max value!!! Nothing is done." << std::endl;
|
||||
}
|
||||
else{
|
||||
|
||||
unsigned int archive_size = archive.size();
|
||||
_dest.resize(0);
|
||||
if (archive_size >= min && archive_size<= max){
|
||||
if ((archive_size >= min) && (archive_size <= max)){
|
||||
for (int i=0; i<archive_size; i++)
|
||||
_dest.push_back(archive[i]);
|
||||
}
|
||||
|
|
@ -79,8 +80,9 @@ class moeoDetArchiveSelect : public eoSelect<MOEOT>
|
|||
_dest.push_back(archive[permutation[i]]);
|
||||
}
|
||||
else {
|
||||
for (int i=0; i<min; i++)
|
||||
for (int i=0; i<min; i++){
|
||||
_dest.push_back(archive[i%archive_size]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@ public:
|
|||
{
|
||||
ObjectiveVector objVec;
|
||||
objVec[0] = _sol[0];
|
||||
objVec[1] = _sol[0] * _sol[0];
|
||||
objVec[1] = 1 / (_sol[0]+1);
|
||||
_sol.objectiveVector(objVec);
|
||||
}
|
||||
};
|
||||
|
|
@ -87,11 +87,15 @@ int main()
|
|||
|
||||
TestEval eval;
|
||||
eoQuadCloneOp < Solution > xover;
|
||||
eoUniformMutation < Solution > mutation(0.05);
|
||||
eoUniformMutation < Solution > mutation(1.0);
|
||||
|
||||
eoRealVectorBounds bounds(1, 1.0, 2.0);
|
||||
eoRealInitBounded < Solution > init(bounds);
|
||||
eoPop < Solution > pop(20, init);
|
||||
|
||||
for(int i=0; i<pop.size(); i++)
|
||||
eval(pop[i]);
|
||||
|
||||
eoSGATransform < Solution > transform(xover, 0.1, mutation, 0.1);
|
||||
eoGenContinue <Solution > continuator(10);
|
||||
moeoUnboundedArchive < Solution > archive;
|
||||
|
|
@ -100,12 +104,17 @@ int main()
|
|||
|
||||
// build ASSEA
|
||||
moeoASEEA <Solution> algo1(10, eval, xover, 0.1, mutation, 0.5, archive, 10);
|
||||
moeoASEEA <Solution> algo2(continuator, popEval, archive, 10);
|
||||
moeoASEEA <Solution> algo3(continuator, eval, archive, 10);
|
||||
moeoASEEA <Solution> algo2(continuator, popEval, xover, 0.1, mutation, 1.0, archive, 10);
|
||||
moeoASEEA <Solution> algo3(continuator, eval, xover, 0.1, mutation, 1.0, archive, 10);
|
||||
moeoASEEA <Solution> algo4(continuator, popEval, transform, archive, 10);
|
||||
moeoASEEA <Solution> algo5(continuator, eval, transform, archive, 10);
|
||||
|
||||
// run the algo
|
||||
|
||||
algo1(pop);
|
||||
algo2(pop);
|
||||
algo3(pop);
|
||||
algo4(pop);
|
||||
algo5(pop);
|
||||
|
||||
std::cout << " OK\n";
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue