Font size

Agent movement speed

Although AnyLogic directly supports movement at a constant speed and zero acceleration, you can model acceleration/deceleration by changing the speed at the appropriate time moments. You can use statechart with states like Static, Slow, Medium, Fast, etc. and timeout transitions to control the motion.

To set the initial speed of the agent

  1. Open the properties of the agent type by clicking it in the Projects view.
  2. Open the Dimensions and movement section of the properties.
  3. In the Initial speed field, specify the initial speed of agents of this type, and choose the correct units of measurement for this speed next to it. The default value is 10 meters per second.

Agent speed functions

Function Description
void setSpeed(double s, SpeedUnits units) Sets the speed ("cruising speed") of the agent to speed s in specified speed units units. If the agent is moving, it will continue moving from the current location with the new speed. If the agent is not moving, it will not start moving until you call moveTo().
double getSpeed() Returns the current speed of the agent (speed is a parameter of the agent, its "cruising speed", non-zero speed does not mean the agent is moving).

If you configure agent movement with the help of MoveTo block, you can set custom agent speed in its properties.

The agent's speed will be changing if you use the moveToInTime() functions to define agent movement.
How can we improve this article?