Search code examples
anylogic

Anylogic: Dynamically change source rate using variable/slider


source

I am trying to dynamically change the source Arrival rate using a variable "arrivalRate" linked to a slider (see image).

However, during the simulation the initial rate remains the same, even when I change the arrivalRate. I know that the arrivalRate variable is changing successfully (it is an int) - but this has no effect on the source rate during the simulation.

Anyone have an idea what the issue is - or how to fix it?


Solution

  • Whenever you see the = sign before a field, it means it's not dynamic, it is only evaluated at the start of the model or at the element creation and will not change throughout the simulation run unless you force it. In other words, the variable arrivalRate is checked only once to assign the source's arrival rate and that's it.

    Now if you want to change it dynamically, in the slider's Action field, write the following:

    source.set_rate( arrivalRate );