pyperplan icon indicating copy to clipboard operation
pyperplan copied to clipboard

multiples runs return different heuristics for the same state

Open matgreco opened this issue 1 year ago • 0 comments

Hi,

I have interest to use the heuristic modules, but when I run the same script, which contain the definition of a task and a state, return different heuristics values. Are there something wrong in my code or is a problem in pyperplan?

The code is following, and if you run this multiples times can provide differents values.

from pyperplan.pddl.pddl import Domain 
from pyperplan.task import Task, Operator

from pyperplan.heuristics.blind import BlindHeuristic
from pyperplan.heuristics.lm_cut import LmCutHeuristic
from pyperplan.search.searchspace import SearchNode

# (name, pre, add, del) 
op1 = Operator("op1", set((1,2)), set((3,4)), set((1,2)))
op2 = Operator("op2", set((3,4)), set((1,2)), set((3,4)))

# (name, facts, initial_state, goals, operators):
t1 = Task("t1", set((-1, -2, -3, -4, 1,2,3,4)), set((1,2)), set((3,4)), set((op1,op2))  )

h_blind  = BlindHeuristic(t1)
h_lmcut  = LmCutHeuristic(t1)

nodo1 = SearchNode(set((1,2)), None, "ac1", 0)
hstate = h_blind(nodo1)
print("heuristic nodo 1", hstate)

nodo2 = SearchNode(set((4,3, -1)), None, "ac2", 0)
hstate = h_lmcut(nodo2)
print("heuristic nodo 2", hstate)

Thanks

matgreco avatar Mar 08 '24 22:03 matgreco