Koen Luppes
Koen Luppes

Reputation: 11

AnyLogic - Why does my condition based transition not work?

enter image description here

I have a question related to a transition in my statechart (see image above). I have a variable called palletInUse which is a boolean-type and changes between true and false. For one transition in my statechart I want it to change when the variable palletInUse has the value true. I have tried it with for example:

palletInUse == true;

and also tried different code like, equals and contentEquals etc. but nothing seems to work. Do you have a solution for this, seemingly simple problem?

Thanks in advance

Upvotes: 0

Views: 1051

Answers (2)

Felipe
Felipe

Reputation: 9431

The condition is not evaluated if nothing is happening, for that reason you have to make something happen constantly to have your condition evaluated. A typical way of doing is as you see in the following pictures:

statechart auxiliar transition

Upvotes: 0

Gregory  Monahov
Gregory Monahov

Reputation: 721

The condition is not monitored constantly, only when something is changed in the agent. When you assign a new value to variable with common "=" Java operator, it is not caught by the AnyLogic engine. You need to call onChange() function after that. Then, the transition should be executed. There are other ways to trigger the condition check without explicit onChange() call. You may find them in AnyLogic Help article. BTW, you may specify just boolean variable as the condition, it is not required to compare it with true or false:

palletInUse

Upvotes: 2

Related Questions