Natasha Jones
Natasha Jones

Reputation: 33

Method the measure the time an agent is not in use during a simulation

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

Upvotes: 0

Views: 231

Answers (2)

Felipe
Felipe

Reputation: 9421

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

agent.timeDriving+=time()-agent.getBlockEnterTime()

Upvotes: 2

Benjamin
Benjamin

Reputation: 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

Upvotes: 1

Related Questions