starling_sim.basemodel.agent.moving_agent
This module contains the MovingAgent class, with useful methods to make an agent move in the environment
Module Contents
Classes
This class describes an agent with the capacity of moving |
- class starling_sim.basemodel.agent.moving_agent.MovingAgent(simulation_model, agent_id, origin, **kwargs)
Bases:
starling_sim.basemodel.agent.spatial_agent.SpatialAgent
This class describes an agent with the capacity of moving
- move_(route=None, duration=None, check_dest=False, destination=None, parameters=None, verb=True)
Compute a route with the given parameters and follow it.
- Parameters:
route – list of consecutive nodes in the environment
duration – total duration of the move
check_dest – boolean indicating the destination changes should be checked while following the route
destination – used for computing the route. If None, self.tempDest is used
parameters – agent specific parameters used for path evaluation
verb – boolean indicating if a message should be displayed when calling the function
- Returns:
yield one or several processes during the route execution
- follow_route_data_(route_data, check_dest, mode, verb=True)
Travel along the given route
- Parameters:
route_data – route_data to be followed
check_dest – boolean indicating if destination changes should be checked during the trip
mode – mode used
verb – boolean indicating if a log should be displayed when calling the function
- change_position(new_position, mode)
Change the current position of the agent.
- Parameters:
new_position – new position of the agent
mode – agent transport mode
- Returns:
- move_to_(destination, duration)
Perform the action of moving from the current position to a given destination
- Parameters:
destination – Destination in the simulation environment
duration – Duration of the trip
- Returns:
yield a trip duration process
- fly_(destination=None, duration=None, length=None, distance_factor=None, speed=None, mode=None, verb=True)
Realise a direct trip from current position to destination without using the network.
The information provided (duration, length, speed) must allow to compute the trip duration and length. Length can be computed using euclidean distance. If duration and length are provided, speed is not used.
- Parameters:
destination – destination of the trip. Default is self.tempDestination.
duration – duration of the trip. Default is computed using length and speed.
length – length of the trip. Default is computed using duration and speed, or using euclidean distance.
distance_factor – value multiplied to euclidean distance to get trip distance. Default is defined by the ‘distance_factor’ config value.
speed – speed of the agent, used to compute duration and length
mode – mode of traveling. Default is self.mode.
verb – boolean indicating if a log should be displayed when calling the function
- Returns:
yield a trip duration process
- approximate_trip(origin, destination, distance_factor, speed)
Approximate the length and time of a trip based on the euclidean distance and speed.
The computation is based on a factor that is applied to the euclidean distance.
- Parameters:
origin – origin position
destination – destination position
distance_factor – value multiplied to euclidean distance to get trip distance.
speed – speed of the travelling agent, in m/s. If None, travel time is not computed
- Returns:
tuple (travel_length, travel_time)