Interface OptimizationProblem<T extends Copyable<T>>

 Type Parameters:
T
 The type of object used to represent candidate solutions to the problem.
 All Superinterfaces:
Problem<T>
 All Known Implementing Classes:
PolynomialRootFinding
public interface OptimizationProblem<T extends Copyable<T>> extends Problem<T>
The OptimizationProblem interface provides search algorithms with a way to interact with an instance of an optimization problem without the need to know the specifics of the problem (e.g., realvalued function optimization, traveling salesperson, bin packing, etc).
Classes that implement this interface should implement the
value(T)
method such that it returns the actual optimization objective value, and should implement thecost(T)
method such that lower values are better. For a minimization problem, these two methods can be implemented the same, while for a maximization problem, thecost(T)
method represents a transformation from maximization to minimization. This enables search algorithms to be implemented without the need to know if the problem is inherently minimization or maximization. That is, a search algorithm can treat every problem as minimization using thecost(T)
method. Upon completion, results can then be reported in terms of the actual optimization objective function, via thevalue(T)
method.Implementers of this interface should implement the
minCost
method to return a lower bound on the minimum cost across all possible solutions to the problem instance. Implementations should be fast (preferably constant time), and need not be tight. The purpose of this method is to enable a search algorithm to know if further search is futile (e.g., if it actually finds a solution whose cost is equal to the bound on the minimum theoretical cost). For a problem with nonnegative costs, a very simple implementation might simply return 0. The default implementation returns Double.NEGATIVE_INFINITY and is appropriate for a case where bounding the minimum cost may require too much time and where costs may be negative.


Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description double
cost(T candidate)
Computes the cost of a candidate solution to the problem instance.default SolutionCostPair<T>
getSolutionCostPair(T candidate)
Computes the cost of a candidate solution to the problem instance.default boolean
isMinCost(double cost)
Checks if a given cost value is equal to the minimum theoretical cost across all possible solutions to the problem instance, where lower cost implies better solution.default double
minCost()
A lower bound on the minimum theoretical cost across all possible solutions to the problem instance, where lower cost implies better solution.double
value(T candidate)
Computes the value of the candidate solution within the usual constraints and interpretation of the problem.



Method Detail

cost
double cost(T candidate)
Computes the cost of a candidate solution to the problem instance. The lower the cost, the more optimal the candidate solution. Parameters:
candidate
 The candidate solution to evaluate. Returns:
 The cost of the candidate solution. Lower cost means better solution.

minCost
default double 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 Double.NEGATIVE_INFINITY. Returns:
 A lower bound on the minimum theoretical cost of the problem instance.

isMinCost
default boolean isMinCost(double cost)
Checks if a given cost value is equal to the minimum theoretical cost across all possible solutions to the problem instance, where lower cost implies better solution. Parameters:
cost
 The cost to check. Returns:
 true if cost is equal to the minimum theoretical cost,

value
double value(T candidate)
Computes the value of the candidate solution within the usual constraints and interpretation of the problem. Parameters:
candidate
 The candidate solution to evaluate. Returns:
 The actual optimization value of the candidate solution.

getSolutionCostPair
default SolutionCostPair<T> getSolutionCostPair(T candidate)
Computes the cost of a candidate solution to the problem instance. The lower the cost, the more optimal the candidate solution.The default implementation delegates work to the
cost(T)
method, which is the desired behavior in most (probably all) cases. You will not likely need to override this default behavior. Specified by:
getSolutionCostPair
in interfaceProblem<T extends Copyable<T>>
 Parameters:
candidate
 The candidate solution to evaluate. Returns:
 A SolutionCostPair object containing the candidate solution and the cost of that candidate solution. Lower cost means better solution.

