Thoughts on new heuristic

This commit is contained in:
Brandon Rozek 2023-11-02 17:37:12 -04:00
parent 135852b74b
commit f6e1dc19eb
No known key found for this signature in database
GPG key ID: 26E457DA82C9F480

View file

@ -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<Action> actions;
private State goal;
private Map<State, Integer> cache;
private Optional<Integer> bound = Optional.empty();
public DeletePrecondRelax(List<Action> actions, State goal) {
this.actions = actions;
this.goal = goal;
this.cache = new HashMap<State, Integer>();
}
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<Integer> getBound() {
return bound;
}
public void setBound(int b) {
bound = Optional.of(b);
}
public void clearBound() {
bound = Optional.empty();
}
}