Skip to content

Commit

Permalink
Add regenerated nodes metric. Low level only.
Browse files Browse the repository at this point in the history
  • Loading branch information
J-morag committed Oct 23, 2024
1 parent 4240bea commit 9c60985
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public class SingleAgentAStar_Solver extends A_Solver {
protected int problemStartTime;
protected int expandedNodes;
private int generatedNodes;
private int numRegeneratedNodes;
/**
* Maximum allowed f value ({@link SingleAgentPlan} cost). Will stop and return null if proved that it cannot be found.
*/
Expand Down Expand Up @@ -135,6 +136,7 @@ protected void init(MAPF_Instance instance, RunParameters runParameters){

this.expandedNodes = 0;
this.generatedNodes = 0;
this.numRegeneratedNodes = 0;
}

/* = A* algorithm = */
Expand Down Expand Up @@ -302,6 +304,7 @@ protected void writeMetricsToReport(Solution solution) {
if(instanceReport != null){
instanceReport.putIntegerValue(InstanceReport.StandardFields.expandedNodesLowLevel, this.expandedNodes);
instanceReport.putIntegerValue(InstanceReport.StandardFields.generatedNodesLowLevel, this.generatedNodes);
instanceReport.putIntegerValue(InstanceReport.StandardFields.regeneratedNodesLowLevel, this.numRegeneratedNodes);
}
}

Expand Down Expand Up @@ -391,7 +394,10 @@ private float calcH() {

protected void keepTheStateWithMinG(AStarState newState, AStarState existingState) {
// decide which state to keep, seeing as how they are both equal and in open.
openList.keepOne(existingState, newState, SingleAgentAStar_Solver.equalStatesDiscriminator);
AStarState dropped = openList.keepOne(existingState, newState, SingleAgentAStar_Solver.equalStatesDiscriminator);
if (dropped == existingState){
SingleAgentAStar_Solver.this.numRegeneratedNodes++;
}
}

/**
Expand Down

0 comments on commit 9c60985

Please sign in to comment.