Package org.jreliability.sl
Class SL<T>
- java.lang.Object
-
- org.jreliability.sl.SL<T>
-
- Type Parameters:
T
- the type of the variables
public class SL<T> extends java.lang.Object
-
-
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
TheTerm
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.
-
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 anANDTerm
with respective AND operation on the bit streams of the operands.protected void
evaluateNOT(Term term)
The evaluation of anNOTTerm
with respective flip of the bit streams of the operand.protected void
evaluateOR(Term term)
The evaluation of anORTerm
with respective OR operation on the bit streams of the operands.protected java.util.BitSet
generateRandomBitstream(double probability)
Generates aBitSet
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 theTerm
(i.e.protected void
initialize(Term term)
-
-
-
Field Detail
-
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.
-
-
Method Detail
-
initialize
protected void initialize(Term term)
- Parameters:
term
- the term to initialize
-
getProbabiliy
public double getProbabiliy(org.apache.commons.collections15.Transformer<T,java.lang.Double> transformer)
Calculates the probability of theTerm
(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 anANDTerm
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 anORTerm
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 anNOTTerm
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 aBitSet
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
-
-