Model Definition¶
Credal Set Specification¶
For the definition of a credal set, the domains should be first specified.
Discrete variable domains in Crema are managed with objects of class Strides
.
Then, for the definition of a credal set defined by its vertices, create an object
of class VertexFactor
as shown below.
///// code 1 .... LINE 13
// Define the domains
Strides strides_left = DomainBuilder.var(0).size(3).strides();
Strides strides_right = Strides.empty();
double p = 0.2;
// define a marginal vertex factor
Similarly, a conditional credal set can be define as shown in the following code.
/// code 2
// define a conditional vertex factor
strides_left = DomainBuilder.var(1).size(2).strides();
strides_right = DomainBuilder.var(0).size(3).strides();
VertexFactor f1 = VertexFactorFactory.factory().domain(strides_left, strides_right) //K(vars[1]|[0])
// when adding the extreme points, value of the conditioning variables should be specified
.addVertex(new double[]{0.4, 0.6}, 0)
.addVertex(new double[]{0.2, 0.8}, 0)
.addVertex(new double[]{0.3, 0.7}, 1)
Crema also allows the specification of credal sets by defining
its constraints. This is done with the class SeparateHalfspaceFactor
.
.get();
// code 3
SeparateHalfspaceFactor f0_constr = SeparateHalfspaceFactorFactory.factory().domain(strides_left, Strides.empty())
// add constraints
.constraint(new double[]{1., 1., 0.,}, Relationship.EQ, p)
.constraint(new double[]{0., 0., 1.,}, Relationship.EQ, 1 - p)
// normalization constraint
Credal Network Specification¶
For defining a credal network, create an object of class SparseModel
, specify
the structure of the graph and associate the factors.
.constraint(new double[]{0., 1., 0.,}, Relationship.GEQ, 0)
.constraint(new double[]{0., 0., 1.,}, Relationship.GEQ, 0)
.get();
// Define the structure
DAGModel<VertexFactor> cnet = new DAGModel<>();