Utilities for the CG:SHOP 2021 Optimization Competition on Coordinated Motion Planning.
Project description
CG:SHOP 2021 PyUtils
We provide some utils for you to easily read the instances and write your solutions.
Reading the instances from the Zip
Best use the instance database. You simply download the .zip and then you can access all instances via
from cgshop2021_pyutils import InstanceDatabase
idb = InstanceDatabase("path/to/zip.zip")
for i in idb:
print("Instance:", i)
Working with an instance
from cgshop2021_pyutils import Instance
i: Instance #just to enable typing
for r in range(i.number_of_robots):
print("Robot", i, "starts at", i.start_of(r)," and has to go to ", i.target_of(r))
for o in i.obstacles:
print(o, "is blocked")
Create a solution
from cgshop2021_pyutils import Solution, SolutionStep, SolutionZipWriter, Direction
from cgshop2021_pyutils import Instance
instance: Instance
solution = Solution(instance)
# First time step in the solution
step_1 = SolutionStep()
step_1[2]=Direction.NORTH # Robot 2 moves north
step_1[1]=Direction.WEST # Robot 1 moves west
solution.add_step(step_1)
# Second time step in the solution
step_2 = SolutionStep()
step_2[0]=Direction.SOUTH # Robot 0 moves north
step_2[2]=Direction.WEST # Robot 2 moves west
solution.add_step(step_2)
print("Makespan:", solution.makespan)
print("SUM:", solution.total_moves)
Write solutions
You can easily write solutions to an uploadable zip.
from cgshop2021_pyutils import SolutionZipWriter, Solution
s1: Solution
s2: Solution
s3: Solution
with SolutionZipWriter("output.zip") as szw:
szw.add_solution(s1)
szw.add_solutions([s1, s2])
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distribution
Close
Hashes for cgshop2021_pyutils-0.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a36b7db43c235e16694fa29810aaea27386d990ad9f0a8a8c89ece055169882c |
|
MD5 | 99fdf4e3e8eff4c599bae70fe11bc87d |
|
BLAKE2b-256 | 679598eb17a2729a8b672d6e6bef57d77baa3dae7b22d2d786fb1e7d6fb9576e |