use of il.ac.bgu.cs.bp.bpjs.analysis.Node in project BPjs by bThink-BGU.
the class DiningPhilTest method printCounterExample.
private static void printCounterExample(VerificationResult res) {
System.out.println("Found a counterexample");
final List<Node> trace = res.getCounterExampleTrace();
trace.forEach(nd -> System.out.println(" " + nd.getLastEvent()));
Node last = trace.get(trace.size() - 1);
System.out.println("selectableEvents: " + last.getSelectableEvents());
last.getSystemState().getBThreadSnapshots().stream().sorted((s1, s2) -> s1.getName().compareTo(s2.getName())).forEach(s -> {
System.out.println(s.getName());
System.out.println(s.getBSyncStatement());
System.out.println();
});
}
use of il.ac.bgu.cs.bp.bpjs.analysis.Node in project BPjs by bThink-BGU.
the class Mazes method verify.
public void verify() throws InterruptedException {
SingleResourceBProgram bprog = prepareProgram();
bprog.appendSource(Requirements.eventNotSelected(targetFoundEvent.getName()));
try {
DfsBProgramVerifier vfr = new DfsBProgramVerifier();
vfr.setProgressListener(new BriefPrintDfsVerifierListener());
vfr.setIterationCountGap(10);
vfr.setVisitedNodeStore(new BProgramStateVisitedStateStore(false));
// vfr.setVisitedNodeStore(new ForgetfulVisitedStateStore());
// prevent from detecting cases where we ust hit a wall.
vfr.setDetectDeadlocks(false);
final VerificationResult res = vfr.verify(bprog);
char[][] maze = getMaze(bprog);
printMaze(maze);
if (res.isCounterExampleFound()) {
System.out.println("Found a counterexample");
for (Node nd : res.getCounterExampleTrace()) {
System.out.println(" " + nd.getLastEvent());
if (nd.getLastEvent() != null) {
String name = nd.getLastEvent().getName();
if (name.startsWith("Enter")) {
String loc = name.split("\\(")[1].replace(")", "").trim();
String[] coord = loc.split(",");
int col = Integer.parseInt(coord[0]);
int row = Integer.parseInt(coord[1]);
maze[row][col] = '•';
}
}
}
printMaze(maze);
} else {
System.out.println("No counterexample found.");
}
System.out.printf("Scanned %,d states\n", res.getScannedStatesCount());
System.out.printf("Time: %,d milliseconds\n", res.getTimeMillies());
} catch (Exception ex) {
ex.printStackTrace(System.out);
}
}
Aggregations