Skip to content

Commit

Permalink
more tracing + error checking.
Browse files Browse the repository at this point in the history
  • Loading branch information
yanntm committed Mar 31, 2024
1 parent 92dc76e commit 144e947
Showing 1 changed file with 37 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ public static List<Integer> treatSkeleton(MccTranslator reader, DoneProperties d
invar = InvariantCalculator.computePInvariants(sumMatrix);
}
approximateStructuralBoundsUsingInvariants(sr, invar, tocheck, maxStruct);
printBounds("after Invariants on skeleton", maxSeen, maxStruct);

checkStatus(spn, tocheck, maxStruct, maxSeen, doneProps, "TOPOLOGICAL CPN_APPROX INITIAL_STATE");

Expand All @@ -99,7 +100,7 @@ public static List<Integer> treatSkeleton(MccTranslator reader, DoneProperties d
List<SparseIntArray> paths = DeadlockTester.findStructuralMaxWithSMT(tocheck, maxSeen, maxStruct, sr, repr, new ArrayList<>(), 5, true);

//interpretVerdict(tocheck, spn, doneProps, new int[tocheck.size()], solverPath, maxSeen, maxStruct);
printBounds("after SMT", maxSeen, maxStruct);
printBounds("after SMT on skeleton", maxSeen, maxStruct);

checkStatus(spn, tocheck, maxStruct, maxSeen, doneProps, "TOPOLOGICAL SAT_SMT CPN_APPROX INITIAL_STATE");
return maxStruct;
Expand Down Expand Up @@ -135,30 +136,40 @@ public static List<Integer> applyReductions(MccTranslator reader, DoneProperties
List<Integer> maxSeen = new ArrayList<>(tocheckIndexes.size());
{
SparseIntArray m0 = new SparseIntArray(spn.getMarks());
for (Expression tc:tocheck) {
maxSeen.add(tc.eval(m0));
if (spn.isSafe() && tc.getOp() == Op.PLACEREF) {
maxStruct.add(1);
} else {
if (spn.isSafe()) {
SparseIntArray ones = new SparseIntArray(spn.getMarks().size());
for (int i=0,ie=spn.getPlaceCount();i<ie; i++) {
ones.append(i, 1);
}
for (Expression tc:tocheck) {
maxSeen.add(tc.eval(m0));
maxStruct.add(tc.eval(ones));
}
printBounds("Initiallly, because the net is safe", maxSeen, maxStruct);
} else {
for (Expression tc:tocheck) {
maxSeen.add(tc.eval(m0));
maxStruct.add(-1);
}
printBounds("Initially", maxSeen, maxStruct);
}
}
boolean hasSkel = false;
if (initMaxStruct != null) {
for (int i=0; i < maxStruct.size() ; i++) {
int init=initMaxStruct.get(i);
if (init != -1 && (maxStruct.get(i) <0 || maxStruct.get(i) > init)) {
maxStruct.set(i, init);
}
}
hasSkel = true;
printBounds("Adding known information on max bounds.", maxSeen, maxStruct);
}

checkStatus(spn, tocheck, maxStruct, maxSeen, doneProps, "TOPOLOGICAL INITIAL_STATE");

List<Integer> lastMaxSeen = null;

printBounds("Before main loop", maxSeen, maxStruct);

boolean first = true;
do {
iter =0;
Expand All @@ -170,23 +181,19 @@ public static List<Integer> applyReductions(MccTranslator reader, DoneProperties
}
StructuralReduction sr = new StructuralReduction(spn);

if (!hasSkel) {
// the invariants themselves
Set<SparseIntArray> invar ;
{
// effect matrix
List<Integer> repr = new ArrayList<>();
IntMatrixCol sumMatrix = InvariantCalculator.computeReducedFlow(spn, repr);
invar = InvariantCalculator.computePInvariants(sumMatrix);
}
approximateStructuralBoundsUsingInvariants(sr, invar, tocheck, maxStruct);

printBounds("after invariants", maxSeen, maxStruct);
// FlowPrinter.drawNet(sr, "After Invariants");
checkStatus(spn, tocheck, maxStruct, maxSeen, doneProps, "TOPOLOGICAL INITIAL_STATE");
} else {
hasSkel = false;
// the invariants themselves
Set<SparseIntArray> invar ;
{
// effect matrix
List<Integer> repr = new ArrayList<>();
IntMatrixCol sumMatrix = InvariantCalculator.computeReducedFlow(spn, repr);
invar = InvariantCalculator.computePInvariants(sumMatrix);
}
approximateStructuralBoundsUsingInvariants(sr, invar, tocheck, maxStruct);

printBounds("after invariants", maxSeen, maxStruct);
// FlowPrinter.drawNet(sr, "After Invariants");
checkStatus(spn, tocheck, maxStruct, maxSeen, doneProps, "TOPOLOGICAL INITIAL_STATE");

lastMaxSeen = new ArrayList<>(maxSeen);
RandomExplorer re = new RandomExplorer(sr);
Expand Down Expand Up @@ -560,7 +567,7 @@ private static void testWithReachability(MccTranslator ori, List<Integer> maxSee
seen++;
}
}
printBounds("After reachability solving "+seen+"queries.", maxSeen, maxStruct);
printBounds("After reachability solving "+seen+" queries.", maxSeen, maxStruct);
}

private static void printBounds(String rule, List<Integer> maxSeen, List<Integer> maxStruct) {
Expand All @@ -571,6 +578,11 @@ private static void printBounds(String rule, List<Integer> maxSeen, List<Integer
printOmegas(maxStruct, sb);

System.out.println("Current structural bounds on expressions ("+ rule + ") : " + sb.toString());
for (int i=0; i< maxSeen.size() ; i++) {
if (maxStruct.get(i) >= 0 && maxSeen.get(i) > maxStruct.get(i)) {
System.out.println("Inconsistency detected : max struct is less than max seen for bound index "+i);
}
}
}

public static void printOmegas(List<Integer> bounds, StringBuilder sb) {
Expand Down

0 comments on commit 144e947

Please sign in to comment.