Skip to content

Commit

Permalink
V0.001.0 - LaCAM (#90)
Browse files Browse the repository at this point in the history
* Lacam

(cherry picked from commit 5dfb825)

* Updated README.md and docs

(cherry picked from commit 2f93331)

---------

Co-authored-by: NoyGabay <[email protected]>
  • Loading branch information
J-morag and NoyGabay authored Jul 8, 2024
1 parent 1445d50 commit f9dfde6
Show file tree
Hide file tree
Showing 12 changed files with 1,944 additions and 3 deletions.
16 changes: 13 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,17 @@ Example arguments to solve all instances in a directory, with 10 agents:<br>
The following algorithms are set to run by default: CBS and Prioritised Planning.
Currently, choosing different algorithms is only possible by changing the code and re-compiling.

The default instance format is from the [MovingAI benchmark](https://movingai.com/benchmarks/mapf/index.html)!.

### Running the project by modifying the code

Modify the `Main.java` file to run your experiment. Examples are provided in the `ExampleMain.java` file.

## News
* 2024-07: Added LaCAM algorithm
* 2024-04: Added PCS algorithm

### Usage Notes
## Usage Notes

* How to create a single instance

Expand Down Expand Up @@ -68,10 +74,10 @@ Modify the `Main.java` file to run your experiment. Examples are provided in the
@param numOfAgents - An array of different amounts of agents.

2.3 numOfInstances - You can choose how many instances you want for the experiment
Note: default = Integer.MAX_VALUE
Note: default = unlimited

## Acknowledgements
Designed by Jonathan Morag and Yonatan Zax.
Originally designed by Jonathan Morag and Yonatan Zax.
Started in 2019 at the heuristic search group of the Department of Software and Information Systems Engineering, Ben-Gurion University of the Negev
Conflict Based Search (CBS) is based on:
Sharon, G., Stern, R., Felner, A., & Sturtevant, N. R. (2015). Conflict-based search for optimal multi-agent pathfinding. Artificial Intelligence, 219, 40-66.
Expand All @@ -86,3 +92,7 @@ Modify the `Main.java` file to run your experiment. Examples are provided in the
Silver, David. "Cooperative pathfinding." Proceedings of the aaai conference on artificial intelligence and interactive digital entertainment. Vol. 1. No. 1. 2005.
Large Neighborhood Search (LNS) is based on:
Li, Jiaoyang, et al. "Anytime multi-agent path finding via large neighborhood search." Proceedings of the International Joint Conference on Artificial Intelligence (IJCAI). 2021.
Priority Inheritance with Backtracking (PIBT) is based on:
Okumura, Keisuke, et al. "Priority inheritance with backtracking for iterative multi-agent path finding." Artificial Intelligence 310 (2022).
Lazy Constraints Addition Search (LaCAM) is based on:
Okumura, Keisuke. "Improving lacam for scalable eventually optimal multi-agent pathfinding." arXiv preprint arXiv:2305.03632 (2023).
53 changes: 53 additions & 0 deletions src/main/java/BasicMAPF/Solvers/LaCAM/HighLevelNode.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package BasicMAPF.Solvers.LaCAM;

import BasicMAPF.Instances.Agent;
import BasicMAPF.Instances.Maps.I_Location;

import java.util.*;

/**
* A class relevant to LaCAM solver.
* High-Level node represent a configuration of locations in LaCAM search.
* The node saves more details such as priority order of agents, time step and Low-Level tree.
*/
public class HighLevelNode {
public HashMap<Agent, I_Location> configuration;
public Queue<LowLevelNode> tree;
public ArrayList<Agent> order;
public HashMap<Agent, Float> priorities;
public HighLevelNode parent;
public HashMap<Agent, Boolean> reachedGoalsMap;
public int timeStep;

public HighLevelNode(HashMap<Agent, I_Location> configuration, LowLevelNode root,ArrayList<Agent> order, HashMap<Agent, Float> priorities, HighLevelNode parent) {
this.configuration = configuration;
this.tree = new LinkedList<>();
this.tree.add(root);
this.order = order;
this.priorities = priorities;
this.parent = parent;


if (parent == null) {
// update reachedGoalsMap according to new configuration
this.reachedGoalsMap = new HashMap<>();
for (Agent agent : this.configuration.keySet()) {
this.reachedGoalsMap.put(agent, false);
}
// update time step
this.timeStep = 1;
}
else {
this.reachedGoalsMap = new HashMap<>(parent.reachedGoalsMap);
for (Map.Entry<Agent, Boolean> entry : this.reachedGoalsMap.entrySet()) {
Agent agent = entry.getKey();
Boolean reachedGoal = entry.getValue();
if (!reachedGoal && configuration.get(agent).getCoordinate().equals(agent.target)) {
this.reachedGoalsMap.put(agent, true);
}
}
// update time step
this.timeStep = parent.timeStep + 1;
}
}
}
52 changes: 52 additions & 0 deletions src/main/java/BasicMAPF/Solvers/LaCAM/HighLevelNodeStar.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package BasicMAPF.Solvers.LaCAM;

import BasicMAPF.Instances.Agent;
import BasicMAPF.Instances.Maps.I_Location;

import java.util.*;

public class HighLevelNodeStar extends HighLevelNode {

public Set<HighLevelNodeStar> neighbors;
public HighLevelNodeStar parent;
public float g;
public float h;
public float f;

public HighLevelNodeStar(HashMap<Agent, I_Location> configuration, LowLevelNode root,ArrayList<Agent> order, HashMap<Agent, Float> priorities, HighLevelNodeStar parent, float g, float h) {
super(configuration, root, order, priorities, parent);
this.parent = parent;
if (parent != null) {
parent.neighbors.add(this);
}
this.neighbors = new HashSet<>();

this.g = g;
this.h = h;
this.f = this.g + this.h;
}

public float getG() {
return g;
}

public float getH() {
return h;
}

public float getF() {
return f;
}

public void setG(float g) {
this.g = g;
}

public void setH(float h) {
this.h = h;
}

public void setF(float f) {
this.f = f;
}
}
Loading

0 comments on commit f9dfde6

Please sign in to comment.