Skip to content

Commit

Permalink
ctest passes; formatted
Browse files Browse the repository at this point in the history
  • Loading branch information
jajhall committed Oct 29, 2024
1 parent 4285c86 commit 1cea261
Show file tree
Hide file tree
Showing 8 changed files with 247 additions and 169 deletions.
10 changes: 6 additions & 4 deletions src/interfaces/highs_c_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -529,11 +529,13 @@ HighsInt Highs_getDualRay(const void* highs, HighsInt* has_dual_ray,
return retcode;
}

HighsInt Highs_getDualUnboundednessDirection(const void* highs,
HighsInt* has_dual_unboundedness_direction,
double* dual_unboundedness_direction_value) {
HighsInt Highs_getDualUnboundednessDirection(
const void* highs, HighsInt* has_dual_unboundedness_direction,
double* dual_unboundedness_direction_value) {
bool v;
HighsInt retcode = (HighsInt)((Highs*)highs)->getDualUnboundednessDirection(v, dual_unboundedness_direction_value);
HighsInt retcode = (HighsInt)((Highs*)highs)
->getDualUnboundednessDirection(
v, dual_unboundedness_direction_value);
*has_dual_unboundedness_direction = (HighsInt)v;
return retcode;
}
Expand Down
6 changes: 3 additions & 3 deletions src/interfaces/highs_c_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -945,9 +945,9 @@ HighsInt Highs_getDualRay(const void* highs, HighsInt* has_dual_ray,
* filled with the unboundedness
* direction.
*/
HighsInt getDualUnboundednessDirection(const void* highs,
HighsInt* has_dual_unboundedness_direction,
double* dual_unboundedness_direction_value);
HighsInt getDualUnboundednessDirection(
const void* highs, HighsInt* has_dual_unboundedness_direction,
double* dual_unboundedness_direction_value);

/**
* Indicates whether a primal ray that is a certificate of primal
Expand Down
6 changes: 3 additions & 3 deletions src/lp_data/HighsInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -275,9 +275,9 @@ class HighsInfo : public HighsInfoStruct {
advanced, &sum_complementarity_violations, 0);
records.push_back(record_double);

record_double = new InfoRecordDouble(
"primal_dual_integral", "Primal-dual integral",
advanced, &primal_dual_integral, 0);
record_double =
new InfoRecordDouble("primal_dual_integral", "Primal-dual integral",
advanced, &primal_dual_integral, 0);
records.push_back(record_double);
}

Expand Down
85 changes: 50 additions & 35 deletions src/mip/HighsMipSolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,12 +135,14 @@ void HighsMipSolver::run() {
mipdata_->transformNewIntegerFeasibleSolution(std::vector<double>());
mipdata_->saveReportMipSolution();
}
printf("HighsMipSolver::run() P-D integral value %g; LB %g; UB %g; gap %g; offset %g\n",
mipdata_->primal_dual_integral.value,
mipdata_->primal_dual_integral.prev_lb,
mipdata_->primal_dual_integral.prev_ub,
mipdata_->primal_dual_integral.prev_gap,
mipdata_->primal_dual_integral.prev_offset);
printf(
"HighsMipSolver::run() P-D integral value %g; LB %g; UB %g; gap %g; "
"offset %g\n",
mipdata_->primal_dual_integral.value,
mipdata_->primal_dual_integral.prev_lb,
mipdata_->primal_dual_integral.prev_ub,
mipdata_->primal_dual_integral.prev_gap,
mipdata_->primal_dual_integral.prev_offset);
cleanupSolve();
return;
}
Expand Down Expand Up @@ -198,8 +200,10 @@ void HighsMipSolver::run() {
mipdata_->lower_bound = mipdata_->nodequeue.getBestLowerBound();

bool bound_change = mipdata_->lower_bound != prev_lower_bound;
if (!submip && bound_change) mipdata_->updatePrimaDualIntegral(prev_lower_bound, mipdata_->lower_bound,
mipdata_->upper_bound, mipdata_->upper_bound);
if (!submip && bound_change)
mipdata_->updatePrimaDualIntegral(prev_lower_bound, mipdata_->lower_bound,
mipdata_->upper_bound,
mipdata_->upper_bound);

mipdata_->printDisplayLine();
search.installNode(mipdata_->nodequeue.popBestBoundNode());
Expand Down Expand Up @@ -289,13 +293,15 @@ void HighsMipSolver::run() {

if (limit_reached) {
double prev_lower_bound = mipdata_->lower_bound;

mipdata_->lower_bound = std::min(mipdata_->upper_bound,
mipdata_->nodequeue.getBestLowerBound());

bool bound_change = mipdata_->lower_bound != prev_lower_bound;
if (!submip && bound_change) mipdata_->updatePrimaDualIntegral(prev_lower_bound, mipdata_->lower_bound,
mipdata_->upper_bound, mipdata_->upper_bound);
if (!submip && bound_change)
mipdata_->updatePrimaDualIntegral(
prev_lower_bound, mipdata_->lower_bound, mipdata_->upper_bound,
mipdata_->upper_bound);
mipdata_->printDisplayLine();
break;
}
Expand All @@ -314,23 +320,27 @@ void HighsMipSolver::run() {
mipdata_->pruned_treeweight = 1.0;

double prev_lower_bound = mipdata_->lower_bound;

mipdata_->lower_bound = std::min(kHighsInf, mipdata_->upper_bound);

bool bound_change = mipdata_->lower_bound != prev_lower_bound;
if (!submip && bound_change) mipdata_->updatePrimaDualIntegral(prev_lower_bound, mipdata_->lower_bound,
mipdata_->upper_bound, mipdata_->upper_bound);
if (!submip && bound_change)
mipdata_->updatePrimaDualIntegral(
prev_lower_bound, mipdata_->lower_bound, mipdata_->upper_bound,
mipdata_->upper_bound);
mipdata_->printDisplayLine();
break;
}

double prev_lower_bound = mipdata_->lower_bound;

mipdata_->lower_bound = std::min(mipdata_->upper_bound,
mipdata_->nodequeue.getBestLowerBound());
bool bound_change = mipdata_->lower_bound != prev_lower_bound;
if (!submip && bound_change) mipdata_->updatePrimaDualIntegral(prev_lower_bound, mipdata_->lower_bound,
mipdata_->upper_bound, mipdata_->upper_bound);
if (!submip && bound_change)
mipdata_->updatePrimaDualIntegral(prev_lower_bound, mipdata_->lower_bound,
mipdata_->upper_bound,
mipdata_->upper_bound);
mipdata_->printDisplayLine();
if (mipdata_->nodequeue.empty()) break;

Expand Down Expand Up @@ -487,13 +497,15 @@ void HighsMipSolver::run() {
mipdata_->nodequeue.clear();
mipdata_->pruned_treeweight = 1.0;

double prev_lower_bound = mipdata_->lower_bound;
double prev_lower_bound = mipdata_->lower_bound;

mipdata_->lower_bound = std::min(kHighsInf, mipdata_->upper_bound);

bool bound_change = mipdata_->lower_bound != prev_lower_bound;
if (!submip && bound_change) mipdata_->updatePrimaDualIntegral(prev_lower_bound, mipdata_->lower_bound,
mipdata_->upper_bound, mipdata_->upper_bound);
bool bound_change = mipdata_->lower_bound != prev_lower_bound;
if (!submip && bound_change)
mipdata_->updatePrimaDualIntegral(
prev_lower_bound, mipdata_->lower_bound, mipdata_->upper_bound,
mipdata_->upper_bound);
break;
}

Expand All @@ -502,14 +514,16 @@ void HighsMipSolver::run() {
break;
}

double prev_lower_bound = mipdata_->lower_bound;
double prev_lower_bound = mipdata_->lower_bound;

mipdata_->lower_bound = std::min(
mipdata_->lower_bound = std::min(
mipdata_->upper_bound, mipdata_->nodequeue.getBestLowerBound());

bool bound_change = mipdata_->lower_bound != prev_lower_bound;
if (!submip && bound_change) mipdata_->updatePrimaDualIntegral(prev_lower_bound, mipdata_->lower_bound,
mipdata_->upper_bound, mipdata_->upper_bound);
bool bound_change = mipdata_->lower_bound != prev_lower_bound;
if (!submip && bound_change)
mipdata_->updatePrimaDualIntegral(
prev_lower_bound, mipdata_->lower_bound, mipdata_->upper_bound,
mipdata_->upper_bound);
mipdata_->printDisplayLine();

if (!mipdata_->domain.getChangedCols().empty()) {
Expand Down Expand Up @@ -540,13 +554,15 @@ void HighsMipSolver::run() {
mipdata_->nodequeue.clear();
mipdata_->pruned_treeweight = 1.0;

double prev_lower_bound = mipdata_->lower_bound;
double prev_lower_bound = mipdata_->lower_bound;

mipdata_->lower_bound = std::min(kHighsInf, mipdata_->upper_bound);

bool bound_change = mipdata_->lower_bound != prev_lower_bound;
if (!submip && bound_change) mipdata_->updatePrimaDualIntegral(prev_lower_bound, mipdata_->lower_bound,
mipdata_->upper_bound, mipdata_->upper_bound);
bool bound_change = mipdata_->lower_bound != prev_lower_bound;
if (!submip && bound_change)
mipdata_->updatePrimaDualIntegral(
prev_lower_bound, mipdata_->lower_bound, mipdata_->upper_bound,
mipdata_->upper_bound);
break;
}

Expand Down Expand Up @@ -577,9 +593,9 @@ void HighsMipSolver::cleanupSolve() {
mipdata_->printDisplayLine('Z');
// Need to complete the calculation of P-D integral, checking for NO
// gap change
mipdata_->updatePrimaDualIntegral(mipdata_->lower_bound, mipdata_->lower_bound,
mipdata_->upper_bound, mipdata_->upper_bound,
false);
mipdata_->updatePrimaDualIntegral(
mipdata_->lower_bound, mipdata_->lower_bound, mipdata_->upper_bound,
mipdata_->upper_bound, false);
timer_.start(timer_.postsolve_clock);
bool havesolution = solution_objective_ != kHighsInf;
bool feasible;
Expand Down Expand Up @@ -686,8 +702,7 @@ void HighsMipSolver::cleanupSolve() {
" Solution status %s\n",
utilModelStatusToString(modelstatus_).c_str(), primal_bound_,
dual_bound_, gapString.data(),
mipdata_->primal_dual_integral.value,
solutionstatus.c_str());
mipdata_->primal_dual_integral.value, solutionstatus.c_str());
if (solutionstatus != "-")
highsLogUser(options_mip_->log_options, HighsLogType::kInfo,
" %.12g (objective)\n"
Expand Down
2 changes: 1 addition & 1 deletion src/mip/HighsMipSolver.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class HighsMipSolver {
int64_t node_count_;
int64_t total_lp_iterations_;
double primal_dual_integral_;

FILE* improving_solution_file_;
std::vector<HighsObjectiveSolution> saved_objective_and_solution_;

Expand Down
Loading

0 comments on commit 1cea261

Please sign in to comment.