@@ -199,13 +199,15 @@ void Allocation::printProb(){
199199}
200200
201201
202- int Allocation::reductionMineDoctors (int mode) {
202+ int Allocation::reductionMineDoctors (int mode, bool alt_store ) {
203203 int nbTotRem = 0 ;
204204
205205 for (int i = 0 ; i < nbDoctors; i++) {
206206 set<int > candidates;
207207 set<int > positions;
208208 int worst_rank = 0 ;
209+ int cand_size = 0 ;
210+ vector<bool > cand_in (nbDoctors, false );
209211 unsigned int count = 0 ;
210212 AgentIterator<Doctor,Hospital> iter (doctors[i], candidates, positions, doctors, hospitals, mode);
211213 for (std::pair<int , int > p: iter) {
@@ -219,7 +221,12 @@ int Allocation::reductionMineDoctors(int mode) {
219221 for (auto & group: hospitals[idxHos].preferences ) {
220222 bool break_yet = false ;
221223 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+ }
223230 if (pref == doctors[i].id ) {
224231 break_yet = true ;
225232 }
@@ -228,7 +235,7 @@ int Allocation::reductionMineDoctors(int mode) {
228235 break ;
229236 }
230237 }
231- if (count >= candidates. size () ) {
238+ if (count >= cand_size ) {
232239#ifdef DEBUG
233240 std::cout << " doctor worst rank of " << doctors[i].id << " is " << worst_rank << std::endl;
234241 int remHere = 0 ;
@@ -265,13 +272,14 @@ int Allocation::reductionMineDoctors(int mode) {
265272 return nbTotRem;
266273}
267274
268- int Allocation::reductionMineHospitals (int mode) {
275+ int Allocation::reductionMineHospitals (int mode, bool alt_store ) {
269276 int nbTotRem = 0 ;
270277
271278 for (int i = 0 ; i < nbHospitals; i++) {
272279 set<int > candidates;
273280 set<int > positions;
274281 unsigned int candidate_cap = 0 ;
282+ vector<bool > cand_in (nbHospitals, false );
275283 int worst_rank = 0 ;
276284 unsigned int count = 0 ;
277285#ifdef DEBUG
@@ -289,8 +297,10 @@ int Allocation::reductionMineHospitals(int mode) {
289297 count += 1 ;
290298 for (const auto & group: doctors[idxDoc].preferences ) {
291299 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 )) {
293302 candidates.insert (pref);
303+ cand_in[pref] = true ;
294304 candidate_cap += hospitals[pref-1 ].cap ;
295305 }
296306 if (pref == hospitals[i].id ) {
@@ -740,6 +750,10 @@ void Allocation::reduction(int mode){
740750 this_time += num;
741751 }
742752 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 );
743757 } else {
744758 this_time = reductionMineHospitals (mode);
745759 this_time += reductionMineDoctors (mode);
0 commit comments