Skip to content

Commit

Permalink
Fix a bug caused by identical (modulo program attributes) Clingo mode…
Browse files Browse the repository at this point in the history
…ls generated by different abductive supports
  • Loading branch information
iensen committed Nov 29, 2021
1 parent da6f998 commit d35b790
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 1 deletion.
2 changes: 1 addition & 1 deletion libplog/src/plogcontrol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ PlogControl::PlogControl(GroundPlog::GroundPlogFacade *groundplog,
, pgf_(pgf)
, psf_(psf)
,logger_(printer),
clingoControl{{"0","--opt-mode=optN"}, [](Clingo::WarningCode, char const *message) {}, messageLimit},
clingoControl{{"0","--opt-mode=optN","--project"}, [](Clingo::WarningCode, char const *message) {}, messageLimit},
solvingMode(mode)
{

Expand Down
4 changes: 4 additions & 0 deletions libplog/src/program.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,10 @@ namespace Plog {
Clingo::AST::Disjunction d;
Clingo::AST::Rule f_r{{defaultLoc, d}, body};
b.add({defaultLoc, f_r});
// See https://github.com/iensen/plog2.0/issues/18.
// We want to 'project' the models on the atoms formed by program's attribute terms, or else we can get two
// identical models generated by different abductive supports counted towards probability.
b.add({defaultLoc,Clingo::AST::ProjectSignature{Clingo::Signature(name.c_str(),numArgs+1,true)}});
}
if(solvingMode == SolvingMode::query_naive || solvingMode == SolvingMode::possible_worlds) {
b.add({defaultLoc, Clingo::AST::ShowSignature{Clingo::Signature("__pr", 4, true), false}});
Expand Down
22 changes: 22 additions & 0 deletions plogapp/tests/multipleabdsupports.plog
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
sorts

#boolean={true, false}.

attributes

a : #boolean.
b : #boolean.
c: #boolean.
statements

a:+.
b:+.
a:- b.
b:- a.
c:- b.
c:- a.
c:+.

obs(c).

?a.
4 changes: 4 additions & 0 deletions test/query_naive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,3 +154,7 @@ TEST(NEWVERSION_NAIVE, _dostmt) {
ASSERT_NEAR(compute_query("plogapp/tests/donaive.plog",NewPlogMode::QUERY_NAIVE), 1.0, 1e-4);
}

TEST(NEWVERSION_NAIVE, _issue18) {
ASSERT_NEAR(compute_query("plogapp/tests/multipleabdsupports.plog",NewPlogMode::QUERY_NAIVE), 0.5, 1e-4);
}

0 comments on commit d35b790

Please sign in to comment.