Skip to main content

Partially Observable Grid Environment for Multiple Agents

Project description

Pogema logo

Partially-Observable Grid Environment for Multiple Agents

CodeFactor Downloads CI CodeQL

Partially observable multi-agent pathfinding (PO-MAPF) is a challenging problem which fundamentally differs from regular MAPF, in which a central controller is assumed to construct a joint plan for all agents before they start execution. PO-MAPF is intrisically decentralized and decision making (e.g. planning) here is interleaved with the execution. At each time step an agent receives a (local) observation of the environment and decides which action to take. The ultimate goal for the agents is to reach their goals while avoiding collisions with each other and the static obstacles.

POGEMA stands for Partially-Observable Grid Environment for Multiple Agents. This is a grid-based environment that was specifically designed to be flexible, tunable and scalable. It can be tailored to a variety of PO-MAPF settings. Currently the (somewhat) standard setting is supported: agents can move between the cardinally-adjacent cells of the grid, each action (move or wait) takes one time step. No information sharing between the agents is happening.

POGEMA can generate random maps and start/goals locations for the agents. It also can take custom maps as the input.

Installation

Just install from PyPI:

pip install pogema

Using Example

from pogema import pogema_v0, Hard8x8
env = pogema_v0(grid_config=Hard8x8())

obs = env.reset()

done = [False, ...]

while not all(done):
    # Use random policy to make actions
    obs, reward, done, info = env.step([env.action_space.sample() for _ in range(len(obs))])

Open In Colab

Environments

Config agents density num agents horizon
Easy8x8 2.2% 1 64
Normal8x8 4.5% 2 64
Hard8x8 8.9% 4 64
ExtraHard8x8 17.8% 8 64
Easy16x16 2.2% 4 128
Normal16x16 4.5% 8 128
Hard16x16 8.9% 16 128
ExtraHard16x16 17.8% 32 128
Easy32x32 2.2% 16 256
Normal32x32 4.5% 32 256
Hard32x32 8.9% 64 256
ExtraHard32x32 17.8% 128 256
Easy64x64 2.2% 64 512
Normal64x64 4.5% 128 512
Hard64x64 8.9% 256 512
ExtraHard64x64 17.8% 512 512

Baselines

The baseline implementations are available as a separate repository.

Interfaces

Pogema provides integrations with a range of MARL frameworks: PettingZoo, PyMARL and SampleFactory.

PettingZoo

from pogema import pogema_v0, GridConfig

# Create Pogema environment with PettingZoo interface
env = pogema_v0(GridConfig(integration="PettingZoo"))

PyMARL

from pogema import pogema_v0, GridConfig

env = pogema_v0(GridConfig(integration="PyMARL"))

SampleFactory

from pogema import pogema_v0, GridConfig

env = pogema_v0(GridConfig(integration="SampleFactory"))

Classic Gym

Pogema is fully capable for single-agent pathfinding tasks.

import gym
import pogema

# This interface provides experience only for agent with id=0,
# other agents will take random actions.
env = gym.make("Pogema-v0")

Example of training stable-baselines3 DQN to solve single-agent pathfinding tasks: Open In Colab

Customization

Random maps

from pogema import pogema_v0, GridConfig

# Define random configuration
grid_config = GridConfig(num_agents=4,  # number of agents
                         size=8, # size of the grid
                         density=0.4,  # obstacle density
                         seed=1,  # set to None for random 
                                  # obstacles, agents and targets 
                                  # positions at each reset
                         max_episode_steps=128,  # horizon
                         obs_radius=3,  # defines field of view
                         )

env = pogema_v0(grid_config=grid_config)
env.reset()
env.render()

Custom maps

from pogema import pogema_v0, GridConfig

grid = """
.....#.....
.....#.....
...........
.....#.....
.....#.....
#.####.....
.....###.##
.....#.....
.....#.....
...........
.....#.....
"""

# Define new configuration with 8 randomly placed agents
grid_config = GridConfig(map=grid, num_agents=8)

# Create custom Pogema environment
env = pogema_v0(grid_config=grid_config)

Citation

If you use this repository in your research or wish to cite it, please make a reference to our paper:

@misc{https://doi.org/10.48550/arxiv.2206.10944,
  doi = {10.48550/ARXIV.2206.10944},  
  url = {https://arxiv.org/abs/2206.10944},
  author = {Skrynnik, Alexey and Andreychuk, Anton and Yakovlev, Konstantin and Panov, Aleksandr I.},
  keywords = {Machine Learning (cs.LG), Artificial Intelligence (cs.AI), Multiagent Systems (cs.MA), FOS: Computer and information sciences, FOS: Computer and information sciences},
  title = {POGEMA: Partially Observable Grid Environment for Multiple Agents},
  publisher = {arXiv},
  year = {2022},
  copyright = {arXiv.org perpetual, non-exclusive license}
}

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

pogema-1.1.5.tar.gz (24.9 kB view details)

Uploaded Source

Built Distribution

pogema-1.1.5-py3-none-any.whl (27.3 kB view details)

Uploaded Python 3

File details

Details for the file pogema-1.1.5.tar.gz.

File metadata

  • Download URL: pogema-1.1.5.tar.gz
  • Upload date:
  • Size: 24.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.8.16

File hashes

Hashes for pogema-1.1.5.tar.gz
Algorithm Hash digest
SHA256 b6bcce2cbc522217b3596ec02ccf4b653ec82fc502b67f485f767be5f9d10b6d
MD5 78b24caed13653ebae80fa2dd0621779
BLAKE2b-256 93dd53b19dbf8efe959c46656adb53dbe9ab7b71cdda38d4d10799a186040170

See more details on using hashes here.

Provenance

File details

Details for the file pogema-1.1.5-py3-none-any.whl.

File metadata

  • Download URL: pogema-1.1.5-py3-none-any.whl
  • Upload date:
  • Size: 27.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.8.16

File hashes

Hashes for pogema-1.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 44c847e7987b20a835ec8ee4bb01a66936725f3c32698b36eaf7eed032a3fab2
MD5 850104f1cf450c73ac67be2a47a94e5c
BLAKE2b-256 c11fe56e1953d515c85253e6c49ca0b90e630a0e66c21a01916f478eedc548c9

See more details on using hashes here.

Provenance

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