Agent can contain variables. Variables are generally used to store the results of model simulation, to model some data or object characteristics, changing over time. AnyLogic supports two types of variables – variables and collections.
A collection represents a group of objects, known as its elements. They are used for defining data objects that group multiple elements into a single unit. Collections are used to store, retrieve and manipulate aggregate data. Typically, they represent data items that form a natural group, such as a queue (in this case elements represent people waiting in a queue), or an autopark (elements are trucks), or a telephone directory (a collection performs mapping of names to phone numbers).
In AnyLogic you enter pieces of code in numerous properties of various model elements. It is important to understand exactly where you are writing the code (which agent type and method it belongs to) and how you can access other model elements from there.
The elements of the same agent type are accessed simply by their names.
To access an element of an embedded object you should put a dot "." after the embedded object name and then write the element name. For example, we referred to the function getX() of the maintenance center when creating the actionchart on Main: center.getX(). If the embedded object is replicated, you should say which one exactly you want to access.
To access the object that shares the container with the current one, first get up to the container object and then get down to another agent.
To access the container of the current object you should call <its name>. Note that there is a special element, Link to upper level agent, on every agent type diagram whose agents live in that agent type (here it is Main). The link is called after this upper level agent type and allows us to access it easily by simply referring to its name. For instance, to get to the element trucks[..], which is contained in Main, from within MC, we call main.trucks in MC.
Reference model: Maintenance - Phase 4
Next let us configure Turbine.
Phase 3. Defining Transport agent behavior
Defining Turbine behavior