@@ -199,13 +199,15 @@ void Allocation::printProb(){
199
199
}
200
200
201
201
202
- int Allocation::reductionMineDoctors (int mode) {
202
+ int Allocation::reductionMineDoctors (int mode, bool alt_store ) {
203
203
int nbTotRem = 0 ;
204
204
205
205
for (int i = 0 ; i < nbDoctors; i++) {
206
206
set<int > candidates;
207
207
set<int > positions;
208
208
int worst_rank = 0 ;
209
+ int cand_size = 0 ;
210
+ vector<bool > cand_in (nbDoctors, false );
209
211
unsigned int count = 0 ;
210
212
AgentIterator<Doctor,Hospital> iter (doctors[i], candidates, positions, doctors, hospitals, mode);
211
213
for (std::pair<int , int > p: iter) {
@@ -219,7 +221,12 @@ int Allocation::reductionMineDoctors(int mode) {
219
221
for (auto & group: hospitals[idxHos].preferences ) {
220
222
bool break_yet = false ;
221
223
for (int pref: group) {
222
- candidates.insert (pref);
224
+ if ((alt_store && cand_in[pref] == false ) ||
225
+ (!alt_store && candidates.count (pref) == 0 )) {
226
+ candidates.insert (pref);
227
+ cand_in[pref] = true ;
228
+ cand_size++;
229
+ }
223
230
if (pref == doctors[i].id ) {
224
231
break_yet = true ;
225
232
}
@@ -228,7 +235,7 @@ int Allocation::reductionMineDoctors(int mode) {
228
235
break ;
229
236
}
230
237
}
231
- if (count >= candidates. size () ) {
238
+ if (count >= cand_size ) {
232
239
#ifdef DEBUG
233
240
std::cout << " doctor worst rank of " << doctors[i].id << " is " << worst_rank << std::endl;
234
241
int remHere = 0 ;
@@ -265,13 +272,14 @@ int Allocation::reductionMineDoctors(int mode) {
265
272
return nbTotRem;
266
273
}
267
274
268
- int Allocation::reductionMineHospitals (int mode) {
275
+ int Allocation::reductionMineHospitals (int mode, bool alt_store ) {
269
276
int nbTotRem = 0 ;
270
277
271
278
for (int i = 0 ; i < nbHospitals; i++) {
272
279
set<int > candidates;
273
280
set<int > positions;
274
281
unsigned int candidate_cap = 0 ;
282
+ vector<bool > cand_in (nbHospitals, false );
275
283
int worst_rank = 0 ;
276
284
unsigned int count = 0 ;
277
285
#ifdef DEBUG
@@ -289,8 +297,10 @@ int Allocation::reductionMineHospitals(int mode) {
289
297
count += 1 ;
290
298
for (const auto & group: doctors[idxDoc].preferences ) {
291
299
for (int pref: group) {
292
- if (candidates.count (pref) == 0 ) {
300
+ if ((alt_store && cand_in[pref] == false ) ||
301
+ (!alt_store && candidates.count (pref) == 0 )) {
293
302
candidates.insert (pref);
303
+ cand_in[pref] = true ;
294
304
candidate_cap += hospitals[pref-1 ].cap ;
295
305
}
296
306
if (pref == hospitals[i].id ) {
@@ -740,6 +750,10 @@ void Allocation::reduction(int mode){
740
750
this_time += num;
741
751
}
742
752
total_removed += this_time;
753
+ } else if (mode == 13 ) {
754
+ // Use descending with faster algo
755
+ this_time = reductionMineDoctors (0 , true );
756
+ this_time += reductionMineHospitals (0 , true );
743
757
} else {
744
758
this_time = reductionMineHospitals (mode);
745
759
this_time += reductionMineDoctors (mode);
0 commit comments