7 MOFitnessP p = boost::static_pointer_cast<MOFitness> (other);
8 uint objCount = (uint) p->size();
10 for (uint i = 0; i<objCount; i++) {
11 if ( this->rank < p->rank) {
14 if (p->rank < this->rank) {
17 if (this->crowding_distance > p->crowding_distance) {
31 for(
int i = 0; i < (int) this->size(); i++) {
32 (*newObject)[i] = (FitnessP) ((*
this)[i]->copy());
34 newObject->rank = this->rank;
35 newObject->nc = this->nc;
36 newObject->Sp = this->Sp;
37 newObject->crowding_distance = this->crowding_distance;
44 xFitness = XMLNode::createXMLTopNode(
"MOFitness");
45 uint size = (uint) this->size();
46 for(uint i = 0; i < size; i++) {
47 std::stringstream sValue;
48 sValue << this->at(i)->getValue();
49 std::string value =
"value" + uint2str(i + 1);
50 xFitness.addAttribute(value.c_str(), sValue.str().c_str());
59double MOFitness::getValueOfObjective(
int objective)
61 return this->at(objective)->getValue();
64double MOFitness::getProperty(std::string prop,
int objective = -1) {
65 if (prop.compare(
"objective") == 0) {
66 if (objective >= 0 && objective < (
int) this->size()) {
67 return getValueOfObjective(objective);
72 }
else if (prop.compare(
"rank") == 0) {
73 return (
double) this->rank;
74 }
else if (prop.compare(
"crowding_distance") == 0) {
75 return this->crowding_distance;
double getValue()
Return fitness value.
bool isBetterThan(FitnessP other)
Mandatory comparison operator.
MOFitness * copy()
object copy (for duplication of an individual)
void write(XMLNode &xFitness)
Write fitness object to XMLNode.