Search code examples
anylogictime-measurement

Putting Time Measurement in agent parameters


In my model I use time measurements to calculate the waiting time of an order (see figure 1). Now I want to add the value of this waiting time for a specific agent in the agent parameter waiting time, but I've no clue how to exactly do that, what I've currently have is shown in figure 2, but this is ofcourse not working since I'm connecting to the measureEnd block and not the specific time.

Figure 1

Figure 2


Solution

  • timeMeasureEnd is a block that has a dataset in it which you can access by using:

    timeMeasureEnd.dataset
    

    This is where your individual agent data is stored.

    But for your case, my preferred way would be to add a variable of type double for your agent, let's say you name it timeStart. Then, in the "On Enter" field of seizeTransporter type:

    agent.timeStart = time();
    

    On the "On Exit" field type:

    agent.WaitingTime = time() - agent.timeStart;