This slides correspond to the talk we gave at the MODEVVA'17 workshop. This work presents an extension of OCL to allow modellers to deal with random numbers and probability distributions in their OCL specifications. We show its implementation in the tool USE and discuss some advantages of this new feature for the validation and verification of models.
2. Random in OCL
• Uncertainty is an essential element of
many of the systems we have to model
• Values of properties representing measures
• Decisions and branches
• Number of elements of populations
• Expected durations, costs, tolerance,…
• Random numbers and probability distributions can be of help here
• They permit combining definite knowledge at one level with uncertain values
• Expectations and assumptions that remain uncertain or imprecise at high-
level, can be made precise and realized by stating the corresponding
percentages or the probability distributions that parameters or values follow
2
3. Random in OCL
• Current OCL specification does not provide support for random
numbers or probability distributions
• Indeterminism only provided by “any()” operation on OCL Collections
11.9.1 Collection
any()
Returns any element in the source collection for which body evaluates to true.
Returns invalid if any body evaluates to invalid for any element, otherwise if
there are one or more elements for which body is true, an indeterminate
choice of one of them is returned, otherwise the result is invalid.
source->any(iterator | body) =
source->select(iterator | body)->asSequence()->first()
3
5. OCL random operations
context Real::rand() : Real
post undetermined:
if self > 0.0 then ( 0.0 <= result ) and ( result < self )
else if self < 0.0 then ( result <= 0.0 ) and ( self < result )
else result = self endif endif
post statisticallyRandom:
-- A sequence contains no recognizable patterns or regularities
-- This property deserves its own discussion :-)
context Integer::srnd() : Integer
post seedGeneration:
-- if self > 0 then self is the new seed
-- else a new seed is automatically generated (time, etc.)
-- in both cases it returns the previous seed
5
15. Conclusions
• Random numbers and Probability distributions permit dealing with
uncertainty at different levels
• Values of parameters and attributes
• Number of objects and links
• Size of test samples and values
• Beyond the basic indeterminism currently provided by OCL.
• Implementation available at
https://www.dropbox.com/s/2j9tgejbj507id0/oclextensions.zip?dl=0
15