IDSIA / crema

Crema: Credal Models Algorithms
https://crema-toolbox.readthedocs.io/
GNU Lesser General Public License v3.0
10 stars 4 forks source link

Merge convex hull functionality (crepo updating) #76

Closed rcabanasdepaz closed 3 years ago

rcabanasdepaz commented 3 years ago

The first step for integrating crepo should imply to integrate the new convex hull functionality from isipta21benchmark branch to the dev. In short, these are a set of CH methods defined at ConvexHull.Method that can be applied to a matrix of doubles, a VertexFactor or applied during inference (with VE) after each marginalization.

A summary of this functionality is:

    DAGModel model = (DAGModel) IO.readUAI("./models/pgm-vcredal.uai");

    VertexFactor vf = (VertexFactor) model.getFactor(0);

    // Apply convexhull to a matrix of doubles
    ConvexHull.as(ConvexHull.Method.QUICK_HULL).apply(vf.getData()[0])
    ConvexHull.as(ConvexHull.Method.LP_CONVEX_HULL).apply(vf.getData()[0])
    ConvexHull.as(ConvexHull.Method.REDUCED_HULL_2).apply(vf.getData()[0])

    //Apply to a factor (functional method)
    VertexFactor r = vf.convexHull(ConvexHull.Method.DEFAULT);

    //Apply to a factor (inline method)
    vf.applyConvexHull(ConvexHull.Method.REDUCED_HULL_3);

    //Variable elimination with convex hull (after marginalization)
    CredalVariableElimination inf = new CredalVariableElimination(model);

    inf.setConvexHullMarg(ConvexHull.Method.REDUCED_HULL_3);
    inf.query(0);

    inf.setConvexHullMarg(ConvexHull.Method.REDUCED_HULL_2);
    inf.query(0);
cbonesana commented 3 years ago

Merge done successfully.