1
1
package pexplicit .runtime .scheduler ;
2
2
3
+ import lombok .Data ;
3
4
import lombok .Getter ;
4
5
import lombok .Setter ;
5
6
import pexplicit .runtime .PExplicitGlobal ;
6
- import pexplicit .runtime .machine .PMachine ;
7
7
import pexplicit .runtime .machine .PMachineId ;
8
- import pexplicit .runtime .scheduler .choice .Choice ;
9
- import pexplicit .runtime .scheduler .choice .DataChoice ;
10
- import pexplicit .runtime .scheduler .choice .ScheduleChoice ;
8
+ import pexplicit .runtime .scheduler .choice .*;
11
9
import pexplicit .runtime .scheduler .explicit .StepState ;
12
10
import pexplicit .values .PValue ;
13
11
20
18
*/
21
19
public class Schedule implements Serializable {
22
20
/**
23
- * List of choices
21
+ * List of current choices
24
22
*/
25
23
@ Getter
26
24
@ Setter
27
- private List <Choice > choices = new ArrayList <>();
25
+ private List <SearchUnit > searchUnits = new ArrayList <>();
28
26
29
27
/**
30
28
* Step state at the start of a scheduler step.
@@ -45,8 +43,8 @@ public Schedule() {
45
43
* @param idx Choice depth
46
44
* @return Choice at depth idx
47
45
*/
48
- public Choice getChoice (int idx ) {
49
- return choices .get (idx );
46
+ public SearchUnit getChoice (int idx ) {
47
+ return searchUnits .get (idx );
50
48
}
51
49
52
50
/**
@@ -55,8 +53,8 @@ public Choice getChoice(int idx) {
55
53
* @param idx Choice depth
56
54
*/
57
55
public void clearChoice (int idx ) {
58
- choices .get (idx ).clearCurrent ();
59
- choices .get (idx ).clearUnexplored ();
56
+ searchUnits .get (idx ).clearCurrent ();
57
+ searchUnits .get (idx ).clearUnexplored ();
60
58
}
61
59
62
60
/**
@@ -65,7 +63,7 @@ public void clearChoice(int idx) {
65
63
* @param choiceNum Choice depth
66
64
*/
67
65
public void removeChoicesAfter (int choiceNum ) {
68
- choices .subList (choiceNum + 1 , choices .size ()).clear ();
66
+ searchUnits .subList (choiceNum + 1 , searchUnits .size ()).clear ();
69
67
}
70
68
71
69
/**
@@ -75,7 +73,7 @@ public void removeChoicesAfter(int choiceNum) {
75
73
*/
76
74
public int getNumUnexploredChoices () {
77
75
int numUnexplored = 0 ;
78
- for (Choice <?> c : choices ) {
76
+ for (SearchUnit <?> c : searchUnits ) {
79
77
numUnexplored += c .getUnexplored ().size ();
80
78
}
81
79
return numUnexplored ;
@@ -88,8 +86,8 @@ public int getNumUnexploredChoices() {
88
86
*/
89
87
public int getNumUnexploredDataChoices () {
90
88
int numUnexplored = 0 ;
91
- for (Choice <?> c : choices ) {
92
- if (c instanceof DataChoice ) {
89
+ for (SearchUnit <?> c : searchUnits ) {
90
+ if (c instanceof DataSearchUnit ) {
93
91
numUnexplored += c .getUnexplored ().size ();
94
92
}
95
93
}
@@ -104,17 +102,17 @@ public int getNumUnexploredDataChoices() {
104
102
* @param current Machine to set as current schedule choice
105
103
* @param unexplored List of machine to set as unexplored schedule choices
106
104
*/
107
- public void setScheduleChoice (int stepNum , int choiceNum , PMachineId current , List <PMachineId > unexplored ) {
108
- if (choiceNum == choices .size ()) {
109
- choices .add (null );
105
+ public void setScheduleChoice (int stepNum , int choiceNum , ScheduleChoice current , List <ScheduleChoice > unexplored ) {
106
+ if (choiceNum == searchUnits .size ()) {
107
+ searchUnits .add (null );
110
108
}
111
- assert (choiceNum < choices .size ());
109
+ assert (choiceNum < searchUnits .size ());
112
110
if (PExplicitGlobal .getConfig ().isStatefulBacktrackEnabled ()
113
111
&& stepNum != 0 ) {
114
112
assert (stepBeginState != null );
115
- choices .set (choiceNum , new ScheduleChoice (stepNum , choiceNum , current , unexplored , stepBeginState ));
113
+ searchUnits .set (choiceNum , new ScheduleSearchUnit (stepNum , choiceNum , current , unexplored , stepBeginState ));
116
114
} else {
117
- choices .set (choiceNum , new ScheduleChoice (stepNum , choiceNum , current , unexplored , null ));
115
+ searchUnits .set (choiceNum , new ScheduleSearchUnit (stepNum , choiceNum , current , unexplored , null ));
118
116
}
119
117
}
120
118
@@ -126,12 +124,12 @@ public void setScheduleChoice(int stepNum, int choiceNum, PMachineId current, Li
126
124
* @param current PValue to set as current schedule choice
127
125
* @param unexplored List of PValue to set as unexplored schedule choices
128
126
*/
129
- public void setDataChoice (int stepNum , int choiceNum , PValue <?> current , List <PValue <?> > unexplored ) {
130
- if (choiceNum == choices .size ()) {
131
- choices .add (null );
127
+ public void setDataChoice (int stepNum , int choiceNum , DataChoice current , List <DataChoice > unexplored ) {
128
+ if (choiceNum == searchUnits .size ()) {
129
+ searchUnits .add (null );
132
130
}
133
- assert (choiceNum < choices .size ());
134
- choices .set (choiceNum , new DataChoice (stepNum , choiceNum , current , unexplored ));
131
+ assert (choiceNum < searchUnits .size ());
132
+ searchUnits .set (choiceNum , new DataSearchUnit (stepNum , choiceNum , current , unexplored ));
135
133
}
136
134
137
135
/**
@@ -140,9 +138,9 @@ public void setDataChoice(int stepNum, int choiceNum, PValue<?> current, List<PV
140
138
* @param idx Choice depth
141
139
* @return Current schedule choice
142
140
*/
143
- public PMachineId getCurrentScheduleChoice (int idx ) {
144
- assert (choices .get (idx ) instanceof ScheduleChoice );
145
- return ((ScheduleChoice ) choices .get (idx )).getCurrent ();
141
+ public ScheduleChoice getCurrentScheduleChoice (int idx ) {
142
+ assert (searchUnits .get (idx ) instanceof ScheduleSearchUnit );
143
+ return ((ScheduleSearchUnit ) searchUnits .get (idx )).getCurrent ();
146
144
}
147
145
148
146
/**
@@ -151,9 +149,9 @@ public PMachineId getCurrentScheduleChoice(int idx) {
151
149
* @param idx Choice depth
152
150
* @return Current data choice
153
151
*/
154
- public PValue <?> getCurrentDataChoice (int idx ) {
155
- assert (choices .get (idx ) instanceof DataChoice );
156
- return ((DataChoice ) choices .get (idx )).getCurrent ();
152
+ public DataChoice getCurrentDataChoice (int idx ) {
153
+ assert (searchUnits .get (idx ) instanceof DataSearchUnit );
154
+ return ((DataSearchUnit ) searchUnits .get (idx )).getCurrent ();
157
155
}
158
156
159
157
/**
@@ -162,10 +160,10 @@ public PValue<?> getCurrentDataChoice(int idx) {
162
160
* @param idx Choice depth
163
161
* @return List of machines, or null if index is invalid
164
162
*/
165
- public List <PMachineId > getUnexploredScheduleChoices (int idx ) {
163
+ public List <ScheduleChoice > getUnexploredScheduleChoices (int idx ) {
166
164
if (idx < size ()) {
167
- assert (choices .get (idx ) instanceof ScheduleChoice );
168
- return ((ScheduleChoice ) choices .get (idx )).getUnexplored ();
165
+ assert (searchUnits .get (idx ) instanceof ScheduleSearchUnit );
166
+ return ((ScheduleSearchUnit ) searchUnits .get (idx )).getUnexplored ();
169
167
} else {
170
168
return new ArrayList <>();
171
169
}
@@ -177,22 +175,22 @@ public List<PMachineId> getUnexploredScheduleChoices(int idx) {
177
175
* @param idx Choice depth
178
176
* @return List of PValue, or null if index is invalid
179
177
*/
180
- public List <PValue <?> > getUnexploredDataChoices (int idx ) {
178
+ public List <DataChoice > getUnexploredDataChoices (int idx ) {
181
179
if (idx < size ()) {
182
- assert (choices .get (idx ) instanceof DataChoice );
183
- return ((DataChoice ) choices .get (idx )).getUnexplored ();
180
+ assert (searchUnits .get (idx ) instanceof DataSearchUnit );
181
+ return ((DataSearchUnit ) searchUnits .get (idx )).getUnexplored ();
184
182
} else {
185
183
return new ArrayList <>();
186
184
}
187
185
}
188
186
189
- public ScheduleChoice getScheduleChoiceAt (Choice choice ) {
190
- if (choice instanceof ScheduleChoice scheduleChoice ) {
187
+ public ScheduleSearchUnit getScheduleChoiceAt (SearchUnit searchUnit ) {
188
+ if (searchUnit instanceof ScheduleSearchUnit scheduleChoice ) {
191
189
return scheduleChoice ;
192
190
} else {
193
- for (int i = choice .getChoiceNumber () - 1 ; i >= 0 ; i --) {
194
- Choice c = choices .get (i );
195
- if (c instanceof ScheduleChoice scheduleChoice ) {
191
+ for (int i = searchUnit .getChoiceNumber () - 1 ; i >= 0 ; i --) {
192
+ SearchUnit c = searchUnits .get (i );
193
+ if (c instanceof ScheduleSearchUnit scheduleChoice ) {
196
194
return scheduleChoice ;
197
195
}
198
196
}
@@ -206,7 +204,7 @@ public ScheduleChoice getScheduleChoiceAt(Choice choice) {
206
204
* @param idx Choice depth
207
205
*/
208
206
public void clearCurrent (int idx ) {
209
- choices .get (idx ).clearCurrent ();
207
+ searchUnits .get (idx ).clearCurrent ();
210
208
}
211
209
212
210
/**
@@ -215,6 +213,6 @@ public void clearCurrent(int idx) {
215
213
* @return Number of choices in the schedule
216
214
*/
217
215
public int size () {
218
- return choices .size ();
216
+ return searchUnits .size ();
219
217
}
220
218
}
0 commit comments