Skip to content

Commit

Permalink
Given a basis, now performing presolve unless solver is simplex or ch…
Browse files Browse the repository at this point in the history
…oose
  • Loading branch information
jajhall committed Jan 5, 2025
1 parent 8ba0572 commit c16e22d
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 28 deletions.
13 changes: 4 additions & 9 deletions check/TestIpm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,21 +140,16 @@ TEST_CASE("test-2087", "[highs_ipm]") {
// since optimal basis cannot be used, and ensure that the offset is
// used in IPX
Highs h;
// h.setOptionValue("output_flag", dev_run);
h.setOptionValue("output_flag", dev_run);
// Use shell since it yields an offset after presolve
std::string model = "shell.mps";
std::string filename = std::string(HIGHS_DIR) + "/check/instances/" + model;
h.readModel(filename);

h.setOptionValue("solver", kIpmString);
// if (dev_run)
printf("\nFirst call to Highs::run() with presolve:\n");
h.run();

// if (dev_run)
printf("\nSecond call to Highs::run() with presolve:\n");
h.run();


const HighsInt first_ipm_iteration_count = h.getInfo().ipm_iteration_count;

h.run();
REQUIRE(first_ipm_iteration_count == h.getInfo().ipm_iteration_count);
}
4 changes: 2 additions & 2 deletions check/TestIpx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ TEST_CASE("test-ipx", "[highs_ipx]") {
lps.SetParameters(parameters);

// Solve the LP.
Int load_status = lps.LoadModel(num_var, offset, obj, lb, ub, num_constr, Ap, Ai, Ax,
rhs, constr_type);
Int load_status = lps.LoadModel(num_var, offset, obj, lb, ub, num_constr, Ap,
Ai, Ax, rhs, constr_type);
REQUIRE(load_status == 0);

highs::parallel::initialize_scheduler();
Expand Down
13 changes: 6 additions & 7 deletions src/ipm/IpxWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,8 @@ HighsStatus solveLpIpx(const HighsOptions& options, HighsTimer& timer,
std::vector<ipx::Int> Ap, Ai;
std::vector<double> objective, col_lb, col_ub, Av, rhs;
std::vector<char> constraint_type;
fillInIpxData(lp, num_col, num_row, offset, objective, col_lb, col_ub, Ap, Ai, Av,
rhs, constraint_type);
fillInIpxData(lp, num_col, num_row, offset, objective, col_lb, col_ub, Ap, Ai,
Av, rhs, constraint_type);
highsLogUser(options.log_options, HighsLogType::kInfo,
"IPX model has %" HIGHSINT_FORMAT " rows, %" HIGHSINT_FORMAT
" columns and %" HIGHSINT_FORMAT " nonzeros\n",
Expand Down Expand Up @@ -388,11 +388,10 @@ HighsStatus solveLpIpx(const HighsOptions& options, HighsTimer& timer,
}

void fillInIpxData(const HighsLp& lp, ipx::Int& num_col, ipx::Int& num_row,
double& offset,
std::vector<double>& obj, std::vector<double>& col_lb,
std::vector<double>& col_ub, std::vector<ipx::Int>& Ap,
std::vector<ipx::Int>& Ai, std::vector<double>& Ax,
std::vector<double>& rhs,
double& offset, std::vector<double>& obj,
std::vector<double>& col_lb, std::vector<double>& col_ub,
std::vector<ipx::Int>& Ap, std::vector<ipx::Int>& Ai,
std::vector<double>& Ax, std::vector<double>& rhs,
std::vector<char>& constraint_type) {
num_col = lp.num_col_;
num_row = lp.num_row_;
Expand Down
9 changes: 4 additions & 5 deletions src/ipm/IpxWrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,10 @@ HighsStatus solveLpIpx(const HighsOptions& options, HighsTimer& timer,
HighsCallback& callback);

void fillInIpxData(const HighsLp& lp, ipx::Int& num_col, ipx::Int& num_row,
double& offset,
std::vector<double>& obj, std::vector<double>& col_lb,
std::vector<double>& col_ub, std::vector<ipx::Int>& Ap,
std::vector<ipx::Int>& Ai, std::vector<double>& Ax,
std::vector<double>& rhs,
double& offset, std::vector<double>& obj,
std::vector<double>& col_lb, std::vector<double>& col_ub,
std::vector<ipx::Int>& Ap, std::vector<ipx::Int>& Ai,
std::vector<double>& Ax, std::vector<double>& rhs,
std::vector<char>& constraint_type);

HighsStatus reportIpxSolveStatus(const HighsOptions& options,
Expand Down
12 changes: 9 additions & 3 deletions src/lp_data/Highs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1260,10 +1260,16 @@ HighsStatus Highs::solve() {

const bool unconstrained_lp = incumbent_lp.a_matrix_.numNz() == 0;
assert(incumbent_lp.num_row_ || unconstrained_lp);
if (basis_.valid || options_.presolve == kHighsOffString ||
unconstrained_lp) {
// Even if options_.solver == kHighsChooseString in isolation will,
// untimately lead to a choice between simplex and IPM, if a basis
// is available, simplex should surely be chosen.
const bool solver_will_use_basis = options_.solver == kSimplexString ||
options_.solver == kHighsChooseString;
if ((basis_.valid || options_.presolve == kHighsOffString ||
unconstrained_lp) &&
solver_will_use_basis) {
// There is a valid basis for the problem, presolve is off, or LP
// has no constraint matrix
// has no constraint matrix, and the solver will use the basis
ekk_instance_.lp_name_ =
"LP without presolve, or with basis, or unconstrained";
// If there is a valid HiGHS basis, refine any status values that
Expand Down
4 changes: 2 additions & 2 deletions src/presolve/ICrashX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ HighsStatus callCrossover(const HighsOptions& options, const HighsLp& lp,
std::vector<double> objective, col_lb, col_ub, Av, rhs;
std::vector<char> constraint_type;

fillInIpxData(lp, num_col, num_row, offset, objective, col_lb, col_ub, Ap, Ai, Av,
rhs, constraint_type);
fillInIpxData(lp, num_col, num_row, offset, objective, col_lb, col_ub, Ap, Ai,
Av, rhs, constraint_type);
// if (res != IpxStatus::OK) return HighsStatus::kError;

const HighsLogOptions& log_options = options.log_options;
Expand Down

0 comments on commit c16e22d

Please sign in to comment.