I'm trying to express with Infer.NET one of the examples in the Anglican web site:
http://www.robots.ox.ac.uk/~fwood/anglican/examples/viewer/?worksheet=nested-number-guessing
Here the description of the problems:
"Two agents play a game in which each agent needs to name a number between 0 and 9 and they win if their numbers add up to 13. The first player knows this, and he knows that the second player gets to see the number the first player chooses, but the second
player mistakenly thinks that the two win if their numbers add up to any number greater than 8 (and the first player knows this as well). What number should the first player choose?"
My solution is as follow:
let n=new Range(10)
let a=Variable.DiscreteUniform(n)
let b=Variable.DiscreteUniform(n)
//SOLUTION 1
//I think this should be the right way to express the model
//It throw AllZeroException
//-----------------------------------------------------------------------------------
Variable.SwitchBlock a (fun a -> Variable.ConstrainTrue( a+b >> 8))
//-----------------------------------------------------------------------------------
//SOLUTION 2
//This works, but I don't feel is the right way to express the model
//-----------------------------------------------------------------------------------
//Variable.ConstrainTrue( a+b >> 8)
//-----------------------------------------------------------------------------------
(a+b).ObservedValue <- 13
let ie=new InferenceEngine()
printfn "a=%A - b=%A" (ie.Infer(a)) (ie.Infer(b))
Solution 1 is throwing AllZeroException.
I suspect the reason for the AllZeroException is the fact that some of the SwitchBlock branchs have probability zero as specify in the Infer.NET FAQ.
If this is in fact the reason, I how can I express the model in order to not incur in this limitation?
Thank You