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.

https://readthedocs.org/projects/road-agent/badge/?version=latest https://badge.fury.io/py/road-agent.svg https://road-agent.readthedocs.io/en/latest/_images/frames.png

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:

https://mybinder.org/badge_logo.svg
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):
    pass

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
b.update_route()

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

Installation

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
wget https://gitlab.com/rgarcia-herrera/road-agent/raw/master/get_segments.sh
wget https://gitlab.com/rgarcia-herrera/road-agent/raw/master/segments.txt
chmod +x get_segments.sh
./get_segments.sh

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

cd ~/opt/brouter
wget http://brouter.de/brouter_bin/brouter_1_4_11.zip
unzip brouter_1_4_11.zip
chmod +x ./standalone/server.sh

Run server.sh 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.

Files for road-agent, version 1.0.1
Filename, size File type Python version Upload date Hashes
Filename, size road_agent-1.0.1-py2-none-any.whl (19.0 kB) File type Wheel Python version py2 Upload date Hashes View hashes
Filename, size road_agent-1.0.1.tar.gz (6.4 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page