AnyLogic 9
Expand
Font size

Phase 1. Creating a model

We will start with the high-level structure of the model: the retailer (we have only one) and the oil change stations (we have many of them). We will model the factory later. This means that we will need two new agent types. Both should be located in the Main agent.

AnyLogic Cloud

To use AnyLogic 9 and continue with this tutorial, make sure you have an AnyLogic Cloud account with an active subscription. Otherwise you will not be able to access AnyLogic 9.

To log in to AnyLogic Cloud and create a new model

  1. Log in to AnyLogic Cloud at https://cloud.anylogic.com.
  2. Switch to the My models screen.
  3. Click New model.

    AnyLogic Cloud: The New Model tile

  4. In the dialog that appears, enter the name of your new model: Motor Oil Supply Chain.

    AnyLogic Cloud: The Create new model dialog

The AnyLogic 9 editor opens:

AnyLogic 9: The editor

You are in the editor of the Main agent type. Main is the top-level agent in the model that is created when the model is started. The designated top-level agent can be changed in the properties of the model.

Creating an agent type

An agent type represents a customizable entity within a simulation model that can exhibit individual behavior, state, and interactions with other agents. It serves as a building block for modeling complex systems.

We will begin by creating an agent type for an oil change station.

To create an agent type

  1. Click + to the right of the Main tab.

    AnyLogic 9: Creating the agent

  2. A new agent type is created. In the properties, rename it to OilChangeStation.

    AnyLogic 9: Renaming the agent

  3. Expand the Projects tree to see all the agent types in the model.

    AnyLogic 9: The projects view

Setting up the agent’s icon

The agent icon is a visual representation of an agent type that is used to depict the agent in the simulation’s graphical interface or animation. It is a good idea to customize it to reflect the agent’s role or characteristics in the model.

To create the icon for the oil change station

  1. Open the graphical diagram of the agent type in the editor — the active tab should be named OilChangeStation.
  2. Open the 2D Pictures palette in the palette view.
  3. Drag and drop the House image onto the diagram.

    AnyLogic 9: Creating the agent image

  4. Enlarge the image to approximately 50x50 pixels by pressing Shift and dragging the lower right handle of the image.
    Holding down the Shift key ensures that the original proportions of the image are maintained.
  5. Open the properties of the image by clicking the image.
    In the Visibility and presentation section, select Agent icon: this will make the image the icon for this agent type.

    AnyLogic 9: The Agent icon property

Creating a population

Since we need to model 500 oil change stations, we need to create a population of agents based on our new agent type. An agent population is a collection or group of agents of the same type, allowing you to model multiple entities that can interact with each other and other things within a simulation model.

To create a population of agents

  1. Switch to the Main agent type by clicking the appropriate tab name.
  2. Drag and drop the OilChangeStation agent type from the project view on the Main diagram.

    AnyLogic 9: Creating the population

  3. Double-click the name of the agent that have appeared on the diagram and rename it to oilChangeStations.
  4. Open its properties and, in the upper section (general properties), select Population of agents.
  5. In Initial number of agents, set the size of the population to 500.

    AnyLogic 9: Setting the population’s properties

Adding another agent type

Now, we will create a new agent type to represent the retailer by repeating the steps above.

To create a new agent type and its icon

  1. Click + to the right of the agent tabs and set the name of the new agent to Retailer.
  2. Create the icon for the Retailer agent type by dragging and dropping the Retail Store image from the 2D picture on the diagram of this agent type, enlarging it, and enabling the Agent icon option in the properties.

    AnyLogic 9: Creating the Retailer agent

  3. Similar to the oil change stations, we need our retailer to be present on the Main agent diagram.
    Switch to the Main agent type by clicking the appropriate tab name.
  4. Drag and drop the Retailer agent type from the project view on the Main diagram to create an instance of it.

    AnyLogic 9: The instance of the retailer on the Main agent diagram

Now, when the model is started, it will create the top-level agent of the Main type and then a population of the OilChangeStation agents and a single Retailer agent within (or embedded into) Main.

How can we improve this article?