Interface Problem<T>

Type Parameters:
T - the type representing a state in the problem
All Known Implementing Classes:
GRProblem, KSProblem, MispProblem, TSPProblem, TSPTWProblem

public interface Problem<T>
Represents an optimization problem formulated as a labeled transition system, without requiring an a priori fixed number of variables.
  • Method Summary

    Modifier and Type
    Method
    Description
    domain(T state)
    Returns the domain of possible labels/actions from a given state.
    double
    evaluate(List<Integer> solution)
    Given a solution (a sequence of applied labels), returns its value and checks if the solution respects the problem's constraints.
    default boolean
    Indicates whether all the transition costs are non-negative, i.e.
    Returns the initial state of the problem.
    double
    Returns the initial objective value associated with the initial state.
    boolean
    isTarget(T state)
    Checks whether the given state is a target (sink) state.
    default Optional<Double>
    Returns the known optimal value of the problem, if available.
    transition(T state, int label)
    Applies a label/action to a state, computing the next state according to the problem's transition function.
    double
    transitionCost(T state, int label)
    Computes the change in objective value resulting from applying a label to a given state.
  • Method Details

    • initialState

      T initialState()
      Returns the initial state of the problem.
      Returns:
      the state representing the starting point of the optimization
    • initialValue

      double initialValue()
      Returns the initial objective value associated with the initial state.
      Returns:
      the starting value of the objective function
    • isTarget

      boolean isTarget(T state)
      Checks whether the given state is a target (sink) state.
      Parameters:
      state - the current state
      Returns:
      true if the state is a target state, false otherwise
    • domain

      Iterator<Integer> domain(T state)
      Returns the domain of possible labels/actions from a given state.
      Parameters:
      state - the current state
      Returns:
      an iterator over all feasible labels for the given state
    • transition

      T transition(T state, int label)
      Applies a label/action to a state, computing the next state according to the problem's transition function.
      Parameters:
      state - the state from which the transition originates
      label - the label to apply
      Returns:
      the resulting state after applying the label
    • transitionCost

      double transitionCost(T state, int label)
      Computes the change in objective value resulting from applying a label to a given state.
      Parameters:
      state - the state from which the transition originates
      label - the label to apply
      Returns:
      the incremental objective cost/value associated with this label
    • hasNonNegativeCosts

      default boolean hasNonNegativeCosts()
      Indicates whether all the transition costs are non-negative, i.e. whether the cost of a partial solution can only increase when it is completed.

      It is only used when the model does not provide a FastLowerBound: the solvers that report a lower bound and a gap (A*, AWA*, ACS) then use the cost of the best open node as lower bound, which is only valid when the remaining costs cannot be negative. With the default value false, no lower bound is reported in that case (the gap is infinite). Maximization problems modeled with negated profits have negative costs and must keep the default value.

      Returns:
      true if every transition cost is non-negative
    • optimalValue

      default Optional<Double> optimalValue()
      Returns the known optimal value of the problem, if available.
      Returns:
      an Optional containing the known optimal value, or empty if unknown
    • evaluate

      double evaluate(List<Integer> solution) throws InvalidSolutionException
      Given a solution (a sequence of applied labels), returns its value and checks if the solution respects the problem's constraints.
      Parameters:
      solution - a solution of the problem (sequence of labels)
      Returns:
      the value of the input solution
      Throws:
      InvalidSolutionException - if the solution does not respect problem's constraints