mil.af.afit.uvr
Interface HEvaluator

All Known Implementing Classes:
EvaluatorWithoutPriorities, EvaluatorWithPriorities

public interface HEvaluator

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 HEvaluators.



  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.

Since:
1.0
See Also:
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

getCostsForSolution

public 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. The solution contains some useful values, precalculated, to save time. See the section on HSolution for more information
Parameters:
solution -  
Returns:
values representing a cost for this solution
Since:
1.0
See Also:
HSolution

getNamesForCosts

public java.lang.String[] getNamesForCosts(HSolution solution)
This method should return names for the costs given in the method getCostsForSolution.
Parameters:
solution -  
Returns:
the names for the costs
Since:
1.0
See Also:
HSolution