problog icon indicating copy to clipboard operation
problog copied to clipboard

subquery/2 and /3 always use the ProbabilitySemiring

Open VincentDerk opened this issue 5 years ago • 5 comments

In subquery/2 (and /3), the semiring is not passed on to the sub evaluation. This means custom semirings or the HALSemiring (continuous vars) do not yet work properly.

Example for dcproblog_develop branch:

b~beta(0.5,1).
c :- b > 1.
event :- subquery(c, Prob), writeln(Prob).
query(event).

VincentDerk avatar Jan 02 '20 10:01 VincentDerk

Hey guys, any update on this?

shuvrobiswas avatar Jan 28 '20 18:01 shuvrobiswas

Hi,

Yeah sorry, last couple of weeks have been super hectic. We briefly looked at it and could not come up with a quick and general fix. I'll be working on improving support continuous random variables over the next weeks. I hope I can get around fixing this issue, too.

pedrozudo avatar Jan 28 '20 19:01 pedrozudo

Hey guys, any timeline on this issue and/or any way I can help?

Created a simple covid19 example (with just plain problog, no continuous variables):

image

shuvrobiswas avatar Apr 07 '20 17:04 shuvrobiswas

Unfortunately I have been swamped with other things, hard to tell when I can look into this again. I don't know whether @pedrozudo found time?

From what I remember, the problem was the current design structure where the engine had no knowledge of the semiring. We could not just pass on a semiring to the engine because the semiring might be based on the results from the engine (for example in the implementation for continuous variables).

I was opting for a user defined function to create a semiring given an engine but I believe there was another reason that made me change my mind. Something to do with how the implementation in the continuous case is done with a Solver and was not necessarily following the procedure in subquery.

Regarding the comment in your example, 0::fever(X) :- healthy(X). adds a reason for fever(X) to become true (even though it will not change the results as you attached a probability of 0). \+ fever(X) :- healthy(X). says that it is impossible to have a fever when you are healthy. It overrides any other rule that could have otherwised caused fever while being healthy.

VincentDerk avatar Apr 07 '20 17:04 VincentDerk

Thanks for the update @VincentDerk and agreed re the fever/healthy comment :+1:

shuvrobiswas avatar Apr 10 '20 00:04 shuvrobiswas