Viskit Tutorial -- Create Assembly

Contents

  1. Introduction
  2. Creating Event Graph
  3. Creating Assembly
    1. Setup
    2. Event Paramaters
    3. State Parameters
    4. Event Nodes
    5. Event Schedules

3. Creating a Simple Assembly

3.1. Setup

It is necessary to have the two event graphs already loaded. The first graph was created during the Event Graph Tutorial and is called ArrivalProcess. The second graph is SimpleServer. Both of these can be loaded from the 'examples' directory. If you don't have both of these loaded, please do so now.

When the event graphs have correctly loaded, there will be ArrivalProcess and SimpleServer icons in the upper left panel under "Event Graphs". This indicates they have been imported into the Java classpath and can be used to build an assembly. This is indicated in Figure 1.

Figure 1. Availability of Event Graphs in Assembly Editor.

3.2. Preview

First lets see what a finished assembly looks like. Use File Open and go to examples directory as before (up 3 levels), select and open ServerAssembly.xml. You will see the view in Figure 2.

Figure 2. ServerAssembly.xml in the Assembly Editor.

When you double click on various nodes in the graph a description popup is displayed. In this case, there are two different types of popups. The blue boxes display an Event Graph Inspector (see Figure 3). The pink boxes generate a Property Change Listener (PCL) Inspector (see Figure 4). The popups allow various parameter to be inspected or modified.

Figure 3. Event Graph Inspector for the 'sever' event.

Figure 4. Property Change Listener for 'numAvailServersStat'.

The purpose of the 'Assembly Editor' is to connect the needed event graphs and establish the proper listeners for the data of interest. Once that is completed, the simulation is run. This example is now ready to run. That is done by using the 'Compile/initialize assembly runner' icon . Once the button is pressed, Viskit automatically changes tot he 'Assembly Run' tab. (A full description of the 'Assembly Run' tab is in Section 4.)

Click on the VCR Run button to start the simulation. The simulation will take several minutes to run. While it is running you will see a result something like Figure 5. You may choose to de-select the 'Verbose output' check box to reduce the quantity of the output.

Figure 5. Assembly run screen during a simulation run.

3.3. Creating an Assembly

We will now create an assembly. First go back to the 'Assembly Editor' tab. It is not necessary to delete or otherwise modify the existing ServerAssembly graph. A new assembly is created with File New Assembly. The 'Assembly Properties' panel is displayed (see Figure 6). Set the name to 'MyServerAssembly' and the package to 'hello.world', and apply the changes. An empty assembly graph is now presented to the user.

Figure 6. New assembly properties panel.

Drag and drop the 'ArrivalProcess(XML) behavior to the assembly graph. For ease of process, it should go near the upper left. Do the same for the 'SimpleServer(XML)' behavior to the upper right. Figure 7 shows the process.

Figure 7. Process of adding behaviors to the assembly.

The two events need to be connected. Select the "Connect Assemblies with Adapter Pattern" icon and draw a line from the "Arrival Process" event to the "Simple Server" event. This will bring up the "Adapter Connection" popup (see Figure 8).

Figure 8. Adapter Connection popup allows you to enter adapter-specific information.

Select the button after "source event", then select "Arrival" from the popup. Click on "Apply changes" to insert it back into the "Adapter Connection" window. Follow the same steps for the "target event" field, and click on "Apply changes" on the "Adapter Connection" window.

Click on the Select icon, and double-click on the "Arrival Process" event box. That will bring up the "Event Graph Inspector" (see Figure 9). Now click on the button after simkit.random.RandomVariate field. Set the "method" field to "factory" using the drop-down list in the "Object Inspector". Press the 'Enter' key to indicate acceptance of the "Factory class" field (see Figure 10). A "Factory methods" popup will display (see Figure 11). This window allows you to select the actual Java means for generating the values. Choose the entry getInstance(java.lang.String,java.lang.Object[],simkit.random.RandomNumber) and click "OK" to use.

Figure 9. Event Graph Inspector window does ???

Figure 10. Object Inspector selects means for constructing variable??

Figure 11. Java-specific means for generating random variable??

In the field java.lang.String enter simkit.random.Normal3Variate. Click on the button after java.lang.Object[]. That brings up the Array Inspector window. Enter '2' in the field for 'Array length' and press 'Enter'. Two new fields will be present in the window (see Figure 13). These fields are the two parameters that describe a normal distribution. The first parameter (top field) is the mean. The second parameter (bottom box) is the standard deviation. Type new Double(5.0) in the top of the two new boxes. In the bottom box type in new Double(.5).

Figure 12. Define random number generator.

Figure 13. Normal distribution parameter (mean and standard deviation) entry.

The random number method (simkit.random.RandomNumber) field must be filled in. Click on the button. Using the drop-down, set the method to 'factory' (see figure 14), then select the simkit.random.RandomVariateFactory class. The 'Factory methods' dialogue window will popup. Click 'OK'.

Figure 14. Define RandomNumber method.

Don't know what to do next. There appear to be problems in the Object Inspector, and clicking on 'Apply changes' doesn't populate the other Object Inspector window.

Figure 14. Problem here.

Apply the changes to the 'Array Inspector' and 'Object Inspector' dialogue windows. To apply the changes to the 'Event Graph Inspector' dialogue window, first click in the 'description' field, then click on the 'Apply Changes' button.


  1. Apply changes until back to Event Graph Inspector dialog. To activate the Apply Changes there, click in the description field. (bug).
  2. Apply changes here.
  3. Now select SimpleServer. Double click on it.
  4. Repeat above steps for setting simkit.random.RandomVariate for the "serviceTime". Make up some numbers as desired for mean and standard deviation. Say 10.0 and 1.0.
  5. for "totalNumberServers" set int to 2.
  6. select in description again due to bug to enable Apply Changes
  7. double click on arrow just to check out
  8. Statistics: Add a PropertyChangeListener to keep some statistics
  9. Select the lib/simkit.jar tree in the PropertyChangeListener lower left panel in the Assembly Editor
  10. drill down to simkit.stat directory, drag and drop SimpleStatsTally onto the graph.
  11. Select Mode: (4'th box from left) Pink "Connect propertyChangeListener to SimEntity"
  12. Drag arrow from pink SimpleStatsTally to blue SimpleServer box
  13. Property Change Connection popup box, select "..." after the "property" field.
  14. Select numberInQueue for measuring mean number of items in the service queue.
  15. Apply changes.
  16. Apply changes again to the Property Change Connection dialog.
  17. Check out XML by File->View Saved XML, agree to save somewhere with MyServerAssembly.xml as filename.
  18. See XML of the assembly. This is used to create next step Java.
  19. Check out Java by File->Generate Java Source.
  20. Validate source by selecting "Compile Test", mostly classloading messages from compiler, shows good results. No warnings or error messages like "compile failed".
  21. Time to run. Close java source/ xml panels if desired.
  22. Initialize Assembly Runner button
  23. Run as before.
  24. Done.