Batch Mode Simulation
In Parts 1 and 2 of the Getting Started tutorial you accomplished the following tasks:
Tutorial Goals
The following is a summary of the concepts and tasks you will learn in Part 3:
Figure 1. VisualSim model with Parameters
VisualSim Model location:
The completed model you are going to build in this tutorial is contained in the following location: $VS/VS_AR/doc/Training_Material/Tutorial/WebHelp/Tutorial/Getting_Started/Part3.xml
Construction StepsStep-1: Open the block diagram created in Part 2 of the tutorial using menu File->Open File and choosing the location where you stored Part2.xml. Save this file in the same location as Part3.xml.
Step-2: Drag a Result ->PlotManager block onto the block diagram. Configure the directory for the output plots as shown in Figure 2. Note
the following.
1.
The PlotManager parameter Plot_Path represents the location where the
plots will be stored,
so make sure that this path is valid for your environment. If you copy
the location from the address bar, the address will be specified
using "\". Change "\" to "/".
Note: Batch simulations cannot run with graphical viewers. Therefore, all Text_Display and Plotters must be configured to be in "Save" mode. This can be done either using the block parameters or by using the Post Processor.
Figure 2: PostProcessor
Double Click on the TimeDataPlotter and Select SavePlot and provide a file name with extension .plt
Figure 3: Plotters in “Save” mode
Step-3: Using Post Processor: Invoke the PostProcessor tool by either double-clicking the PostProcessor Desktop icon or by executing the script (PostProcessor.bat for Windows and PostProcessor.sh for Linux) from the Terminal Window or DOS Command Prompt.
Step-4: Click Activity->Configure Model and select the above model. If the model contains the PlotManager (make sure model is saved), the window in Figure 4 will be displayed. There will be a mixture of Text_Displays and Plotters. First, select parameters that we will vary during this simulation. Click on Save for all Plots and Displays that will needed to be saved. Do not select the View for any item. This will ensure that no real-time displays are available when the Batch-mode simulation is executed. Add a file name for each item that needs to be saved. All plotter views must have a file name with a .plt extension or you will get an error. All text_Displays must have a file name with a .txt extension or you will get an error. Click "Apply". A file called Part3_index.xml will be created in the same directory as the model. Figure 4: Post Processor Configure Menu Operation
Step-4: Now, we must create a batch file. The batch file can be located anywhere but must be invoked from the $VS/VS_AR directory (i.e., <VS_Version>/VS_AR) only. In the batch file, each simulation run has its own execution line definition. The batch file can be created using any editing script. An example batch file for this model which you can modify is as follows:
$VS/VS_AR/doc/Training_Material/Tutorial/WebHelp/Tutorial/Getting_Started/Sim_Batch_Run.bat
The format of this batch file is as follows:
<java directory/bin>/java -classpath <VisualSim install location> VisualSim.actor.gui.VisualSimBatchModeSimulator -resultpath <Preferred path to store result summary> -parameter_name parameter_value ... model_name For this model, the following would be an example of a line contained in the batch file.
Batch file line in Windows (Sim_Batch_Run.bat) <java directory\bin>\java -classpath <VisualSim Location>\VS_AR VisualSim.actor.gui.VisualSimBatchModeSimulator -resultpath C:\VisualSim\Sim_Run -Input_Rate 1.0 -Execution_Time 2.5 file:<Model Location>\Part3.xml Example: (Please Note that the following is a single line) C:\VisualSim\Java\jdk1.8.0_91\bin\java -classpath C:/VisualSim16/VS_AR VisualSim.actor.gui.VisualSimBatchModeSimulator -resultpath C:\VisualSim16\VS_AR\User_Library -Input_Rate 0.5 -Execution_Time 2.5 C:/VisualSim16/VS_AR/doc/Training_Material/Tutorial/WebHelp/Tutorial/Getting_Started/Part3.xml
Batch file line in Linux (Sim_Batch_Run.sh) <java directory/bin>/java -classpath <VisualSim Location>/VS_AR VisualSim.actor.gui.VisualSimBatchModeSimulator -resultpath /VisualSim/Sim_Run -Input_Rate 1.0 -Execution_Time 2.5 file:///<Model Location>/Part3.xml
Copy the batch file mentioned above into the same directory as Part3.xml is located, and modify it to reflect your own environment (i.e., modify for locations of java and your model). Make sure that in the file there is an invocation line defined for each of the three simulation runs. The file name must reflect our host OS (e.g., Windows - Sim_Batch_Run.bat, Linux - Sim_Batch_Run.sh). Finally, make sure that the "execution" permissions are set (e.g., in Linux, chmod +x Sim_Batch_Run.sh).
Step-5: Use the command line to change directory to $VS/VS_AR. From that directory, invoke the batch file. If there are any errors, the model will not run and errors will be displayed in the execution Command Window.
Step-6: Return to the Post Processor window and refer to Figure 5. Select menu Activity->Open Plot Index and select the file Part3_Index.xml. A window will open with the top-half displaying the list of simulations and the bottom half showing the list of available plots. The user may do the following: · Select a plot name or All · Select a list of simulations · Select one among three options below: § View Plot shows results from a single simulation § View Selected Traces shows output for only the list of simulations selected § View All Trace shows the results of all the simulations in a single view · A Plotter window will appear with the combined simulation. · The annotated numbers for the trace names represent the simulation run. In this step, select all choices in the "Select Parameters" section, and in the "Select Plot" section, choose "ALL". Figure 5: Latency plot from the batch run simulation ResultsThe
resulting plot from Step 6 above will look like Figure 6. An
empty plot window may pop up. In this case, select
Edit->Fill. The plot will be visible. Figure 6: Latency plot from the batch run simulation To format the plot, select Edit->Format. Select dots, give a Title, X-axis name and Y-axis name. This is shown in Figure 5. Figure 7: Plotter format options |
Congrats
You have now designed a block diagram, created a model, analyzed the parameters, simulated multiple runs, and interpreted the combined results within VisualSim!!!. You are now ready to explore your own system