|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
An HEvaluator
gives costs for a given solution. The array
of values returned by the getCostsForSolution(...)
is compared
lexicographically against other solutions. That means that each cost in the
array is considered to be infinitely more important than the next. For an example
minimizing costs, { 1.2, 5.4 } is better than { 1.3, 0.0 }
because 1.2 is smaller than 1.3. If you want to have fuzzier costs, combine
them all into one element in the array.
Here is an example of the kind of code that is used to compare values returned by
the HEvaluator
s.
private final boolean firstIsBetterThanSecond( double[] first, double[] second )
{
int i=0;
final int valLength = first.length;
boolean result = false;
for( i = 0; i < valLength; i++ )
{
if( (float)first[0] > (float)second[0] )
{
result = maximizing ? true : false;
i = Integer.MAX_VALUE;
break;
} // end if
else if( (float)first[0] < (float)second[0] )
{
result = maximizing ? false : true;
i = Integer.MAX_VALUE;
break;
} // end else
// else it must have been equal
} // end for: through each value
return result;
} // end firstIsBetterThanSecond
The casting to floats is recommended and often used to ignore the inevitable errors at the tail end of floating point numbers.
HSolution
Method Summary | |
double[] |
getCostsForSolution(HSolution solution)
This method should weight the appropriate values and return a total cost for the solution, based on whatever is most important. |
java.lang.String[] |
getNamesForCosts(HSolution solution)
This method should return names for the costs given in the method getCostsForSolution. |
Method Detail |
public double[] getCostsForSolution(HSolution solution)
HSolution
for more informationsolution
- HSolution
public java.lang.String[] getNamesForCosts(HSolution solution)
solution
- HSolution
|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |