Skip to main content

MAPFM Client

This is a client library for the https://mapf.nl/ MMAPF problems

The MAPFM problem

MAPFM is an abbreviation of "Matching in multi-agent pathfinding". With MAPFM problems, you are given:

  • A grid/maze
  • A list of agent starting positions (each agent has a color)
  • A list of agent goal positions (each goal has a color)

The solution for that problem is a list of paths, one for each agent st.

  • Each path starts on the starting position of an agent
  • Each path ends on a goal position of the same color as the agent
  • No path crosses a wall in the grid
  • No 2 agents are ever on the same position at the same time
  • No 2 agents ever cross the same edge (in opposite directions) at the same time This solution is optimal if there is no other solution st. the sum of the lengths of the paths of all the agents is smaller than this solution.

Using the client library

Install the library with:

pip install mapfmclient

Then go to https://mapf.nl/benchmarks/. Here you can find a list of benchmarks. If you click on a benchmark you can see prefiously posted solutions. By clicking on a solution, You can see what the problem looks like. Find a problem that you like, and find its index on the https://mapfw.nl/benchmarks/ page (Sorry, you will have to count yourself, starting from 1. This will change later).

Now go to your account page at https://mapfw.nl/auth/account. To find your API Token

This is all the info you need to start coding. The basic outline of your code should look like this:

from mapfmclient import MapfwBenchmarker
if __name__ == '__main__':
    benchmarker = MapfwBenchmarker("<YOUR API TOKEN>", <BENCHMARK ID(s)>, "<YOUR ALGORITHMS NAME>",
                                   "<YOUR ALGORITHMS VERSION>", <DEBUG_MODE>, solver=<SOLVER>,cores=<CORES>)
    benchmarker.run()

The only things that you need to do are to fill in

  • Your own API Token
  • The number of the benchmark that you want to solve
  • The name of your algorithm
  • Its version qnd the debug mode. (This should be set to True while you are developing your algorithm. This means that your attempts will not be shown on the global leader boards. You can however still see your own solution at https://mapf.nl/latest-debug.)
  • Your solver function
  • The amount of cores that you want to use for this benchmark (Default=1. For all cores, use -1)

Note that the benchmark id does not need to be complete. Any uniquely identifying prefix of the id will work. On https://mapf.nl, 5 characters are usually used.

You should implement the "solver" function yourself. This function should take in a problem and return the solution. A basic outline of this function can be as follows:

from mapfmclient import Problem, Solution, MarkedLocation


class Maze:
    def __init__(self, grid, width, height):
        self.grid = grid
        self.width = width
        self.height = height


def solve(problem):
    maze = Maze(problem.grid, problem.width, problem.height)

    paths = []
    for agent in agents:
        paths.append(find_path(agent, maze))

    """
    Now paths looks like:

    paths = list[Path]
    Path = List[(x, y)]
    """

    return Solution.from_paths(paths)

It is also possible to run multiple benchmarks at the same time. Instead of giving an integer as the benchmark index, you can also give an iterable to the MapfwBenchmarker constructor. Valid uses are:

Run benchmark 3, with solver solve, with algorithm TestAlgorithm and version TestVersion, in debug on 1 core:

MapfBenchmarker("<YOUR API TOKEN>", 1, "TestAlgotithm",
                    "TestVersion", True, solver=solve,cores=1)

Run benchmark 1,2 and 3, with solver solve, with algorithm TestAlgorithm and version TestVersion, in debug on 3 cores:

MapfBenchmarker("<YOUR API TOKEN>", [1, 2, 3], "TestAlgotithm",
                    "TestVersion", True, solver=solve,cores=3)

If you want a list of all the indexes of the benchmarks, that is possible with the get_all_benchmarks function. As an argument you can add the index, or a list of indexes of benchmarks that you dont want to run

from mapfmclient import get_all_benchmarks
all_benchmarks = get_all_benchmarks()
without_benchmark_3 = get_all_benchmarks(without="3ab4d")
without_benchmark_2_and_4 = get_all_benchmarks(without=[1, 3, 4])

When your are ready, set the debug mode to False. The next time you run your code, your attempt will be publicly listed.

This should be all that you need to know to get started! Please note that this is just some example code and feel free to change it however you like.

Good luck! And let us know if you have any questions.

Note: This client is largely an adaptation of a similar project for a different problem called MAPFW (MAPF with waypoints). It can be found here

Release files for mapfmclient 0.2.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mapfmclient 0.2.5
File Size Uploaded
mapfmclient-0.2.5.tar.gz 11.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for mapfmclient 0.2.5
File Interpreter ABI Platform
mapfmclient-0.2.5-py3-none-any.whl Python 3 none any Details

Total release size:23.2 kB

Release files / mapfmclient-0.2.5.tar.gz

Download URL mapfmclient-0.2.5.tar.gz
Size 11.7 kB
Tags Source
SHA-256 checksum
How to use checksums
922a26b1b258c914735cdb7a7032e1a5b2ad708613a39848a8d970368115a4a8
BLAKE2b-256 checksum
How to use checksums
68eae6e787bbab541227d3fa742481e58fdad3b48834fd0185fd395a244e415a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.3.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.5

Release files / mapfmclient-0.2.5-py3-none-any.whl

Download URL mapfmclient-0.2.5-py3-none-any.whl
Size 11.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
245cbdd69ffe87938f41c01eb994740742c545d5e21b847403cf4d90dd87eab9
BLAKE2b-256 checksum
How to use checksums
cd793515ada9fdcc6e9a5d55ad834f3e26d5c3cb9b67684c72252870f859fb0c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.3.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.5

Release history Release notifications | RSS feed

This release

0.2.5 This release

2 release files

0.2.4

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.0

2 release files

0.0.9

2 release files

0.0.8

2 release files

0.0.7

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page