Class NoLayerDecisionDiagram<T>
- Type Parameters:
T- the type representing the problem state at a given node in the diagram
- All Implemented Interfaces:
DecisionDiagram<T>
Each node in the diagram is represented by a NoLayerDecisionDiagram.Node object, and edges between nodes
represent labels applied during the problem-solving process. Unlike the layered
LinkedDecisionDiagram, nodes are not organized in fixed layers: termination is detected via
Problem.isTarget(Object) instead.
This class supports the compilation of exact, relaxed, and restricted decision diagrams.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classAn edge of aNoLayerDecisionDiagram, representing the application of a label from an origin node to a destination node.static classA node of aNoLayerDecisionDiagram, associating a problem state with its incoming/outgoing edges and the bounds computed during compilation. -
Constructor Summary
ConstructorsConstructorDescriptionNoLayerDecisionDiagram(DdoModel<T> model, SubProblem<T> rootSubProblem, CompilationType type, int maxWidth, double primalBound, Optional<Cache<T>> cache) Creates a new decision diagram rooted at the given subproblem. -
Method Summary
Modifier and TypeMethodDescriptionReturns the sequence of decisions leading to the best solution represented in this DD.Returns the value of the best solution represented in this decision diagram, if it exists.voidcompile()Triggers the compilation of the decision diagram according to the configuration parameters provided by the user (e.g., width, relaxation, variable heuristic, etc.).Provides an iterator over the nodes belonging to the exact cutset of the diagram.Exports the compiled decision diagram as a Graphviz-compatible DOT formatted string.booleanisExact()Indicates whether the compiled decision diagram is exact.doubleReturns the minimum lower bound among the nodes expanded during the compilation of this decision diagram, mainly used to compute the optimality gap during a large neighborhood search.intReturns the number of nodes pruned during the compilation of this decision diagram because they were dominated.longReturns the number of nodes expanded during the compilation: the nodes whose successors were computed.intReturns the number of nodes pruned during the compilation of this decision diagram because their fast lower bound could not improve the best known solution.longReturns the number of successors computed during the compilation (one per transition applied, before any pruning or merge with an existing node).intnbNodes()Returns the total number of nodes created during the compilation of this decision diagram.booleanChecks whether the best path found in the relaxed decision diagram is exact.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.ddolib.common.mdd.DecisionDiagram
isInterrupted
-
Constructor Details
-
NoLayerDecisionDiagram
public NoLayerDecisionDiagram(DdoModel<T> model, SubProblem<T> rootSubProblem, CompilationType type, int maxWidth, double primalBound, Optional<Cache<T>> cache) Creates a new decision diagram rooted at the given subproblem.- Parameters:
model- the model providing the problem and heuristics used during compilationrootSubProblem- the subproblem from which the diagram is compiledtype- whether the diagram must be compiled exact, relaxed, or restrictedmaxWidth- the maximum number of nodes allowed once compilation starts pruningprimalBound- the current best known upper bound, used to prune nodescache- the cache used to detect and skip suboptimal subproblems, if enabled
-
-
Method Details
-
compile
public void compile()Description copied from interface:DecisionDiagramTriggers the compilation of the decision diagram according to the configuration parameters provided by the user (e.g., width, relaxation, variable heuristic, etc.).The compilation builds the layered graph structure that encodes the feasible (or relaxed) state space of the problem. Depending on the configuration, this process may yield either an exact or a relaxed DD.
- Specified by:
compilein interfaceDecisionDiagram<T>
-
isExact
public boolean isExact()Description copied from interface:DecisionDiagramIndicates whether the compiled decision diagram is exact.An exact DD represents the full solution space of the original problem, meaning that the best path in the DD corresponds exactly to the true optimal solution.
- Specified by:
isExactin interfaceDecisionDiagram<T>- Returns:
trueif the compiled DD is exact;falseif it is relaxed
-
bestValue
Description copied from interface:DecisionDiagramReturns the value of the best solution represented in this decision diagram, if it exists.For a relaxed DD, this corresponds to a bound (lower or upper depending on the problem formulation). For an exact DD, it is the exact optimal value.
- Specified by:
bestValuein interfaceDecisionDiagram<T>- Returns:
- an
Optionalcontaining the best objective value, or an emptyOptionalif no solution is available
-
bestSolution
Description copied from interface:DecisionDiagramReturns the sequence of decisions leading to the best solution represented in this DD.The returned solution corresponds to the path in the diagram that achieves the best (lowest or highest) objective value. If the DD is relaxed, the returned set may not correspond to a fully feasible solution.
- Specified by:
bestSolutionin interfaceDecisionDiagram<T>- Returns:
- an
Optionalcontaining the set ofDecisionobjects defining the best solution, or an emptyOptionalif none exists
-
exactCutset
Description copied from interface:DecisionDiagramProvides an iterator over the nodes belonging to the exact cutset of the diagram.The exact cutset is the set of subproblems (nodes) that exactly represent the state space at a specific layer, usually the last layer before relaxation or completion. It can be used to guide recomputation, heuristic extensions, or incremental compilation.
- Specified by:
exactCutsetin interfaceDecisionDiagram<T>- Returns:
- an
Iteratorover theSubProblemelements forming the exact cutset
-
relaxedBestPathIsExact
public boolean relaxedBestPathIsExact()Description copied from interface:DecisionDiagramChecks whether the best path found in the relaxed decision diagram is exact.This can occur when the relaxation did not alter the structure along the optimal path, meaning the computed best value is equal to the true optimum even though the DD is relaxed.
- Specified by:
relaxedBestPathIsExactin interfaceDecisionDiagram<T>- Returns:
trueif the relaxed best path corresponds to an exact feasible solution;falseotherwise
-
exportAsDot
Description copied from interface:DecisionDiagramExports the compiled decision diagram as a Graphviz-compatible DOT formatted string.This method is typically used for visualization or debugging purposes. The resulting DOT string can be rendered using Graphviz tools (e.g.,
dot,neato, or web-based renderers).- Specified by:
exportAsDotin interfaceDecisionDiagram<T>- Returns:
- a
Stringcontaining the DOT representation of the compiled decision diagram
-
nbNodes
public int nbNodes()Description copied from interface:DecisionDiagramReturns the total number of nodes created during the compilation of this decision diagram.- Specified by:
nbNodesin interfaceDecisionDiagram<T>- Returns:
- the number of nodes
-
nbExpandedNodes
public long nbExpandedNodes()Description copied from interface:DecisionDiagramReturns the number of nodes expanded during the compilation: the nodes whose successors were computed.- Specified by:
nbExpandedNodesin interfaceDecisionDiagram<T>- Returns:
- the number of expanded nodes
-
nbGeneratedNodes
public long nbGeneratedNodes()Description copied from interface:DecisionDiagramReturns the number of successors computed during the compilation (one per transition applied, before any pruning or merge with an existing node).- Specified by:
nbGeneratedNodesin interfaceDecisionDiagram<T>- Returns:
- the number of generated nodes
-
nbFastLowerBoundPruning
public int nbFastLowerBoundPruning()Description copied from interface:DecisionDiagramReturns the number of nodes pruned during the compilation of this decision diagram because their fast lower bound could not improve the best known solution.- Specified by:
nbFastLowerBoundPruningin interfaceDecisionDiagram<T>- Returns:
- the number of nodes pruned by the fast lower bound
-
nbDominancePruning
public int nbDominancePruning()Description copied from interface:DecisionDiagramReturns the number of nodes pruned during the compilation of this decision diagram because they were dominated.- Specified by:
nbDominancePruningin interfaceDecisionDiagram<T>- Returns:
- the number of nodes pruned by dominance
-
minLowerBound
public double minLowerBound()Description copied from interface:DecisionDiagramReturns the minimum lower bound among the nodes expanded during the compilation of this decision diagram, mainly used to compute the optimality gap during a large neighborhood search.- Specified by:
minLowerBoundin interfaceDecisionDiagram<T>- Returns:
- the minimum lower bound of the expanded nodes
-