3
3
import lombok .Getter ;
4
4
import lombok .Setter ;
5
5
import pexplicit .runtime .PExplicitGlobal ;
6
- import pexplicit .runtime .machine .PMachine ;
6
+ import pexplicit .runtime .machine .PMachineId ;
7
7
import pexplicit .runtime .scheduler .choice .Choice ;
8
8
import pexplicit .runtime .scheduler .choice .DataChoice ;
9
9
import pexplicit .runtime .scheduler .choice .ScheduleChoice ;
@@ -48,51 +48,15 @@ public Choice getChoice(int idx) {
48
48
return choices .get (idx );
49
49
}
50
50
51
- /**
52
- * Clear choice at a choice depth
53
- *
54
- * @param idx Choice depth
55
- */
56
- public void clearChoice (int idx ) {
57
- choices .get (idx ).clearCurrent ();
58
- choices .get (idx ).clearUnexplored ();
59
- }
60
-
61
51
/**
62
52
* Remove choices after a choice depth
63
53
*
64
54
* @param choiceNum Choice depth
65
55
*/
66
56
public void removeChoicesAfter (int choiceNum ) {
67
- choices .subList (choiceNum + 1 , choices .size ()).clear ();
68
- }
69
-
70
- /**
71
- * Get the number of unexplored choices in this schedule
72
- *
73
- * @return Number of unexplored choices
74
- */
75
- public int getNumUnexploredChoices () {
76
- int numUnexplored = 0 ;
77
- for (Choice <?> c : choices ) {
78
- numUnexplored += c .getUnexplored ().size ();
57
+ if ((choiceNum + 1 ) < choices .size ()) {
58
+ choices .subList (choiceNum + 1 , choices .size ()).clear ();
79
59
}
80
- return numUnexplored ;
81
- }
82
-
83
- /**
84
- * Get the number of unexplored data choices in this schedule
85
- *
86
- * @return Number of unexplored data choices
87
- */
88
- public int getNumUnexploredDataChoices () {
89
- int numUnexplored = 0 ;
90
- for (Choice <?> c : choices ) {
91
- if (c instanceof DataChoice ) {
92
- numUnexplored += c .getUnexplored ().size ();
93
- }
94
- }
95
- return numUnexplored ;
96
60
}
97
61
98
62
/**
@@ -101,19 +65,18 @@ public int getNumUnexploredDataChoices() {
101
65
* @param stepNum Step number
102
66
* @param choiceNum Choice number
103
67
* @param current Machine to set as current schedule choice
104
- * @param unexplored List of machine to set as unexplored schedule choices
105
68
*/
106
- public void setScheduleChoice (int stepNum , int choiceNum , PMachine current , List < PMachine > unexplored ) {
69
+ public void setScheduleChoice (int stepNum , int choiceNum , PMachineId current ) {
107
70
if (choiceNum == choices .size ()) {
108
71
choices .add (null );
109
72
}
110
73
assert (choiceNum < choices .size ());
111
74
if (PExplicitGlobal .getConfig ().isStatefulBacktrackEnabled ()
112
75
&& stepNum != 0 ) {
113
76
assert (stepBeginState != null );
114
- choices .set (choiceNum , new ScheduleChoice (stepNum , choiceNum , current , unexplored , stepBeginState ));
77
+ choices .set (choiceNum , new ScheduleChoice (stepNum , choiceNum , current , stepBeginState ));
115
78
} else {
116
- choices .set (choiceNum , new ScheduleChoice (stepNum , choiceNum , current , unexplored , null ));
79
+ choices .set (choiceNum , new ScheduleChoice (stepNum , choiceNum , current , null ));
117
80
}
118
81
}
119
82
@@ -123,14 +86,13 @@ public void setScheduleChoice(int stepNum, int choiceNum, PMachine current, List
123
86
* @param stepNum Step number
124
87
* @param choiceNum Choice number
125
88
* @param current PValue to set as current schedule choice
126
- * @param unexplored List of PValue to set as unexplored schedule choices
127
89
*/
128
- public void setDataChoice (int stepNum , int choiceNum , PValue <?> current , List < PValue <?>> unexplored ) {
90
+ public void setDataChoice (int stepNum , int choiceNum , PValue <?> current ) {
129
91
if (choiceNum == choices .size ()) {
130
92
choices .add (null );
131
93
}
132
94
assert (choiceNum < choices .size ());
133
- choices .set (choiceNum , new DataChoice (stepNum , choiceNum , current , unexplored ));
95
+ choices .set (choiceNum , new DataChoice (current ));
134
96
}
135
97
136
98
/**
@@ -139,7 +101,7 @@ public void setDataChoice(int stepNum, int choiceNum, PValue<?> current, List<PV
139
101
* @param idx Choice depth
140
102
* @return Current schedule choice
141
103
*/
142
- public PMachine getCurrentScheduleChoice (int idx ) {
104
+ public PMachineId getCurrentScheduleChoice (int idx ) {
143
105
assert (choices .get (idx ) instanceof ScheduleChoice );
144
106
return ((ScheduleChoice ) choices .get (idx )).getCurrent ();
145
107
}
@@ -155,57 +117,24 @@ public PValue<?> getCurrentDataChoice(int idx) {
155
117
return ((DataChoice ) choices .get (idx )).getCurrent ();
156
118
}
157
119
158
- /**
159
- * Get unexplored schedule choices at a choice depth.
160
- *
161
- * @param idx Choice depth
162
- * @return List of machines, or null if index is invalid
163
- */
164
- public List <PMachine > getUnexploredScheduleChoices (int idx ) {
165
- if (idx < size ()) {
166
- assert (choices .get (idx ) instanceof ScheduleChoice );
167
- return ((ScheduleChoice ) choices .get (idx )).getUnexplored ();
168
- } else {
169
- return new ArrayList <>();
170
- }
171
- }
172
-
173
- /**
174
- * Get unexplored data choices at a choice depth.
175
- *
176
- * @param idx Choice depth
177
- * @return List of PValue, or null if index is invalid
178
- */
179
- public List <PValue <?>> getUnexploredDataChoices (int idx ) {
180
- if (idx < size ()) {
181
- assert (choices .get (idx ) instanceof DataChoice );
182
- return ((DataChoice ) choices .get (idx )).getUnexplored ();
183
- } else {
184
- return new ArrayList <>();
185
- }
186
- }
187
-
188
- public ScheduleChoice getScheduleChoiceAt (Choice choice ) {
189
- if (choice instanceof ScheduleChoice scheduleChoice ) {
190
- return scheduleChoice ;
191
- } else {
192
- for (int i = choice .getChoiceNumber () - 1 ; i >= 0 ; i --) {
193
- Choice c = choices .get (i );
194
- if (c instanceof ScheduleChoice scheduleChoice ) {
195
- return scheduleChoice ;
196
- }
120
+ public ScheduleChoice getScheduleChoiceAt (int choiceNum ) {
121
+ for (int i = choiceNum ; i >= 0 ; i --) {
122
+ if (choiceNum >= choices .size ()) {
123
+ continue ;
124
+ }
125
+ Choice c = choices .get (i );
126
+ if (c instanceof ScheduleChoice scheduleChoice ) {
127
+ return scheduleChoice ;
197
128
}
198
129
}
199
130
return null ;
200
131
}
201
132
202
133
/**
203
- * Clear current choices at a choice depth
204
- *
205
- * @param idx Choice depth
134
+ * Clear current choices
206
135
*/
207
- public void clearCurrent ( int idx ) {
208
- choices .get ( idx ). clearCurrent ();
136
+ public void clear ( ) {
137
+ choices .clear ();
209
138
}
210
139
211
140
/**
0 commit comments