git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@1720 331e1502-861f-0410-8da2-ba01fb791d7f
This commit is contained in:
jhumeau 2010-03-25 14:39:49 +00:00
commit 4d5b8db81e
23 changed files with 44 additions and 62 deletions

View file

@ -66,8 +66,6 @@ class moeoVFAS:public moeoPopAlgo < typename M::EOType >
take a base vector of weight, and modify it to relaunch the algo with a diferent fitness
use a selectOne to determine which moeot should be the base for the algo launch
use a eoPop to keep result from each iteration
@param _algorithm The solution based heuristic to use. It should at least use the fitness value at some point.
@param _continue The stopping criterion.
@param _select a selector to choose on which moeot we use the algorithm
@ -77,7 +75,7 @@ class moeoVFAS:public moeoPopAlgo < typename M::EOType >
*/
moeoVFAS (moeoSolAlgo<MOEOT> & _algorithm, eoContinue <MOEOT> & _continue,moeoSelectOne<MOEOT> &_select,
std::vector<double> &_weights, eoEvalFunc< MOEOT > &_eval , moeoVariableWeightStrategy<MOEOT> &_wstrat ):
algo(_algorithm),cont(_continue), select(_select), weights(_weights),eval(_eval),wstrat(_wstrat), refPoint(defaultRefPoint),rstrat(defaultRstrat)
algo(_algorithm),cont(_continue), select(_select), weights(_weights),eval(_eval),refPoint(defaultRefPoint), wstrat(_wstrat), rstrat(defaultRstrat)
{}
/*!
@ -98,7 +96,7 @@ class moeoVFAS:public moeoPopAlgo < typename M::EOType >
*/
moeoVFAS (moeoSolAlgo<MOEOT> & _algorithm, eoContinue <MOEOT> & _continue,moeoSelectOne<MOEOT> &_select,
std::vector<double> &_weights, ObjectiveVector &_refPoint, eoEvalFunc< MOEOT > &_eval , moeoVariableWeightStrategy<MOEOT> &_wstrat , moeoVariableRefPointStrategy<MOEOT>& _rstrat):
algo(_algorithm),cont(_continue), select(_select), weights(_weights),eval(_eval),wstrat(_wstrat), rstrat(_rstrat),refPoint(_refPoint)
algo(_algorithm),cont(_continue), select(_select), weights(_weights),eval(_eval),refPoint(_refPoint),wstrat(_wstrat), rstrat(_rstrat)
{}
/**
@ -110,7 +108,7 @@ class moeoVFAS:public moeoPopAlgo < typename M::EOType >
**/
moeoVFAS (moeoSolAlgo<MOEOT> & _algorithm, eoContinue <MOEOT> & _continue,moeoSelectOne<MOEOT> &_select,
eoEvalFunc< MOEOT > &_eval, moeoVariableWeightStrategy<MOEOT> &_wstrat):
algo(_algorithm),cont(_continue), select(_select), weights(defaultWeights), eval(_eval), wstrat(defaultWstrat), refPoint(defaultRefPoint), rstrat(defaultRstrat)
algo(_algorithm),cont(_continue), select(_select), weights(defaultWeights), eval(_eval), refPoint(defaultRefPoint), wstrat(defaultWstrat), rstrat(defaultRstrat)
{
weights.resize(MOEOT::ObjectiveVector::nObjectives(),1.0/MOEOT::ObjectiveVector::nObjectives());
}
@ -127,7 +125,6 @@ class moeoVFAS:public moeoPopAlgo < typename M::EOType >
moeoObjectiveVectorNormalizer<MOEOT> norm(_pop);
moeoAggregationFitnessAssignment<MOEOT> fitness(weights,eval);
bool res=false;
int iteration=0;
fitness(_pop);
MOEOT moeot(select(_pop));
wstrat(weights,moeot);
@ -151,9 +148,9 @@ class moeoVFAS:public moeoPopAlgo < typename M::EOType >
moeoSelectOne<MOEOT> &select;
std::vector<double> &weights;
std::vector<double> defaultWeights;
eoEvalFunc<MOEOT> &eval;
ObjectiveVector &refPoint;
ObjectiveVector defaultRefPoint;
eoEvalFunc<MOEOT> &eval;
moeoVariableWeightStrategy<MOEOT> &wstrat;
moeoVariableRefPointStrategy<MOEOT> &rstrat;
moeoDummyRefPointStrategy<MOEOT> defaultRstrat;

View file

@ -37,7 +37,6 @@ class moeoIndexedArchive : public moeoArchive < MOEOT >
* @param _moeo the given individual
*/
bool operator()(const MOEOT & _moeo){
bool added=false;
std::pair<bool,std::vector<typename moeoArchiveIndex<MOEOT>::modif> > res=index(_moeo);
if (!(res.first)){
return false;

View file

@ -238,7 +238,7 @@ public:
unsigned int k_succ(const ObjectiveVector& _objVec1, const ObjectiveVector& _objVec2){
unsigned int res=0;
if(!(*comparator)(_objVec2, _objVec1)){
for(int i=0; i < ObjectiveVector::nObjectives(); i++){
for(unsigned int i=0; i < ObjectiveVector::nObjectives(); i++){
if( (ObjectiveVector::minimizing(i) && ((_objVec1[i] - _objVec2[i]) >= (-1.0 * 1e-6 ))) ||
(ObjectiveVector::maximizing(i) && ((_objVec1[i] - _objVec2[i]) <= 1e-6 ))){
res+=pow(2,ObjectiveVector::nObjectives()-i-1);

View file

@ -74,7 +74,7 @@ class moeoAchievementScalarizingFunctionMetricFitnessAssignment : public moeoSin
* @param _weight the weights applied to the objectives
* @param _eval a evalFunc to regenerate the objectiveVector if needed
*/
moeoAchievementScalarizingFunctionMetricFitnessAssignment(unsigned int _rho, ObjectiveVector& _reference, const ObjectiveVector& _weight, eoEvalFunc<MOEOT>& _eval): eval(_eval), normalizer(defaultNormalizer), distance(_rho, _weight), metric( distance, _reference, defaultNormalizer){}
moeoAchievementScalarizingFunctionMetricFitnessAssignment(unsigned int _rho, ObjectiveVector& _reference, const ObjectiveVector& _weight, eoEvalFunc<MOEOT>& _eval): normalizer(defaultNormalizer), eval(_eval), distance(_rho, _weight), metric( distance, _reference, defaultNormalizer){}
/**
* ctor with an evaluing fonction, applied if give moeot is invalid, and a noramlizer, applied to ObjectiveVectors
@ -92,7 +92,7 @@ class moeoAchievementScalarizingFunctionMetricFitnessAssignment : public moeoSin
* @param _reference the reference point
* @param _weight the weights applied to the objectives
*/
moeoAchievementScalarizingFunctionMetricFitnessAssignment(unsigned int _rho, const ObjectiveVector& _reference, const ObjectiveVector& _weight) : eval(defaultEval), normalizer(defaultNormalizer), distance(_rho, _weight), metric(distance, _reference, defaultNormalizer){}
moeoAchievementScalarizingFunctionMetricFitnessAssignment(unsigned int _rho, const ObjectiveVector& _reference, const ObjectiveVector& _weight) : normalizer(defaultNormalizer), eval(defaultEval), distance(_rho, _weight), metric(distance, _reference, defaultNormalizer){}
/**
* Sets the fitness values for a moeot
@ -131,16 +131,18 @@ class moeoAchievementScalarizingFunctionMetricFitnessAssignment : public moeoSin
private:
moeoObjectiveVectorNormalizer<MOEOT> defaultNormalizer;
moeoAchievementScalarizingFunctionDistance<MOEOT> distance;
moeoDistanceMetric<MOEOT> metric;
eoEvalFunc<MOEOT> &eval;
moeoObjectiveVectorNormalizer<MOEOT> &normalizer;
class DummyEval: public eoEvalFunc<MOEOT>{
void operator()(MOEOT &moeo){
}
} defaultEval;
moeoObjectiveVectorNormalizer<MOEOT> &normalizer;
moeoObjectiveVectorNormalizer<MOEOT> defaultNormalizer;
eoEvalFunc<MOEOT> &eval;
moeoAchievementScalarizingFunctionDistance<MOEOT> distance;
moeoDistanceMetric<MOEOT> metric;
};
#endif /*moeoAugmentedScalarizingFunctionMetricFitnessASSIGNMENT_H_*/

View file

@ -78,7 +78,7 @@ class moeoAugmentedAchievementScalarizingFunctionMetricFitnessAssignment : publi
* @param _reference the reference point
* @param _weight the weights applied to the objectives
*/
moeoAugmentedAchievementScalarizingFunctionMetricFitnessAssignment(unsigned int _rho, const ObjectiveVector &_reference,const ObjectiveVector &_weight,eoEvalFunc<MOEOT> &_eval) : eval(_eval),normalizer(defaultNormalizer), distance(_rho,_weight), metric(distance,_reference,normalizer)
moeoAugmentedAchievementScalarizingFunctionMetricFitnessAssignment(unsigned int _rho, const ObjectiveVector &_reference,const ObjectiveVector &_weight,eoEvalFunc<MOEOT> &_eval) : normalizer(defaultNormalizer), eval(_eval), distance(_rho,_weight), metric(distance,_reference,normalizer)
{}
/**
* ctor with an evaluing fonction, applied if give moeot is invalid, and a noramlizer, applied to ObjectiveVectors
@ -96,7 +96,7 @@ class moeoAugmentedAchievementScalarizingFunctionMetricFitnessAssignment : publi
* @param _reference the reference point
* @param _weight the weights applied to the objectives
*/
moeoAugmentedAchievementScalarizingFunctionMetricFitnessAssignment(unsigned int _rho, const ObjectiveVector &_reference,const ObjectiveVector &_weight) : eval(defaultEval),normalizer(defaultNormalizer), distance(_rho,_weight), metric(distance,_reference,normalizer)
moeoAugmentedAchievementScalarizingFunctionMetricFitnessAssignment(unsigned int _rho, const ObjectiveVector &_reference,const ObjectiveVector &_weight) : normalizer(defaultNormalizer), eval(defaultEval), distance(_rho,_weight), metric(distance,_reference,normalizer)
{}
/**
@ -145,16 +145,17 @@ class moeoAugmentedAchievementScalarizingFunctionMetricFitnessAssignment : publi
private:
moeoObjectiveVectorNormalizer<MOEOT> defaultNormalizer;
moeoAugmentedAchievementScalarizingFunctionDistance<MOEOT> distance;
moeoObjectiveVectorNormalizer<MOEOT> &normalizer;
moeoDistanceMetric<MOEOT> metric;
eoEvalFunc<MOEOT> &eval;
class DummyEval: public eoEvalFunc<MOEOT>{
void operator()(MOEOT &moeo){
}
} defaultEval;
moeoObjectiveVectorNormalizer<MOEOT> defaultNormalizer;
moeoObjectiveVectorNormalizer<MOEOT> &normalizer;
eoEvalFunc<MOEOT> &eval;
moeoAugmentedAchievementScalarizingFunctionDistance<MOEOT> distance;
moeoDistanceMetric<MOEOT> metric;
};
#endif /*moeoAugmentedScalarizingFunctionMetricFitnessASSIGNMENT_H_*/

View file

@ -72,7 +72,7 @@ class moeoAugmentedWeightedChebychevMetricFitnessAssignment : public moeoSingleO
* @param _weight the weights applied to the objectives
* @param _eval a evalFunc to regenerate the objectiveVector if needed
*/
moeoAugmentedWeightedChebychevMetricFitnessAssignment(unsigned int _rho, const ObjectiveVector& _reference, const ObjectiveVector& _weight, eoEvalFunc<MOEOT>& _eval) : eval(_eval), normalizer(defaultNormalizer), distance(_rho, _weight), metric(distance, _reference, normalizer){}
moeoAugmentedWeightedChebychevMetricFitnessAssignment(unsigned int _rho, const ObjectiveVector& _reference, const ObjectiveVector& _weight, eoEvalFunc<MOEOT>& _eval) : normalizer(defaultNormalizer), eval(_eval), distance(_rho, _weight), metric(distance, _reference, normalizer){}
/**
* ctor with an evaluation fonction, applied if give moeot is invalid, and a noramlizer, applied to ObjectiveVectors
@ -90,7 +90,7 @@ class moeoAugmentedWeightedChebychevMetricFitnessAssignment : public moeoSingleO
* @param _reference the reference point
* @param _weight the weights applied to the objectives
*/
moeoAugmentedWeightedChebychevMetricFitnessAssignment(unsigned int _rho, const ObjectiveVector& _reference, const ObjectiveVector& _weight) : eval(defaultEval), normalizer(defaultNormalizer), distance(_rho, _weight), metric(distance, _reference, normalizer){}
moeoAugmentedWeightedChebychevMetricFitnessAssignment(unsigned int _rho, const ObjectiveVector& _reference, const ObjectiveVector& _weight) : normalizer(defaultNormalizer), eval(defaultEval), distance(_rho, _weight), metric(distance, _reference, normalizer){}
/**
* Sets the fitness values for a moeot
@ -133,11 +133,12 @@ class moeoAugmentedWeightedChebychevMetricFitnessAssignment : public moeoSingleO
}
} defaultEval;
moeoAugmentedWeightedChebychevDistance<MOEOT> distance;
moeoObjectiveVectorNormalizer<MOEOT> defaultNormalizer;
moeoObjectiveVectorNormalizer<MOEOT> &normalizer;
moeoDistanceMetric<MOEOT> metric;
eoEvalFunc<MOEOT> &eval;
moeoAugmentedWeightedChebychevDistance<MOEOT> distance;
moeoDistanceMetric<MOEOT> metric;
};

View file

@ -99,7 +99,7 @@ class moeoConstraintFitnessAssignment : public moeoSingleObjectivization < MOEOT
}
else{
for(unsigned int l=0; l<dim; l++){
if (l==to_optimize)
if ((int)l==to_optimize)
if (_mo.minimizing(l))
res-=(normalizer(_mo)[l]) * weight[l];
else

View file

@ -76,7 +76,7 @@ class moeoWeightedChebychevMetricFitnessAssignment : public moeoSingleObjectiviz
* @param _weight the weights applied to the objectives
* @param _eval a evalFunc to regenerate the objectiveVector if needed
*/
moeoWeightedChebychevMetricFitnessAssignment(unsigned int _rho, const ObjectiveVector& _reference, const ObjectiveVector& _weight, eoEvalFunc<MOEOT>& _eval) : eval(_eval), normalizer(defaultNormalizer), distance(_rho, _weight), metric(distance, _reference, normalizer){}
moeoWeightedChebychevMetricFitnessAssignment(unsigned int _rho, const ObjectiveVector& _reference, const ObjectiveVector& _weight, eoEvalFunc<MOEOT>& _eval) : normalizer(defaultNormalizer), eval(_eval), distance(_rho, _weight), metric(distance, _reference, normalizer){}
/**
* ctor with an evaluation fonction, applied if give moeot is invalid, and a noramlizer, applied to ObjectiveVectors
@ -94,7 +94,7 @@ class moeoWeightedChebychevMetricFitnessAssignment : public moeoSingleObjectiviz
* @param _reference the reference point
* @param _weight the weights applied to the objectives
*/
moeoWeightedChebychevMetricFitnessAssignment(unsigned int _rho, const ObjectiveVector& _reference, const ObjectiveVector& _weight) : eval(defaultEval), normalizer(defaultNormalizer), distance(_rho, _weight), metric(distance, _reference, normalizer){}
moeoWeightedChebychevMetricFitnessAssignment(unsigned int _rho, const ObjectiveVector& _reference, const ObjectiveVector& _weight) : normalizer(defaultNormalizer), eval(defaultEval), distance(_rho, _weight), metric(distance, _reference, normalizer){}
/**
* Sets the fitness values for a moeot
@ -133,17 +133,16 @@ class moeoWeightedChebychevMetricFitnessAssignment : public moeoSingleObjectiviz
private:
moeoWeightedChebychevDistance<MOEOT> distance;
moeoObjectiveVectorNormalizer<MOEOT> defaultNormalizer;
moeoObjectiveVectorNormalizer<MOEOT>& normalizer;
moeoDistanceMetric<MOEOT> metric;
eoEvalFunc<MOEOT> &eval;
class DummyEval: public eoEvalFunc<MOEOT>{
void operator()(MOEOT &moeo){
}
} defaultEval;
moeoObjectiveVectorNormalizer<MOEOT> defaultNormalizer;
moeoObjectiveVectorNormalizer<MOEOT>& normalizer;
eoEvalFunc<MOEOT> &eval;
moeoWeightedChebychevDistance<MOEOT> distance;
moeoDistanceMetric<MOEOT> metric;
};
#endif /*moeoWeightedChebychevMetricFitnessASSIGNMENT_H_*/

View file

@ -77,10 +77,10 @@ class moeoDistanceMetric : public moeoUnaryMetric < typename MOEOT::ObjectiveVec
}
private:
moeoObjectiveVectorNormalizer<MOEOT> defaultNormalizer;
moeoObjectiveVectorNormalizer<MOEOT>& normalizer;
moeoObjSpaceDistance<MOEOT>& distance;
const ObjectiveVector& reference;
moeoObjectiveVectorNormalizer<MOEOT> defaultNormalizer;
moeoObjectiveVectorNormalizer<MOEOT>& normalizer;
};
#endif

View file

@ -67,20 +67,20 @@ class moeoDetArchiveSelect : public eoSelect<MOEOT>
unsigned int archive_size = archive.size();
_dest.resize(0);
if ((archive_size >= min) && (archive_size <= max)){
for (int i=0; i<archive_size; i++)
for (unsigned int i=0; i<archive_size; i++)
_dest.push_back(archive[i]);
}
else if (archive_size > max){
UF_random_generator<unsigned int> rndGen;
std::vector <int> permutation;
for(int i=0; i < archive_size; i++)
for(unsigned int i=0; i < archive_size; i++)
permutation.push_back(i);
random_shuffle(permutation.begin(), permutation.end(), rndGen);
for (int i=0; i<max; i++)
for (unsigned int i=0; i<max; i++)
_dest.push_back(archive[permutation[i]]);
}
else {
for (int i=0; i<min; i++){
for (unsigned int i=0; i<min; i++){
_dest.push_back(archive[i%archive_size]);
}
}

View file

@ -95,7 +95,6 @@ class moeoAugmentedQexploreWeightStrategy: public moeoVariableWeightStrategy<MOE
bool translate(int dim, std::vector<double> &_weights){
_weights.clear();
_weights.resize(dim,0);
int max=dim-1;
for (unsigned int i=0;i<nums.size();i++){
_weights[nums[i]]++;
if (depth>1 && _weights[nums[i]]==depth) {

View file

@ -52,7 +52,6 @@ class moeoDummyWeightStrategy: public moeoVariableWeightStrategy<MOEOT>
* @param _moeot not used
*/
void operator()(std::vector<double> &_weights,const MOEOT &_moeot){
double sum=0;
for (unsigned int i=0;i<_weights.size();i++){
_weights[i]=(1.0/_weights.size());
}

View file

@ -93,7 +93,7 @@ int main()
eoRealInitBounded < Solution > init(bounds);
eoPop < Solution > pop(20, init);
for(int i=0; i<pop.size(); i++)
for(unsigned int i=0; i<pop.size(); i++)
eval(pop[i]);
eoSGATransform < Solution > transform(xover, 0.1, mutation, 0.1);

View file

@ -74,8 +74,6 @@ class DummyEval: public eoEvalFunc<Solution>{
int main()
{
int res=EXIT_SUCCESS;
std::cout << "[moeoChebyshevMetric] => ";
// objective vectors

View file

@ -74,8 +74,6 @@ class DummyEval: public eoEvalFunc<Solution>{
int main()
{
int res=EXIT_SUCCESS;
std::cout << "[moeoChebyshevMetric] => ";
// objective vectors

View file

@ -70,8 +70,6 @@ typedef MOEO < ObjectiveVector, double, double > Solution;
int main()
{
int res=EXIT_SUCCESS;
std::cout << "[moeoAggregationFitnessAssignment] => ";
// objective vectors

View file

@ -74,8 +74,6 @@ class DummyEval: public eoEvalFunc<Solution>{
int main()
{
int res=EXIT_SUCCESS;
std::cout << "[moeoChebyshevMetric] => ";
// objective vectors

View file

@ -74,8 +74,6 @@ class DummyEval: public eoEvalFunc<Solution>{
int main()
{
int res=EXIT_SUCCESS;
std::cout << "[moeoChebyshevMetric] => ";
// objective vectors

View file

@ -74,8 +74,6 @@ class DummyEval: public eoEvalFunc<Solution>{
int main()
{
int res=EXIT_SUCCESS;
std::cout << "[moeoAggregationFitnessAssignment] => ";
// objective vectors

View file

@ -102,7 +102,7 @@ int main()
// test with max > archive size
moeoDetArchiveSelect <Solution> select1(archive, 10);
select1(source, dest);
for(int i=0; i< archive.size(); i++){
for(unsigned int i=0; i< archive.size(); i++){
assert(dest[i].objectiveVector()[0]==archive[i].objectiveVector()[0]);
assert(dest[i].objectiveVector()[1]==archive[i].objectiveVector()[1]);
}

View file

@ -266,7 +266,6 @@ class selectMove: public moMoveSelect<testMove>
int main()
{
std::string test_result;
int return_value;
Solution solution;

View file

@ -246,7 +246,6 @@ class solutionSingler : public moeoSingleObjectivization<Solution>
int main()
{
std::string test_result;
int return_value;
Solution solution;

View file

@ -277,7 +277,6 @@ class selectMove: public moMoveSelect<testMove>
int main()
{
std::string test_result;
int return_value;
Solution solution;