'Define agent with parameter (%) and delay time in main is based of it. (Anylogic)
I have a simple model which has a separate Agent called 'Passenger'. Inside the Passenger I have a parameters called 'WITH_CHILDREN' which it's default value is randomTrue(0.5).
In my main process, I would like the Passenger that results TRUE for 'WITH_CHILDREN' to take longer at a specific delay process.
I thought it would be something like (inside the on enter action of the delay):
if(passenger.WITH_CHILDREN == true){
delayTime = triangular(1,5,15);
else{
delayTime = triangular(0,1,1.5);
}
However there are many errors with this :( I would like to link it from the Agent as oppose to setting the percentage in the delay as I have future percentages parameters that will be used on other delays.... If that makes sense.
Solution 1:[1]
You can define this directly in the delay time of the delay block using the following code:
agent.WITH_CHILDREN ? triangular(1,5,15) : triangular(0,1,1.5)
And because an image is better than 1000 words (I made a mistake in the image... it's agent. not passenger.
when you use delayTime in the actions, it's only a readable variable, you can't change it.
And learn about the ? and : operators in java in here: http://www.cafeaulait.org/course/week2/43.html
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 |