Interface IntegerCostOptimizationProblem<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 Subinterfaces:
SingleMachineSchedulingProblem
All Known Implementing Classes:
BinPacking, BinPacking.Triplet, BinPacking.UniformRandom, BoundMax, IntegerCostFunctionScaler, LargestCommonSubgraph, MinimizeMakespan, MinimizeMaximumFlowtime, MinimizeMaximumLateness, MinimizeMaximumTardiness, OneMax, OneMaxAckley, PermutationInAHaystack, PermutationToBitVectorProblem.IntegerCost, Porcupine, QuadraticAssignmentProblem, RandomTSPMatrix.Integer, RoyalRoad, TSP.Integer, TSP.IntegerMatrix, TwoMax, TwoMaxEqualPeaks, WeightedEarlinessTardiness, WeightedFlowtime, WeightedLateness, WeightedNumberTardyJobs, WeightedSquaredTardiness, WeightedTardiness

public interface IntegerCostOptimizationProblem<T extends Copyable<T>> extends Problem<T>
The IntegerCostOptimizationProblem 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., traveling salesperson, bin packing, etc). It specifically concerns problems whose cost function is always integer valued, such as most combinatorial optimization problems.

Classes that implement this interface should implement the value(T) method such that it returns the actual optimization objective value, and should implement the cost(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, the cost(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 the cost(T) method. Upon completion, results can then be reported in terms of the actual optimization objective function, via the value(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 non-negative costs, a very simple implementation might simply return 0. The default implementation returns Integer.MIN_VALUE.

  • Method Summary

    Modifier and Type
    Method
    Description
    int
    cost(T candidate)
    Computes the cost of a candidate solution to the problem instance.
    default double
    costAsDouble(T candidate)
    Computes the cost of a candidate solution to the problem instance.
    Computes the cost of a candidate solution to the problem instance.
    default boolean
    isMinCost(int 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 int
    A lower bound on the minimum theoretical cost across all possible solutions to the problem instance, where lower cost implies better solution.
    int
    value(T candidate)
    Computes the value of the candidate solution within the usual constraints and interpretation of the problem.
  • Method Details

    • cost

      int 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 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.
      Returns:
      A lower bound on the minimum theoretical cost of the problem instance.
    • isMinCost

      default boolean isMinCost(int 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

      int 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 interface Problem<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.
    • costAsDouble

      default double costAsDouble(T candidate)
      Computes the cost of a candidate solution to the problem instance. The lower the cost, the more optimal the candidate solution. Note that subinterfaces provide methods for computing the cost as more specific types (e.g., as an int).

      The default implementation delegates work to the cost(T) method. You should not need to override this default behavior.

      Specified by:
      costAsDouble in interface Problem<T extends Copyable<T>>
      Parameters:
      candidate - The candidate solution to evaluate.
      Returns:
      The cost of the candidate solution as a value of type double. Lower cost means better solution.