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;
}
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;
}
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");
}
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");
}
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!!!!!");
}
Aggregations