public class StateReducer extends ListenerAdapter {
private boolean debugMode;
+ private boolean stateReductionMode;
private final PrintWriter out;
private String detail;
private int depth;
public StateReducer (Config config, JPF jpf) {
debugMode = config.getBoolean("debug_state_transition", false);
+ stateReductionMode = config.getBoolean("activate_state_reduction", true);
if (debugMode) {
out = new PrintWriter(System.out, true);
} else {
@Override
public void choiceGeneratorSet (VM vm, ChoiceGenerator<?> newCG) {
- // Initialize with necessary information from the CG
- if (newCG instanceof IntIntervalGenerator) {
- IntIntervalGenerator iigCG = (IntIntervalGenerator) newCG;
- // Check if CG has been initialized, otherwise initialize it
- if (!isInitialized) {
- Integer[] choices = iigCG.getChoices();
- // Get the upper bound from the last element of the choices
- choiceUpperBound = choices[choices.length - 1];
- isInitialized = true;
- } else {
- newCG.setDone();
+ if (stateReductionMode) {
+ // Initialize with necessary information from the CG
+ if (newCG instanceof IntIntervalGenerator) {
+ IntIntervalGenerator iigCG = (IntIntervalGenerator) newCG;
+ // Check if CG has been initialized, otherwise initialize it
+ if (!isInitialized) {
+ Integer[] choices = iigCG.getChoices();
+ // Get the upper bound from the last element of the choices
+ choiceUpperBound = choices[choices.length - 1];
+ isInitialized = true;
+ } else {
+ newCG.setDone();
+ }
}
}
}
@Override
public void choiceGeneratorAdvanced (VM vm, ChoiceGenerator<?> currentCG) {
- // Check every choice generated and make sure that all the available choices
- // are chosen first before repeating the same choice of value twice!
- if (currentCG instanceof IntIntervalGenerator) {
- IntIntervalGenerator iigCG = (IntIntervalGenerator) currentCG;
- Integer nextChoice = iigCG.getNextChoice();
- if (!cgChoiceSet.contains(nextChoice)) {
- cgChoiceSet.add(nextChoice);
- }
- // Allow reinitialization after an upper bound is hit
- // This means all available choices have been explored once during this iteration
- if (cgChoiceSet.contains(choiceUpperBound)) {
- isInitialized = false;
- cgChoiceSet.clear();
+ if (stateReductionMode) {
+ // Check every choice generated and make sure that all the available choices
+ // are chosen first before repeating the same choice of value twice!
+ if (currentCG instanceof IntIntervalGenerator) {
+ IntIntervalGenerator iigCG = (IntIntervalGenerator) currentCG;
+ Integer nextChoice = iigCG.getNextChoice();
+ if (!cgChoiceSet.contains(nextChoice)) {
+ cgChoiceSet.add(nextChoice);
+ }
+ // Allow reinitialization after an upper bound is hit
+ // This means all available choices have been explored once during this iteration
+ if (cgChoiceSet.contains(choiceUpperBound)) {
+ isInitialized = false;
+ cgChoiceSet.clear();
+ }
}
}
}