When you initiate the movement of an agent, it starts moving at the speed that is set for this agent as its initial speed.
Please note that in AnyLogic, the agent's initial speed can be set in several places. Let's list them, and also determine which ones take precedence over others. So, the agent's movement speed can be set in the following elements:
- Agent type. The Initial speed property in the Dimensions and movement section. Here you set the default initial speed for all agents of this type.
- Single agent / population of agents. The Initial speed property in the Dimensions and movement section. Here you can override the value set in the agent type for this particular agent (or agents in this population). An important note about default values and how they can be changed. Until you change this value yourself, it will automatically change when you change the initial speed set for the corresponding agent type. If you enter some other value here, then this dependency will be lost.
-
The Source block of the Process Modeling Library (Speed property) - here you can set the speed of the agents created by this block. Overrides the values set in both the agent type and the agent or population itself.
In this article, we do not consider blocks similar to the Source block of other AnyLogic libraries, since they create agents specific to these libraries (pedestrians, cars, etc.). In general, these blocks provide similar properties for setting speed, for example, the PedSource block of the Pedestrian Library that creates pedestrians has the Initial Speed property in the Pedestrian section), and similarly for the blocks TrainSource, CarSource, etc.
- If you configure agent movement with the help of MoveTo block, you can set custom agent speed in its properties. To do this, select the Set agent speed option, and then the speed of the agent movement specified by the block can be explicitly set below in the Speed field. This value overrides all other speed settings for this agent for this particular agent movement initiated by this block (and only for it!).
In all cases, you can choose the speed units. By default, the speed is set to 10 meters per second.
In the model example, the agent types Car and Train are left with their default speed values, while the real speed values are set for the populations cars and trains.
Demo model: Route Provider Open the model page in AnyLogic Cloud. There you can run the model or download it (by clicking Model source files).Although AnyLogic directly supports movement at a constant speed only, you can model acceleration and/or deceleration by changing the speed at the appropriate time moments using the agent functions (see below). You can use statechart with states like Static, Slow, Medium, Fast, etc. and timeout transitions to control the motion.
- Functions
-
Function Description double getSpeed() Returns the agent speed (speed is the setting of the agent, its "cruising speed"), measured in meters per second. Note that nonzero speed does not mean the agent is moving - it starts moving only after moveTo() function is called. double getSpeed(SpeedUnits units) Returns the agent speed, measured in specified units. Note that nonzero speed does not mean the agent is moving - it starts moving only after moveTo() function is called. units — a constant defining the speed units void setSpeed(double speedInMPS) Sets the new speed ("cruising speed") for the agent (measured in meters per second). If the agent is moving, it continues moving from the current location with the new speed. Note that nonzero speed does not mean the agent is moving - it starts moving only after moveTo() function is called. speedInMPS — new speed value void setSpeed(double speedInUnits, SpeedUnits units) Sets new speed for the agent (measured in the given units). If the agent is moving, it continues moving with the new speed. Note that nonzero speed does not mean the agent is moving - it starts moving only after moveTo() function is called. speedInUnits — new speed value units — a constant defining the speed units
-
How can we improve this article?
-