|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
The objective function is used to
evaluate a Solution
.
This code is licensed for public use under the Common Public License version 0.5.
The Common Public License, developed by IBM and modeled after their industry-friendly IBM Public License,
differs from other common open source licenses in several important ways:
Copyright © 2001 Robert Harder
Method Summary | |
double[] |
evaluate(Solution soln,
Move move)
The TabuSearch expects an objective/
constraint penalties function to be able
to evaluate a solution's worth. |
Method Detail |
public double[] evaluate(Solution soln, Move move)
TabuSearch
expects an objective/
constraint penalties function to be able
to evaluate a solution's worth. The TabuSearch
will
pass the ObjectiveFunction a Solution
and
optionally pass a proposed Move
. If the passed move is
not null, then the evaluation should consider the effect that executing
this move on the solution would have before evaluating it. If you can use some
sort of incremental evaluation technique, this will save you time. If you
must operate on the solution to actually calculate its value, you must
return the solution to its original state before the method returns.
Casting example:
public double[] evaluate( Solution soln, Move move )
{
MySolutionClass solution = (MySolutionClass) soln;
// ...
} // end evaluate
The array of returned values will later be compared lexicographically in the classic "goal-programming" style. If instead you want some goals to overpower higher goals, use the style of weighting the levels with appropriate values. Although all numbers are stored and calculated as doubles, they are cast to floats before being compared.
Be careful that you do not "reuse" arrays which can lead to different solutions sharing the same array of values in memory. A good technique is to evaluate your values as scalars and then return a fresh array like this:
double val1 = ...;
double val2 = ...;
...
return new double[]{ val1, val2 };
soln
- The solution to evaluatemove
- If not null the proposed move
Solution
,
Move
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |