Skip to content

Commit

Permalink
Merge pull request #203 from AI-Planning/locm-fixes
Browse files Browse the repository at this point in the history
Reverting to the paper style, and putting in a check.
  • Loading branch information
haz authored Jul 6, 2023
2 parents 02b6dba + 0bd1279 commit 2d567cf
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 10 deletions.
32 changes: 23 additions & 9 deletions macq/extract/locm.py
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,7 @@ def _step4(HS: Hypotheses, debug: bool = False) -> Bindings:
# check if hypothesis parameters (v1 & v2) need to be unified
if (
(h1.B == h2.B and h1.k == h2.k and h1.k_ == h2.k_)
and # See https://github.com/AI-Planning/macq/discussions/200
or # See https://github.com/AI-Planning/macq/discussions/200
(h1.C == h2.C and h1.l == h2.l and h1.l_ == h2.l_) # fmt: skip
):
v1 = state_bindings[h1]
Expand Down Expand Up @@ -818,14 +818,21 @@ def _step7(
pind = None
for hyp in state_params_to_hyps[sort][start_state][param]:
if hyp.C == ap:
if (psort is not None and psort != hyp.G_) or \
(pind is not None and pind != hyp.l_):
print(f"\n\tError: The following set of hypotheses for sort {sort} and state {start_state} are not consistent (ap = {ap}):")
for hyp in state_params_to_hyps[sort][start_state][param]:
if hyp.C == ap:
print(f"\t\t{hyp}")
print("\n\t This domain cannot be handled by LOCMv1. Please see https://github.com/AI-Planning/macq/discussions/200 for more info.\n\n")
exit(1)
assert psort is None or psort == hyp.G_
assert pind is None or pind == hyp.l_
psort = hyp.G_
pind = hyp.l_
assert psort is not None
assert pind is not None
start_fluent.param_sorts.append(f"sort{psort}")
start_fluent.param_act_inds.append(pind - 1)
if psort is not None:
start_fluent.param_sorts.append(f"sort{psort}")
start_fluent.param_act_inds.append(pind - 1)

a.update_precond(start_fluent)

Expand All @@ -850,14 +857,21 @@ def _step7(
pind = None
for hyp in state_params_to_hyps[sort][end_state][param]:
if hyp.B == ap:
if (psort is not None and psort != hyp.G_) or \
(pind is not None and pind != hyp.k_):
print(f"\n\tError: The following set of hypotheses for sort {sort} and state {end_state} are not consistent (ap = {ap}):")
for hyp in state_params_to_hyps[sort][end_state][param]:
if hyp.B == ap:
print(f"\t\t{hyp}")
print("\n\t This domain cannot be handled by LOCMv1. Please see https://github.com/AI-Planning/macq/discussions/200 for more info.\n\n")
exit(1)
assert psort is None or psort == hyp.G_
assert pind is None or pind == hyp.k_
psort = hyp.G_
pind = hyp.k_
assert psort is not None
assert pind is not None
end_fluent.param_sorts.append(f"sort{psort}")
end_fluent.param_act_inds.append(pind - 1)
if psort is not None:
end_fluent.param_sorts.append(f"sort{psort}")
end_fluent.param_act_inds.append(pind - 1)

a.update_delete(start_fluent)
a.update_add(end_fluent)
Expand Down
2 changes: 1 addition & 1 deletion tests/extract/test_locm.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ def test_locm_step4(HS=None, is_test=True):
for G, bG in bindings.items():
for S, bGS in bG.items():
print(f"\nG={G}, S={S}")
assert 4 == len({v for _, v in bGS})
assert 1 == len({v for _, v in bGS})

else:
return bindings
Expand Down

0 comments on commit 2d567cf

Please sign in to comment.