@@ -138,7 +138,7 @@ void HighsMipSolver::run() {
138138 // Now the worker lives in mipdata.
139139 // The master worker is used in evaluateRootNode.
140140 mipdata_->workers .emplace_back (*this , &mipdata_->lp , mipdata_->domain ,
141- &mipdata_->cutpool , mipdata_->conflictPool );
141+ &mipdata_->cutpool , & mipdata_->conflictPool );
142142
143143 HighsMipWorker& master_worker = mipdata_->workers .at (0 );
144144
@@ -312,73 +312,60 @@ void HighsMipSolver::run() {
312312 int k = 0 ;
313313
314314 // Initialize worker relaxations and mipworkers
315- // todo lps and workers are still empty right now
316-
317315 const HighsInt mip_search_concurrency = options_mip_->mip_search_concurrency ;
318316 const HighsInt num_worker = mip_search_concurrency - 1 ;
319317 highs::parallel::TaskGroup tg;
320318
321- auto recreatePools = [&](HighsInt index, HighsMipWorker& worker) -> void {
322- HighsCutPool* p = &mipdata_->cutpools .at (index);
323- p->~HighsCutPool ();
324- ::new (static_cast <void *>(p))
325- HighsCutPool (numCol (), options_mip_->mip_pool_age_limit ,
326- options_mip_->mip_pool_soft_limit , index);
327- mipdata_->conflictpools [index] =
328- HighsConflictPool (5 * options_mip_->mip_pool_age_limit ,
329- options_mip_->mip_pool_soft_limit );
330- worker.conflictpool_ = mipdata_->conflictpools [index];
319+ auto destroyOldWorkers = [&]() {
320+ if (mipdata_->workers .size () <= 1 ) return ;
321+ while (mipdata_->cutpools .size () > 1 ) {
322+ mipdata_->cutpools .pop_back ();
323+ }
324+ while (mipdata_->conflictpools .size () > 1 ) {
325+ mipdata_->conflictpools .pop_back ();
326+ }
327+ while (mipdata_->domains .size () > 1 ) {
328+ mipdata_->domains .pop_back ();
329+ }
330+ while (mipdata_->lps .size () > 1 ) {
331+ mipdata_->lps .pop_back ();
332+ }
333+ while (mipdata_->workers .size () > 1 ) {
334+ mipdata_->workers .pop_back ();
335+ }
331336 };
332337
333- auto recreateLpAndDomains = [&](HighsInt index, HighsMipWorker& worker) {
334- HighsLpRelaxation* p = &mipdata_->lps .at (index);
335- p->~HighsLpRelaxation ();
336- ::new (p) HighsLpRelaxation (mipdata_->lp , index);
337- mipdata_->domains [index] = HighsDomain (mipdata_->domain );
338- worker.globaldom_ = mipdata_->domains .at (index);
338+ auto constructMasterWorkerPools = [&](HighsMipWorker& worker) {
339+ assert (mipdata_->cutpools .size () == 1 &&
340+ mipdata_->conflictpools .size () == 1 );
341+ mipdata_->cutpools .emplace_back (numCol (), options_mip_->mip_pool_age_limit ,
342+ options_mip_->mip_pool_soft_limit , 1 );
343+ worker.cutpool_ = &mipdata_->cutpools .back ();
344+ mipdata_->conflictpools .emplace_back (5 * options_mip_->mip_pool_age_limit ,
345+ options_mip_->mip_pool_soft_limit );
346+ worker.conflictpool_ = &mipdata_->conflictpools .back ();
339347 };
340348
341- // (Re-)Initialise local cut and conflict pool for master worker
342- if (mip_search_concurrency > 1 ) {
343- if (mipdata_->cutpools .size () <= 1 ) {
344- mipdata_->cutpools .emplace_back (numCol (),
345- options_mip_->mip_pool_age_limit ,
346- options_mip_->mip_pool_soft_limit , 1 );
347- master_worker.cutpool_ = &mipdata_->cutpools .back ();
348- mipdata_->conflictpools .emplace_back (5 * options_mip_->mip_pool_age_limit ,
349- options_mip_->mip_pool_soft_limit );
350- master_worker.conflictpool_ = mipdata_->conflictpools .back ();
351- } else {
352- master_worker.cutpool_ = &mipdata_->cutpools [1 ];
353- master_worker.conflictpool_ = mipdata_->conflictpools [1 ];
354- recreatePools (1 , master_worker);
355- }
356- master_worker.upper_bound = mipdata_->upper_bound ;
357- }
349+ auto createNewWorker = [&](HighsInt i) {
350+ mipdata_->domains .emplace_back (mipdata_->domain );
351+ mipdata_->lps .emplace_back (mipdata_->lp , i);
352+ mipdata_->cutpools .emplace_back (numCol (),
353+ options_mip_->mip_pool_age_limit ,
354+ options_mip_->mip_pool_soft_limit , i + 1 );
355+ mipdata_->conflictpools .emplace_back (5 * options_mip_->mip_pool_age_limit ,
356+ options_mip_->mip_pool_soft_limit );
357+ mipdata_->workers .emplace_back (
358+ *this , &mipdata_->lps .back (), mipdata_->domains .back (),
359+ &mipdata_->cutpools .back (), &mipdata_->conflictpools .back ());
360+ mipdata_->lp .notifyCutPoolsLpCopied (1 );
361+ };
358362
359- // Create / re-initialise workers
360- for (int i = 1 ; i < mip_search_concurrency; i++) {
361- if (mipdata_->workers .size () <= i) {
362- mipdata_->domains .emplace_back (mipdata_->domain );
363- mipdata_->lps .emplace_back (mipdata_->lp , i);
364- mipdata_->cutpools .emplace_back (numCol (),
365- options_mip_->mip_pool_age_limit ,
366- options_mip_->mip_pool_soft_limit , i + 1 );
367- mipdata_->conflictpools .emplace_back (5 * options_mip_->mip_pool_age_limit ,
368- options_mip_->mip_pool_soft_limit );
369- mipdata_->workers .emplace_back (
370- *this , &mipdata_->lps .back (), mipdata_->domains .back (),
371- &mipdata_->cutpools .back (), mipdata_->conflictpools .back ());
372- } else {
373- recreatePools (i + 1 , mipdata_->workers .at (i));
374- recreateLpAndDomains (i, mipdata_->workers .at (i));
375- mipdata_->workers [i].resetSearch ();
376- mipdata_->workers [i].resetSepa ();
377- }
378- mipdata_->workers [i].upper_bound = mipdata_->upper_bound ;
379- }
380- if (mip_search_concurrency > 1 ) {
381- mipdata_->lp .notifyCutPoolsLpCopied (mip_search_concurrency - 1 );
363+ destroyOldWorkers ();
364+ constructMasterWorkerPools (master_worker);
365+ master_worker.upper_bound = mipdata_->upper_bound ;
366+ master_worker.solutions_ .clear ();
367+ for (HighsInt i = 1 ; i != mip_search_concurrency; ++i) {
368+ createNewWorker (i);
382369 }
383370
384371 // Lambda for combining limit_reached across searches
0 commit comments