Stochastical Expressions

Introduction

When modelling with the Palladio Component Model, you can use stochastical expression to specify

Stochastical Expressions can include

Examples

DoublePDF[(1.0;0.3)(1.5;0.2)(2.0;0.5)]
  • Specifies a time interval as boxed probability density function
  • the probability of the time being between 0 and 1 second is 30 percent (0.3)
  • the probability of the time being between 1 and 1.5 seconds is 20 percent (0.2)
  • the probability of the time being between 1.5 and 2 seconds is 50 percent (0.5)
  • the probabilty of the time being longer than 2 seconds is 0 percent.
  • all probabilities sum up to 1.0 
IntPMF[(27;0.1)(28;0.2)(29;0.6)(30;0.1)]
  • Specifies the number of  executing a loop as a probability mass function (PMF)
  • the probability of executing the loop exactly 27 times is 10 percent (0.1)
DoublePMF[(22.3;0.4)(24.8;0.6)]
  • Specifies a floating point variable charcterisation as a probability mass function (PMF)
  • the probability of the variable taking the value 22.3 is 40 percent (0.4)
EnumPMF[("circle";0.2) ("rectangle";0.3)("triangle";0.5)]
  • Specifies a probability mass function over the domain of a parameter
  • Graphics-Objects can either be circles, rectangles, or triangles with the respective probabilities
BoolPMF[(false;0.3)(true;0.7)]
  • Specifies a probabilty mass function for a boolean guard on a branch transition
  • The guard is false with a probability of 30 percent and true with a probablity of 70 percent.
23
  • An integer constant
  • Can be used for example for loop iteration numbers, variable characterisations or resource demands
42.5
  • An floating point number constant
  • Can be used for variable characterisations and resource demands (not for loop iterations)
"Hello World!"
  • A string constant
number.VALUE
  • Characterises the value of the variable "number"
  • You can assign a constant or probabilty function to a characterisation
  • For example, number.VALUE = 762.3 or number.VALUE = DoublePMF[(22.3;0.4)(24.8;0.6)]
graphic.TYPE
  • Characterises the type of the variable "graphic"
  • For example: graphc.TYPE = "polygon"
file.BYTESIZE
  • Characterises the size of variable "file" in bytes
array.NUMBER_OF_ELEMENTS
  • Characterises the number of elements in the collection variable "array"
  • For example:  array.NUMBER_OF_ELEMENTS = IntPMF[(15;0.1)(16;0.9)]
set.STRUCTURE
  • Characterises the structure of the collection variable "set"
  • For example: sorted, unsorted
2+4, 34.3-1, 88.2*1.2, 14/2, 60%12

number.VALUE * 15, file.BYTESIZE / 2
  • Arithmetric expressions can combine constants
  • Allowed are + (addition), - (substraction), * (multiplication), / (division), % (modulo)
  • Arithmetric expressions may include variable characterisations
DoublePDF[(1.0;0.3)(1.5;0.2)(2.0;0.5)] * 15

IntPMF[(1124.0;0.3)(1125.5;0.7)] + 2.5

DoublePDF[(12.0;0.9)(15;0.1)] -
DoublePDF[(128.0;0.3)(256;0.2)(512.0;0.5)]
  • Arithmetric expressions can also combine probability functions
number.VALUE < 20, foo.NUMBER_OF_ELEMENT == 12,
blah.VALUE >= 108.3 AND fasel.TYPE == "mytype"
  • Boolean expressions evalute to true or false
  • You can use them on guarded branch transitions
  • Valid operators are > (greater), < (less), == (equal), <>(not equal), >= (greater equal), <= (less equal), AND, OR, NOT

Predefined Functions

A number of predefined functions can be used in the stochastic expressions. There are two types of functions: Predefined probability functions and auxiliary functions. The functions are listed in the following by their keyword in the stochastic expression.

Predefined probability functions

All functions are evaluated internally with the umontreal.iro.lecuyer.randvar and umontreal.iro.lecuyer.probdist packages. The passed parameters must be double values or be evaluated to double values.

Auxiliary functions

Examples

BNF-Grammar

Parser:

expression : compareExpr;
compareExpr : sumExpr( ( GREATER | LESS | EQUAL | NOTEQUAL | GREATEREQUAL | LESSEQUAL) sumExpr | );
sumExpr : prodExpr ( ( PLUS | MINUS ) prodExpr )*;
prodExpr : powExpr ( ( MUL | DIV | MOD ) powExpr )*;
powExpr : atom( POW atom|);
atom: ( NUMBER | scoped_id | definition | STRING_LITERAL | boolean_keywords | LPAREN compareExpr RPAREN);
scoped_id : ID ( DOT ( ID | "INNER") )*;

definition : "IntPMF" SQUARE_PAREN_L ( numeric_int_sample )+ SQUARE_PAREN_R
| "DoublePMF" SQUARE_PAREN_L ( numeric_real_sample )+ SQUARE_PAREN_R
| "EnumPMF" SQUARE_PAREN_L ( stringsample )+ SQUARE_PAREN_R
| "DoublePDF" SQUARE_PAREN_L( real_pdf_sample )+ SQUARE_PAREN_R
| "BoolPMF" SQUARE_PAREN_L ( boolsample )+ SQUARE_PAREN_R;

boolean_keywords: ( "false"| "true");
numeric_int_sample: LPAREN NUMBER SEMI NUMBER RPAREN;
numeric_real_sample: LPAREN NUMBER SEMI NUMBER RPAREN;
stringsample: LPAREN STRING_LITERAL SEMI NUMBER RPAREN;
real_pdf_sample: LPAREN NUMBER SEMI NUMBER RPAREN;
boolsample: LPAREN boolean_keywords SEMI NUMBER RPAREN
;
characterisation_keywords: ( "BYTESIZE" | "STRUCTURE" | "NUMBER_OF_ELEMENTS" | TYPE" | "VALUE");

Lexer:

mPLUS | mMINUS | mMUL | mDIV | mMOD | mPOW | mLPAREN | mRPAREN | mSEMI | mDEFINITION | mEQUAL | mSQUARE_PAREN_L | mSQUARE_PAREN_R | mNUMBER | mNOTEQUAL | mGREATER | mLESS | mGREATEREQUAL | mLESSEQUAL | mSTRING_LITERAL | mDOT | mID | mWS 

mPLUS:’+’; mMINUS:’-’; mMUL:’*’; mDIV:’/’; mMOD:’%’; mPOW:’ˆ’; mLPAREN:’(’; mRPAREN:’)’; mSEMI:’;’; DEFINITION:’=’; mEQUAL:"=="; mSQUARE_PAREN_L:’[’; mSQUARE_PAREN_R:’]’; 

mDIGIT:’0’..’9’; 
mNUMBER: ( mDIGIT )+( ’.’ ( mDIGIT )+ | );
mALPHA: ’a’..’z’| ’A’..’Z’;

mNOTEQUAL:"<>"; mGREATER:">"; mLESS:"<"; mGREATEREQUAL:">="; mLESSEQUAL:"<="; 
mSTRING_LITERAL:"\""( mALPHA | ’_’ )+ "\""; 
mDOT: ’.’; 
mID:( mALPHA | ’_’)+;             // variable ids
mWS: ( ’ ’| ’\t’| ’\r’| ’\n’);    // whitespace