-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* 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
Showing
12 changed files
with
1,944 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
52
src/main/java/BasicMAPF/Solvers/LaCAM/HighLevelNodeStar.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
Oops, something went wrong.