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.

Source Distribution

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

Uploaded Source

Built Distribution

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

Uploaded Python 2

File details

Details for the file road_agent-1.0.1.tar.gz.

File metadata

  • Download URL: road_agent-1.0.1.tar.gz
  • Upload date:
  • Size: 6.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/2.7.13

File hashes

Hashes for road_agent-1.0.1.tar.gz
Algorithm Hash digest
SHA256 c8c023a4edb3fa5a53503cf825fd402c444cb16d15ab4406098d301a51a46007
MD5 fe22b24de69c7f124c1c06877d878b62
BLAKE2b-256 1b19a219df760a7de48262bf1383b8fc2cbe67d0c982e408c51d7622b380a5c6

See more details on using hashes here.

File details

Details for the file road_agent-1.0.1-py2-none-any.whl.

File metadata

  • Download URL: road_agent-1.0.1-py2-none-any.whl
  • Upload date:
  • Size: 19.0 kB
  • Tags: Python 2
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/2.7.13

File hashes

Hashes for road_agent-1.0.1-py2-none-any.whl
Algorithm Hash digest
SHA256 730f23209ffa8a202df24d0908bd61bf407e64aaee6046a94d2758bdb63188a8
MD5 5e58501d4dc18f7d5a54b0d8cebdff10
BLAKE2b-256 ba14c6fa416cac4706530611af62f230f31f73f422bb1a17a37c72a90d22bb14

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page