0
votes

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.

1
Is this a follow up post for your question here stackoverflow.com/questions/68216923/… ? There the solution to add to the dataset did not require a while loop?Jaco-Ben Vosloo

1 Answers

0
votes

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
    }
}