Class BDDs


  • public abstract class BDDs
    extends java.lang.Object
    The BDDs contains common reliabilityFunctions for/on BDDs.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected static java.lang.String NEWLINE
      The platform-independent newline symbol.
    • Constructor Summary

      Constructors 
      Constructor Description
      BDDs()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      protected static <T> BDD<T> buildConstraintBDD​(java.util.List<org.jreliability.bdd.BDDConstraint.Literal<T>> literals, int rhs, int index, int sum, int materialLeft, java.util.Map<org.jreliability.bdd.BDDConstraint.Pair<java.lang.Integer,​java.lang.Integer>,​BDD<T>> memo, BDDProvider<T> provider)
      Returns a greater-equal constraint represented as a BDD via a recursive procedure proposed by Een & Soerrensson 2006.
      static <T> double calculateTop​(BDD<T> bdd, org.apache.commons.collections15.Transformer<T,​java.lang.Double> transformer)
      Calculates the top event of the BDD based on a functionTransformer that delivers for each variable T a double value.
      protected static <T> void collectDotEdges​(BDD<T> bdd, java.lang.StringBuffer dot, java.util.Map<BDD<T>,​java.lang.String> variables, java.util.Set<BDD<T>> considered)
      Traverses the BDD to collects all edges for the DOT representation.
      protected static <T> void collectDotMarkers​(BDD<T> bdd, java.lang.StringBuffer dot, java.util.Map<T,​java.lang.String> markers)
      Traverses the BDD to setup the correct ranks of all nodes belonging to the same variable.
      protected static <T> void collectDotNodes​(BDD<T> bdd, java.lang.StringBuffer dot, java.util.Map<BDD<T>,​java.lang.String> variables, java.util.Map<T,​java.lang.Integer> counters)
      Traverses the BDD to collects all nodes for the DOT representation.
      protected static <T> void collectDotRanks​(BDD<T> bdd, java.lang.StringBuffer dot, java.util.Map<BDD<T>,​java.lang.String> variables, java.util.Map<T,​java.lang.String> markers)
      Traverses the BDD to setup the correct ranks of all nodes belonging to the same variable.
      protected static <T> void collectNodes​(BDD<T> bdd, T t, java.util.Set<BDD<T>> considered, java.util.Set<BDD<T>> nodes)
      Traverses the BDD to collect all nodes for a given variable T.
      protected static <T> void collectVariables​(BDD<T> bdd, java.util.Set<T> variables, java.util.Set<BDD<T>> considered)
      Traverses the BDD to collect all variables.
      protected static <T> void collectVariablesSorted​(BDD<T> bdd, java.util.List<T> variables)
      Traverses the BDD to collect all variables in the current variable order of the BDD.
      protected static <T> double evaluate​(BDD<T> bdd, org.apache.commons.collections15.Transformer<T,​java.lang.Double> transformer, java.util.Set<BDD<T>> upSort)
      Evaluates the BDD to determine the top event.
      static <T> BDD<T> getBDD​(java.util.List<java.lang.Integer> coeffs, java.util.List<BDD<T>> vars, LinearTerm.Comparator comp, int rhs, BDDProvider<T> provider)
      Converts a linear constraint to a BDD.
      protected static <T> BDD<T> getConstraintBDD​(org.jreliability.bdd.BDDConstraint<T> constraint, BDDProvider<T> provider)
      Returns a greater-equal constraint represented as a BDD.
      static <T> java.util.Set<BDD<T>> getNodes​(T t, BDD<T> bdd)
      Returns all nodes of the BDD that represent the variable T.
      static <T> java.util.Set<T> getVariables​(BDD<T> bdd)
      Returns all variables (elements) T included in the BDD.
      static <T> java.lang.String toDot​(BDD<T> bdd)
      Returns a graphical representation of the BDD in the DOT input format.
      protected static <T> void traverseBDD​(BDD<T> bdd, java.util.Set<BDD<T>> upSort)
      Traverses the BDD to sort the nodes.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • NEWLINE

        protected static final java.lang.String NEWLINE
        The platform-independent newline symbol.
    • Constructor Detail

      • BDDs

        public BDDs()
    • Method Detail

      • getVariables

        public static <T> java.util.Set<T> getVariables​(BDD<T> bdd)
        Returns all variables (elements) T included in the BDD.
        Type Parameters:
        T - the type of variables
        Parameters:
        bdd - the bdd
        Returns:
        all variables T included in the bdd
      • getNodes

        public static <T> java.util.Set<BDD<T>> getNodes​(T t,
                                                         BDD<T> bdd)
        Returns all nodes of the BDD that represent the variable T.
        Type Parameters:
        T - the type of variable
        Parameters:
        t - the variable
        bdd - the bdd
        Returns:
        all nodes in the bdd that represent variable t
      • getBDD

        public static <T> BDD<T> getBDD​(java.util.List<java.lang.Integer> coeffs,
                                        java.util.List<BDD<T>> vars,
                                        LinearTerm.Comparator comp,
                                        int rhs,
                                        BDDProvider<T> provider)
        Converts a linear constraint to a BDD.
        Type Parameters:
        T - the type of variables of the BDD
        Parameters:
        coeffs - the coefficients
        vars - the variables
        comp - the comparator ("<","<=","=",">=",">")
        rhs - the right hand side value
        provider - 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 a BDD.
        Type Parameters:
        T - the type of variables
        Parameters:
        constraint - the greater-equal constraint
        provider - the bdd provider
        Returns:
        the bdd representation of the given constraint
      • toDot

        public static <T> java.lang.String toDot​(BDD<T> bdd)
        Returns a graphical representation of the BDD 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:
        Graphviz – The DOT language
      • calculateTop

        public static <T> double calculateTop​(BDD<T> bdd,
                                              org.apache.commons.collections15.Transformer<T,​java.lang.Double> transformer)
        Calculates the top event of the BDD based on a functionTransformer that delivers for each variable T a double value.
        Type Parameters:
        T - the type of variable
        Parameters:
        bdd - the bdd
        transformer - the transformer that returns a double value for each variable
        Returns:
        the top event of the bdd
      • traverseBDD

        protected static <T> void traverseBDD​(BDD<T> bdd,
                                              java.util.Set<BDD<T>> upSort)
        Traverses the BDD to sort the nodes.
        Type Parameters:
        T - the type of variables
        Parameters:
        bdd - the bdd
        upSort - the sorted bdd nodes
      • evaluate

        protected static <T> double evaluate​(BDD<T> bdd,
                                             org.apache.commons.collections15.Transformer<T,​java.lang.Double> transformer,
                                             java.util.Set<BDD<T>> upSort)
        Evaluates the BDD to determine the top event.
        Type Parameters:
        T - the type of the variables
        Parameters:
        bdd - the bdd
        transformer - the transformer
        upSort - the sorted bdd nodes
        Returns:
        the top event
      • buildConstraintBDD

        protected static <T> BDD<T> buildConstraintBDD​(java.util.List<org.jreliability.bdd.BDDConstraint.Literal<T>> literals,
                                                       int rhs,
                                                       int index,
                                                       int sum,
                                                       int materialLeft,
                                                       java.util.Map<org.jreliability.bdd.BDDConstraint.Pair<java.lang.Integer,​java.lang.Integer>,​BDD<T>> memo,
                                                       BDDProvider<T> provider)
        Returns a greater-equal constraint represented as a BDD via a recursive procedure proposed by Een & Soerrensson 2006.
        Type Parameters:
        T - the type of variables
        Parameters:
        literals - the literals
        rhs - the right hand side of the constraint
        index - the index
        sum - the current sum
        materialLeft - the material that is potentially left to be added to the sum
        memo - the memo maps each point in the recursion to its bdd
        provider - the used bdd provider
        Returns:
        the bdd representation of the given constraint
      • collectDotNodes

        protected static <T> void collectDotNodes​(BDD<T> bdd,
                                                  java.lang.StringBuffer dot,
                                                  java.util.Map<BDD<T>,​java.lang.String> variables,
                                                  java.util.Map<T,​java.lang.Integer> counters)
        Traverses the BDD to collects all nodes for the DOT representation.
        Type Parameters:
        T - the type of variables
        Parameters:
        bdd - the bdd
        dot - the dot input
        variables - the used variables
        counters - the used counters for each element
      • collectDotEdges

        protected static <T> void collectDotEdges​(BDD<T> bdd,
                                                  java.lang.StringBuffer dot,
                                                  java.util.Map<BDD<T>,​java.lang.String> variables,
                                                  java.util.Set<BDD<T>> considered)
        Traverses the BDD to collects all edges for the DOT representation.
        Type Parameters:
        T - the type of variable
        Parameters:
        bdd - the bdd
        dot - the dot input string
        variables - the used variables
        considered - the marker for already considered bdds
      • collectDotMarkers

        protected static <T> void collectDotMarkers​(BDD<T> bdd,
                                                    java.lang.StringBuffer dot,
                                                    java.util.Map<T,​java.lang.String> markers)
        Traverses the BDD to setup the correct ranks of all nodes belonging to the same variable.
        Type Parameters:
        T - the type of variable
        Parameters:
        bdd - the bdd
        dot - the dot input string
        markers - the marker variables for each variable
      • collectDotRanks

        protected static <T> void collectDotRanks​(BDD<T> bdd,
                                                  java.lang.StringBuffer dot,
                                                  java.util.Map<BDD<T>,​java.lang.String> variables,
                                                  java.util.Map<T,​java.lang.String> markers)
        Traverses the BDD to setup the correct ranks of all nodes belonging to the same variable.
        Type Parameters:
        T - the type of variable
        Parameters:
        bdd - the bdd
        dot - the dot input
        variables - the used variables
        markers - the marker variables
      • collectVariables

        protected static <T> void collectVariables​(BDD<T> bdd,
                                                   java.util.Set<T> variables,
                                                   java.util.Set<BDD<T>> considered)
        Traverses the BDD to collect all variables.
        Type Parameters:
        T - the type of variables
        Parameters:
        bdd - the bdd
        variables - the variables
        considered - the already considered bdds
      • collectVariablesSorted

        protected static <T> void collectVariablesSorted​(BDD<T> bdd,
                                                         java.util.List<T> variables)
        Traverses the BDD to collect all variables in the current variable order of the BDD.
        Type Parameters:
        T - the type of variables
        Parameters:
        bdd - the bdd
        variables - the variables
      • collectNodes

        protected static <T> void collectNodes​(BDD<T> bdd,
                                               T t,
                                               java.util.Set<BDD<T>> considered,
                                               java.util.Set<BDD<T>> nodes)
        Traverses the BDD to collect all nodes for a given variable T.
        Type Parameters:
        T - the type of variables
        Parameters:
        bdd - the bdd
        t - the variable
        considered - the already considered bdds
        nodes - the found nodes