最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Anylogic Event not triggering - Stack Overflow

programmeradmin1浏览0评论

I have a event that triggers by the condition linesSorted == totalLines. Which are 2 int variables. totalLines increases to about 200 when the model is just starting (within the first second), while linesSorted increases slowly as the simulation progresses.

However, even when the 2 variables are equal, the event is not triggered. The event, 2 variables, and the process blocks are in the same agent, a single agent created inside main.

Why is the event not triggering?

I tried moving the event and variables into main and it does trigger. Why does it only trigger if they are in main?

I have a event that triggers by the condition linesSorted == totalLines. Which are 2 int variables. totalLines increases to about 200 when the model is just starting (within the first second), while linesSorted increases slowly as the simulation progresses.

However, even when the 2 variables are equal, the event is not triggered. The event, 2 variables, and the process blocks are in the same agent, a single agent created inside main.

Why is the event not triggering?

I tried moving the event and variables into main and it does trigger. Why does it only trigger if they are in main?

Share Improve this question asked Mar 13 at 10:57 XanderWXanderW 131 silver badge5 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 1

Just because you define a condition does NOT mean that it is evaluated upon any change in the model.

This would make your models very slow as any condition would constantly check if it triggers.

Instead, it is your responsibility to "tell" the event about it.

In general, you should avoid condition-based events, transitions, etc. They lure you into a false sense of security.

You can replace ANY condition with a safer setup. In your case, whenever you change the 2 int variables, you would check if the condition is now met. If so, you trigger the code of the event (delete the event and put the code into a function)

发布评论

评论列表(0)

  1. 暂无评论