0
votes

In a model I use a selectoutput block using a condition, based on the agent's p_Dx_EGFR_SOC_AH parameter, which is of type Option list (options: Mutated, NotMutated, UnknownStatus). If agent.p_Dx_EGFR_SOC_AH == Mutated evaluates to true, then the exit via the true port, otherwise they exit through the false port. To check whether it works correctly, I included a traceln(agent.p_Dx_EGFR_SOC_AH); in the On exit (True) field of that selectoutput block.

enter image description here

It turns out it's not working as expected. The traceline shows that agents with either of the three options of the parameter exit through the True port:

enter image description here

This is also true for the False port; agents with either of the three options exit through that port. Am I doing something wrong here, or is this a known bug in AnyLogic?

1

1 Answers

1
votes

The problem here, is that the order in which things are calculated is in reverse... so let's imagine the following model and the condition to exit true is agent.parameter==0 and the default value of the parameter is 0 model

the order in which things happens is

  1. the agent is on at the exit port of the source block
  2. the agent calculates the condition on the selectoutput block
  3. the agent moves out of the source block and makes the calculations on the "on exit" action

that means that if you change the value of the parameter on the on exit action of the source block agent.parameter=1, the agent will still exit on the true exit of the selectoutput becacuse the condition was already calculated

if you change the value of the parameter on the on at exit action, the agent will exit through the false exit of the selectoutput block

It's a bit weird, but that's the way things are done

Sometimes you don't have the "on at exit" action, in which case you might need in between an auxiliary delay of 1 milisecond in order to have the order you want.