imit_model / AnyLogic / UsersManual(AnyLogic)
.pdf
AnyLogic V User’s Manual
Table 16.
To simplify work with probability distributions, AnyLogic ActiveObject class has static methods (inherited from Func class), wrapping the described above methods of probability distribution classes. You can simply call the static method of the ActiveObject class to obtain random values without instantiating the distribution class, e.g. ActiveObject.exponential( 0.6 ). For more information please consult AnyLogic Class Reference.
© 1992-2004 XJ Technologies http://www.xjtek.com |
257 |
Chapter 11. Running and observing a model
11. Running and observing a model
If you have already built up your model, you may run the model simulation. There are several ways to run the model generated by AnyLogic. You can run the model:
•Directly from AnyLogic.
•Using command line on any Java-enabled machine, see section 18.1, “Running a model from the command line”.
•As an applet, see section 18.2, “Running a model as an applet”.
This chapter describes how to run a model from AnyLogic. This is the simplest way of running the model. The same instance of AnyLogic that was used for editing and building the model launches and serves as a model viewer, controller, and debugger. If you wish, you can specify arbitrary options for Java virtual machine.
AnyLogic gives you the maximum control over the model execution. AnyLogic is an ideal environment for iterating the design and debugging your model (the detailed information on debugging AnyLogic models is given in Chapter 14, “Debugging a model”). AnyLogic shows you the running model in terms of design notation. AnyLogic visual model viewer/debugger features include:
•Step and run modes with a variety of options
•Easy navigation with Model Explorer: any model element is accessible
•On-the-fly animation of structure and statecharts
•Graphical breakpoints, log and inspect windows
•Dataset visualization (scatter, histogram, Gantt) and export to other applications
•Event viewer
•Variable and parameter modification at runtime.
Please note that you cannot use AnyLogic to view a model running as an applet.
258 |
© 1992-2004 XJ Technologies http://www.xjtek.com |
AnyLogic V User’s Manual
11.1 Running the model with AnyLogic
View and debug your model using the Model and View items in the main menu and the Model toolbar, Figure 131. Not all of these buttons are present on the toolbar by default. To add/remove buttons, use the Customize dialog box (see section 21.1, “Customizing toolbars and menus”).
Figure 131. Model toolbar
11.1.1Creating and destroying the model
►To bring the project up to date and create the model (but not start it)
1.Click the Step
toolbar button, or Choose Model|Step from the main menu, or Press F10.
►To bring the project up to date and run the model
1.Click the Run
toolbar button, or Choose Model|Run from the main menu, or Press F5.
You can tell AnyLogic to save your project every time before creating the model.
►To set project autosave before creating the model
1.Choose Tools|Options… from the main menu. The Options dialog box is displayed.
2.On the Miscellaneous page, select the Autosave project on model run check box.
3.Click OK.
© 1992-2004 XJ Technologies http://www.xjtek.com |
259 |
Chapter 11. Running and observing a model
You can set up a timeout for creating a model. When you are creating the model and the specified timeout elapses, AnyLogic stops model creation and displays the message box, with the “Error occurred during the model creation” error message.
►To set up a model creation timeout
1.Choose Tools|Options… from the main menu. The Options dialog box is displayed.
2.Click the Viewer tab of the dialog box.
3.In the Model creation timeout (sec) edit box, specify the timeout for model creation (in seconds).
►To destroy the created model
1.Click the Stop
toolbar button, or Choose Model|Stop from the main menu, or Press Shift+F5.
11.1.2Controlling the model execution
AnyLogic can execute the model in a variety of modes. The modes differ in how frequently the viewer windows are updated (e.g., on every simulation step, each 5 seconds, on every visible change, etc.), and when the model stops to give control back to the user.
The simulation performance depends on the execution mode and on the windows opened in the viewer. The fewer windows are opened, the faster the simulation runs.
There is a notion of simulation step. Each step corresponds to an event in AnyLogic simulation engine, see section 14.2.1, “Event processing at the simulation engine”. In complex models there may be a large density of events, and normally you do not need to trace the model execution to that level of detail. Moreover, depending on which windows are opened in AnyLogic viewer, some steps may appear invisible for the user, because they correspond to events of the objects currently not displayed. Therefore, for user convenience, “regular” Run and Step commands make steps with respect to visible changes only. However,
260 |
© 1992-2004 XJ Technologies http://www.xjtek.com |
AnyLogic V User’s Manual
in case you wish to see all primitive steps, you may use Detailed Play and Primitive Step commands.
►To run the model
1.Click the Run
toolbar button, or Choose Model|Run from the main menu, or Press F5.
When a model starts running, current model time, step and replication values are displayed in the status bar, see Figure 132.
Figure 132. Status bar
You can change the period of status bar update during model run.
►To set up the status bar update period
1.Choose Tools|Options… from the main menu. The Options dialog box is displayed.
2.Click the Viewer tab of the dialog box.
3.In the Model status refresh interval (ms) edit box, specify the update period in milliseconds.
By default, the Run command executes the model as fast as possible, refreshing windows rarely with the period of time specified in AnyLogic options. However, you can refresh windows when needed.
►To refresh windows (excluding animation window) when running the model
1.Choose Model|Refresh Windows from the main menu.
You can configure the viewer update period during model run using the Viewer page of the Options dialog box.
© 1992-2004 XJ Technologies http://www.xjtek.com |
261 |
Chapter 11. Running and observing a model
►To set up the viewer update period
1.Choose Tools|Options… from the main menu. The Options dialog box is displayed.
2.Click the Viewer tab of the dialog box.
3.In the Forced screen refresh interval during play (ms) edit box, specify the viewer update period (in milliseconds).
You can turn the Views Auto Refresh mode on, in which case the model runs in such a way that each change in open windows is reflected.
►To turn the Views Auto Refresh mode on/off
1.Click the Views Auto Refresh
toolbar button, or Choose Model|Auto Refresh Views from the main menu.
If Views Auto Refresh mode is set, the button is shown pressed.
►To make a step (run until a change in any window, then stop)
1.Click the Step
toolbar button, or Choose Model|Step from the main menu, or Press F10.
►To pause the model
1.Click the Pause
toolbar button, or Choose Model|Pause from the main menu, or Press Ctrl+F10.
►To play the model with respect to the current window
(as run, screen updated on any change in the current window)
1.Choose Model|Play in Window from the main menu.
262 |
© 1992-2004 XJ Technologies http://www.xjtek.com |
AnyLogic V User’s Manual
►To make one step with respect to the current window (run until a change in the current windows, then stop)
1.Choose Model|Step in Window from the main menu.
►To make one primitive step
(move to the next event of the simulation engine, then stop)
1.Choose Model|Primitive Step from the main menu, or Press F11.
►To play the model displaying maximum details
(non-stop execution, screen updated on each event of the simulation engine)
1.Choose Model|Detailed Play from the main menu, or Press Ctrl+F11.
►To run the model until a particular time or step condition holds
1.Choose Model|Run to from the main menu.
The Run To Condition dialog box is displayed, as shown in Figure 133.
Figure 133. Run To Condition dialog box
2.Check the type of stop condition (Time, Step, or both).
3.Type the time in the Time edit box. In the corresponding drop-down list specify whether this time is absolute or relative to the current model time.
© 1992-2004 XJ Technologies http://www.xjtek.com |
263 |
Chapter 11. Running and observing a model
4.Type the step in the Step edit box. In the corresponding drop-down list, specify whether this step number is absolute or relative to the current model step.
5.Click the Run button.
►To restart the model
1.Click the Restart Model
toolbar button, or Choose Model|Restart from the main menu, or Press Ctrl+Shift+F5.
The model restart means that all objects in the model are destroyed and created again. The model time is set to 0. No steps are executed. For more information on initialization order see section 22.2.1, “Model initialization order”.
The commands Model|Run, Model|Step, etc. become disabled when there is no activity in the model. This indicates that your model has finished.
11.1.3Setting up model simulation speed
AnyLogic model can be run either in real time or virtual time mode. In real time mode, the mapping of AnyLogic model time to the real time is made. It is frequently needed when you have developed some animation and want it to appear as in real life. In virtual time mode the model runs at its maximum speed and no mapping is made between model time units and a second of astronomical time.
► To set virtual/real time mode
1.Click the Enable virtual time mode
toolbar button.
If virtual time mode is set, the button is shown pressed.
In the real time mode, you can increase or decrease model speed by changing the model simulation speed scale (see section 13.1, “Simulation speed” to know how to define model simulation speed). The model speed scale value is displayed in the Model speed toolbar combo box. The default 1x scale means that the model is simulated with the model simulation speed defined in the properties of the current AnyLogic experiment, 2x means that model is run
264 |
© 1992-2004 XJ Technologies http://www.xjtek.com |
AnyLogic V User’s Manual
twice faster than the specified model speed, etc. For instance, if model speed is 6 model time units per second, 2x means that 12 model time units correspond to 1 second. You can change the model simulation speed as you like.
►To change the model simulation speed scale
1.To decrease model speed, click the Decrease model speed
toolbar button, or Choose from the main menu.
2.To increase model speed, click the Increase model speed
toolbar button, or Choose from the main menu.
11.2 Viewing and controlling the model
You view and control the running model using the following windows (see Figure 134): the Model Explorer window, animated structure diagram window, animated statechart diagram window, inspect, log, chart windows.
The Model Explorer window displays the model elements, organized in a tree, and provides easy navigation and fast access to any of them. The animated structure diagram window visualizes the structure diagram of an active object and provides access to its elements. The variables and parameters changes are automatically displayed and active elements of model are graphically highlighted.
Using these windows you can:
•Open log windows, displaying textual output of a model or of an active object.
•Open inspect windows, displaying the information about the current status of model elements.
•Modify parameters and variables of active objects.
•Visualize datasets by various types of charts (scatter, histogram, Gantt).
•Set up breakpoints on elements of the model.
The animated statechart diagram window provides on-the-fly animation of a statechart and provides access to statechart elements.
© 1992-2004 XJ Technologies http://www.xjtek.com |
265 |
