+ private void completeBacktrackChoiceList(List<Integer> newChoiceList, int currentChoice, int conflictEventNumber,
+ LinkedList<Integer[]> backtrackChoiceLists) {
+ // Put the conflicting event numbers first and reverse the order
+ newChoiceList.add(choices[currentChoice]);
+ newChoiceList.add(choices[conflictEventNumber]);
+ // Put the rest of the event numbers into the array starting from the minimum to the upper bound
+ for (int i = conflictEventNumber + 1; i < choices.length - 1; i++) {
+ // Check the sleep sets for excepted events that do not conflict with the current one
+ int prevChoiceNum = newChoiceList.get(newChoiceList.size()-1);
+ HashSet<Integer> sleepSet = sleepSetMap.get(prevChoiceNum);
+ if (choices[i] != choices[currentChoice] && !sleepSet.contains(choices[i])) {
+ newChoiceList.add(choices[i]);
+ }
+ }
+ // Set the last element to '-1' as the end of the sequence
+ newChoiceList.add(-1);
+ Integer[] newChoiceArray = copyIntegerListToArray(newChoiceList);
+ backtrackChoiceLists.addLast(newChoiceArray);
+ if (!isResetAfterAnalysis) {
+ // The start index for the recursion is always 1 (from the main branch)
+ choiceListStartIndexMap.put(newChoiceArray, 1);
+ } else {
+ choiceListStartIndexMap.put(newChoiceArray, conflictEventNumber + 1);
+ }
+ }
+