Commit fad53fb0 authored by manuschn's avatar manuschn

global density baseline experiment config and documentation

parent f4d4d567
# Global Density Observation
```{admonition} TL;DR
This observation is a global observation, that provides an agent with information on its own and the other agents predicted paths. The paths are predicted from the shortest path of each agent to its respective target. The information is encoded into a density map.
### 💡 The idea
The density observation is based on the idea that every agent's path to its target is represented in a discrete map of the environment assigning each location (cell) a value encoding the information if and when the cell will be occupied. For simplicity, we assume that an agent follows the shortest path to its target and don't consider alternative paths. The individual values along the agents' shortest paths are combined into a "density" for each cell. For example, if all agents would occupy the same cell at the same time step, the density would be very high. If the agents would use the same cell but at different time steps the density for that cell would be lower. The density map therefore potentially allows the agents to learn from the (projected) cell occupancy distribution.
### 🗂️ Files and usage
The observation is defined in "neurips2020-flatland-baselines/envs/flatland/observations/", the model used in the example in "neurips2020-flatland-baselines/models/".
The observation can be configured with the following parameters:
* width and height: have to correspond to the shape of the environment
* max_t: max number of time steps the path of each agent is predicted for
* encoding: defining how to factor in the time information into the density value (2d options: exp_decay, lin_decay, binary; 3d option: series; see next section for more details)
An example config is located in "neurips2020-flatland-baselines/baselines/global_density_obs/sparse_small_apex_expdecay_maxt1000.yaml" and can be run with
`python ./ -f baselines/global_density_obs/sparse_small_apex_expdecay_maxt1000.yaml`
### 📦 Implementation Details
The observation for each agent consists of two arrays representing the cells of the environment. The first array contains the density values for the agent itself, and the second one the mean of the other agents' values for each cell. The arrays are either two or three dimensional depending on the encoding.
The idea behind this parameter is to provide a way to compress the space and time information into a 2d representation. However, it is possible to get a 3d observation with a separate, 2d density map for each time step, by using the option "series" (for time series) for the encoding. In this case, a binary representation for the individual agent occupancies is used.
The other options use a function of the time step *t* and the maximal time step *max_t* to determine the density value:
* exp_decay: e^(-t / max_t^(1/2))
* lin_decay: (max_t - t) / max_t
* binary: 1
We created a custom model (GlobalDensObsModel) for this observation that uses a convolutional neural network to process the observation. For the experiments, we used the IMPALA (see links section) implementation.
### 📈 Results
We trained the agents with the different encoding options and different values for max_t using Ape-X (see links section). However, we didn't search systematically or exhaustibly for the best settings.
The best runs achieved around 45% mean completion on the sparse, small flatand environment with max_t = 1000 and encoding = exp_decay. The mean completion rate is considerably lower than the tree observation but show that learning is possible from global observations and can inform approaches to combine local, tree and global observations.
More information on the runs is can be found in the weights and biases report linked below.
### 🔗 Links
* [IMPALA Paper – IMPALA: Scalable Distributed Deep-RL with Importance Weighted Actor-Learner Architectures (Espeholt et al.)](
* [Ape-X Paper – Distributed Prioritized Experience Replay (Horgan et al.)](
* [W&B report for training runs](|-sparse-small_v0--VmlldzoxMTYxMDE)
### 🌟 Credits
run: APEX
env: flatland_sparse
timesteps_total: 15000000 # 1.5e7
checkpoint_freq: 10
checkpoint_at_end: True
keep_checkpoints_num: 5
checkpoint_score_attr: episode_reward_mean
num_samples: 3
num_workers: 13
num_envs_per_worker: 5
num_gpus: 0
hiddens: []
dueling: False
observation: density
width: 25
height: 25
max_t: 1000
encoding: exp_decay
generator: sparse_rail_generator
generator_config: small_v0
project: flatland
entity: masterscrat
tags: ["small_v0", "density_obs", "apex"] # TODO should be set programmatically
custom_model: global_dens_obs_model
architecture: impala
residual_layers: [[16, 2], [32, 4]]
evaluation_num_workers: 2
evaluation_interval: 100
evaluation_num_episodes: 100
explore: False
observation: density
width: 25
height: 25
max_t: 1000
encoding: exp_decay
regenerate_rail_on_reset: True
regenerate_schedule_on_reset: True
render: False
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment