Skip to content

Commit

Permalink
explicitly forbid inconsistent heuristics (unsupported)
Browse files Browse the repository at this point in the history
  • Loading branch information
J-morag committed Jan 25, 2023
1 parent dee56f6 commit 0eabd59
Showing 1 changed file with 10 additions and 14 deletions.
24 changes: 10 additions & 14 deletions src/main/java/BasicMAPF/Solvers/AStar/SingleAgentAStar_Solver.java
Original file line number Diff line number Diff line change
Expand Up @@ -84,36 +84,35 @@ protected void init(MAPF_Instance instance, RunParameters runParameters){
this.existingSolution.putPlan(this.existingPlan);
}

if(runParameters instanceof RunParameters_SAAStar
if(runParameters instanceof RunParameters_SAAStar parameters
&& ((RunParameters_SAAStar) runParameters).heuristicFunction != null){
RunParameters_SAAStar parameters = ((RunParameters_SAAStar) runParameters);
this.gAndH = parameters.heuristicFunction;
}
else{
this.gAndH = new defaultGAndH();
}
if(runParameters instanceof RunParameters_SAAStar
if (! this.gAndH.isConsistent()){
throw new IllegalArgumentException("Support for inconsistent heuristic is not implemented.");
}

if(runParameters instanceof RunParameters_SAAStar parameters
&& ((RunParameters_SAAStar) runParameters).problemStartTime >= 0){
RunParameters_SAAStar parameters = ((RunParameters_SAAStar) runParameters);
this.problemStartTime = parameters.problemStartTime;
}
if(runParameters instanceof RunParameters_SAAStar
if(runParameters instanceof RunParameters_SAAStar parameters
&& ((RunParameters_SAAStar) runParameters).conflictAvoidanceTable != null){
RunParameters_SAAStar parameters = ((RunParameters_SAAStar) runParameters);
this.conflictAvoidanceTable = parameters.conflictAvoidanceTable;
}
// else keep the value that it has already been initialised with (above)
if(runParameters instanceof RunParameters_SAAStar){
RunParameters_SAAStar parameters = ((RunParameters_SAAStar) runParameters);
if(runParameters instanceof RunParameters_SAAStar parameters){
this.sourceCoor = parameters.sourceCoor != null ? parameters.sourceCoor : agent.source;
this.targetCoor = parameters.targetCoor != null ? parameters.targetCoor : agent.target;
}
else{
this.sourceCoor = agent.source;
this.targetCoor = agent.target;
}
if(runParameters instanceof RunParameters_SAAStar){
RunParameters_SAAStar parameters = ((RunParameters_SAAStar) runParameters);
if(runParameters instanceof RunParameters_SAAStar parameters){
this.fBudget = parameters.fBudget;
}
else{
Expand Down Expand Up @@ -181,7 +180,6 @@ protected Solution solveAStar() {

/**
* Initialises {@link #openList OPEN}.
*
* OPEN is not initialised with a single root state as is common. This is because states in this solver represent
* {@link Move moves} (classically - operators) rather than {@link I_Location map locations} (classically - states).
* Instead, OPEN is initialised with all possible moves from the starting position.
Expand Down Expand Up @@ -403,9 +401,7 @@ public SingleAgentPlan backTracePlan(SingleAgentPlan existingPlan) {
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof AStarState)) return false;

AStarState that = (AStarState) o;
if (!(o instanceof AStarState that)) return false;

if (
// (timeDimension || that.timeDimension) &&
Expand Down

0 comments on commit 0eabd59

Please sign in to comment.