Interface Problem<T>
- Type Parameters:
T- the type representing a state in the problem
- All Known Implementing Classes:
ALPProblem,BKSProblem,GRProblem,KSProblem,LCSProblem,Max2SatProblem,MaxCoverProblem,MCPProblem,MispProblem,MKSProblem,MSCTProblem,PDPProblem,PDPTWProblem,PSProblem,SMICProblem,SRFLPProblem,TSPProblem,TSProblem,TSPTWProblem
A Problem defines the state space, the transitions between states induced by
decisions, and the objective values associated with those transitions. Implementations provide
the essential operations required by solvers such as SequentialSolver or ExactSolver.
-
Method Summary
Modifier and TypeMethodDescriptionReturns the domain of possible values for a given variable when applied to a specific state.doubleevaluate(int[] solution) Given a solution such thatsolution[i]is the value of the variablex_i, returns the value of this solution and checks if the solution respects the problem's constraints.default booleanIndicates whether all the transition costs are non-negative, i.e.Returns the initial state of the problem.doubleReturns the initial objective value associated with the initial state.intnbVars()Returns the total number of decision variables in this problem.Returns the known optimal value of the problem, if available.transition(T state, Decision decision) Applies a decision to a state, computing the next state according to the problem's transition function.doubletransitionCost(T state, Decision decision) Computes the change in objective value resulting from applying a decision to a given state.
-
Method Details
-
nbVars
int nbVars()Returns the total number of decision variables in this problem.- Returns:
- the total number of decision variables in this problem
-
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
-
domain
Returns the domain of possible values for a given variable when applied to a specific state.- Parameters:
state- the current statevar- the variable index whose domain is queried- Returns:
- an iterator over all feasible values for the variable in this state
-
transition
Applies a decision to a state, computing the next state according to the problem's transition function.- Parameters:
state- the state from which the transition originatesdecision- the decision to apply- Returns:
- the resulting state after applying the decision
-
transitionCost
Computes the change in objective value resulting from applying a decision to a given state.- Parameters:
state- the state from which the transition originatesdecision- the decision to apply- Returns:
- the incremental objective cost/value associated with this decision
-
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 valuefalse, 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:
trueif every transition cost is non-negative
-
optimalValue
Returns the known optimal value of the problem, if available.Note: This value should correspond to the expected output of the solver. For maximization problems, be careful with negative values.
- Returns:
- an
Optionalcontaining the known optimal value, or empty if unknown
-
evaluate
Given a solution such thatsolution[i]is the value of the variablex_i, returns the value of this solution and checks if the solution respects the problem's constraints.Note: For maximization problems, the returned value is minus the computed value.
- Parameters:
solution- a solution of the problem- Returns:
- the value of the input solution
- Throws:
InvalidSolutionException- if the solution does not respect the problem's constraints
-