Inspecting Agents

You can observe the current state of an agent during model simulation using inspect window just like you do with variables. The only difference is that you should first enable inspecting for the agent as described below:

 Enable inspecting for an agent
  1. Open the diagram of the agent type.
  2. Ensure that there is an icon drawn. If the agent has no icon, draw it using some shape, say a rectangle, and make this shape a part of agent's icon by selecting the Icon check box in its properties. 
  3. Enable showing inspect window for this shape on user click. Go to the Advanced section of the shape's properties and type return true; in the On click field. Shapes with the On click action enabled will respond to mouse clicks and show inspect windows.
By default an inspect window displays the agent's name. However, you can adjust the agent to output information you need by overriding its toString() function.

Specify information you want to be shown in the inspect window

  1. In the Projects view, double-click the agent type.
  2. Override the toString() function of this agent type. Go to the Advanced Java section of the agent type's properties and enter the following code in the Additional class code:
public String toString(){
 String info;
 // info = ...    
 return info;

}

Now you can run your model and inspect the state of your agent population during the model simulation.

 To open inspect window for an agent population
  1. Click the icon of the agent population on the presentation. 
  2. The yellow popup box will be shown. If needed, move it by dragging the window title.
  3. Resize it to the desired size by dragging the lower right corner of the window.

If you want to have a look at a well-engineered inspect window, inspect a block from Process Modeling Library.  


Inspect window of Process Modeling Library's Service agent

You can copy the output to the Clipboard for further pasting it to some external application.  

 To copy the content of the inspect window to the Clipboard

  1. Right-click (Mac OS: Ctrl+click) in the inspect window and choose Copy from the context menu. 
You can close inspect window any time you like.

 To close inspect window

  1. Hover the mouse over the title of the inspect window and click the "cross" button  in the upper right corner of the window.