0

I have a simulation for a supply chain delivery simulation where three vehicle agents are moving from a manufacturer to customers, the model is based on the AnyLogic webinar for Delivery Fleet Optimization with GIS. And the flowchart logic is set up like this:

enter image description here

I am trying to extract some times from the simulation. One of these times is the agent time between trips therefore need to find the time that the agent is not moving during the simulation, ideally this would be done for each vehicle individually or provide the average kind of thing.

I have seen an example here: TimeMeasurementStart and End Where it is discussed you can use a code to collect time data instead of the blocks however some assistance on the specifics of the code required or where that code goes would be really helpful if anyone has any tips!

My assumption would be that if I could say something like: total time - time moving = time not moving

Any help would be appriciated! Natasha

  • There are many, depends on your model. Please ask more specific questions, share details about your setup, etc. I suggest you read up here to learn how to ask great questions: Use https://stackoverflow.com/help/how-to-ask and this article focussed on AnyLogic: https://www.benjamin-schumann.com/blog/2021/4/1/how-to-win-at-anylogic-on-stackoverflow :) – Benjamin Apr 19 '21 at 17:17
  • 1
    Hi Benjamin I have adjusted the question with much more specifics I hope this helps – Natasha Jones Apr 19 '21 at 18:09

2 Answers2

2

alternative to @Benjamin's proposal is to just on exit do:

agent.timeDriving+=time()-agent.getBlockEnterTime()
Felipe
  • 8,311
  • 2
  • 15
  • 31
  • Good point, thx. Note that you still need that custom agent type, the variable "timeDriving" inside it and that the block needs to know that the custom agent type is being used – Benjamin Apr 20 '21 at 07:45
1

First, make sure your trucks are custom agent types that you created yourself, lets call them Truck. Also, your MoveTo blocks must know that it is Truck agents flowing through it (set "Agent type" under "Advanced" to Truck)

Add a variable timeDriving and another timerStart to it. The former is used to sum all driving durations. The latter is used temporarily to measure when driving starts.

Then, use the code boxes in all MoveTo elements as below: enter image description here

Benjamin
  • 10,603
  • 3
  • 16
  • 28