The concept of dynamic constraint is to allow parametric calculation of a Constraint Property with another constraint rather than one from its type (Constraint Block). Such constraint can be dynamically obtained during the simulation from typing Constraint Block or one of its subtypes. This section uses the ForwardContractValuation.mdzip sample to demonstrate this concept.
To dynamically apply different constraints to a Constraint Property
In ForwardContractValuation.mdzip, we will dynamically assign a constraint to the Valuation_Rule Constraint Property, which is typed by the Valuation Constraint Block (having two subtypes: Long Valuation and Short Valuation Constraint Blocks with two different constraint expressions) as shown in the following figure. The context of this simulation will be the System Block.
In the following figure, the state machine is used as the classifier behavior of the System block. The Calculate Contract Value for Long Position and Calculate Contract Value for Short Position states apply different valuations to the System block via its entry activity.
The Calculate Contract Value for Long Position's entry activity assigns the runtime value of the Long Valuation Constraint Block to the Valuation_Rule Constraint Property (see the first figure below). Consequently, the values of the constraint parameters will be calculated with the constraint expression specified in Long Valuation.
Similarly, the second figure below demonstrates the Short Valuation dynamic assignment.
The model used in the figures on this page is the ForwardContractValuation.mdzip sample model that comes with the modeling tool.
To open this sample, do one of the following
Related pages