Step 7. Changing Passenger Arrival Rate InteractivelyEdit
In the current model the passenger arrival rate is fixed. However, AnyLogic provides a set of controls enabling changing the model parameters at the model runtime.
Now we will introduce how you can vary parameters of Pedestrian Library objects dynamically. We want to interactively change the passenger arrival rate to assure acceptable performance of service points with hypothetic load. We will introduce the corresponding control element in the presentation to change the rate interactively.
- Open the Controls stencil of the Palette and drag the Slider element from there into the graphical editor, e.g. to the right of the entrance layout:
- Set the properties of the slider. We want to vary the passenger arrival rate from 0 to 5000 pedestrians per hour. Therefore, specify 5000/hour() as slider’s Maximum value. We type 5000/hour() here since the default model time unit in pedestrian models is day. And since we want to define our rate in peds per hour, we divide the value by the constant defining time value equal to one hour according to the current time unit setting.
- Type 1000/hour() as the slider's Default value.
- Specify pedSource.set_rate(value); as the slider's Action. This code will modify the rate of our PedSource object each time the user will move the slider. value here is the local variable that stores the current value of the slider.
- Add a title for the slider. Drag the Text element from the Presentation palette onto the diagram (above the slider).
- Define the text to be displayed by this label in the Text property:
- In the same way add two text labels displaying slider's minimum (0) and maximum (5000) values. Place them below the slider as shown in the figure below:
Run the model. Now you can change the passenger rate interactively with the slider. Therefore, you can find the maximal passenger arrival rate that can be served.