- if (!isResetAfterAnalysis && choiceCounter <= choiceUpperBound && !cgMap.containsValue(choiceCounter)) {
- // Update the choices of the first CG and add '-1'
- if (choices == null) {
- // Initialize backtrack set that stores all the explored backtrack lists
- maxUpperBound = cgChoices.length;
- // All the choices are always the same so we only need to update it once
- choices = new Integer[cgChoices.length + 1];
- System.arraycopy(cgChoices, 0, choices, 0, cgChoices.length);
- choices[choices.length - 1] = -1;
- String firstChoiceListString = buildStringFromChoiceList(choices);
- backtrackSet.add(firstChoiceListString);
+ if (!isResetAfterAnalysis) {
+ if (choiceCounter <= choiceUpperBound && !cgMap.containsValue(choiceCounter)) {
+ // Update the choices of the first CG and add '-1'
+ if (choices == null) {
+ // Initialize backtrack set that stores all the explored backtrack lists
+ maxUpperBound = cgChoices.length;
+ // All the choices are always the same so we only need to update it once
+ choices = new Integer[cgChoices.length + 1];
+ System.arraycopy(cgChoices, 0, choices, 0, cgChoices.length);
+ choices[choices.length - 1] = -1;
+ String firstChoiceListString = buildStringFromChoiceList(choices);
+ backtrackSet.add(firstChoiceListString);
+ }
+ icsCG.setNewValues(choices);
+ icsCG.reset();
+ // Advance the current Integer CG
+ // This way we explore all the event numbers in the first pass
+ icsCG.advance(choices[choiceCounter]);
+ cgMap.put(icsCG, choices[choiceCounter]);
+ } else {
+ // We repeat the same trace if a state match is not found yet
+ icsCG.setNewValues(choices);
+ icsCG.reset();
+ // Use a modulo since choiceCounter is going to keep increasing
+ int choiceIndex = choiceCounter % (choices.length - 1);
+ icsCG.advance(choices[choiceIndex]);
+ unusedCG.add(icsCG);