'Anylogic transitions - Rate condition
I was trying to create a transition between two states with a rate logic: I want that event to happen x times randomly, but only for a limited model time interval (for example from 1 pm to 00 am model time, to specify that this event CAN happen only in this range of time). Do you have any way to suggest? Thanks a lot, P
Solution 1:[1]
Change the transition from rate to message with a particular message as follows:
Then, create a function that returns a double value. The body of the function should be:
if( time() < x )
return 0;
else if( time() >= x && time() < y )
return rate;
else
return 0;
Of course replace x and y with the start time and end time of the time range during which the rate is not 0 and replace rate with the desired rate.
Then create an event of trigger type rate. In the rate field write function(). In the action field write:
if( time() >= x && time() < y )
send( "rate", this);
This last condition before the action of sending the message is important in case the event was scheduled slightly after the range. An event might be schedule a second before the end of the range for a second after the range ends... So we are making sure this is addressed and avoided.
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 |


