Using nd-sorting now

This commit is contained in:
maartenkeijzer 2001-03-14 12:47:14 +00:00
commit 67c3575873

View file

@ -2,7 +2,7 @@
#include <eo> #include <eo>
//#include <utils/eoMOFitnessStat.h> //#include <utils/eoMOFitnessStat.h>
//#include <utils/eoFileSnapshot.h> #include <eoNDSorting.h>
using namespace std; using namespace std;
typedef vector<double> fitness_type; typedef vector<double> fitness_type;
@ -10,9 +10,6 @@ typedef vector<double> fitness_type;
struct eoDouble : public EO<fitness_type> struct eoDouble : public EO<fitness_type>
{ {
double value; double value;
void printOn(ostream& os) const { os << fitness()[0] << ' ' << fitness()[1] << ' ' << value; }
void readFrom(istream& is) { is >> value; }
}; };
class Mutate : public eoMonOp<eoDouble> class Mutate : public eoMonOp<eoDouble>
@ -30,8 +27,8 @@ class Eval : public eoEvalFunc<eoDouble>
{ {
double v = _eo.value; double v = _eo.value;
fitness_type f(2); fitness_type f(2);
f[0] = v * v; f[1] = v * v;
f[1] = (v - 1.) * (v - 1.); f[0] = (v - 1.) * (v - 1.);
_eo.fitness(f); _eo.fitness(f);
} }
@ -64,7 +61,8 @@ void the_main()
eoDominanceMap<eoDouble> dominance(maximizes); eoDominanceMap<eoDouble> dominance(maximizes);
// Pareto ranking needs a dominance map // Pareto ranking needs a dominance map
eoParetoRanking<eoDouble> perf2worth(dominance); //eoParetoRanking<eoDouble> perf2worth(dominance);
eoNDSorting<eoDouble> perf2worth(dominance, 0.0);
// Three selectors // Three selectors
eoDetTournamentWorthSelect<eoDouble> select1(perf2worth, 3); eoDetTournamentWorthSelect<eoDouble> select1(perf2worth, 3);
@ -94,6 +92,7 @@ void the_main()
cp.add(fitness1); cp.add(fitness1);
eoGnuplot1DSnapshot snapshot("pareto"); eoGnuplot1DSnapshot snapshot("pareto");
snapshot.pointSize =3;
cp.add(snapshot); cp.add(snapshot);