Package org.ddolib.modeling
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,PSProblem,SMICProblem,SRFLPProblem,TSPProblem,TSProblem,TSPTWProblem
public interface Problem<T>
Represents an optimization problem formulated as a labeled transition
system, following the semantics of dynamic programming.
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.Returns the initial state of the problem.doubleReturns the initial objective value associated with the initial state.intnbVars()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
-
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
-
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 problem's constraints.
-