jariba / europa-pso

Automatically exported from code.google.com/p/europa-pso
1 stars 0 forks source link

Retracting decisions on guards leaves inconsistencies #158

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?

Run the case in PLASMA/System/test/backtrack-test.nddl

What is the expected output? What do you see instead?

The Solver should complete with cond = true, turn_before = true, and transition 
= true.  Instead, it fails with

Solvers/base/Solver.cc:641: Error: 
m_db->getConstraintEngine()->constraintConsistent() is false
    Can only call this if variable changes have been propagated first.
Error("m_db->getConstraintEngine()->constraintConsistent()", "Can only call 
this if variable changes have been propagated first.", 
"Solvers/base/Solver.cc", 641)Finished

The problem is that the inconsistency created on backtrack-test.nddl:23 isn't 
removed by retracting the decision--propagation must complete before the 
post-propagation hooks into the rule engine execute, and the inconsistency 
preempts it.  Allowing violations just causes a crash later on, because the 
ViolationMgrImpl doesn't handle removal messages on violated constraints, so 
undoing the rule leaves a dangling pointer there.  

Original issue reported on code.google.com by miata...@gmail.com on 1 Oct 2012 at 10:58

GoogleCodeExporter commented 8 years ago
I started with the working hypothesis that incomplete propagation was the 
culprit that was preventing the offending constraint from being removed. 
However, after looking at this in the debugger, I'm not seeing 
RulesEngine::scheduleForUndoing being called when the decision that specified 
the parent guard is retracted. So even when propagation completes the rule that 
contains the offending constraint isn't retracted. I want to understand why 
that's the case before taking any action.

Original comment by javier.barreiro@gmail.com on 11 Oct 2012 at 12:56

GoogleCodeExporter commented 8 years ago
I've put in place a fix to make sure that system propagators like the one that 
triggers rule activation/retraction run before other propagators. I would've 
committed this fix last night, but some regression tests broke in a puzzling 
way (entities aren't being cleaned as expected), so I'll need another pass to 
finish the fix in, hopefully I'll get a chance to work on this tonight or 
tomorrow.

I'll also fix ViolationMgr to deal with constraint deletion, as Mike points 
out, it's just part of a complete implementation, but I'll do that in a 
separate iteration.

Original comment by javier.barreiro@gmail.com on 16 Oct 2012 at 8:34

GoogleCodeExporter commented 8 years ago
ok, I've committed changes to ensure that system propagators like the 
RulesEngine one are not preempted by violations caused by user propagators.
I also added code so that the ViolationMgr manages constraint removal more 
robustly.

That addresses the problem illustrated by backtrack-test.nddl (I added it to 
our regression tests) and it works with ConstraintEngine.allowViolations() set 
to both true and false.

Original comment by javier.barreiro@gmail.com on 17 Oct 2012 at 11:43