Module org.cicirello.chips_n_salsa
Package org.cicirello.search.problems
Class IntegerCostFunctionScaler<T extends Copyable<T>>
java.lang.Object
org.cicirello.search.problems.IntegerCostFunctionScaler<T>
- Type Parameters:
T
- The type of object used to represent candidate solutions to the problem.
- All Implemented Interfaces:
IntegerCostOptimizationProblem<T>
,Problem<T>
public final class IntegerCostFunctionScaler<T extends Copyable<T>>
extends Object
implements IntegerCostOptimizationProblem<T>
This is a wrapper class for
IntegerCostOptimizationProblem
objects that enables scaling
all cost values by a positive constant. This transformation doesn't change what solution is
optimal, and doesn't change the topology of the search space. It simply scales the cost values.
For example, if you want to explore the effects of the range of the cost function on the behavior
of a search algorithm, you can use this class to scale the cost values of a problem whose cost
function range is known.
Note that this does not scale the results of the value(T)
method, which will continue to
return the actual value of the candidate solution (see its documentation for details).
-
Constructor Summary
ConstructorDescriptionIntegerCostFunctionScaler
(IntegerCostOptimizationProblem<T> problem, int scale) Constructs the IntegerCostFunctionScaler. -
Method Summary
Modifier and TypeMethodDescriptionint
Computes the cost of a candidate solution to the problem instance.int
minCost()
A lower bound on the minimum theoretical cost across all possible solutions to the problem instance, where lower cost implies better solution.int
Computes the value of the candidate solution within the usual constraints and interpretation of the problem.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.cicirello.search.problems.IntegerCostOptimizationProblem
costAsDouble, getSolutionCostPair, isMinCost
-
Constructor Details
-
IntegerCostFunctionScaler
Constructs the IntegerCostFunctionScaler.- Parameters:
problem
- The original problem specification.scale
- The scale factor, which must be positive. All cost values of the original problem will be multiplied by scale.- Throws:
IllegalArgumentException
- if scale ≤ 0.
-
-
Method Details
-
cost
Computes the cost of a candidate solution to the problem instance. The lower the cost, the more optimal the candidate solution.In the case of the IntegerCostFunctionScaler, the cost values are all multiplied by the scale factor.
- Specified by:
cost
in interfaceIntegerCostOptimizationProblem<T extends Copyable<T>>
- Parameters:
candidate
- The candidate solution to evaluate.- Returns:
- The cost of the candidate solution. Lower cost means better solution.
-
minCost
public int minCost()A lower bound on the minimum theoretical cost across all possible solutions to the problem instance, where lower cost implies better solution. The default implementation returns Integer.MIN_VALUE.In the case of the IntegerCostFunctionScaler, the cost values are all multiplied by the scale factor.
- Specified by:
minCost
in interfaceIntegerCostOptimizationProblem<T extends Copyable<T>>
- Returns:
- A lower bound on the minimum theoretical cost of the problem instance.
-
value
Description copied from interface:IntegerCostOptimizationProblem
Computes the value of the candidate solution within the usual constraints and interpretation of the problem.- Specified by:
value
in interfaceIntegerCostOptimizationProblem<T extends Copyable<T>>
- Parameters:
candidate
- The candidate solution to evaluate.- Returns:
- The actual optimization value of the candidate solution.
-