use of com.sri.ai.util.rplot.dataframe.AEBPTestingDataFrame in project aic-praise by aic-sri-international.
the class AnytimeExactBPTest3 method solveGabrielWithBoxing.
public static AEBPTestingDataFrame solveGabrielWithBoxing(Variable query, EditableFactorNetwork factorNetwork, long maximunTimeInSeconds, String PGMName) {
println("\nSolving with Gabriel's Anytime - boxing\n");
Predicate<Polytope> criteria = p -> ((IntensionalConvexHullOfFactors) p).getIndices().size() > 10;
AEBP aebp = new AEBP(factorNetwork, query, criteria, true);
/*while(aebp.hasNext()) {
Polytope p = aebp.next();
println(p);
}*/
return AEBPSolver.solve(aebp, query, maximunTimeInSeconds, 0, PGMName, "Boxing");
}
use of com.sri.ai.util.rplot.dataframe.AEBPTestingDataFrame in project aic-praise by aic-sri-international.
the class AnytimeExactBPTest3 method solveGabrielWithoutBoxing.
private static AEBPTestingDataFrame solveGabrielWithoutBoxing(Variable query, EditableFactorNetwork factorNetwork, long maximunTimeInSeconds, String PGMName) {
println("\nSolving with Gabriel's Anytime - no boxing\n");
AEBP aebp = new AEBP(factorNetwork, query);
AEBPTestingDataFrame df = AEBPSolver.solve(aebp, query, maximunTimeInSeconds, 1, PGMName, "noBoxing");
return df;
}
use of com.sri.ai.util.rplot.dataframe.AEBPTestingDataFrame in project aic-praise by aic-sri-international.
the class AEBPSolver method ExecuteSolverForACertainAmountOftime.
private static AEBPTestingDataFrame ExecuteSolverForACertainAmountOftime(long maximunTimeInSeconds, AEBPTaskSolver solver) {
ExecutorService executor = Executors.newSingleThreadExecutor();
Future<AEBPTestingDataFrame> future = executor.submit(solver);
AEBPTestingDataFrame result = null;
try {
System.out.println("Started..");
result = future.get(maximunTimeInSeconds, TimeUnit.SECONDS);
System.out.println("Finished!");
} catch (TimeoutException toe) {
System.out.println("Timeout occurred, interrupting solver.");
result = solver.interrupt();
future.cancel(true);
try {
// Wait until the solver shuts down properly from the interrupt
System.out.println("Waiting for interrupted result");
result = future.get();
System.out.println("Finished waiting for interrupted result");
} catch (Throwable t) {
System.out.println("Finished waiting for interrupted result : " + (t.getMessage() == null ? t.getClass().getName() : t.getMessage()));
}
} catch (Throwable t) {
System.out.println("Terminated! : " + (t.getMessage() == null ? t.getClass().getName() : t.getMessage()));
t.printStackTrace();
}
executor.shutdown();
System.out.println("executor is shutdown:" + executor.isShutdown());
return result;
}
use of com.sri.ai.util.rplot.dataframe.AEBPTestingDataFrame in project aic-praise by aic-sri-international.
the class AnytimeExactBPTest2 method solveWithBothMethods.
public static AEBPTestingDataFrame solveWithBothMethods(TableVariable query, TableFactorNetwork factorNetwork, double maximunTimeInSeconds, String PGMName) {
// AEBPTestingDataFrame result = solveWithRodrigos(query, factorNetwork, maximunTimeInSeconds, PGMName);
AEBPTestingDataFrame result = solveWithGabrielsNotIncremental(query, factorNetwork, maximunTimeInSeconds, PGMName);
AEBPTestingDataFrame gabriels = solveWithGabriels(query, factorNetwork, maximunTimeInSeconds, PGMName);
for (int i = 0; i < gabriels.getNumberOfRows(); i++) {
result.addRow(gabriels.getRow(i));
}
return result;
}
use of com.sri.ai.util.rplot.dataframe.AEBPTestingDataFrame in project aic-praise by aic-sri-international.
the class AnytimeExactBPTest3 method testing.
public static void testing(List<TableFactor> factors, int time, TableVariable query, String PGMname) {
TableFactorNetwork network = new TableFactorNetwork(factors);
// AEBPTestingDataFrame df = solveGabrielWithBoxing(query, network, time,PGMname);
AEBPTestingDataFrame df = solveGabrielWithoutBoxing(query, network, time, PGMname);
// AEBPTestingDataFrame df3 = solveRodrigoWithoutBoxing(query, network, time, PGMname);
// df.concatenate(df2);
// df.concatenate(df3);
AEBPRPlotting.plottingTheInterval(df, true, PGMname + ".pdf");
AEBPRPlotting.plottingTheInterval(df, true, PGMname + ".pdf");
}
Aggregations