BayesianLogic / blog

The BLOG programming language
http://bayesianlogic.github.io/
BSD 4-Clause "Original" or "Old" License
98 stars 31 forks source link

Bugs in MHSampler #301

Open datang1992 opened 10 years ago

datang1992 commented 10 years ago

@lileicc @cberzan

The current MHSampler implementation fails on the following small example (just a baby version of the hurricane-new):

/**
 * Hurricane 
 * Figure 4.2 in Milch's thesis
 * this one doesnot have deterministic relationship
 */

type City;
type PrepLevel;
type DamageLevel;

random City First ~ UniformChoice({c for City c});

random PrepLevel Prep(City c) ~
  if (First == c) then Categorical({High -> 0.5, Low -> 0.5})
  else case Damage(First) in {
    Severe -> Categorical({High -> 0.9, Low -> 0.1}),
    Mild -> Categorical({High -> 0.1, Low -> 0.9})
  };

random DamageLevel Damage(City c) ~
  case Prep(c) in {
    High -> Categorical({Severe -> 0.2, Mild -> 0.8}),
  Low -> Categorical({Severe -> 0.8, Mild -> 0.2})
  };

distinct City A, B;
distinct PrepLevel Low, High;
distinct DamageLevel Severe, Mild;

obs Damage(First) = Severe;

query First;

In BLOG-0.9, it will have exceptions on this example. Though in BLOG-0.7 no exceptions exist, the output is always incorrect.

cberzan commented 10 years ago

@datang1992 That's because the syntax changed in 0.9. See the updated example/hurricane.blog and let me know if there's any problem.

datang1992 commented 10 years ago

@cberzan It's not because the syntax problem. I have updated the latest version and this BLOG problem won't have syntax error in BLOG-0.9 but it will fail on MHSampler saying that some variables are not instantiated.

lileicc commented 10 years ago

It is not because the syntax problem. Da, would you please double check (git diff) the changes to GenericProposal btw 0.7 and 0.9?

On Wed, Aug 20, 2014 at 4:29 PM, Da Tang notifications@github.com wrote:

@cberzan https://github.com/cberzan It's not because the syntax problem. This BLOG problem won't have syntax error in BLOG-0.9 but it will fail on MHSampler saying that some variables are not instantiated.

— Reply to this email directly or view it on GitHub https://github.com/BayesianLogic/blog/issues/301#issuecomment-52859684.