potassco / clingo

🤔 A grounder and solver for logic programs.
https://potassco.org/clingo
MIT License
606 stars 81 forks source link

domRec ignored for heuristic with external atom #467

Open kherud opened 10 months ago

kherud commented 10 months ago

Domain heuristics with external atoms are ignored when enumerating answer sets with solution recording. I'm looking at example 10.6 of the potassco guide (see also the Python program attached):

1 {a(1..3)}. 
a(2) :- a(3). 
a(3) :- a(2).
{b(1)}. 

#show a/1.
#heuristic a(1..3). [1,false]

When called with --heuristic=Domain --enum-mode=domRec 0, the two answers a(1) and a(2) a(3) are correctly output.

However, if the last line is replaced with

#external e.
#heuristic a(1..3) : e. [1,false]

the warning domRec ignored: No domain atoms found. is printed and answers are enumerated without solution recording. This is also the case if e was set to true in advance.

Is this intended?

domrec.zip

rkaminsk commented 10 months ago

@BenKaufmann do you know what is happening here? Right now, I am not sure where clasp is taking the domain atoms from in this scenario.

BenKaufmann commented 10 months ago

@rkaminsk For clasp, the "domain atoms" considered by "domRec" are the atoms that have an associated heuristic directive applying on the top-level. The mode was mostly intended to be used with a fixed set of atoms to minimize.

In the first example, the relevant atoms are a(1..3) because the heuristic directives are unconditionally true.

In the second example, there are no "domain atoms" because all heuristic directives depend on the external atom e, which is assumed to be false. Of course, one could argue that if e is assumed to be true, the relevant atoms again should be a(1..3) (i.e. heuristic is true wrt root- instead of top-level). However, this is currently not implemented.

rkaminsk commented 10 months ago

I'll postpone this one for the time being. Let's hope we'll find some time to improve the domain recording options in the future.