KeyError Wildfire XADD compilation
GMMDMDIDEMS opened this issue · 5 comments
Trying to reproduce the Wildfire
XADD compilation example from the README
I get a KeyError
.
The code to easily reproduce the error:
from pyRDDLGym_symbolic.examples import run_xadd_compilation
run_xadd_compilation.main(
domain="Wildfire", cpf="burning___x1__y1", save_graph=True, reparam=False
)
Traceback
---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
Cell In[10], line 1
----> 1 run_xadd_compilation.main(
2 domain="Wildfire", cpf="burning___x1__y1", save_graph=True, reparam=False
3 )
File ~/.venv/lib/python3.11/site-packages/pyRDDLGym_symbolic/examples/run_xadd_compilation.py:40, in main(domain, instance, cpf, save_graph, reparam)
38 # XADD compilation
39 xadd_model = RDDLModelXADD(model, reparam=reparam)
---> 40 xadd_model.compile()
41 context = xadd_model.context
43 if save_graph:
File ~/.venv/lib/python3.11/site-packages/pyRDDLGym_symbolic/core/model.py:68, in RDDLModelXADD.compile(self, reparam)
66 self.reparam = reparam
67 self.reset_dist_var_num()
---> 68 self.convert_cpfs_to_xadds()
69 self.compiled = True
File ~/.venv/lib/python3.11/site-packages/pyRDDLGym_symbolic/core/model.py:96, in RDDLModelXADD.convert_cpfs_to_xadds(self)
94 # Post-processing for Bernoulli CPFs
95 if self._need_postprocessing:
---> 96 expr_xadd_node_id = self.postprocess(
97 expr_xadd_node_id,
98 **self._postprocessing_kwargs)
99 self.cpfs[name] = expr_xadd_node_id
100 self.cpfs = self.cpfs
File ~/.venv/lib/python3.11/site-packages/pyRDDLGym_symbolic/core/model.py:465, in RDDLModelXADD.postprocess(self, node_id, **kwargs)
463 print("bernoulli_set: ", bernoulli_set)
464 # Manually remove the Bernoulli variable from the Boolean variable set.
--> 465 self.context._bool_var_set.remove(v)
466 for rv in bernoulli_set:
467 bern_param_node_id = get_bernoulli_node_id(rv)
KeyError: Bernoulli_params_1_154
Debugging attempt
I generally lack knowledge regarding XADD, but while trying to debug it I came across the following (possibly helpful):
def postprocess(...)
is called several times. In the first call, Bernoulli_params_1_154
is in both self.context._bool_var_set
and var_set
. Therefore no problems:
var_set: {put_out___x1__y1, Bernoulli_params_1_154, out_of_fuel___x1__y1, burning___x1__y1}
self.context._bool_var_set: {burning___x1__y2, burning___x5__y4, burning___x2__y2, burning___x2__y3, burning___x1__y3, burning___x5__y1, burning___x5__y3, burning___x5__y5, burning___x2__y1, burning___x3__y4, burning___x4__y5, burning___x3__y5, burning___x4__y1, burning___x1__y5, burning___x1__y1, burning___x4__y3, burning___x3__y2, burning___x4__y4, out_of_fuel___x1__y1, burning___x3__y1, Bernoulli_params_1_154, burning___x5__y2, burning___x2__y4, burning___x3__y3, put_out___x1__y1, burning___x2__y5, burning___x1__y4, burning___x4__y2}
In a later call of the def postprocess(...)
function, Bernoulli_params_1_154
was not added to self._bool_var_set
via def add_boolean_var(...)
. Accordingly, Bernoulli_params_1_154
is only in var_set
and no longer in self.context._bool_var_set
:
var_set: {out_of_fuel___x2__y1, Bernoulli_params_1_154, burning___x2__y1, put_out___x2__y1}
self.context._bool_var_set: {burning___x3__y5, burning___x1__y5, burning___x4__y1, burning___x5__y2, put_out___x1__y4, burning___x3__y3, burning___x5__y1, burning___x3__y1, put_out___x1__y1, burning___x5__y4, put_out___x2__y1, out_of_fuel___x2__y1, put_out___x1__y2, put_out___x1__y5, burning___x1__y3, burning___x3__y2, burning___x2__y4, burning___x1__y2, burning___x5__y3, out_of_fuel___x1__y3, put_out___x1__y3, burning___x2__y2, out_of_fuel___x1__y4, out_of_fuel___x1__y5, burning___x1__y1, out_of_fuel___x1__y1, burning___x2__y1, burning___x2__y3, burning___x4__y5, burning___x5__y5, burning___x3__y4, burning___x4__y4, burning___x4__y2, burning___x4__y3, out_of_fuel___x1__y2, burning___x2__y5, burning___x1__y4}
Trying to remove Bernoulli_params_1_154
from self.context._bool_var_set
therefore results in a KeyError
. Is this potentially to the duplicate (due to the first def postprocess(...)
call, where we already deleted Bernoulli_params_1_154
)?
Hi! It's most likely that you are using an outdated xaddpy version. With xaddpy==0.2.5
and the latest pyrddlgym-symbolic
repo, you should be able to compile successfully. Please let me know if that's not the case.
Unfortunately it does not work. I am using xaddpy==0.2.5
and the updated pyrddlgym-symbolic==0.0.4 4dc3861
, so the currently latest commit. Are you able to reproduce the error?
No, I can't. Can you reinstall both xaddpy and pyrddlgym-symbolic and try again?
Thanks for the support. The problem is that poetry
does not install the latest version of pyRDDLGym-symbolic
, even though I specified the latest commit and not the latest published package version. I've tried reinstalling, clearing the cache and setting up my venv
from scratch, but with no success. When I compare the files in my venv
, I see that e.g. the examples/files
in the pyRDDLGym-symbolic
package are missing.
Now I have cloned and referenced the package. That works. As I assume that the next package version will solve the problem, I am closing this issue.