Skip to content

Commit 4ceb340

Browse files
committed
Methods leveledOff adapted to new graph structure.
1 parent fe6d374 commit 4ceb340

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

aima-core/src/main/java/aima/core/logic/planning/GraphPlanAlgorithm.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -176,11 +176,10 @@ private boolean checkAllGoalsNonMutex(Level<Literal, ActionSchema> level, List<L
176176
* @return Boolean stating if the hashtable is levelled off.
177177
*/
178178
private boolean leveledOff(Hashtable<Integer, List<Literal>> nogoods) {
179-
if (nogoods.size() < 2)
179+
int lastLevel = nogoods.size()-1;
180+
if (lastLevel < 1)
180181
return false;
181-
List<Integer> keys = new ArrayList<>(nogoods.keySet());
182-
keys.sort(Comparator.reverseOrder());
183-
return nogoods.get(keys.get(0)).equals(nogoods.get(keys.get(1)));
182+
return nogoods.get(lastLevel).equals(nogoods.get(lastLevel-1));
184183
}
185184

186185
/**
@@ -189,9 +188,9 @@ private boolean leveledOff(Hashtable<Integer, List<Literal>> nogoods) {
189188
* @return Boolean stating if the graph is levelled off.
190189
*/
191190
private boolean levelledOff(Graph graph) {
192-
if (graph.numLevels() < 3)
191+
if (graph.numLevels() < 2)
193192
return false;
194-
return graph.getLiteralLevel(graph.numLevels() - 1).equals(graph.getLiteralLevel(graph.numLevels() - 3));
193+
return graph.getLiteralLevel(graph.numLevels() - 1).equals(graph.getLiteralLevel(graph.numLevels() - 2));
195194
}
196195

197196
public List<List<ActionSchema>> generateCombinations(List<List<ActionSchema>> actionLists) {

0 commit comments

Comments
 (0)