Search code examples
anylogic

Fixed Output sequence for selectOutput5


Problem statement: I want to experiment with different sequences for the routing through the selectOutput5 block.

Example:

Random (all 5 Outputs can be choosen by probability 0.2) (thats the easy part that i solved)

Fixed: (Output1: 6 agents, after those six agents, Output2: six agents and so on... Do you have an idea on how i can do this based on expressions or conditions?

Thank you very much and have a great weekend


Solution

  • Set the "Use:" property in your SelectOutput5 block to "Exit number". Then you can define which exit to use.

    For your example, I would create an int type variable named currExit and set the initial value to 1. Set the value of "Exit number [1..5]:" in your SelectOutput5 block to currExit and write this code to the "On enter:" property:

    if (self.in.count()%6==0) {
        currExit++;
        if (currExit>5) currExit=1;
    }
    

    This switches to the next exit for every 6th agent (self.in.count() returns the number of agents that have entered the block so far).