X-Git-Url: http://plrg.eecs.uci.edu/git/?p=jpf-core.git;a=blobdiff_plain;f=src%2Fmain%2Fgov%2Fnasa%2Fjpf%2Flistener%2FStateReducer.java;h=474058355c1f7f82f00403cf67705e4d406fd8a5;hp=2194ff160d3074b2a9325a2c75cab2b97f2d0d1f;hb=8fb77ba10fd95f3f2f5707b1b69e30c4dbb7a04a;hpb=a0dfd528f6fa9940a4d4fcb424a9e2612453ff53 diff --git a/src/main/gov/nasa/jpf/listener/StateReducer.java b/src/main/gov/nasa/jpf/listener/StateReducer.java index 2194ff1..4740583 100644 --- a/src/main/gov/nasa/jpf/listener/StateReducer.java +++ b/src/main/gov/nasa/jpf/listener/StateReducer.java @@ -87,6 +87,8 @@ public class StateReducer extends ListenerAdapter { private HashSet visitedStateSet; // Current state private int stateId; + // Previous choice number + private int prevChoiceValue; public StateReducer(Config config, JPF jpf) { debugMode = config.getBoolean("debug_state_transition", false); @@ -104,6 +106,7 @@ public class StateReducer extends ListenerAdapter { vodGraphMap = new HashMap<>(); visitedStateSet = new HashSet<>(); stateId = -1; + prevChoiceValue = -1; initializeStateReduction(); } @@ -297,17 +300,14 @@ public class StateReducer extends ListenerAdapter { if (stateReductionMode) { // Update vodGraph int currChoice = choiceCounter - 1; - int prevChoice = currChoice - 1; - if (currChoice < 0) { + if (currChoice < 0 || choices[currChoice] == -1 || prevChoiceValue == choices[currChoice]) { // Current choice has to be at least 0 (initial case can be -1) - visitedStateSet.add(stateId); return; } - // Current choice and previous choice values could be -1 (since we use -1 as the end-of-array condition) - int currChoiceValue = (choices[currChoice] == -1) ? 0 : choices[currChoice]; // When current choice is 0, previous choice could be -1 - int prevChoiceValue = (prevChoice == -1) ? -1 : choices[prevChoice]; - updateVODGraph(prevChoiceValue, currChoiceValue); + updateVODGraph(prevChoiceValue, choices[currChoice]); + // Current choice becomes previous choice in the next iteration + prevChoiceValue = choices[currChoice]; // Line 19 in the paper page 11 (see the heading note above) stateId = search.getStateId(); // Add state ID into the visited state set