Class CompareOperation
- java.lang.Object
-
- de.uka.ipd.sdq.stoex.analyser.operations.CompareOperation
-
- Direct Known Subclasses:
EqualsOperation
,GreaterEqualOperation
,GreaterOperation
,LessEqualOperation
,LessOperation
,NotEqualOperation
public abstract class CompareOperation extends Object
Abstract class with interface for compare operations (e.g., equals, less, etc.). Includes some helper methods for probability functions.
-
-
Constructor Summary
Constructors Constructor Description CompareOperation()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description IProbabilityMassFunction
compare(Object left, Object right)
Compares to objects that represent the left-hand side and the right-hand side of a comparison expression.double
comparePointWise(IProbabilityMassFunction left, IProbabilityMassFunction right, CompareOperation op)
Compares two probability mass functions pointwise.IProbabilityMassFunction
getBoolPMF(double trueProb)
Converts a probability into a boolean PMF.protected abstract IProbabilityMassFunction
getComparePMF(boolean left, boolean right)
Compares two boolean values.protected abstract IProbabilityMassFunction
getComparePMF(double left, double right)
Compares two doubles.protected abstract IProbabilityMassFunction
getComparePMF(double left, IProbabilityMassFunction right)
Compares a PMF with a double.protected abstract IProbabilityMassFunction
getComparePMF(IProbabilityMassFunction left, double right)
Compares a PMF with a double.protected abstract IProbabilityMassFunction
getComparePMF(IProbabilityMassFunction left, IProbabilityMassFunction right)
Compares two PMFs.protected abstract IProbabilityMassFunction
getComparePMF(String left, IProbabilityMassFunction right)
Compares a String and an EnumPMFprotected abstract IProbabilityMassFunction
getComparePMF(String left, String right)
Compares two Strings.double
getProbabilityForValue(IProbabilityMassFunction iPMF, double valueToSeek)
Retrieves the probability for a given value from a PMF.double
getThresholdProbability(IProbabilityMassFunction iPMF, double threshold, boolean includeThreshold)
Returns the sum of probabilities before a given value of a PMF.static IProbabilityMassFunction
invertBoolPMF(IProbabilityMassFunction function)
This method inverts a BoolPMF as required by a NOT statement.
-
-
-
Method Detail
-
compare
public IProbabilityMassFunction compare(Object left, Object right)
Compares to objects that represent the left-hand side and the right-hand side of a comparison expression.- Parameters:
left
-right
-- Returns:
-
comparePointWise
public double comparePointWise(IProbabilityMassFunction left, IProbabilityMassFunction right, CompareOperation op)
Compares two probability mass functions pointwise.- Parameters:
left
-right
-- Returns:
-
getBoolPMF
public IProbabilityMassFunction getBoolPMF(double trueProb)
Converts a probability into a boolean PMF. The probability is taken as value for true and 1-probability as value for false.- Parameters:
left
-right
-- Returns:
-
getProbabilityForValue
public double getProbabilityForValue(IProbabilityMassFunction iPMF, double valueToSeek)
Retrieves the probability for a given value from a PMF.- Parameters:
iPMF
-valueToSeek
-- Returns:
-
getThresholdProbability
public double getThresholdProbability(IProbabilityMassFunction iPMF, double threshold, boolean includeThreshold)
Returns the sum of probabilities before a given value of a PMF.- Parameters:
iPMF
-threshold
-includeThreshold
-- Returns:
-
getComparePMF
protected abstract IProbabilityMassFunction getComparePMF(boolean left, boolean right)
Compares two boolean values.- Parameters:
left
-right
-- Returns:
-
getComparePMF
protected abstract IProbabilityMassFunction getComparePMF(double left, double right)
Compares two doubles.- Parameters:
left
-right
-- Returns:
-
getComparePMF
protected abstract IProbabilityMassFunction getComparePMF(double left, IProbabilityMassFunction right)
Compares a PMF with a double.- Parameters:
left
-right
-- Returns:
-
getComparePMF
protected abstract IProbabilityMassFunction getComparePMF(IProbabilityMassFunction left, double right)
Compares a PMF with a double.- Parameters:
left
-right
-- Returns:
-
getComparePMF
protected abstract IProbabilityMassFunction getComparePMF(IProbabilityMassFunction left, IProbabilityMassFunction right)
Compares two PMFs.- Parameters:
left
-right
-- Returns:
-
getComparePMF
protected abstract IProbabilityMassFunction getComparePMF(String left, IProbabilityMassFunction right)
Compares a String and an EnumPMF- Parameters:
left
-right
-- Returns:
-
getComparePMF
protected abstract IProbabilityMassFunction getComparePMF(String left, String right)
Compares two Strings.- Parameters:
left
-right
-- Returns:
-
invertBoolPMF
public static IProbabilityMassFunction invertBoolPMF(IProbabilityMassFunction function)
This method inverts a BoolPMF as required by a NOT statement. This method would be better placed elsewhere, but it accesses internal knowledge how a BoolPMF is represented as a IProbabilityMassFunction which is only available in this class.- Parameters:
function
-- Returns:
- The inverted function, assuming this is a BoolPMF.
- Throws:
UnsupportedOperationException
- if the passed PMF is not a BoolPMF, i.e. if it does not contain the String literals "TRUE" and "FALSE".
-
-