Package org.jreliability.bdd
Class BDDs
java.lang.Object
org.jreliability.bdd.BDDs
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected static <T> BDD
<T> buildConstraintBDD
(List<org.jreliability.bdd.BDDConstraint.Literal<T>> literals, int rhs, int index, int sum, int materialLeft, Map<org.jreliability.bdd.BDDConstraint.Pair<Integer, Integer>, BDD<T>> memo, BDDProvider<T> provider) Returns a greater-equal constraint represented as aBDD
via a recursive procedure proposed by Een & Soerrensson 2006.static <T> double
calculateTop
(BDD<T> bdd, org.apache.commons.collections15.Transformer<T, Double> transformer) Calculates the top event of theBDD
based on a functionTransformer that delivers for each variableT
a double value.protected static <T> void
collectDotEdges
(BDD<T> bdd, StringBuffer dot, Map<BDD<T>, String> variables, Set<BDD<T>> considered) Traverses theBDD
to collects all edges for the DOT representation.protected static <T> void
collectDotMarkers
(BDD<T> bdd, StringBuffer dot, Map<T, String> markers) Traverses theBDD
to setup the correct ranks of all nodes belonging to the same variable.protected static <T> void
collectDotNodes
(BDD<T> bdd, StringBuffer dot, Map<BDD<T>, String> variables, Map<T, Integer> counters) Traverses theBDD
to collects all nodes for the DOT representation.protected static <T> void
collectDotRanks
(BDD<T> bdd, StringBuffer dot, Map<BDD<T>, String> variables, Map<T, String> markers) Traverses theBDD
to setup the correct ranks of all nodes belonging to the same variable.protected static <T> void
Traverses theBDD
to collect all nodes for a given variableT
.protected static <T> void
collectVariables
(BDD<T> bdd, Set<T> variables, Set<BDD<T>> considered) Traverses theBDD
to collect all variables.protected static <T> void
collectVariablesSorted
(BDD<T> bdd, List<T> variables) protected static <T> double
evaluate
(BDD<T> bdd, org.apache.commons.collections15.Transformer<T, Double> transformer, Set<BDD<T>> upSort) Evaluates the BDD to determine the top event.static <T> BDD
<T> getBDD
(List<Integer> coeffs, List<BDD<T>> vars, LinearTerm.Comparator comp, int rhs, BDDProvider<T> provider) Converts a linear constraint to aBDD
.protected static <T> BDD
<T> getConstraintBDD
(org.jreliability.bdd.BDDConstraint<T> constraint, BDDProvider<T> provider) Returns a greater-equal constraint represented as aBDD
.Returns all nodes of theBDD
that represent the variableT
.static <T> Set
<T> getVariables
(BDD<T> bdd) Returns all variables (elements)T
included in theBDD
.static <T> String
Returns a graphical representation of theBDD
in the DOT input format.protected static <T> void
traverseBDD
(BDD<T> bdd, Set<BDD<T>> upSort) Traverses the BDD to sort the nodes.
-
Field Details
-
NEWLINE
The platform-independent newline symbol.
-
-
Constructor Details
-
BDDs
public BDDs()
-
-
Method Details
-
getVariables
Returns all variables (elements)T
included in theBDD
.- Type Parameters:
T
- the type of variables- Parameters:
bdd
- the bdd- Returns:
- all variables T included in the bdd
-
getNodes
Returns all nodes of theBDD
that represent the variableT
.- Type Parameters:
T
- the type of variable- Parameters:
t
- the variablebdd
- the bdd- Returns:
- all nodes in the bdd that represent variable t
-
getBDD
public static <T> BDD<T> getBDD(List<Integer> coeffs, List<BDD<T>> vars, LinearTerm.Comparator comp, int rhs, BDDProvider<T> provider) Converts a linear constraint to aBDD
.- Type Parameters:
T
- the type of variables of the BDD- Parameters:
coeffs
- the coefficientsvars
- the variablescomp
- the comparator ("<","<=","=",">=",">")rhs
- the right hand side valueprovider
- the bdd provider- Returns:
- the BDD representing this linear constraint
-
getConstraintBDD
protected static <T> BDD<T> getConstraintBDD(org.jreliability.bdd.BDDConstraint<T> constraint, BDDProvider<T> provider) Returns a greater-equal constraint represented as aBDD
.- Type Parameters:
T
- the type of variables- Parameters:
constraint
- the greater-equal constraintprovider
- the bdd provider- Returns:
- the bdd representation of the given constraint
-
toDot
Returns a graphical representation of theBDD
in the DOT input format.- Type Parameters:
T
- the type of variable- Parameters:
bdd
- the bdd- Returns:
- the bdd as a DOT input string
- See Also:
-
calculateTop
public static <T> double calculateTop(BDD<T> bdd, org.apache.commons.collections15.Transformer<T, Double> transformer) Calculates the top event of theBDD
based on a functionTransformer that delivers for each variableT
a double value.- Type Parameters:
T
- the type of variable- Parameters:
bdd
- the bddtransformer
- the transformer that returns a double value for each variable- Returns:
- the top event of the bdd
-
traverseBDD
Traverses the BDD to sort the nodes.- Type Parameters:
T
- the type of variables- Parameters:
bdd
- the bddupSort
- the sorted bdd nodes
-
evaluate
protected static <T> double evaluate(BDD<T> bdd, org.apache.commons.collections15.Transformer<T, Double> transformer, Set<BDD<T>> upSort) Evaluates the BDD to determine the top event.- Type Parameters:
T
- the type of the variables- Parameters:
bdd
- the bddtransformer
- the transformerupSort
- the sorted bdd nodes- Returns:
- the top event
-
buildConstraintBDD
protected static <T> BDD<T> buildConstraintBDD(List<org.jreliability.bdd.BDDConstraint.Literal<T>> literals, int rhs, int index, int sum, int materialLeft, Map<org.jreliability.bdd.BDDConstraint.Pair<Integer, Integer>, BDD<T>> memo, BDDProvider<T> provider) Returns a greater-equal constraint represented as aBDD
via a recursive procedure proposed by Een & Soerrensson 2006.- Type Parameters:
T
- the type of variables- Parameters:
literals
- the literalsrhs
- the right hand side of the constraintindex
- the indexsum
- the current summaterialLeft
- the material that is potentially left to be added to the summemo
- the memo maps each point in the recursion to its bddprovider
- the used bdd provider- Returns:
- the bdd representation of the given constraint
-
collectDotNodes
protected static <T> void collectDotNodes(BDD<T> bdd, StringBuffer dot, Map<BDD<T>, String> variables, Map<T, Integer> counters) Traverses theBDD
to collects all nodes for the DOT representation.- Type Parameters:
T
- the type of variables- Parameters:
bdd
- the bdddot
- the dot inputvariables
- the used variablescounters
- the used counters for each element
-
collectDotEdges
protected static <T> void collectDotEdges(BDD<T> bdd, StringBuffer dot, Map<BDD<T>, String> variables, Set<BDD<T>> considered) Traverses theBDD
to collects all edges for the DOT representation.- Type Parameters:
T
- the type of variable- Parameters:
bdd
- the bdddot
- the dot input stringvariables
- the used variablesconsidered
- the marker for already considered bdds
-
collectDotMarkers
Traverses theBDD
to setup the correct ranks of all nodes belonging to the same variable.- Type Parameters:
T
- the type of variable- Parameters:
bdd
- the bdddot
- the dot input stringmarkers
- the marker variables for each variable
-
collectDotRanks
protected static <T> void collectDotRanks(BDD<T> bdd, StringBuffer dot, Map<BDD<T>, String> variables, Map<T, String> markers) Traverses theBDD
to setup the correct ranks of all nodes belonging to the same variable.- Type Parameters:
T
- the type of variable- Parameters:
bdd
- the bdddot
- the dot inputvariables
- the used variablesmarkers
- the marker variables
-
collectVariables
Traverses theBDD
to collect all variables.- Type Parameters:
T
- the type of variables- Parameters:
bdd
- the bddvariables
- the variablesconsidered
- the already considered bdds
-
collectVariablesSorted
- Type Parameters:
T
- the type of variables- Parameters:
bdd
- the bddvariables
- the variables
-
collectNodes
Traverses theBDD
to collect all nodes for a given variableT
.- Type Parameters:
T
- the type of variables- Parameters:
bdd
- the bddt
- the variableconsidered
- the already considered bddsnodes
- the found nodes
-