Class NoLayerDecisionDiagram<T>

java.lang.Object
org.ddolib.nolayer.solving.ddo.core.mdd.NoLayerDecisionDiagram<T>
Type Parameters:
T - the type representing the problem state at a given node in the diagram
All Implemented Interfaces:
DecisionDiagram<T>

public class NoLayerDecisionDiagram<T> extends Object implements DecisionDiagram<T>
This class implements a decision diagram as a linked structure for the no-layer framework.

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 Classes
    Modifier and Type
    Class
    Description
    static class 
    An edge of a NoLayerDecisionDiagram, representing the application of a label from an origin node to a destination node.
    static class 
    A node of a NoLayerDecisionDiagram, associating a problem state with its incoming/outgoing edges and the bounds computed during compilation.
  • Constructor Summary

    Constructors
    Constructor
    Description
    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.
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns 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.
    void
    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.
    boolean
    Indicates whether the compiled decision diagram is exact.
    double
    Returns 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.
    int
    Returns the number of nodes pruned during the compilation of this decision diagram because they were dominated.
    long
    Returns the number of nodes expanded during the compilation: the nodes whose successors were computed.
    int
    Returns the number of nodes pruned during the compilation of this decision diagram because their fast lower bound could not improve the best known solution.
    long
    Returns the number of successors computed during the compilation (one per transition applied, before any pruning or merge with an existing node).
    int
    Returns the total number of nodes created during the compilation of this decision diagram.
    boolean
    Checks 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, wait

    Methods 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 compilation
      rootSubProblem - the subproblem from which the diagram is compiled
      type - whether the diagram must be compiled exact, relaxed, or restricted
      maxWidth - the maximum number of nodes allowed once compilation starts pruning
      primalBound - the current best known upper bound, used to prune nodes
      cache - the cache used to detect and skip suboptimal subproblems, if enabled
  • Method Details

    • compile

      public void compile()
      Description copied from interface: DecisionDiagram
      Triggers 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:
      compile in interface DecisionDiagram<T>
    • isExact

      public boolean isExact()
      Description copied from interface: DecisionDiagram
      Indicates 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:
      isExact in interface DecisionDiagram<T>
      Returns:
      true if the compiled DD is exact; false if it is relaxed
    • bestValue

      public Optional<Double> bestValue()
      Description copied from interface: DecisionDiagram
      Returns 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:
      bestValue in interface DecisionDiagram<T>
      Returns:
      an Optional containing the best objective value, or an empty Optional if no solution is available
    • bestSolution

      public Optional<Set<Decision>> bestSolution()
      Description copied from interface: DecisionDiagram
      Returns 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:
      bestSolution in interface DecisionDiagram<T>
      Returns:
      an Optional containing the set of Decision objects defining the best solution, or an empty Optional if none exists
    • exactCutset

      public Iterator<SubProblem<T>> exactCutset()
      Description copied from interface: DecisionDiagram
      Provides 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:
      exactCutset in interface DecisionDiagram<T>
      Returns:
      an Iterator over the SubProblem elements forming the exact cutset
    • relaxedBestPathIsExact

      public boolean relaxedBestPathIsExact()
      Description copied from interface: DecisionDiagram
      Checks 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:
      relaxedBestPathIsExact in interface DecisionDiagram<T>
      Returns:
      true if the relaxed best path corresponds to an exact feasible solution; false otherwise
    • exportAsDot

      public String exportAsDot()
      Description copied from interface: DecisionDiagram
      Exports 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:
      exportAsDot in interface DecisionDiagram<T>
      Returns:
      a String containing the DOT representation of the compiled decision diagram
    • nbNodes

      public int nbNodes()
      Description copied from interface: DecisionDiagram
      Returns the total number of nodes created during the compilation of this decision diagram.
      Specified by:
      nbNodes in interface DecisionDiagram<T>
      Returns:
      the number of nodes
    • nbExpandedNodes

      public long nbExpandedNodes()
      Description copied from interface: DecisionDiagram
      Returns the number of nodes expanded during the compilation: the nodes whose successors were computed.
      Specified by:
      nbExpandedNodes in interface DecisionDiagram<T>
      Returns:
      the number of expanded nodes
    • nbGeneratedNodes

      public long nbGeneratedNodes()
      Description copied from interface: DecisionDiagram
      Returns the number of successors computed during the compilation (one per transition applied, before any pruning or merge with an existing node).
      Specified by:
      nbGeneratedNodes in interface DecisionDiagram<T>
      Returns:
      the number of generated nodes
    • nbFastLowerBoundPruning

      public int nbFastLowerBoundPruning()
      Description copied from interface: DecisionDiagram
      Returns 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:
      nbFastLowerBoundPruning in interface DecisionDiagram<T>
      Returns:
      the number of nodes pruned by the fast lower bound
    • nbDominancePruning

      public int nbDominancePruning()
      Description copied from interface: DecisionDiagram
      Returns the number of nodes pruned during the compilation of this decision diagram because they were dominated.
      Specified by:
      nbDominancePruning in interface DecisionDiagram<T>
      Returns:
      the number of nodes pruned by dominance
    • minLowerBound

      public double minLowerBound()
      Description copied from interface: DecisionDiagram
      Returns 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:
      minLowerBound in interface DecisionDiagram<T>
      Returns:
      the minimum lower bound of the expanded nodes