Search code examples
simulationanylogic

Measuring and displaying agent duration in states


I would like to build on to the query from the following link: Agent time-in-state statistics

In my scenario, I have a varying number of agents and I need to display the duration spent in each state by all the agents within the resource pool on a bar chart. In short, each bar in the bar chart must display the total time spent in a specific state for all the agents.

Is there any way to let the bar chart data be a value that loops through the agents within the resource pool and sum up their total duration in each state which is periodically refreshed? Thanks!


Solution

  • As per your referenced answer you need to record the time spent in each state using a variable, and then display this variable in the barchart.

    See example below

    enter image description here

    I have a an agent with a simple statechart and for each state I record the time you enter the state to a variable in the agent. Then when you exit I save the duration (difference between the enter time and the current time) to a variable on main.

    On main there is a population of these agents, all of them saving the time they spent in each state to the variables on main.

    Then also on main I have a bar chart that simply displays the variables

    enter image description here

    And here is result when you run it

    enter image description here