From f6e1dc19eb900983e1318540326c9b9e82c7629d Mon Sep 17 00:00:00 2001 From: Brandon Rozek Date: Thu, 2 Nov 2023 17:37:12 -0400 Subject: [PATCH] Thoughts on new heuristic --- .../heuristics/DeletePrecondRelax.java | 66 +++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 src/main/java/org/rairlab/planner/heuristics/DeletePrecondRelax.java diff --git a/src/main/java/org/rairlab/planner/heuristics/DeletePrecondRelax.java b/src/main/java/org/rairlab/planner/heuristics/DeletePrecondRelax.java new file mode 100644 index 0000000..3f4fc16 --- /dev/null +++ b/src/main/java/org/rairlab/planner/heuristics/DeletePrecondRelax.java @@ -0,0 +1,66 @@ +package org.rairlab.planner.heuristics; + +import org.rairlab.planner.State; +import org.rairlab.planner.Action; +import org.rairlab.planner.State; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; + +/* + * IN PROGRESS + + * Heuristic that returns the number of actions + * needed to perform to satisfy a goal where + * preconditions and deletes of actions are not + * taken into account. + * + * The difficult part here is how do we deal with effect computation? + * Since normally free variables are instantiated. + * I think in this case, we keep it as free variables. + * (Gotta make sure it's fresh and distinct wrt to the other formulae) + * + * Then for the goal condition check we see if the two + * formulas "unify" with each other... + */ +public class DeletePrecondRelax { + + private List actions; + private State goal; + private Map cache; + private Optional bound = Optional.empty(); + + public DeletePrecondRelax(List actions, State goal) { + this.actions = actions; + this.goal = goal; + this.cache = new HashMap(); + } + + public int h(State s) { + if (cache.containsKey(s)) { + return cache.get(s); + } + int ch = compute_h(s); + this.cache.put(s, ch); + return ch; + } + + // TODO: Fill in... + public int compute_h(State s) { + return 0; + } + + public Optional getBound() { + return bound; + } + + public void setBound(int b) { + bound = Optional.of(b); + } + + public void clearBound() { + bound = Optional.empty(); + } +}