fast computation of dominance-depth corrected for minimizing objectives
This commit is contained in:
parent
effaa56cfd
commit
6fc4d043e0
2 changed files with 22 additions and 4 deletions
|
|
@ -155,7 +155,10 @@ private:
|
|||
*/
|
||||
bool operator()(const MOEOT & _moeo1, const MOEOT & _moeo2)
|
||||
{
|
||||
return cmp(_moeo2.objectiveVector(), _moeo1.objectiveVector());
|
||||
if (MOEOT::ObjectiveVector::maximizing(0))
|
||||
return cmp(_moeo2.objectiveVector(), _moeo1.objectiveVector());
|
||||
else
|
||||
return cmp(_moeo1.objectiveVector(), _moeo2.objectiveVector());
|
||||
}
|
||||
private:
|
||||
/** the corresponding comparator for objective vectors */
|
||||
|
|
@ -207,6 +210,17 @@ private:
|
|||
moeoPtrComparator<MOEOT> cmp(objComparator);
|
||||
std::sort(sortedptrpop.begin(), sortedptrpop.end(), cmp);
|
||||
|
||||
|
||||
//
|
||||
std::cout << std::endl << "sorted pop" << std::endl;
|
||||
std::cout << "====================" << std::endl;
|
||||
for(unsigned int i=0; i<_pop.size(); i++)
|
||||
{
|
||||
std::cout << i << " : " << (*sortedptrpop[i]) << std::endl;
|
||||
}
|
||||
std::cout << "====================" << std::endl;
|
||||
//
|
||||
|
||||
// compute an upper bound on the second objective (1)
|
||||
double max_obj1 = std::numeric_limits<double>::min();
|
||||
for(unsigned int i=0; i<_pop.size(); i++)
|
||||
|
|
|
|||
|
|
@ -81,8 +81,8 @@ int main()
|
|||
obj3[1] = 5;
|
||||
obj4[0] = 5;
|
||||
obj4[1] = 1;
|
||||
obj5[0] = 3;
|
||||
obj5[1] = 3;
|
||||
obj5[0] = 4;
|
||||
obj5[1] = 4;
|
||||
|
||||
// population
|
||||
eoPop < Solution > pop;
|
||||
|
|
@ -97,6 +97,10 @@ int main()
|
|||
// fitness assignment
|
||||
moeoDominanceDepthFitnessAssignment< Solution > fitnessAssignment;
|
||||
fitnessAssignment(pop);
|
||||
|
||||
for (unsigned int fun=0; fun<pop.size(); fun++) {
|
||||
std::cout << pop[fun].fitness() << std::endl;
|
||||
}
|
||||
|
||||
// pop[0]
|
||||
if (pop[0].fitness() != 2.0)
|
||||
|
|
@ -129,7 +133,7 @@ int main()
|
|||
return EXIT_FAILURE;
|
||||
}
|
||||
// pop[5]
|
||||
if (pop[5].fitness() != 2.0)
|
||||
if (pop[5].fitness() != 1.0)
|
||||
{
|
||||
std::cout << "ERROR (bad fitness for pop[5])" << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue