On this page
Magic Model Analyst is capable of initializing both context and runtime objects automatically even if a simulation context does not exist, and no object is configured to initiate the runtime objects.
Context initialization
When executing a Behavior, Magic Model Analyst allows you to simulate its context as well.
To simulate a Behavior with its context
- Right-click a Behavior or a Behavior's diagram and select Simulation > Run with Context to execute it together with its context.
To simulate a Behavior without its context
- Right-click a Behavior or a Behavior's diagram and select Simulation > Run to execute it without its context.
When you simulate a Behavior with its context, Magic Model Analyst will initialize the context of the selected Behavior and simulate the Classifier Behavior. During the Classifier Behavior simulation, if the runtime object of the context Classifier is stable, the selected Behavior will be simulated.
If a selected Behavior has no context, the Run with Context menu will be disabled.
Running a model simulation using the shortcut menu.
Runtime object initialization
When you use an InstanceSpecification to initialize a runtime object, you will also need to use the corresponding slot values of such InstanceSpecification to initialize the feature values of the runtime object. Magic Model Analyst will use the default value of the corresponding feature (property) of each slot if the slot value is empty.
The value of each feature (property) will be automatically initialized only if its Lower-value Multiplicity is more than zero or is undefined. Otherwise (the feature's Lower-value Multiplicity is zero), the feature value will be empty (nothing is initialized). However, characteristic of the initialization depends on the type of the feature. The following sections explain the types of feature that can influence initialization characteristics
Structural feature typed by primitive datatype
The default value of a structural feature, which is typed by a primitive datatype, is its initialized value.This default initialization value, which can be set from Options > Environment >Simulation as shown in following figure. When true and value property has no default value, the value will be initialized to 0 value. The default value is false.
The datatypes which are affected by this option are listed in the table as follows
The Simulation Environment Options - Initialize Empty Values to 0.
This initialization value applies to numerical datatypes only. For other types, see the table for values used for automatic initialization of the Structural Feature typed by primitive datatype as follows.
Primitive DataType (QualifiedName) | Value |
---|---|
| false |
| All numerical data types pick up their default initialization value from Environment Options as shown in the above figure |
| All numerical data types picks up their default initialization value from the Environment Options as shown in the above figure |
| • UML Standard Profile::UML2 Metamodel::PrimitiveTypes::Real |
| "" (Empty String) |
Structural feature typed by non-datatype
If the type of a structural feature is not a datatype, the conditions are applied as follows
- If the structural feature has a non-empty slot value, it will be initialized with such value.
- Otherwise, if the structural feature's default value is specified, it will be initialized with the default value.
If the structural feature also has internal feature(s), for each internal feature, the conditions are applied as follows
- If the internal feature has a non-empty slot value, it will be initialized with such value.
- Otherwise, if the internal feature's default value is specified, it will be initialized with the default value.
If an internal feature also has its own internal feature(s), the same rule above will be applied recursively.
Structural feature typed by user-defined eatatype
For a structural feature typed by a user-defined datatype, the conditions are applied as follows
- If the Datatype has internal structural feature(s), the value of the structural feature will be initialized as described in Structural feature typed by non-datatype.
- If the Datatype has no internal structural feature, the following conditions are applied
- The value of the structural feature will be initialized as described in Structural feature typed by primitive datatype if the Datatype is inherited from a primitive datatype.
- The initialized value of the structural feature will be its default value if the Datatype is not inherited from any primitive datatype. If the default value of the feature is, however, not specified, the initialized value will be empty.