Class NbUnassignedWidth<T>
java.lang.Object
org.ddolib.common.heuristics.width.NbUnassignedWidth<T>
- Type Parameters:
T- the type of the states
- All Implemented Interfaces:
WidthHeuristic<T>
Width heuristic giving to the decision diagrams compiled from a subproblem a maximum width equal
to its number of unassigned variables, i.e. the number of variables minus the depth of the
subproblem (at least 1). It is the default width heuristic of ddo (
NbUnassignedWidth):
the diagrams compiled close to the root are wide, those compiled deep in the search are narrow,
where they are cheap to compile exactly.
The width can be scaled by a constant factor, like the Times heuristic of ddo.
-
Constructor Summary
ConstructorsConstructorDescriptionNbUnassignedWidth(int nbVars) Creates a width heuristic equal to the number of unassigned variables.NbUnassignedWidth(int nbVars, int factor) Creates a width heuristic equal to the number of unassigned variables times a factor. -
Method Summary
Modifier and TypeMethodDescriptionintmaximumWidth(T state) Returns the width at the root, where no variable is assigned: the number of variables (times the factor).intmaximumWidth(T state, int depth) Computes the maximum width allowed for the decision diagrams compiled from a subproblem, given its state and its depth (the number of variables already assigned).toString()
-
Constructor Details
-
NbUnassignedWidth
public NbUnassignedWidth(int nbVars) Creates a width heuristic equal to the number of unassigned variables.- Parameters:
nbVars- the number of variables of the problem
-
NbUnassignedWidth
public NbUnassignedWidth(int nbVars, int factor) Creates a width heuristic equal to the number of unassigned variables times a factor.- Parameters:
nbVars- the number of variables of the problemfactor- the factor applied to the number of unassigned variables (at least 1)- Throws:
IllegalArgumentException- ifnbVarsis negative orfactor < 1
-
-
Method Details
-
maximumWidth
Returns the width at the root, where no variable is assigned: the number of variables (times the factor). The solvers callmaximumWidth(Object, int)instead.- Specified by:
maximumWidthin interfaceWidthHeuristic<T>- Parameters:
state- the state of the subproblem- Returns:
- the width at the root
-
maximumWidth
Description copied from interface:WidthHeuristicComputes the maximum width allowed for the decision diagrams compiled from a subproblem, given its state and its depth (the number of variables already assigned). The solvers call this method; by default, it ignores the depth and returnsWidthHeuristic.maximumWidth(Object).- Specified by:
maximumWidthin interfaceWidthHeuristic<T>- Parameters:
state- the state of the subproblemdepth- the depth of the subproblem, i.e. its number of assigned variables- Returns:
- the maximum width for the layers of the decision diagrams
-
toString
-