Comments (1)
Seems to be missing indeed. Here is some script as starting point.
"""
Script to create random MAPF instance
"""
import os
import collections
import random
import copy
import yaml
def reachable(map_size, start, goal, obstacles):
visited = set()
stack = [tuple(start)]
while stack:
vertex = stack.pop()
if vertex not in visited:
if vertex == tuple(goal):
return True
visited.add(vertex)
for delta in [[1,0], [-1,0], [0,1], [0,-1]]:
pos = (vertex[0] + delta[0],vertex[1] + delta[1])
if pos[0] >= 0 and pos[0] < map_size[0] and pos[1] >= 0 and pos[1] < map_size[1] and pos not in obstacles:
stack.append(pos)
return False
def randAgents1(map_size, num_agents, num_groups, num_obstacles):
locations = [(x, y) for x in range(0, map_size[0]) for y in range(0, map_size[1])]
random.shuffle(locations)
#
Group = collections.namedtuple('Group', 'start goal')
groups = []
obstacles = []
# assign obstacles
for agentIdx in range(0, num_obstacles):
location = locations[0]
obstacles.append(location)
del locations[0]
locationsE = copy.deepcopy(locations) #list(locations)
random.shuffle(locationsE)
# different number of agents; fixed agents per group
for groupIdx in range(0, num_groups):
group = Group(start=[], goal=[])
groups.append(group)
for agentIdx in range(0, num_agents):
groupIdx = agentIdx % num_groups
while True:
locationS = locations[0]
locationE = locationsE[0]
if reachable(map_size, locationS, locationE, obstacles):
groups[groupIdx].start.append(locationS)
groups[groupIdx].goal.append(locationE)
del locations[0]
del locationsE[0]
# print("reachable!")
break
else:
# print("not reachable!")
random.shuffle(locations)
random.shuffle(locationsE)
# try again...
return groups, obstacles
def writeFile(obstacles, map_size, groups, file_name):
data = dict()
data["map"] = dict()
data["map"]["dimensions"] = map_size
data["map"]["obstacles"] = list(obstacles)
data["agents"] = []
i = 0
for group in groups:
for agentIdx in range(0, len(group.start)):
agent = dict()
agent["name"] = "agent" + str(i)
agent["start"] = list(group.start[agentIdx])
agent["goal"] = list(group.goal[agentIdx])
i += 1
data["agents"].append(agent)
with open(file_name, "w") as f:
yaml.dump(data, f, indent=4)
if __name__ == "__main__":
map_size = [8, 8]
num_agents = 15
num_groups = num_agents
num_obstacles = int(map_size[0] * map_size[1] * 0.2)
for num_agents in range(1, 15):
for i in range(0, 100):
groups, obstacles = randAgents1(map_size, num_agents, num_groups, num_obstacles)
writeFile(obstacles, map_size, groups, "map_{}by{}_obst{}_agents{}_ex{}.yaml".format(
map_size[0],
map_size[1],
num_obstacles,
num_agents,
i))
from libmultirobotplanning.
Related Issues (20)
- Need help working with cbs_ta and ecbs_ta HOT 1
- Potential Bug on ECBS-TA HOT 3
- Undefined References from yaml-cpp During Build Process HOT 4
- Code questions HOT 13
- Paper question HOT 1
- Error while running the test and the example available in the README HOT 3
- Error while adding a new action HOT 9
- Assertion failing on special scenarios HOT 1
- Assertion triggering on simple crossing scenario HOT 2
- Timeout of cbs_roadmap HOT 1
- high level of LB in ECBS do not used? HOT 5
- Low-level search in CBS-TA HOT 2
- CBS on roadmap finds suboptimal solution HOT 10
- There may be infinite loop if there is no way from start point to goal point HOT 6
- Target Assignment Part HOT 4
- In a specific map scene, the cbs algorithm cannot find a solution and falls into an infinite loop HOT 1
- Multi-goal TA HOT 7
- Error while running the roadmap example in the README HOT 3
- Inter-agent collisions using Prioritized Planning using SIPP HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from libmultirobotplanning.