Skip to content

Commit 6b4a6ee

Browse files
committed
Removed MipSolverInfo and last vestiges of MIP race
1 parent 079dc03 commit 6b4a6ee

File tree

6 files changed

+23
-95
lines changed

6 files changed

+23
-95
lines changed

highs/lp_data/HStruct.h

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -183,22 +183,4 @@ struct HighsSimplexStats {
183183
void initialise(const HighsInt iteration_count_ = 0);
184184
};
185185

186-
struct HighsMipSolverInfo {
187-
// Data pulled from the MIP solver that are required after instance
188-
// is deleted
189-
HighsModelStatus modelstatus;
190-
std::vector<double> solution;
191-
double solution_objective;
192-
double bound_violation;
193-
double integrality_violation;
194-
double row_violation;
195-
double dual_bound;
196-
double primal_bound;
197-
double gap;
198-
HighsInt max_submip_level;
199-
int64_t node_count;
200-
int64_t total_lp_iterations;
201-
double primal_dual_integral;
202-
void clear();
203-
};
204186
#endif /* LP_DATA_HSTRUCT_H_ */

highs/lp_data/Highs.cpp

Lines changed: 14 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -933,8 +933,6 @@ HighsStatus Highs::presolve() {
933933
return returnFromHighs(return_status);
934934
}
935935

936-
HighsMipSolverInfo getMipSolverInfo(const HighsMipSolver& solver);
937-
938936
HighsStatus Highs::run() {
939937
const bool options_had_highs_files = this->optionsHasHighsFiles();
940938
if (options_had_highs_files) {
@@ -4025,24 +4023,22 @@ HighsStatus Highs::callSolveMip() {
40254023
}
40264024
HighsLp& lp = has_semi_variables ? use_lp : model_.lp_;
40274025
HighsMipSolver solver(callback_, options_, lp, solution_);
4028-
HighsMipSolverInfo mip_solver_info;
40294026
solver.run();
4030-
mip_solver_info = getMipSolverInfo(solver);
40314027
options_.log_dev_level = log_dev_level;
40324028
// Set the return_status, model status and, for completeness, scaled
40334029
// model status
40344030
HighsStatus return_status =
4035-
highsStatusFromHighsModelStatus(mip_solver_info.modelstatus);
4036-
model_status_ = mip_solver_info.modelstatus;
4031+
highsStatusFromHighsModelStatus(solver.modelstatus_);
4032+
model_status_ = solver.modelstatus_;
40374033
// Extract the solution
4038-
if (mip_solver_info.solution_objective != kHighsInf) {
4034+
if (solver.solution_objective_ != kHighsInf) {
40394035
// There is a primal solution
40404036
//
40414037
// If the original model has semi-variables, its solution is
40424038
// (still) given by the first model_.lp_.num_col_ entries of the
40434039
// solution from the MIP solver
40444040
solution_.col_value.resize(model_.lp_.num_col_);
4045-
solution_.col_value = mip_solver_info.solution;
4041+
solution_.col_value = solver.solution_;
40464042
this->saved_objective_and_solution_ = solver.saved_objective_and_solution_;
40474043
model_.lp_.a_matrix_.productQuad(solution_.row_value, solution_.col_value);
40484044
solution_.value_valid = true;
@@ -4062,7 +4058,7 @@ HighsStatus Highs::callSolveMip() {
40624058
// There is no basis: should be so by default
40634059
assert(!basis_.valid);
40644060
// Get the objective and any KKT failures
4065-
info_.objective_function_value = mip_solver_info.solution_objective;
4061+
info_.objective_function_value = solver.solution_objective_;
40664062
// Remember to judge primal feasibility according to
40674063
// mip_feasibility_tolerance, so take a copy of the original
40684064
// value...
@@ -4071,23 +4067,23 @@ HighsStatus Highs::callSolveMip() {
40714067
// NB getKktFailures sets the primal and dual solution status
40724068
getKktFailures(options_, model_, solution_, basis_, info_);
40734069
// Set the MIP-specific values of info_
4074-
info_.mip_node_count = mip_solver_info.node_count;
4075-
info_.mip_dual_bound = mip_solver_info.dual_bound;
4076-
info_.mip_gap = mip_solver_info.gap;
4077-
info_.primal_dual_integral = mip_solver_info.primal_dual_integral;
4070+
info_.mip_node_count = solver.node_count_;
4071+
info_.mip_dual_bound = solver.dual_bound_;
4072+
info_.mip_gap = solver.gap_;
4073+
info_.primal_dual_integral = solver.primal_dual_integral_;
40784074
// Get the number of LP iterations, avoiding overflow if the int64_t
40794075
// value is too large
4080-
int64_t mip_total_lp_iterations = mip_solver_info.total_lp_iterations;
4076+
int64_t mip_total_lp_iterations = solver.total_lp_iterations_;
40814077
info_.simplex_iteration_count = mip_total_lp_iterations > kHighsIInf
40824078
? -1
40834079
: HighsInt(mip_total_lp_iterations);
40844080
info_.valid = true;
40854081
if (model_status_ == HighsModelStatus::kOptimal)
40864082
return_status = checkOptimality("MIP");
40874083
// Overwrite max infeasibility to include integrality if there is a solution
4088-
if (mip_solver_info.solution_objective != kHighsInf) {
4089-
const double mip_max_bound_violation = std::max(
4090-
mip_solver_info.row_violation, mip_solver_info.bound_violation);
4084+
if (solver.solution_objective_ != kHighsInf) {
4085+
const double mip_max_bound_violation =
4086+
std::max(solver.row_violation_, solver.bound_violation_);
40914087
const double delta_max_bound_violation =
40924088
std::abs(mip_max_bound_violation - info_.max_primal_infeasibility);
40934089
// Possibly report a mis-match between the max bound violation
@@ -4099,7 +4095,7 @@ HighsStatus Highs::callSolveMip() {
40994095
"(%10.4g); Difference of %10.4g\n",
41004096
mip_max_bound_violation, info_.max_primal_infeasibility,
41014097
delta_max_bound_violation);
4102-
info_.max_integrality_violation = mip_solver_info.integrality_violation;
4098+
info_.max_integrality_violation = solver.integrality_violation_;
41034099
if (info_.max_integrality_violation > options_.mip_feasibility_tolerance) {
41044100
info_.primal_solution_status = kSolutionStatusInfeasible;
41054101
assert(model_status_ == HighsModelStatus::kInfeasible);
@@ -4809,22 +4805,3 @@ void Highs::getHighsFiles() {
48094805
this->options_.write_basis_file = this->files_.write_basis_file;
48104806
this->files_.clear();
48114807
}
4812-
4813-
HighsMipSolverInfo getMipSolverInfo(const HighsMipSolver& mip_solver) {
4814-
HighsMipSolverInfo mip_solver_info;
4815-
mip_solver_info.clear();
4816-
mip_solver_info.modelstatus = mip_solver.modelstatus_;
4817-
mip_solver_info.solution = mip_solver.solution_;
4818-
mip_solver_info.solution_objective = mip_solver.solution_objective_;
4819-
mip_solver_info.bound_violation = mip_solver.bound_violation_;
4820-
mip_solver_info.integrality_violation = mip_solver.integrality_violation_;
4821-
mip_solver_info.row_violation = mip_solver.row_violation_;
4822-
mip_solver_info.dual_bound = mip_solver.dual_bound_;
4823-
mip_solver_info.primal_bound = mip_solver.primal_bound_;
4824-
mip_solver_info.gap = mip_solver.gap_;
4825-
mip_solver_info.max_submip_level = mip_solver.max_submip_level;
4826-
mip_solver_info.node_count = mip_solver.node_count_;
4827-
mip_solver_info.total_lp_iterations = mip_solver.total_lp_iterations_;
4828-
mip_solver_info.primal_dual_integral = mip_solver.primal_dual_integral_;
4829-
return mip_solver_info;
4830-
}

highs/lp_data/HighsInterface.cpp

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4300,19 +4300,3 @@ void HighsLinearObjective::clear() {
43004300
this->rel_tolerance = 0.0;
43014301
this->priority = 0;
43024302
}
4303-
4304-
void HighsMipSolverInfo::clear() {
4305-
this->modelstatus = HighsModelStatus::kNotset;
4306-
this->solution.clear();
4307-
this->solution_objective = -kHighsInf;
4308-
this->bound_violation = -kHighsInf;
4309-
this->integrality_violation = -kHighsInf;
4310-
this->row_violation = -kHighsInf;
4311-
this->dual_bound = -kHighsInf;
4312-
this->primal_bound = -kHighsInf;
4313-
this->gap = -kHighsInf;
4314-
this->max_submip_level = -1;
4315-
this->node_count = -kHighsSize_tInf;
4316-
this->total_lp_iterations = -kHighsSize_tInf;
4317-
this->primal_dual_integral = -kHighsInf;
4318-
}

highs/mip/HighsMipSolver.cpp

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -794,51 +794,44 @@ void HighsMipSolver::cleanupSolve() {
794794
std::array<char, 128> gapString =
795795
getGapString(gap_, primal_bound_, options_mip_);
796796

797-
// Don't log to console if this is in a MIP race
798-
HighsOptions temp_options = *options_mip_;
799-
if (mipdata_->terminatorActive()) {
800-
temp_options.log_to_console = false;
801-
temp_options.setLogOptions();
802-
}
803-
804-
bool timeless_log = temp_options.timeless_log;
805-
highsLogUser(temp_options.log_options, HighsLogType::kInfo,
797+
bool timeless_log = options_mip_->timeless_log;
798+
highsLogUser(options_mip_->log_options, HighsLogType::kInfo,
806799
"\nSolving report\n");
807800
if (this->orig_model_->model_name_.length())
808-
highsLogUser(temp_options.log_options, HighsLogType::kInfo,
801+
highsLogUser(options_mip_->log_options, HighsLogType::kInfo,
809802
" Model %s\n",
810803
this->orig_model_->model_name_.c_str());
811-
highsLogUser(temp_options.log_options, HighsLogType::kInfo,
804+
highsLogUser(options_mip_->log_options, HighsLogType::kInfo,
812805
" Status %s\n"
813806
" Primal bound %.12g\n"
814807
" Dual bound %.12g\n"
815808
" Gap %s\n",
816809
utilModelStatusToString(modelstatus_).c_str(), primal_bound_,
817810
dual_bound_, gapString.data());
818811
if (!timeless_log)
819-
highsLogUser(temp_options.log_options, HighsLogType::kInfo,
812+
highsLogUser(options_mip_->log_options, HighsLogType::kInfo,
820813
" P-D integral %.12g\n",
821814
mipdata_->primal_dual_integral.value);
822-
highsLogUser(temp_options.log_options, HighsLogType::kInfo,
815+
highsLogUser(options_mip_->log_options, HighsLogType::kInfo,
823816
" Solution status %s\n", solutionstatus.c_str());
824817
if (solutionstatus != "-")
825-
highsLogUser(temp_options.log_options, HighsLogType::kInfo,
818+
highsLogUser(options_mip_->log_options, HighsLogType::kInfo,
826819
" %.12g (objective)\n"
827820
" %.12g (bound viol.)\n"
828821
" %.12g (int. viol.)\n"
829822
" %.12g (row viol.)\n",
830823
solution_objective_, bound_violation_, integrality_violation_,
831824
row_violation_);
832825
if (!timeless_log)
833-
highsLogUser(temp_options.log_options, HighsLogType::kInfo,
826+
highsLogUser(options_mip_->log_options, HighsLogType::kInfo,
834827
" Timing %.2f (total)\n"
835828
" %.2f (presolve)\n"
836829
" %.2f (solve)\n"
837830
" %.2f (postsolve)\n",
838831
timer_.read(), analysis_.mipTimerRead(kMipClockPresolve),
839832
analysis_.mipTimerRead(kMipClockSolve),
840833
analysis_.mipTimerRead(kMipClockPostsolve));
841-
highsLogUser(temp_options.log_options, HighsLogType::kInfo,
834+
highsLogUser(options_mip_->log_options, HighsLogType::kInfo,
842835
" Max sub-MIP depth %d\n"
843836
" Nodes %llu\n"
844837
" Repair LPs %llu (%llu feasible; %llu iterations)\n"

highs/mip/HighsMipSolver.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
#ifndef MIP_HIGHS_MIP_SOLVER_H_
99
#define MIP_HIGHS_MIP_SOLVER_H_
1010

11-
#include <atomic>
12-
1311
#include "Highs.h"
1412
#include "lp_data/HighsCallback.h"
1513
#include "lp_data/HighsOptions.h"

highs/mip/HighsMipSolverData.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -301,12 +301,6 @@ struct HighsMipSolverData {
301301
const double mipsolver_objective_value,
302302
const ExternalMipSolutionQueryOrigin external_solution_query_origin);
303303

304-
HighsInt mipRaceConcurrency() const;
305-
void mipRaceUpdate();
306-
HighsInt mipRaceNewSolution(const HighsInt instance, double& objective_value,
307-
std::vector<double>& solution);
308-
void mipRaceReport() const;
309-
310304
HighsInt terminatorConcurrency() const;
311305
bool terminatorActive() const { return terminatorConcurrency() > 0; }
312306
HighsInt terminatorMyInstance() const;

0 commit comments

Comments
 (0)