Search in sources :

Example 6 with AEBPTestingDataFrame

use of com.sri.ai.util.rplot.dataframe.AEBPTestingDataFrame in project aic-praise by aic-sri-international.

the class AEBPSolver method solve.

public static AEBPTestingDataFrame solve(Iterator<? extends Approximation<Factor>> anytimeEBPIterator, Variable query, long maximunTimeInSeconds, int runNumber, String PGMName, String methodName) {
    AEBPTaskSolver solver = new AEBPTaskSolver(anytimeEBPIterator, runNumber, PGMName, methodName, query);
    AEBPTestingDataFrame result = ExecuteSolverForACertainAmountOftime(maximunTimeInSeconds, solver);
    return result;
}
Also used : AEBPTestingDataFrame(com.sri.ai.util.rplot.dataframe.AEBPTestingDataFrame)

Example 7 with AEBPTestingDataFrame

use of com.sri.ai.util.rplot.dataframe.AEBPTestingDataFrame in project aic-praise by aic-sri-international.

the class AnytimeExactBPTest2 method solveAndStoreInDataFrame.

private static AEBPTestingDataFrame solveAndStoreInDataFrame(Iterator<? extends Approximation<Factor>> anytimeEBPIterator, TableVariable query, double maximunTimeInSeconds, int runNumber, String PGMName, String methodName) {
    AEBPTestingDataFrame df = new AEBPTestingDataFrame();
    int i = 0;
    Double currentTotalTime = .0;
    // long startTime = System.currentTimeMillis();
    while (currentTotalTime < maximunTimeInSeconds) {
        println(++i);
        Long currentTime = System.currentTimeMillis();
        if (!anytimeEBPIterator.hasNext()) {
            break;
        }
        Polytope result = (Polytope) anytimeEBPIterator.next();
        Pair<? extends List<Double>, ? extends List<Double>> maxAndMin = printPolytopeAndMaxAndMin(query, result);
        Double currentPartialTime = .001 * (System.currentTimeMillis() - currentTime);
        // currentTotalTime = .001*(System.currentTimeMillis() - startTime);
        currentTotalTime += currentPartialTime;
        println("time: " + currentTotalTime);
        df.addRow(runNumber, i, maxAndMin.second.get(0), maxAndMin.first.get(0), currentPartialTime, currentTotalTime, methodName, PGMName);
        println("...");
    }
    println("-----Done-----");
    return df;
}
Also used : Polytope(com.sri.ai.praise.core.representation.interfacebased.polytope.api.Polytope) ProductPolytope(com.sri.ai.praise.core.representation.interfacebased.polytope.core.byexpressiveness.convexhull.ProductPolytope) AEBPTestingDataFrame(com.sri.ai.util.rplot.dataframe.AEBPTestingDataFrame)

Example 8 with AEBPTestingDataFrame

use of com.sri.ai.util.rplot.dataframe.AEBPTestingDataFrame in project aic-praise by aic-sri-international.

the class AnytimeExactBPTest2 method main.

public static void main(String[] args) {
    String[] fileNames = { // "1a1x.uai",
    "grid40x40.f5.wrap.uai", "or_chain_10.fg.uai", "1a2j.uai", "grid80x80.f10.uai", "1a3c.uai", "grid80x80.f10.wrap.uai", "grid80x80.f15.uai", "or_chain_1.fg.uai", "BN_0.uai", "BN_5.uai", "grid80x80.f15.uai", "BN_101.uai", "BN_6.uai", "grid80x80.f15.wrap.uai", "BN_10.uai", "grid10x10.f10.uai", "grid80x80.f2.uai", "BN_11.uai", "grid10x10.f10.wrap.uai", "grid80x80.f2.wrap.uai", "BN_12.uai", "grid10x10.f15.wrap.uai", "grid80x80.f5.uai", "BN_13.uai", "grid10x10.f5.wrap.uai", "grid80x80.f5.wrap.uai", "BN_14.uai", "grid20x20.f10.uai", "BN_15.uai", "grid20x20.f15.uai", "or_chain_1.fg.uai", "BN_16.uai", "grid20x20.f15.wrap.uai", "pedigree13.uai", "BN_18.uai", "grid20x20.f5.uai", "pedigree18.uai", "BN_1.uai", "grid20x20.f5.wrap.uai", "pedigree19.uai", "BN_2.uai", "grid40x40.f5.uai", "pedigree20.uai" };
    for (String fileName : fileNames) {
        println("----------" + fileName + "----------");
        printPlotToFile(fileName, 20);
    }
    Pair<TableVariable, TableFactorNetwork> pairQueryNet = isingModel("5_5", 10, .2);
    AEBPTestingDataFrame df = solveWithBothMethods(pairQueryNet.first, pairQueryNet.second, 180, "Ising");
    AEBPRPlotting.plottingTheInterval(df, true, "IsingWeightPointTwo");
}
Also used : TableFactorNetwork(com.sri.ai.praise.core.representation.interfacebased.factor.core.table.TableFactorNetwork) AEBPTestingDataFrame(com.sri.ai.util.rplot.dataframe.AEBPTestingDataFrame) TableVariable(com.sri.ai.praise.core.representation.interfacebased.factor.core.table.TableVariable)

Example 9 with AEBPTestingDataFrame

use of com.sri.ai.util.rplot.dataframe.AEBPTestingDataFrame in project aic-praise by aic-sri-international.

the class AnytimeExactBPTest2 method printPlotToFile.

public static void printPlotToFile(String fileName, double maxTime) {
    Pair<TableVariable, TableFactorNetwork> pairQueryNet = importUAIFile(fileName);
    AEBPTestingDataFrame df = solveWithBothMethods(pairQueryNet.first, pairQueryNet.second, maxTime, fileName.split(".uai")[0]);
    AEBPRPlotting.plottingTheInterval(df, true, fileName.split(".uai")[0] + ".pdf");
    AEBPRPlotting.plottingTheInterval(df, true, fileName.split(".uai")[0] + ".pdf");
    df.printToCsv(fileName.split(".uai")[0] + ".csv");
}
Also used : TableFactorNetwork(com.sri.ai.praise.core.representation.interfacebased.factor.core.table.TableFactorNetwork) AEBPTestingDataFrame(com.sri.ai.util.rplot.dataframe.AEBPTestingDataFrame) TableVariable(com.sri.ai.praise.core.representation.interfacebased.factor.core.table.TableVariable)

Example 10 with AEBPTestingDataFrame

use of com.sri.ai.util.rplot.dataframe.AEBPTestingDataFrame in project aic-praise by aic-sri-international.

the class BenchmarkingIsingModel method main.

public static void main(String[] args) {
    // 100;
    int timeLimit = 1;
    int nRepetitions = 3;
    // ,7,8); // 10 is too much I think
    LinkedList<Integer> complexitiesForExactBP = list(2, 3, 4, 5, 6);
    AEBPTestingDataFrame df = new AEBPTestingDataFrame();
    testManyEBP(nRepetitions, complexitiesForExactBP, df);
    toCsv(df);
    int complexityForAnytime = 20;
    LinkedList<Pair<Double, Double>> listWithOneElement = list(pair(1., 1.));
    LinkedList<Pair<Double, Double>> weightsForGridWithRandomFactors = listWithOneElement;
    LinkedList<Pair<Double, Double>> weightsForIsingWithWeigthsAndPotentialFixed = list(pair(.01, .01), pair(.01, .1), pair(.01, 1.), pair(.01, 10.), pair(.1, .01), pair(.1, .1), pair(.1, 1.), pair(.1, 10.), pair(1., .01), pair(1., .1), pair(1., 1.), pair(1., 10.), pair(10., .01), pair(10., .1), pair(10., 1.), pair(10., 10.));
    LinkedList<Pair<Double, Double>> weightsForIsingWithWeigthsAndPotentialNormal = list(pair(.001, -1.), pair(.01, -1.), pair(1., -1.), pair(10., -1.));
    testManyAEBP(timeLimit, nRepetitions, df, complexityForAnytime, weightsForGridWithRandomFactors, weightsForIsingWithWeigthsAndPotentialFixed, weightsForIsingWithWeigthsAndPotentialNormal);
    // write dataframe
    toCsv(df);
    println("done!!!!!");
}
Also used : AEBPTestingDataFrame(com.sri.ai.util.rplot.dataframe.AEBPTestingDataFrame) Pair(com.sri.ai.util.base.Pair)

Aggregations

AEBPTestingDataFrame (com.sri.ai.util.rplot.dataframe.AEBPTestingDataFrame)11 TableFactorNetwork (com.sri.ai.praise.core.representation.interfacebased.factor.core.table.TableFactorNetwork)5 TableVariable (com.sri.ai.praise.core.representation.interfacebased.factor.core.table.TableVariable)3 AEBP (com.sri.ai.praise.core.inference.byinputrepresentation.interfacebased.core.exactbp.anytime.gabriel.AEBP)2 Polytope (com.sri.ai.praise.core.representation.interfacebased.polytope.api.Polytope)2 Predicate (com.google.common.base.Predicate)1 AssignmentsIterator (com.sri.ai.grinder.helper.AssignmentsIterator)1 TestCases (com.sri.ai.praise.core.inference.byinputrepresentation.interfacebased.core.exactbp.anytime.gabriel.TestCases)1 AnytimeExactBP (com.sri.ai.praise.core.inference.byinputrepresentation.interfacebased.core.exactbp.anytime.rodrigo.AnytimeExactBP)1 ExactBPNode (com.sri.ai.praise.core.inference.byinputrepresentation.interfacebased.core.exactbp.fulltime.api.ExactBPNode)1 ExactBP (com.sri.ai.praise.core.inference.byinputrepresentation.interfacebased.core.exactbp.fulltime.core.ExactBP)1 EditableFactorNetwork (com.sri.ai.praise.core.representation.interfacebased.factor.api.EditableFactorNetwork)1 Factor (com.sri.ai.praise.core.representation.interfacebased.factor.api.Factor)1 Variable (com.sri.ai.praise.core.representation.interfacebased.factor.api.Variable)1 TableFactor (com.sri.ai.praise.core.representation.interfacebased.factor.core.table.TableFactor)1 IntensionalConvexHullOfFactors (com.sri.ai.praise.core.representation.interfacebased.polytope.core.byexpressiveness.convexhull.IntensionalConvexHullOfFactors)1 ProductPolytope (com.sri.ai.praise.core.representation.interfacebased.polytope.core.byexpressiveness.convexhull.ProductPolytope)1 Util.list (com.sri.ai.util.Util.list)1 Util.println (com.sri.ai.util.Util.println)1 Pair (com.sri.ai.util.base.Pair)1