Class ExpressionSolveVisitor
java.lang.Object
org.eclipse.emf.ecore.util.Switch<T>
de.uka.ipd.sdq.stoex.util.StoexSwitch<Object>
de.uka.ipd.sdq.stoex.analyser.visitors.ExpressionSolveVisitor
A visitor for stochastic expressions, which evaluates
the operations within a expression and returns the
resulting expression, which does not contain any operation
any more.
For example, when a stochastic expression contains a
division operation between a INT_PMF and a constant it
returns an INT_PMF divided by the constant.
The visitor is invoked as usual via the
doSwitch(Expression toSolve) command. It returns the solved
expression.
This class uses the operations in
de.uka.ipd.sdq.stoex.analyser.operations as an interface
to the probability function package.
-
Field Summary
Modifier and TypeFieldDescriptionprotected static final IProbabilityFunctionFactory
protected static final ProbfunctionFactory
protected static final StoexFactory
protected final StoexSerialiser
protected final HashMap<Expression,
TypeEnum> Fields inherited from class de.uka.ipd.sdq.stoex.util.StoexSwitch
copyright, modelPackage
-
Constructor Summary
ConstructorDescriptionExpressionSolveVisitor
(HashMap<Expression, TypeEnum> typeAnn, StoexSerialiser stoexSerialiser) Constructor storing the evaluated type annotations. -
Method Summary
Modifier and TypeMethodDescriptionPerforms logical operations (AND, OR).Creates a BoolPMF for the given BoolLiteral.Performs compare operations.Just returns the given double literal.caseFunctionLiteral
(FunctionLiteral object) Returns the result of interpreting the object as an instance of 'Function Literal'.Returns the result of interpreting the object as an instance of 'If Else Expression'.Just returns the given int literal.caseNotExpression
(NotExpression notExpression) Returns the result of interpreting the object as an instance of 'Not Expression'.caseParenthesis
(Parenthesis parenthesis) Forwards the visitor to the inner expression within the parenthesis.Performs a power operation (only for constants).caseProbabilityFunctionLiteral
(ProbabilityFunctionLiteral probFuncLit) Just returns the given probfunction literal.Performs product operations (MULT, DIV, MOD).caseStringLiteral
(StringLiteral object) Returns the result of interpreting the object as an instance of 'String Literal'.Performs term operations (ADD, SUB)caseVariable
(Variable var) Skips variables.Methods inherited from class de.uka.ipd.sdq.stoex.util.StoexSwitch
caseAbstractNamedReference, caseAtom, caseBooleanExpression, caseComparison, caseExpression, caseIfElse, caseNamespaceReference, caseNegativeExpression, caseNumericLiteral, casePower, caseProduct, caseRandomVariable, caseTerm, caseUnary, caseUnitCarryingElement, caseVariableReference, defaultCase, doSwitch, isSwitchFor
-
Field Details
-
iProbFuncFactory
-
probFuncFactory
-
stocFactory
-
stoexSerialiser
-
typeAnnotation
-
-
Constructor Details
-
ExpressionSolveVisitor
public ExpressionSolveVisitor(HashMap<Expression, TypeEnum> typeAnn, StoexSerialiser stoexSerialiser) Constructor storing the evaluated type annotations.- Parameters:
typeAnn
-
-
-
Method Details
-
caseCompareExpression
Performs compare operations.- Overrides:
caseCompareExpression
in classStoexSwitch<Object>
- Parameters:
expr
- the target of the switch.- Returns:
- the result of interpreting the object as an instance of 'Compare Expression'.
- See Also:
-
caseBooleanOperatorExpression
Performs logical operations (AND, OR).- Overrides:
caseBooleanOperatorExpression
in classStoexSwitch<Object>
- Parameters:
expr
- the target of the switch.- Returns:
- the result of interpreting the object as an instance of 'Boolean Operator Expression'.
- See Also:
-
caseTermExpression
Performs term operations (ADD, SUB)- Overrides:
caseTermExpression
in classStoexSwitch<Object>
- Parameters:
expr
- the target of the switch.- Returns:
- the result of interpreting the object as an instance of 'Term Expression'.
- See Also:
-
caseProductExpression
Performs product operations (MULT, DIV, MOD).- Overrides:
caseProductExpression
in classStoexSwitch<Object>
- Parameters:
expr
- the target of the switch.- Returns:
- the result of interpreting the object as an instance of 'Product Expression'.
- See Also:
-
caseIfElseExpression
Description copied from class:StoexSwitch
Returns the result of interpreting the object as an instance of 'If Else Expression'. This implementation returns null; returning a non-null result will terminate the switch.- Overrides:
caseIfElseExpression
in classStoexSwitch<Object>
- Parameters:
expr
- the target of the switch.- Returns:
- the result of interpreting the object as an instance of 'If Else Expression'.
- See Also:
-
caseParenthesis
Forwards the visitor to the inner expression within the parenthesis.- Overrides:
caseParenthesis
in classStoexSwitch<Object>
- Parameters:
parenthesis
- the target of the switch.- Returns:
- the result of interpreting the object as an instance of 'Parenthesis'.
- See Also:
-
caseVariable
Skips variables. This visitor cannot handle variables. Use the PCM Solver to handle variables in stochastic expressions.- Overrides:
caseVariable
in classStoexSwitch<Object>
- Parameters:
var
- the target of the switch.- Returns:
- the result of interpreting the object as an instance of 'Variable'.
- See Also:
-
caseBoolLiteral
Creates a BoolPMF for the given BoolLiteral.- Overrides:
caseBoolLiteral
in classStoexSwitch<Object>
- Parameters:
bl
- the target of the switch.- Returns:
- the result of interpreting the object as an instance of 'Bool Literal'.
- See Also:
-
caseIntLiteral
Just returns the given int literal.- Overrides:
caseIntLiteral
in classStoexSwitch<Object>
- Parameters:
il
- the target of the switch.- Returns:
- the result of interpreting the object as an instance of 'Int Literal'.
- See Also:
-
caseDoubleLiteral
Just returns the given double literal.- Overrides:
caseDoubleLiteral
in classStoexSwitch<Object>
- Parameters:
dl
- the target of the switch.- Returns:
- the result of interpreting the object as an instance of 'Double Literal'.
- See Also:
-
caseStringLiteral
Description copied from class:StoexSwitch
Returns the result of interpreting the object as an instance of 'String Literal'. This implementation returns null; returning a non-null result will terminate the switch.- Overrides:
caseStringLiteral
in classStoexSwitch<Object>
- Parameters:
object
- the target of the switch.- Returns:
- the result of interpreting the object as an instance of 'String Literal'.
- See Also:
-
caseProbabilityFunctionLiteral
Just returns the given probfunction literal.- Overrides:
caseProbabilityFunctionLiteral
in classStoexSwitch<Object>
- Parameters:
probFuncLit
- the target of the switch.- Returns:
- the result of interpreting the object as an instance of 'Probability Function Literal'.
- See Also:
-
casePowerExpression
Performs a power operation (only for constants).- Overrides:
casePowerExpression
in classStoexSwitch<Object>
- Parameters:
expr
- the target of the switch.- Returns:
- the result of interpreting the object as an instance of 'Power Expression'.
- See Also:
-
caseFunctionLiteral
Description copied from class:StoexSwitch
Returns the result of interpreting the object as an instance of 'Function Literal'. This implementation returns null; returning a non-null result will terminate the switch.- Overrides:
caseFunctionLiteral
in classStoexSwitch<Object>
- Parameters:
object
- the target of the switch.- Returns:
- the result of interpreting the object as an instance of 'Function Literal'.
- See Also:
-
caseNotExpression
Returns the result of interpreting the object as an instance of 'Not Expression'. This implementation casts the result of its inner expression to boolean and returns the resulting values. If it cannot be cast to Boolean or BoolPMF, an exception is thrown.- Overrides:
caseNotExpression
in classStoexSwitch<Object>
- Parameters:
notExpression
- the target of the switch.- Returns:
- the result of interpreting the object as an instance of 'Not Expression'.
- See Also:
- Generated class or method.
-