Giovani Monzambe
Giovani Monzambe

Reputation: 33

Conditional triggered transition with Anylogic

I have a model, where there is a =n agent that we want to change the state based on a condition. my condition is that, the distance between the agent and another agent must be <= 411 before the state changes. I have tried the following code in my condition field:

if (double distanceTo(getNearestAgent(main.Agent))<=411)
{
return true; 
}

i get the syntax errors : misplaced construct(s), and ( expected

What am I doing wrong ? Plz assist

Upvotes: 0

Views: 199

Answers (1)

Benjamin
Benjamin

Reputation: 12795

Since you clarified that "Agent" is the name of your population on Main, your code syntax is wrong. Try this instead:

if (distanceTo(getNearestAgent(main.Agent))<=411) {
    return true; 
}

btw: Be extremly careful with condition-based transitions, they might not trigger when the condition is actually satisfied. Read in the help and around the web to make sure you get it right. Or better: do not use them at all, they also eat performance unnecessarily

Upvotes: 0

Related Questions