Search code examples
simulationanylogic

AnyLogic: intelligent distribution function between two machines


in my model I have simulated 2 machines, see picture.

enter image description here

The machine has a capacity of maximum agents. I have modeled the capacity with a restricted area. This is set to 19 for the upper machine. I have written a function for the distribution. If the upper machine processes 19 agents, incoming agents should be routed to the lower machine.

But now I have the following problem: the distribution does not correspond to the common sense. Suppose the upper machine is currently working with 19 agents and the lower one is being filled. 5 are in the lower one. If the upper machine then lets out an agent, the capacity at the top is free again. This means that the lower machine is never full, but always only half full, because the upper machine is always full.

Does anyone know of some sort of intelligent distribution function? So that the machine that was loaded last is always filled?


Solution

  • You can set a counter as an int starting with 0

    this would work

    if(counter<20){
       counter++;
       return outputTop;
    }else if(counter<25){
       counter++;
       if(counter==25) counter=0;
       return outputBottom;
    }