1

So for my project in area of Industrial Engineering, I am making a warehouse simulation and optimization model in software Anylogic. I want to know the time my picker spends in being busy( that is moving) and so I came across this built-in function 'timeInState'. This helps me to determine the total time by picker has spent being 'busy'.

The issue I am facing is that upon calling this function, I am getting no value (0), but my pickers are clearly moving in the model. Maybe the parameters I am giving is not the right way to do it. I was thinking if anyone familiar with this can help me out? . To clarify the function, its meaning and parameter initialization is as below:

double timeInState(ResourceUsageState state) -Returns the time the unit has spent in the given "usage state" so far. Parameter: state - the state (ResourceUsageState.USAGE_IDLE or ResourceUsageState.USAGE_BUSY)

Thanks for your help !

Anuj Jain
  • 11
  • 1

2 Answers2

0

The timeInState function has nothing to do with state charts but records durations for resources. It is named rather unfortunately...

There is no build-in way to measure state durations (for good reasons ;-) ).

Easiest solution:

  1. create a double variable timer and another timeInStateX
  2. on-enter of your state X, set timer=time()
  3. on-exit of your state X, add the duration as timeInStateX += (time()-timer

Make sure to not accidentally overwrite the timer from elsewhere, though

Benjamin
  • 10,603
  • 3
  • 16
  • 28
0

The timeInState function does work to capture time busy so you must have another problem. You should be calling it similarly to <resource reference>.timeInState(ResourceUsageState.USAGE_BUSY) or (specifying time units) <resource reference>.timeInState(ResourceUsageState.USAGE_BUSY, TimeUnits.MINUTE).

You'll need to give more context to understand why it's not working for you.

You are also seizing and releasing these agents as resources in a ResourcePool right?

Stuart Rossiter
  • 2,432
  • 1
  • 17
  • 20
  • By do you mean the name of the ResourcePool block or is it the name of the agent of the Resource pool ? Also the seizing and release is done by the rackstore block, so I guess that is okay. – Anuj Jain Feb 08 '20 at 05:40
  • Also, should the agent be created from the 'agent' tab or from the process modelling library- 'agent type' or 'resource type' tab. I believe they both are different. By agent I mean the agent which we specify in the ResourcePool tab. – Anuj Jain Feb 08 '20 at 05:55
  • It has to be called on an agent from the resource pool (not the resource pool itself) and, yes, the agent type for the resource pool needs to be created via the Resource Type element (which is the same as creating it via New --> Agent Type and ticking 'Use in flowchart' as a resource). If not, it doesn't have the `timeInState` method available. – Stuart Rossiter Feb 09 '20 at 23:13
  • I called the from the agent of the resourcepool created from the resource type element. As you mentioned, the function should be listed in the menu but it is not there. I was able to see the function before as I had been giving the resource reference as name of resourcepool. Do you know why the method is not available ? – Anuj Jain Feb 16 '20 at 15:56