use of com.sri.ai.praise.core.representation.classbased.table.core.uai.UAIModel in project aic-praise by aic-sri-international.
the class UAIModelToExpressionFactorNetwork method main.
public static void main(String[] args) {
try {
// Importing the file and reading it
FileReader modelFile = new FileReader(new File("").getAbsolutePath() + "/UAITests/BN_0.uai");
UAIModel model = UAIModelReader.read(modelFile);
// Converting the network
ExpressionFactorNetwork network = convert(model, null);
// Printing the factors
for (IdentityWrapper<Factor> fwrapped : network.getAs()) {
ExpressionFactor f = (ExpressionFactor) fwrapped.getObject();
println(f);
}
/*// This seems to be OK! But when we analyze the connections between the factors:
IdentityWrapper<Factor> f = network.getAs().iterator().next();
println("Printing one of the factors of the network:\n\t "+f);
println("Printing this factor's connections:\n\t" + network.getBsOfA(f));
println("This shows that there is something wrong\n"
+ "In fact the connections in the graph are made based on the 'freeVariables' of a factor");
println("freeVariables of f: "+Expressions.freeVariables((ExpressionFactor)f.getObject(),((ExpressionFactor)f.getObject()).getContext()));
println("\nWe can check that those 'abnomalies' are indeed variables on the network:");
for(Variable v:network.getBs()) {
System.out.print(v + ", ");
}*/
} catch (IOException e) {
e.printStackTrace();
}
}
use of com.sri.ai.praise.core.representation.classbased.table.core.uai.UAIModel in project aic-praise by aic-sri-international.
the class TestCases method retrieveUAIFile.
private static UAIModel retrieveUAIFile(String folderName, String fileName) {
if (!fileName.endsWith(".uai")) {
fileName = fileName + ".uai";
}
try {
FileReader modelFile = new FileReader(new File("").getAbsolutePath() + "/UAITests/" + folderName + "/" + fileName);
FileReader evidenceFIle = new FileReader(new File("").getAbsolutePath() + "/UAITests/" + folderName + "/" + fileName + ".evid");
UAIModel model = UAIModelReader.read(modelFile);
UAIEvidenceReading.read(evidenceFIle, model);
return model;
} catch (FileNotFoundException e) {
FileReader modelFile;
try {
modelFile = new FileReader(new File("").getAbsolutePath() + "/UAITests/" + folderName + "/" + fileName);
return UAIModelReader.read(modelFile);
} catch (FileNotFoundException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
Aggregations