Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .bazelversion
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
8.1.1
22 changes: 20 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Ignore BAZEL files
yj# Ignore BAZEL files
MODULE.bazel.lock
/bazel-*

Expand All @@ -11,4 +11,22 @@ MODULE.bazel.lock
/third_party/*/lib

# Distable toolchain temporaly
/toolchain
/toolchain

# macOS
.DS_Store

# LaTeX build artifacts
*.aux
*.bbl
*.blg
*.fdb_latexmk
*.fls
*.log
*.run.xml
*.synctex.gz
*.toc
*-blx.bib

# MCAP recordings (heavy files)
data/*.mcap
15 changes: 9 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM amd64/ubuntu:24.10 AS mapf-base
FROM ubuntu:24.04 AS mapf-base

WORKDIR /tmp

Expand Down Expand Up @@ -77,12 +77,15 @@ RUN wget https://github.com/bazelbuild/buildtools/releases/download/v7.3.1/build
&& chmod +x buildifier-linux-${TARGETARCH} \
&& mv buildifier-linux-${TARGETARCH} /usr/bin/buildifier

# Install MCAP CLI
# Python + matplotlib for the experiment plots (viz/plot_*.py).

RUN wget https://github.com/foxglove/mcap/releases/download/releases%2Fmcap-cli%2Fv0.0.50/mcap-linux-${TARGETARCH} \
&& chmod +x mcap-linux-${TARGETARCH} \
&& mv mcap-linux-${TARGETARCH} /usr/bin/mcap
RUN apt-get update -q \
&& apt-get install -yq --no-install-recommends \
python3 \
python3-matplotlib \
&& rm -rf /var/lib/apt/lists/* \
&& apt-get clean

WORKDIR /mapf
ENTRYPOINT ["/bin/zsh", "-lc"]
CMD ["trap : TERM INT; sleep infinity & wait"]
CMD ["trap : TERM INT; sleep infinity & wait"]
1 change: 0 additions & 1 deletion MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ bazel_dep(name = "boost.describe", version = "1.83.0")
bazel_dep(name = "boost.program_options", version = "1.83.0")
bazel_dep(name = "googletest", version = "1.15.2")
bazel_dep(name = "google_benchmark", version = "1.8.5")
bazel_dep(name = "mcap", version = "1.4.0")
bazel_dep(name = "platforms", version = "0.0.10")
bazel_dep(name = "protobuf", version = "29.0")
bazel_dep(name = "rules_cc", version = "0.0.16")
Expand Down
60 changes: 24 additions & 36 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# MAPF
Experiments in Multi-Agent Pathfinding
Experiments in Multi-Agent Pathfinding.

The repository implements three solvers (BFS, A*, PIBT) on grid graphs, a benchmark
and ablation test suite, a JSON exporter, and a dependency-free Python visualizer that
turns exported solutions into an interactive HTML animation and an SVG trajectory image.

## Getting started

Expand Down Expand Up @@ -66,62 +70,46 @@ Use paths, relative to MODULE directory.
bazel run //solver:main -- -s bfs_solver -i data/mapf_problem_1.pb.txt -o data/mapf_solution_1.pb.txt
```

## Running simulator
## Visualizing a solution

### Show information about simulator binary options
Solve an instance and write a JSON description (map, obstacles, every agent's path) suitable for the visualizer:

```sh
bazel run //simulator:main -- --help
bazel run //solver:export_solution -- \
--width 32 --height 20 --agents 40 --obstacles \
--solver pibt_solver --out viz/data/arena.json
```

### List available solver names
Render an interactive HTML animation and a static SVG trajectory image:

```sh
bazel run //simulator:main -- --list-solvers
python3 viz/visualize.py viz/data/arena.json --out viz/out
```

Simulator input is a file with text formated [MAPFProblem](models/proto/models.proto#L22) protobuf message. [See](data/mapf_problem_1.pb.txt) example of file structure.

Simulator output is a MCAP file with serialized [Scene](scene/proto/scene.proto) protobuf message.

Use paths, relative to MODULE directory.

### Simulator run command example

```sh
bazel run //simulator:main -- -s bfs_solver -i data/mapf_problem_1.pb.txt -o data/scene.mcap
```
Open `viz/out/arena.html` in a browser for the animation, or use `viz/out/arena_trails.svg` as a static figure.

## Repository contents

Guide to packages:

* __geom__: Package with geometry primitives (`Vec2`, floating point number comparators, etc.). See __geom/tests__ for usage examples, __geom/proto__ for available proto-definitions.

* __graph__: Package with graph primitives (`Node`, `Edge`, `Endpoints`, etc.). See __graph/test__ for usage examples, __graph/proto__ for available proto-definitions.

* __models__: Package with MAPF-problem specific primitives (`AgentState`, `AgentTask`, `AgentPath`, `MAPFProblem`, `MAPFSolution`, etc.). See __models/test__ for usage examples, __models/proto__ for available proto-definitions.
* __geom__: Geometry primitives (`Vec2`, floating point comparators). See __geom/tests__ for usage and __geom/proto__ for proto definitions.

* __scene__: Package with scene primitive, being recorded during simulation. See __models/proto__ for available proto-definitions.
* __graph__: Graph primitives (`Node`, `Edge`, `Endpoints`). See __graph/test__ for usage and __graph/proto__ for proto definitions.

* __simulator__: Package with simulator primitives. The simulator is implemented using a single-threaded [actor model](https://en.wikipedia.org/wiki/Actor_model).

* __simulator/acotrs__: Available actors declarations, `Actor` interface is defined [here](simulator/actors/include/actors/actor.h).
* __models__: MAPF problem types (`AgentState`, `AgentTask`, `AgentPath`, `MAPFProblem`, `MAPFSolution`). See __models/test__ for usage and __models/proto__ for proto definitions.

* __simulator/context__: Global simulation context, holding current timestamp and `EventBus`, which is an object, that encapsulates interaction between different actors.

* __simulator/event__: Event primitives, which encapsulates messages handling in runtime.
* __solver__: Package with available MAPF-problem solvers.

* __simulator/launcher__: Simulation launcher, running event loop.
* __solver/solvers__: Solver implementations (BFS, A*, PIBT). The `Solver` interface is defined [here](solver/solvers/include/solvers/solver_base.h).

* __simulator/main__: Simulator binary. See [CLI-options](simulator/main/src/main.cpp#L24) to determine available running modes.
* __solver/factory__: Factory with registered solvers. After registering a solver in [the factory constructor](solver/factory/src/solver_factory.cpp), it automatically becomes available in CLI options.

* __simulator/messages__: Available messages declarations. `Message` interface is defined [here](simulator/messages/include/messages/message.h).
* __solver/main__: Solver binary. See [CLI options](solver/main/src/main.cpp) for the supported flags.

* __solver__: Package with available MAPF-problem solvers.
* __solver/tools__: `export_solution` binary — solves an arena instance and writes a JSON file consumed by the visualizer.

* __solver/solvers__: Available solvers declarations, `Solver` interface is defined [here](solver/solvers/include/solvers/solver_base.h).
* __solver/tests__: GoogleTest correctness tests plus the benchmark, ablation and statistical experiments (`Experiment.OperatingEnvelope`, `Experiment.LargeScale`, `Experiment.Ablation`, `Experiment.Suboptimality`).

* __solver/factory__: Factory with registered solvers. After registering solver in [factory constructor](solver/factory/src/solver_factory.cpp#L11), it automatically becomes available in CLI-options.
* __viz__: Standard-library Python visualizer. `visualize.py` renders a JSON solution to HTML + SVG; `plot_envelope.py` renders the operating-envelope plot; `plot_suboptimality.py` renders the statistical box-plots.

* __solver/main__: Sover binary. See [CLI-options](solver/main/src/main.cpp#L17) to determine available running modes.
* __data__: Example MAPF problems (text-format protobuf).
Loading