AnyLogic - Why does my condition based transition not work?

北城余情 提交于 2020-01-06 07:14:51

问题


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


回答1:


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




回答2:


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:



来源:https://stackoverflow.com/questions/47888704/anylogic-why-does-my-condition-based-transition-not-work

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!