1

I have a job shop scheduling model in anylogic and I want to do a gantt chart for the resource pools (machines). In resource pools actions section exists one called On unit state change and in the help of the resource pool it says the this field has a busy variable associated to it.

Here is the help of resource pool.

I though I could do a while loop in this field so that when the busy variable is true I add the value 1 to my data set and when busy is false I add the value 0. But the problem is when I run my model using that while loop I don't get any error but my model doens't run anymore.

Here is the while loop.

If anyone know what to do please help. Thank you in advance.

  • Is this a follow up post for your question here https://stackoverflow.com/questions/68216923/anylogic-build-a-time-color-chart-for-the-utilization-of-resource-pools/68219960 ? There the solution to add to the dataset did not require a while loop? – Jaco-Ben Vosloo Jul 07 '21 at 06:09

1 Answers1

0

Yeah, while loops can easily kill models if the condition stays true.

You need to understand that the code is executed whenever any resource in the pool changes its state.

So you should not use a while loop but a simple if-statement:

if (unit.equals(theUnitMyGanttChartCaresAbout) {
    if (busy) {
        // tell Gantt chart that "unit" started being busy
    } else {
        // tell Gantt chart that "unit" started being idle
    }
} 
Benjamin
  • 10,603
  • 3
  • 16
  • 28
  • Well, the key point is that the "On unit state change" action is *only* executed (once) when a resource changes state, so a `while` loop makes no sense: that code doesn't "stay running" after the state change has happened. So this is more a misunderstanding of how actions work for library elements. – Stuart Rossiter Jul 06 '21 at 11:41