AnyLogic 9
Expand
Font size

Phase 5. Adding metrics

It looks like the model now fully reflects the system (the supply chain), but we are not ready to solve the problem. The model requires the following metrics:

  • Inventory — average retailer stock over time.
  • Quality of service — the maximum percentage of oil change stations out of oil at any given time.

It is also important to be able to control the (s,S) parameters from outside the model.

Creating the population statistics

The agent population provides means to gather statistics out of box.

To create a statistics pool

  1. Switch to the Main agent type.
  2. Select the oilChangeStations population.
  3. In the Statistics section of the properties, click Add. This will add a statistics collection element for the entire population.

    AnyLogic 9: The population properties

  4. Set up the statistics element:
    Name: nOutOfOil
    Type: Count: Condition: item.tank.amount() <= 0
    Here, item refers to the population item, that is, an oil change station. The rest is simple: we count the number of stations where the amount of oil is less than or equal to 0. Adding such a statistic means adding an nOutOfOil() function that returns the corresponding number. No statistics will be collected unless you call this function somewhere.

    AnyLogic 9: The population properties

  5. Staying in the Main agent, select the Retailer stock chart we have created earlier. Press Ctrl, then drag and drop the chart on the diagram to create a copy.
  6. Set up the properties of the data item for this new chart:
    Title: Stations out of oil
    Value: oilChangeStations.nOutOfOil() — with this, the plot will call the statistics function and update itself.
    Style: Color: red

    AnyLogic 9: The chart configuration

Adding controls for parameters

To adjust the values of parameters, use the elements of the Controls palette.

To configure the controls

  1. Switch to the Retailer agent type. Select the Smin and Smax parameters and copy them using the context menu.
  2. Switch to the Main agent type. Paste the parameters onto the graphical diagram.
  3. Select the retailer presentation on the Main agent (the image) and in the properties set its parameters to Smax and Smin.

    AnyLogic 9: The parameters on the Main agent diagram

    This will propagate the parameters to Main, the top level of the model.
  4. From the Controls palette, add two Sliders and connect one to Smax and the other to Smin.

    AnyLogic 9: The sliders

    Set the range of both sliders to 0..500.

Run the model again. Try adjusting Smin and Smax with the sliders: optimize away!

AnyLogic 9: Running the model

Although we have the plots with retailer inventory and stations out of oil and can visually assess both, we have not yet created formal numerical metrics for either! They are, as you may recall, average retailer inventory and maximum percentage of stations out of oil at any given time.
How can we improve this article?