@@ -2785,3 +2785,49 @@ void HighsMipSolverData::updatePrimalDualIntegral(const double from_lower_bound,
27852785}
27862786
27872787void HighsPrimaDualIntegral::initialise () { this ->value = -kHighsInf ; }
2788+
2789+ void MipRaceIncumbent::clear () {
2790+ this ->start_write_incumbent = -1 ;
2791+ this ->finish_write_incumbent = -1 ;
2792+ this ->best_incumbent_objective = -kHighsInf ;
2793+ this ->best_incumbent_solution .clear ();
2794+ }
2795+
2796+ void MipRaceIncumbent::initialise (const HighsInt num_col) {
2797+ this ->clear ();
2798+ this ->best_incumbent_solution .resize (num_col);
2799+ }
2800+
2801+ void MipRaceIncumbent::write (const double objective,
2802+ const std::vector<double >& solution) {
2803+ assert (this ->best_incumbent_solution .size () == solution.size ());
2804+ this ->start_write_incumbent ++;
2805+ this ->best_incumbent_objective = objective;
2806+ this ->best_incumbent_solution = solution;
2807+ this ->finish_write_incumbent ++;
2808+ assert (this ->start_write_incumbent == this ->finish_write_incumbent );
2809+ }
2810+
2811+ bool MipRaceIncumbent::readOk (double & objective,
2812+ std::vector<double >& solution) const {
2813+ const HighsInt start_write_incumbent = this ->start_write_incumbent ;
2814+ assert (this ->finish_write_incumbent <= start_write_incumbent);
2815+ // If a write call has not completed, return failure
2816+ if (this ->finish_write_incumbent < start_write_incumbent) return false ;
2817+ // finish_write_incumbent = start_write_incumbent so start reading
2818+ objective = this ->best_incumbent_objective ;
2819+ solution = this ->best_incumbent_solution ;
2820+ // Read is OK if no new write has started
2821+ return this ->start_write_incumbent == start_write_incumbent;
2822+ }
2823+
2824+ void MipRaceRecord::clear () { this ->record .clear (); }
2825+
2826+ void MipRaceRecord::initialise (const HighsInt num_race_instance,
2827+ const HighsInt num_col) {
2828+ this ->clear ();
2829+ MipRaceIncumbent mip_race_incumbent;
2830+ mip_race_incumbent.initialise (num_col);
2831+ for (HighsInt instance = 0 ; instance < num_race_instance; instance++)
2832+ this ->record .push_back (mip_race_incumbent);
2833+ }
0 commit comments