From: rtrimana Date: Mon, 10 Feb 2020 21:38:03 +0000 (-0800) Subject: Adding a prevChoiceValue class property to store the previous choice to update the... X-Git-Url: http://plrg.eecs.uci.edu/git/?p=jpf-core.git;a=commitdiff_plain;h=8fb77ba10fd95f3f2f5707b1b69e30c4dbb7a04a;ds=sidebyside Adding a prevChoiceValue class property to store the previous choice to update the VOD graph correctly. --- 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