use of com.sri.ai.grinder.sgdpllt.theory.differencearithmetic.DifferenceArithmeticTheory in project aic-expresso by aic-sri-international.
the class IntersectionExtensionalSetSimplifierTest method setUp.
@Before
public void setUp() {
context = new TrueContext(new CompoundTheory(new DifferenceArithmeticTheory(false, false), new TupleTheory()));
IntegerInterval intType = new IntegerInterval(1, 10);
context = (Context) GrinderUtil.extendRegistryWith(map("M", intType.toString(), "N", intType.toString()), Arrays.asList(intType), context);
simplifier = new IntersectionExtensionalSetSimplifier();
}
use of com.sri.ai.grinder.sgdpllt.theory.differencearithmetic.DifferenceArithmeticTheory in project aic-expresso by aic-sri-international.
the class InversionSimplifierTest method setUp.
@Before
public void setUp() {
context = new TrueContext(new CompoundTheory(new DifferenceArithmeticTheory(false, false), new TupleTheory()));
FunctionType gFunctionType = new FunctionType(new IntegerInterval("1..10"), new IntegerInterval("1..10"));
context = (Context) GrinderUtil.extendRegistryWith(map("g", gFunctionType.toString()), Arrays.asList(gFunctionType), context);
simplifier = new InversionSimplifier();
}
use of com.sri.ai.grinder.sgdpllt.theory.differencearithmetic.DifferenceArithmeticTheory in project aic-expresso by aic-sri-international.
the class DistributeIntersectionOverUnionSimplifierTest method setUp.
@Before
public void setUp() {
context = new TrueContext(new CompoundTheory(new DifferenceArithmeticTheory(false, false), new TupleTheory()));
IntegerInterval intType = new IntegerInterval(1, 10);
context = (Context) GrinderUtil.extendRegistryWith(map("M", intType.toString(), "N", intType.toString()), Arrays.asList(intType), context);
simplifier = new DistributeIntersectionOverUnionSimplifier();
}
use of com.sri.ai.grinder.sgdpllt.theory.differencearithmetic.DifferenceArithmeticTheory in project aic-expresso by aic-sri-international.
the class ExpressionStepSolverToLiteralSplitterStepSolverAdapterTest method testCompoundTheoryWithDifferenceArithmeticWithRandomDisjunctiveFormulas.
@Test
public void testCompoundTheoryWithDifferenceArithmeticWithRandomDisjunctiveFormulas() {
TheoryTestingSupport theoryTestingSupport = TheoryTestingSupport.make(makeRandom(), new CompoundTheory(new EqualityTheory(false, true), new DifferenceArithmeticTheory(false, true), new PropositionalTheory()));
// using different testing variables and types to test distribution of testing information
// to sub constraint theories.
Categorical booleanType = BOOLEAN_TYPE;
Categorical dogsType = new Categorical("Dogs", 4, arrayList(parse("fido"), parse("rex")));
IntegerInterval oneTwoThree = new IntegerInterval(1, 3);
Map<String, Type> variablesAndTypes = map("F", booleanType, "G", booleanType, "R", dogsType, "S", dogsType, "T", oneTwoThree, "U", oneTwoThree);
theoryTestingSupport.setVariableNamesAndTypesForTesting(variablesAndTypes);
runRandomDisjunctiveFormulasTest(theoryTestingSupport);
}
use of com.sri.ai.grinder.sgdpllt.theory.differencearithmetic.DifferenceArithmeticTheory in project aic-praise by aic-sri-international.
the class UAIMARSolver method main.
public static void main(String[] args) throws IOException {
if (args.length != 4) {
throw new IllegalArgumentException("Usage: UAIMARSolver <file or directory with UAI-format files> <solution directory> <timeout in ms> equalities|difference_arithmetic");
}
File uaiInput = new File(args[0]);
if (!uaiInput.exists()) {
throw new IllegalArgumentException("File or directory specified does not exist: " + uaiInput.getAbsolutePath());
}
File solutionDir = new File(args[1]);
if (!solutionDir.exists() || !solutionDir.isDirectory()) {
throw new IllegalArgumentException("Solution directory is invalid: " + solutionDir.getAbsolutePath());
}
int maxSolverTimeInSeconds = Integer.parseInt(args[2]);
Theory theory;
if (args[3].equals("equalities")) {
theory = new CompoundTheory(new PropositionalTheory(), new EqualityTheory(true, true));
} else if (args[3].equals("difference_arithmetic")) {
theory = new CompoundTheory(new PropositionalTheory(), new DifferenceArithmeticTheory(true, true));
} else {
throw new IllegalArgumentException("4-th argument must be either 'equalities' or 'difference_arithmetic'");
}
List<UAIModel> models = new ArrayList<>();
Map<UAIModel, File> modelToFile = new HashMap<>();
if (uaiInput.isDirectory()) {
for (File uaiFile : uaiInput.listFiles((dir, name) -> name.endsWith(".uai"))) {
UAIModel model = read(uaiFile, solutionDir);
models.add(model);
modelToFile.put(model, uaiFile);
}
} else {
UAIModel model = read(uaiInput, solutionDir);
models.add(model);
modelToFile.put(model, uaiInput);
}
// Sort based on what we consider to be the simplest to hardest
//Collections.sort(models, (model1, model2) -> Double.compare(model1.ratioUniqueTablesToTables(), model2.ratioUniqueTablesToTables()));
//Collections.sort(models, (model1, model2) -> Integer.compare(model1.largestNumberOfFunctionTableEntries(), model2.largestNumberOfFunctionTableEntries()));
Collections.sort(models, (model1, model2) -> Integer.compare(model1.totalNumberEntriesForAllFunctionTables(), model2.totalNumberEntriesForAllFunctionTables()));
//Collections.sort(models, (model1, model2) -> Integer.compare(model1.numberTables(), model2.numberTables()));
Map<String, Boolean> modelSolvedStatus = new LinkedHashMap<>();
Map<String, Long> modelSolvedTime = new LinkedHashMap<>();
System.out.println("#models read=" + models.size());
final AtomicInteger cnt = new AtomicInteger(1);
models.stream().forEach(model -> {
System.out.println("Starting to Solve: " + modelToFile.get(model).getName() + " (" + cnt.getAndAdd(1) + " of " + models.size() + ")");
long start = System.currentTimeMillis();
boolean solved = solve(model, model.getEvidence(), model.getMARSolution(), maxSolverTimeInSeconds, theory);
long took = (System.currentTimeMillis() - start);
System.out.println("---- Took " + took + "ms. solved=" + solved);
modelSolvedStatus.put(modelToFile.get(model).getName(), solved);
modelSolvedTime.put(modelToFile.get(model).getName(), took);
});
System.out.println("MODELS SOLVE STATUS");
modelSolvedStatus.entrySet().stream().forEach(e -> System.out.printf("%-25s %-5b %12sms.\n", e.getKey(), e.getValue(), modelSolvedTime.get(e.getKey())));
System.out.println("SUMMARY");
System.out.println("#models solved=" + modelSolvedStatus.values().stream().filter(status -> status == true).count());
System.out.println("#models unsolved=" + modelSolvedStatus.values().stream().filter(status -> status == false).count());
}
Aggregations