Reference Example

Consider the following blog file which models researchers and publications

type Person;
type Publication;

guaranteed Person p[10];
guaranteed Publication q[3];

// random variables for timestep 1
random Boolean DoR1(Person);
random Boolean Rep1(Person);
random Boolean AttC1(Person);
random Boolean Pub1(Person, Publication);

// random variables for timestep >=2
random Boolean DoR2(Person);
random Boolean Rep2(Person);
random Boolean AttC2(Person);
random Boolean Pub2(Person, Publication);


parfactor Person X. MultiArrayPotential[[4, 2, 3, 1, 4, 1, 3, 1]]
        (Rep1(X), AttC1(X), DoR1(X));

parfactor Person X. MultiArrayPotential[[4, 2, 3, 1, 4, 1, 3, 1]]
        (Rep2(X), AttC2(X), DoR2(X));

parfactor Person X, Publication P. MultiArrayPotential[[4, 3, 2, 1, 4, 3, 2, 1]]
        (Rep1(X), AttC1(X), Pub1(X,P));

parfactor Person X, Publication P. MultiArrayPotential[[4, 3, 2, 1, 4, 3, 2, 1]]
        (Rep2(X), AttC2(X), Pub2(X,P));

parfactor Person X. MultiArrayPotential[[9, 7, 7, 3, 4, 1, 5, 8]]
        (Rep1(X), Rep2(X), AttC1(X));


// evidence for timestep 1
obs DoR1(p1, @1) = false;
obs DoR1(p5, @1) = true;
obs DoR1(p9, @1) = false;

// evidence for other timesteps
obs DoR2(p1, @2) = false;
obs DoR2(p1, @3) = true;
obs DoR2(p2, @5) = true;
obs DoR2(p4, @8) = true;
obs DoR2(p4, @9) = false;

// queries
query AttC1(p1, @1, @1);
query AttC2(p1, @1, @2);
query AttC1(p1, @4, @1);
query AttC2(p1, @3, @13);
query AttC2(p1, @4, @4);

Note that the given model has observations for parameterised random variables with more than one logical variable. Only one variable will be handled lifted by the lifted absorption operator implemented by Taghipour.

Dynamic Queries

As specified in the documentation, queries about the first timestep must query the randvar with suffix 1. Queries about subsequent timesteps must query the randvar with suffix 2, no matter from what timestep. So query AttC2(p1, @1, @2); queries randvar AttC at timestep 2 with the model at timestep 1, whereas query AttC1(p1, @4, @1); queries the randvar AttC at timestep 1 seen from timestep 4.

Output

The result (parsing and jtree construction omitted) is the distribution for the query variables, followed by additional information about the inference procedure. For details about the additional information see the LJT example.

The resulting distributions are printed in the following form

======== Query Results =========
Distribution of values for AttC1(p1) for timestep: 1 from time step 1
    0.9501385041551247    true
    0.04986149584487535    false

Distribution of values for AttC2(p1) for timestep: 2 from time step 1
    0.9461522300395692    true
    0.053847769960430884    false

[...]

The first entry refers to query AttC1(p1, @1, @1);, the second entry to query AttC2(p1, @1, @2); and so on.