use of com.sri.ai.praise.core.representation.interfacebased.factor.core.table.TableFactorNetwork in project aic-praise by aic-sri-international.
the class AnytimeExactBPTest2 method importUAIFile.
public static Pair<TableVariable, TableFactorNetwork> importUAIFile(String fileName) {
Pair<TableVariable, TableFactorNetwork> pairQueryNet = new Pair<>();
try {
FileReader modelFile = new FileReader(new File("").getAbsolutePath() + "/UAITests/" + fileName);
UAIModel model = UAIModelReader.read(modelFile);
// Converting the network
pairQueryNet.second = new TableFactorNetwork(model);
// get one variable and test over the network
ArrayList<Variable> vars = new ArrayList<>(pairQueryNet.second.getBs());
// pick any variable
pairQueryNet.first = (TableVariable) vars.get(0);
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return pairQueryNet;
}
use of com.sri.ai.praise.core.representation.interfacebased.factor.core.table.TableFactorNetwork in project aic-praise by aic-sri-international.
the class AnytimeExactBPTest2 method isingModel.
public static Pair<TableVariable, TableFactorNetwork> isingModel(String queryName, int gridSize, double potential) {
Pair<TableVariable, TableFactorNetwork> pairQueryNet;
// TestCases.isingModelGridWithRandomWeigthsAndPotetial(gridSize, potential);
List<TableFactor> factors = null;
TableVariable query = null;
for (TableFactor f : factors) {
for (TableVariable v : f.getVariables()) {
if (v.getName().equals(queryName)) {
query = v;
// Util.println("Query not null");
}
}
// Util.println(f.getVariables());
}
TableFactorNetwork tfn = new TableFactorNetwork(factors);
pairQueryNet = new Pair<>(query, tfn);
return pairQueryNet;
}
use of com.sri.ai.praise.core.representation.interfacebased.factor.core.table.TableFactorNetwork 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");
}
use of com.sri.ai.praise.core.representation.interfacebased.factor.core.table.TableFactorNetwork 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.praise.core.representation.interfacebased.factor.core.table.TableFactorNetwork 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");
}
Aggregations