@@ -58,24 +58,29 @@ def compute(self, state):
5858 goals = self .automated_planner .goals
5959 types = state .types
6060 facts = state .facts
61-
6261 fact_costs = self .automated_planner .pddl .init_facts_costs (facts )
6362 while not (len (fact_costs ) == self .automated_planner .pddl .length (facts ) and self .__facts_eq (fact_costs , facts )):
6463 facts , state = self .automated_planner .pddl .get_facts_and_state (fact_costs , types )
6564 if self .automated_planner .satisfies (goals , state ):
66- costs = [fact_costs [g ] for g in goals ]
65+ costs = []
66+ fact_costs_str = dict ( [(str (k ), val ) for k , val in fact_costs .items ()] )
67+ for g in goals :
68+ if str (g ) in fact_costs_str :
69+ costs .append (fact_costs_str [str (g )])
6770 costs .insert (0 , 0 )
6871 return self .heuristic_keys [self .current_h ](costs )
6972
7073 for ax in self .cache .axioms :
71- fact_costs = self .automated_planner .pddl .compute_costs_one_step_derivatiion (
74+ fact_costs = self .automated_planner .pddl .compute_costs_one_step_derivation (
7275 facts , fact_costs , ax , self .current_h
7376 )
7477
7578 actions = self .automated_planner .available_actions (state )
79+ if not actions :
80+ break
7681 for act in actions :
7782 fact_costs = self .automated_planner .pddl .compute_cost_action_effect (
78- fact_costs , act , domain , self .cache .preconds , self . cache . additions , self .current_h
83+ fact_costs , act , domain , self .cache .additions , self .current_h
7984 )
8085 return float ("inf" )
8186
@@ -84,14 +89,13 @@ def __pre_compute(self):
8489 return
8590 domain = self .automated_planner .domain
8691 domain , axioms = self .automated_planner .pddl .compute_hsp_axioms (domain )
87- preconditions = dict ()
92+ # preconditions = dict()
8893 additions = dict ()
94+ self .automated_planner .pddl .cache_global_preconditions (domain )
8995 for name , definition in domain .actions .items ():
90- precond = self .automated_planner .pddl .filter_negative_preconds (definition )
91- preconditions [name ] = precond
9296 additions [name ] = self .automated_planner .pddl .effect_diff (definition .effect ).add
9397 self .cache .additions = additions
94- self .cache .preconds = preconditions
98+ self .cache .preconds = self . automated_planner . pddl . g_preconditions
9599 self .cache .domain = domain
96100 self .cache .axioms = axioms
97101 self .has_been_precomputed = True
0 commit comments