use of edu.mit.csail.sdg.translator.A4Options in project org.alloytools.alloy by AlloyTools.
the class AlloyModelsTest method testRecursion.
@Test
public void testRecursion() throws Exception {
String filename = "src/test/resources/test-recursion.als";
Module world = CompUtil.parseEverything_fromFile(A4Reporter.NOP, null, filename);
A4Options options = new A4Options();
options.unrolls = 10;
for (Command command : world.getAllCommands()) {
A4Solution ans = TranslateAlloyToKodkod.execute_command(A4Reporter.NOP, world.getAllReachableSigs(), command, options);
while (ans.satisfiable()) {
String hc = "Answer: " + ans.toString().hashCode();
System.out.println(hc);
ans = ans.next();
}
return;
}
}
use of edu.mit.csail.sdg.translator.A4Options in project org.alloytools.alloy by AlloyTools.
the class SimpleGUI method doRun.
/**
* This method executes a particular RUN or CHECK command.
*/
private Runner doRun(Integer commandIndex) {
if (wrap)
return wrapMe(commandIndex);
final int index = commandIndex;
if (WorkerEngine.isBusy())
return null;
if (index == (-2))
subrunningTask = 1;
else
subrunningTask = 0;
latestAutoInstance = "";
if (index >= 0)
latestCommand = index;
if (index == -1 && commands != null) {
latestCommand = commands.size() - 1;
if (latestCommand < 0)
latestCommand = 0;
}
// To update the accelerator to point to the command actually chosen
doRefreshRun();
OurUtil.enableAll(runmenu);
if (commands == null)
return null;
if (commands.size() == 0 && index != -2 && index != -3) {
log.logRed("There are no commands to execute.\n\n");
return null;
}
int i = index;
if (i >= commands.size())
i = commands.size() - 1;
SimpleCallback1 cb = new SimpleCallback1(this, null, log, VerbosityPref.get().ordinal(), latestAlloyVersionName, latestAlloyVersion);
SimpleTask1 task = new SimpleTask1();
A4Options opt = new A4Options();
opt.tempDirectory = alloyHome() + fs + "tmp";
opt.solverDirectory = alloyHome() + fs + "binary";
opt.recordKodkod = RecordKodkod.get();
opt.noOverflow = NoOverflow.get();
opt.unrolls = Version.experimental ? Unrolls.get() : (-1);
opt.skolemDepth = SkolemDepth.get();
opt.coreMinimization = CoreMinimization.get();
opt.inferPartialInstance = InferPartialInstance.get();
opt.coreGranularity = CoreGranularity.get();
opt.originalFilename = Util.canon(text.get().getFilename());
opt.solver = Solver.get();
task.bundleIndex = i;
task.bundleWarningNonFatal = WarningNonfatal.get();
task.map = text.takeSnapshot();
task.options = opt.dup();
task.resolutionMode = (Version.experimental && ImplicitThis.get()) ? 2 : 1;
task.tempdir = maketemp();
try {
runmenu.setEnabled(false);
runbutton.setVisible(false);
showbutton.setEnabled(false);
stopbutton.setVisible(true);
int newmem = SubMemory.get(), newstack = SubStack.get();
if (newmem != subMemoryNow || newstack != subStackNow)
WorkerEngine.stop();
if (AlloyCore.isDebug() && VerbosityPref.get() == Verbosity.FULLDEBUG)
WorkerEngine.runLocally(task, cb);
else
WorkerEngine.run(task, newmem, newstack, alloyHome() + fs + "binary", "", cb);
subMemoryNow = newmem;
subStackNow = newstack;
} catch (Throwable ex) {
WorkerEngine.stop();
log.logBold("Fatal Error: Solver failed due to unknown reason.\n" + "One possible cause is that, in the Options menu, your specified\n" + "memory size is larger than the amount allowed by your OS.\n" + "Also, please make sure \"java\" is in your program path.\n");
log.logDivider();
log.flush();
doStop(2);
}
return null;
}
use of edu.mit.csail.sdg.translator.A4Options in project org.alloytools.alloy by AlloyTools.
the class SimpleGUI method doShowParseTree.
/**
* This method displays the parse tree.
*/
private Runner doShowParseTree() {
if (wrap)
return wrapMe();
doRefreshRun();
OurUtil.enableAll(runmenu);
if (commands != null) {
Module world = null;
try {
int resolutionMode = (Version.experimental && ImplicitThis.get()) ? 2 : 1;
A4Options opt = new A4Options();
opt.tempDirectory = alloyHome() + fs + "tmp";
opt.solverDirectory = alloyHome() + fs + "binary";
opt.originalFilename = Util.canon(text.get().getFilename());
world = CompUtil.parseEverything_fromFile(A4Reporter.NOP, text.takeSnapshot(), opt.originalFilename, resolutionMode);
} catch (Err er) {
text.shade(er.pos);
log.logRed(er.toString() + "\n\n");
return null;
}
world.showAsTree(this);
}
return null;
}
use of edu.mit.csail.sdg.translator.A4Options in project org.alloytools.alloy by AlloyTools.
the class InternalTest method main2.
/**
* Displays the amount of memory taken per solution enumeration.
*/
public static void main2(String[] args) throws Exception {
String filename = "models/examples/algorithms/dijkstra.als";
Module world = CompUtil.parseEverything_fromFile(A4Reporter.NOP, null, filename);
A4Options options = new A4Options();
for (Command command : world.getAllCommands()) {
A4Solution ans = TranslateAlloyToKodkod.execute_command(A4Reporter.NOP, world.getAllReachableSigs(), command, options);
while (ans.satisfiable()) {
String hc = "Answer: " + ans.toString().hashCode();
System.gc();
System.gc();
System.gc();
Thread.sleep(500);
System.gc();
System.gc();
System.gc();
Thread.sleep(500);
long t = Runtime.getRuntime().totalMemory(), f = Runtime.getRuntime().freeMemory(), m = Runtime.getRuntime().maxMemory();
System.out.println(hc + " total=" + t + " free=" + f + " max=" + m);
System.out.flush();
ans = ans.next();
}
return;
}
}
use of edu.mit.csail.sdg.translator.A4Options in project org.alloytools.alloy by AlloyTools.
the class AlloyTest method main.
public static void main(String[] args) throws Exception {
A4Reporter rep = new A4Reporter();
Module world = CompUtil.parseEverything_fromFile(rep, null, "/home/aleks/mvc.als");
A4Options options = new A4Options();
options.solver = A4Options.SatSolver.SAT4J;
options.skolemDepth = 1;
for (Command command : world.getAllCommands()) {
A4Solution ans = null;
try {
ans = TranslateAlloyToKodkod.execute_commandFromBook(rep, world.getAllReachableSigs(), command, options);
System.out.println(ans);
} catch (Err ex) {
Logger.getLogger(AlloyTest.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
Aggregations