On this page


Magic Model Analyst can simulate the time required to implement an Activity as specified by the duration constraints. It calculates the total Activity duration by adding the simulation time of all visited Actions, and aids in accurately identifying which activities take the longest time to complete. You can see full details about the Activity duration for simulation, including the Activity names and the time between the start and finish of an Activity, in the Simulation console by setting the Console log's filter options to Info. An Activity can contain many Actions. You can specify a duration constraint on any Action in the Activity. The minimum and maximum duration of an Action can be provided through the min and max of the duration constraint. If you simulate the Activity with a specific duration mode, Magic Model Analyst will compute the total time spent when simulating the Activity for you.

When a Behavior's duration is empty or the time is unspecified, Magic Model Analyst will use the duration of called Actions as the duration of the Behavior.


Note

If a Behavior has a property or a structural feature value named duration, Magic Model Analyst will automatically assign the duration value to that particular feature value at runtime. The duration value property must be defined in the Activity, e.g., Change Color as shown in the following figure, or the parent of the duration value property. You can have only one duration value property in the parent Activity to avoid creating multiple duration value properties.


The duration value property is automatically assigned during simulation runtime.

Supported time units

Magic Model Analyst supports extensive Time Units (suffixes) in duration constraints, as well as Time Units of Simulation Configuration, accept time Event, and others. The following list summarizes these suffixes

  • ns, nsec, nanosecond, nanoseconds
  • µs, microsec, microsecond, microseconds

  • ms, millisec, millisecond, milliseconds (by default)
  • s, sec, second, seconds
  • m, min, minute, minutes (All UI, e.g. Charts, CSVExport, etc., will be shown as "min" instead of "m" for meters.)
  • h, hr, hrs, hour, hours
  • d, day, days
  • wk, week, weeks
  • mo, month, months
  • y, a, yr, year, years

You can parse the Time Unit specified as a suffix after a number or at the end of an expression string. However, floating numbers in duration constraints are not supported. Floating numbers are rounded to integers instead of automatically converted to smaller units. If you do not specify a suffix, the millisecond will be used by default. The examples are as follows

  • 100m or 100min is considered 100 minutes.
  • xs is considered the value of the property x in seconds.
  • 200 is considered 200 milliseconds.

    Note

    • If the Time Unit is less than 1 nanosecond, e.g. 0.5 nanosecond or 0.0005 microsecond, a warning message is displayed in the Console pane stating that the default value of 1 nanosecond is applied.
    • Nanosecond and microsecond are supported only for the simulation clock and model based clock, but they are not supported for the built-in PC clock because the returned time of the PC clock using System.currentTimeMillis() is in millisecond. See also in Simulation time and simulation clock.

Duration simulation modes

Magic Model Analyst supports four duration simulation modes. 


Duration Simulation ModeDescription
Min When you select min as the duration simulation mode, Magic Model Analyst will increase the time spent on an Activity by the min duration specified on the duration constraint when an element with an applied duration constraint is activated.
MaxIf you select max as the duration simulation mode, Magic Model Analyst will increase the time spent on an Activity by the max duration specified on the duration constraint when an element with an applied duration constraint is activated. 
Average When Magic Model Analyst simulates your model with the average duration simulation mode, it will use the average value between the max and min duration of the duration constraint as the duration of time spent on simulating an element with an applied duration constraint. 
Random The random mode allows Magic Model Analyst to obtain the duration of time spent on simulating an element with an applied duration constraint from a uniformly distributed random number between the min and max duration of the duration constraint. 


If you specify a duration simulation mode, the time spent on an Activity simulation will be calculated from the duration constraint applied to the elements of the Activity. The duration of time spent on simulating elements with no duration constraints will be zero. If you simulate a model without specifying any duration simulation mode, Magic Model Analyst will ignore those duration constraints and obtain the time spent on simulating the Actions and activities from the simulation clock.

The Duration Simulation modes (min, max, average, and random) are available in the model's Specification window. You can specify the duration constraints of the Activity element by entering the value in the element's Specification window.

Running an Activity simulation

The DurationConstraint.mdzip sample is used as an example to explain how the Activity duration simulation works.

To specify the duration simulation mode and the duration constraints of an Activity, and run the Activity simulation 



  1. Either double-click or right-click a «SimulationConfig»  (e.g., winter) on the diagram pane and select Specification to open the Specification window.

  2. From the Duration Simulation Mode property, select a duration type (e.g., min). The selected duration mode will appear in the «SimulationConfig».



  3. Click .
  4. Open the rainy day scenario on the diagram pane and open the Specification window of each element to specify the duration constraint for the selected duration simulation mode. In this example, double-click 'dig the snow' and specify the duration constraint value.




  5. Click .
  6. Right-click the «SimulationConfig» or click  on the toolbar to run the simulation. View the simulation results of the Activity duration in the Simulation window.


    Right-clicking the «SimulationConfig» on the diagram pane to select the Simulation menu to run the simulation of the «SimulationConfig».

    The Run toolbar button triggers the command to run the simulation of the «SimulationConfig».
    The Console tab in the Simulation window contains the simulation of Activity duration of the DurationConstraint.mdzip sample from start to finish.

If you simulate a call Behavior Action having a duration constraint with a duration simulation mode and the time spent on the called Behavior is beyond the range of the duration constraint specified on the call Behavior Action, the call Behavior Action will be considered as a broken constraint element. Magic Model Analyst will then pause the model simulation at the call Behavior Action.

Duration constraints on Activities

Magic Model Analyst also supports simulation when you define a duration constraint for an Activity itself apart from a Call Behavior Action. The duration constraint on the Activity is interpreted the same as the duration constraint on the Call Behavior Action. The duration constraint can be shown in the Timeline chart or on the Console pane. In the following figure, the duration constraint is shown on the Console pane.


A duration constraint is applied on the Activity as shown on the Console pane.

Note

If the duration constraints are defined on both Activity and Call Behavior Action, the constraints of the Call Behavior Action will be used, and the constraints of the Activity will be ignored.

Glossary

ConceptDescription
Activity

The duration simulation mode specifies the duration to run the simulation of the elements with applied duration constraints.

Duration constraintThe duration constraint is an interval constraint that refers to a duration interval. Use the duration interval to determine whether the constraint is satisfied.
Call Behavior ActionThe call Behavior Action is a call Action that invokes a Behavior directly rather than invoking an operation that invokes the Behavior.

Sample model


DurationConstraint.mdzip