BayesianLogic / blog

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

bug in particle filter logic that forgets the past #330

Open cberzan opened 10 years ago

cberzan commented 10 years ago

Minimal example illustrating the problem:

random Real controls(Timestep t) ~ UnivarGaussian(0, 10);

random Real state(Timestep t) ~
    if t == @0 then 0
    else controls(t) + state(t - 1);

obs controls(@1) = 1;
obs controls(@2) = 2;
obs controls(@3) = 3;

query state(@1); // ***
query state(@2); // ***
query state(@3);

If you run this, you get that state(@3) is a delta distribution at 6. This is the correct result.

But if you comment out the lines marked with "***", you get a completely different distribution for state(@3), which is incorrect.

This bug is a combination of laziness (don't instantiate vars that we don't need) and forgetting the past (forget all instantiated vars from timesteps smaller than the current timestep). In the example above (with the "***" lines commented out), when sampling state(@3), sample(@2) is not instantiated, and controls(@2) is already forgotten.

Current workaround: Query the state at every timestep, to make sure it is always instantiated in the current timestep.

lileicc commented 10 years ago

Hello, Constantin,

The bug is known (and almost planned). For dbn, we didnot take extra effort to figure out what variables are need for future query. So we will only instantiate the variables to support evidence and query vars at the current time step.

The (dirty and quick) solution is exactly as you said, to query variables every time.

Lei

On Mon, Dec 1, 2014 at 5:43 PM, cberzan notifications@github.com wrote:

Minimal example illustrating the problem:

random Real controls(Timestep t) ~ UnivarGaussian(0, 10);

random Real state(Timestep t) ~ if t == @0 then 0 else controls(t) + state(t - 1);

obs controls(@1) = 1; obs controls(@2) = 2; obs controls(@3) = 3;

query state(@1); // query state(@2); // query state(@3);

If you run this, you get that state(@3) is a delta distribution at 6. This is the correct result.

But if you comment out the lines marked with "***", you get a completely different distribution for state(@3), which is incorrect.

This bug is a combination of laziness (don't instantiate vars that we don't need) and forgetting the past (forget all instantiated vars from timesteps smaller than the current timestep). In the example above (with the "***" lines commented out), when sampling state(@3), sample(@2) is not instantiated, and controls(@2) is already forgotten.

Current workaround: Query the state at every timestep, to make sure it is always instantiated in the current timestep.

— Reply to this email directly or view it on GitHub https://github.com/BayesianLogic/blog/issues/330.