Class SL<T>

  • Type Parameters:
    T - the type of the variables

    public class SL<T>
    extends java.lang.Object
    The SL uses the concept of stochastic logic [A] to evaluate a given Term. [A] Aliee, H. and Zarandi, H.R.. Fault tree analysis using stochastic logic: A reliable and high speed computing. In Proceedings of the Annual Reliability and Maintainability Symposium (RAMS), 2011.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected int bitStreamLength
      The length of the used bit streams for stochastic logic.
      protected java.util.Map<Term,​java.lang.Integer> numberOfOperands
      The number of operands for each term which are then popped from the stack.
      protected java.util.Stack<java.util.BitSet> operandsStack
      The stack to process the terms.
      protected Term term
      The Term to be evaluated.
      protected java.util.Map<Term,​java.util.BitSet> termCache
      In stochastic logic, equal variables have to be modeled using exactly the same bit stream (since they are actually the same!).
      protected java.util.List<Term> termsForStackProcessing
      A list that orders the terms in such a way that they can later be sequentially evaluated using a stack.
    • Constructor Summary

      Constructors 
      Constructor Description
      SL​(Term term)
      Constructs an SL with a given Term.
      SL​(Term term, int bitStreamLength)
      Constructs an SL with a given Term and a given length of the bit streams to use.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected void evaluate​(org.apache.commons.collections15.Transformer<T,​java.lang.Double> transformer)
      The evaluation performs the actual stochastic logic calculations by a sequential processing of the different terms according to their order and using a stack.
      protected void evaluateAND​(Term term)
      The evaluation of an ANDTerm with respective AND operation on the bit streams of the operands.
      protected void evaluateNOT​(Term term)
      The evaluation of an NOTTerm with respective flip of the bit streams of the operand.
      protected void evaluateOR​(Term term)
      The evaluation of an ORTerm with respective OR operation on the bit streams of the operands.
      protected java.util.BitSet generateRandomBitstream​(double probability)
      Generates a BitSet representing the bit stream where the ratio of 1s and 0s resembles the given probability.
      double getProbabiliy​(org.apache.commons.collections15.Transformer<T,​java.lang.Double> transformer)
      Calculates the probability of the Term (i.e.
      protected void initialize​(Term term)
      Initializes the SL by ordering the Term for the stack processing.
      • Methods inherited from class java.lang.Object

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

      • term

        protected Term term
        The Term to be evaluated.
      • bitStreamLength

        protected final int bitStreamLength
        The length of the used bit streams for stochastic logic.
      • termsForStackProcessing

        protected java.util.List<Term> termsForStackProcessing
        A list that orders the terms in such a way that they can later be sequentially evaluated using a stack.
      • numberOfOperands

        protected java.util.Map<Term,​java.lang.Integer> numberOfOperands
        The number of operands for each term which are then popped from the stack.
      • operandsStack

        protected java.util.Stack<java.util.BitSet> operandsStack
        The stack to process the terms.
      • termCache

        protected java.util.Map<Term,​java.util.BitSet> termCache
        In stochastic logic, equal variables have to be modeled using exactly the same bit stream (since they are actually the same!). This is realized by the term cache.
    • Constructor Detail

      • SL

        public SL​(Term term)
        Constructs an SL with a given Term.
        Parameters:
        term - the term to evaluate
      • SL

        public SL​(Term term,
                  int bitStreamLength)
        Constructs an SL with a given Term and a given length of the bit streams to use.
        Parameters:
        term - the term to evaluate
        bitStreamLength - the length of the bit streams
    • Method Detail

      • initialize

        protected void initialize​(Term term)
        Initializes the SL by ordering the Term for the stack processing.
        Parameters:
        term - the term to initialize
      • getProbabiliy

        public double getProbabiliy​(org.apache.commons.collections15.Transformer<T,​java.lang.Double> transformer)
        Calculates the probability of the Term (i.e. the top event) based on a given probabilities of the basic events.
        Parameters:
        transformer - the probabilities of the basic events
        Returns:
        the probability of the top event
      • evaluate

        protected void evaluate​(org.apache.commons.collections15.Transformer<T,​java.lang.Double> transformer)
        The evaluation performs the actual stochastic logic calculations by a sequential processing of the different terms according to their order and using a stack. Note that this function leaves its current result on the stack - eventually, the result for the top event will remain on the stack!
        Parameters:
        transformer - the probability of the basic events
      • evaluateAND

        protected void evaluateAND​(Term term)
        The evaluation of an ANDTerm with respective AND operation on the bit streams of the operands.
        Parameters:
        term - the ANDTerm to evaluate
      • evaluateOR

        protected void evaluateOR​(Term term)
        The evaluation of an ORTerm with respective OR operation on the bit streams of the operands.
        Parameters:
        term - the ORTerm to evaluate
      • evaluateNOT

        protected void evaluateNOT​(Term term)
        The evaluation of an NOTTerm with respective flip of the bit streams of the operand.
        Parameters:
        term - the NOTTerm to evaluate
      • generateRandomBitstream

        protected java.util.BitSet generateRandomBitstream​(double probability)
        Generates a BitSet representing the bit stream where the ratio of 1s and 0s resembles the given probability. This implementation does not apply this probability on a per-bit basis but considers the bit length with respective rounding effects!
        Parameters:
        probability - the probability to model with the bit stream
        Returns:
        the bit stream