Search code examples
anylogic

Anylogic: condition doesn't work always in the same way


I've got a selectOutput block with the following condition: ((agent.DEG_MED)<=(agent.DEG_REG)).

-(agent.DEG_MED) is a double

-(agent.DEG_REG) is a double

if condition is true --> agent.DEG_MED stay the same

if condition is false --> agent.DEG_MED became equals to agent.DEG_REG


ex 1. correct FALSE CONDITION

IN> 12.675171736997056

IN> 1.0

FALSE 12.675171736997056

FALSE 1.0


ex. 2 incorrect TRUE CONDITION

IN> 3.454258675078864

IN> 1.0

TRUE 3.454258675078864

TRUE 1.0


In the ex.2 I should have FALSE exit, but it results to be true. I dont'see any difference with ex.1.

Really need some help!

Thanks


Solution

  • You likely re-evaluate the condition before the value actually has been changed.

    Put a Delay object (with 0 delay time) before the SelectOutput, this allows the engine to actually update your 2nd value.

    PS: This is a common issue, search this place for "on at exit" or SelectOutput