Skip to main content

Object-oriented framework for modeling of mobile agents.

Project description

A Python framework for modeling mobile agents.

Create simulations of mobile agents, to be run on real-world maps. Like the game of tag described in the docs, some of whose frames are shown below.

The Road Agent framework is distributed with two router alternatives:
  1. NXRouter, wich uses shortest paths computed with the NetworkX library.

  2. BRouter wich uses a BRouter server to query routes.

NXRouter is simpler but easier to run. BRouter is very robust but it requires the installation and running of the BRouter server which is a java program and maybe a long download, but routes are more realistic.

Read the full documentation.

Short example simulation

This is a veery short stub just to show the main feature of the agent class, which is to navigate a map, in this case using routes computed using NetworkX’s shortest_path.

To create a simulation one must extend the Agent class with the behaviours under study. This example just does an empty extension.

A more interesting simulation is included in this Jupyter Notebook.

Maybe this binder will work:
from LatLon import LatLon
from road_agent import Agent
from road_agent.router import NXRouter
import osmnx as ox

G = ox.graph_from_point((19.3838,-99.1758), distance=1000)
router = NXRouter(G)
r = router.get_route(points=points, speed=3)

# extend Agent class to code behaviours specific to your mobile agent
class Bike(Agent):

point = LatLon(19.3881769, -99.1794493)
dest = LatLon(19.3858363, -99.1767216)

# create bike instance
b = Bike(point=point, dest=dest)

# create route using NetworkX

# traverse agent's route, step by step
for t in range(len(b.route)):


Install library using pip:

$ pip install road-agent

Install optional dependency: BRouter

Agents may use BRouter for routing, which can use several different profiles for routing and is specially good creating routes for riding bikes. It is a java program, which runs in a web server. Here’s how to install a local server.

BRouters needs data files for its routing algorithm. Download data files (rd5) into segments4 dir. You may copy-paste these steps to download them all, but beware: it’s about 5.2 gigabytes:

mkdir -p ~/opt/brouter/segments4
cd ~/opt/brouter/segments4
chmod +x

Download and unzip BRouter (replace ~/opt/ with your preferred install dir and 1_4_11 with latest version):

cd ~/opt/brouter
chmod +x ./standalone/

Run to start BRouter server.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

road_agent-1.0.1.tar.gz (6.4 kB view hashes)

Uploaded source

Built Distribution

road_agent-1.0.1-py2-none-any.whl (19.0 kB view hashes)

Uploaded py2

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page