Package org.ddolib.nolayer.modeling
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 TypeMethodDescriptionReturns the domain of possible labels/actions from a given state.doubleGiven a solution (a sequence of applied labels), returns its value 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.booleanChecks whether the given state is a target (sink) state.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.doubletransitionCost(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
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
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
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 originateslabel- the label to apply- Returns:
- the resulting state after applying the label
-
transitionCost
Computes the change in objective value resulting from applying a label to a given state.- Parameters:
state- the state from which the transition originateslabel- 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 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.- Returns:
- an
Optionalcontaining the known optimal value, or empty if unknown
-
evaluate
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
-