Phase 2. Setting up the transport base

We will be defining model logic and processes on each agent type diagram in the next phases of model development. We will start with  Main configuration which sets trucks and helicopters position in the space.

Complex simulation modeling cannot go without algorithms that usually perform some data processing or calculations. AnyLogic supports actioncharts - structured block charts allowing defining algorithms graphically in the style of structured programming. We use widely known extension of an approach suggested by Dijkstra that splits algorithms into sub-sections with a single point of entry. It states that three ways of combining programs—sequencing, selection, and iteration—are sufficient to express any computable algorithm. The style reduces understanding an algorithm to understanding each structure on its own. 

Action charts are very helpful since using them you can define algorithms even if you are not familiar with syntax of Java operators.

In fact, action chart visually defines a function and you can use ordinary AnyLogic functions as before. However, using actioncharts gives you one more evident benefit: it visualizes the implemented algorithm, making it more intuitive to other users.

Place the transport at the maintenance center  

  1. Go to  Main and open the Actionchart palette in the Palette view.
  2. Drag the Action chart element into  Main.

  3. Call it setTransportBase. This actionchart does not return anything, it is Just action. Next, insert the element For loop  in this actionchart. When working with actionchart elements, make sure you add them in the right place:

  4. This for loop is of Collection iterator Type for helicopters Collection. Define Item as Helicopter h.

  5. Next, insert Code  into this for loop. 

  6. We want the helicopters to be initially located at the maintenance center coordinates:


  7. Add another block of For loop  with the Code  in this actionchart and configure it to place trucks at the maintenance center, same as helicopters.
  8. You can resize the actionchart elements for the code text to fit in:


We have created the actionchart, called setTransportBase, that represents the function which places the transport at the maintenance center. This is where we need the transport types to be located initially at the model start. 

Select  Main in the model tree (or click anywhere in its graphical editor) and go to its properties. Expand the properties section Agent actions and tell it to run our function On startup of the model: 

Now you can run the model again. You will see that the trucks and helicopters are "sitting" now in the maintenance center. We will define their movement and all other agents behavior in the following phases of model development.


Reference model: Maintenance - Phase 2


          Phase 1. Creating different types of agents

          Phase 3. Defining Transport agent behavior