Skip to content

Commit c16e22d

Browse files
committed
Given a basis, now performing presolve unless solver is simplex or choose
1 parent 8ba0572 commit c16e22d

File tree

6 files changed

+27
-28
lines changed

6 files changed

+27
-28
lines changed

check/TestIpm.cpp

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -140,21 +140,16 @@ TEST_CASE("test-2087", "[highs_ipm]") {
140140
// since optimal basis cannot be used, and ensure that the offset is
141141
// used in IPX
142142
Highs h;
143-
// h.setOptionValue("output_flag", dev_run);
143+
h.setOptionValue("output_flag", dev_run);
144144
// Use shell since it yields an offset after presolve
145145
std::string model = "shell.mps";
146146
std::string filename = std::string(HIGHS_DIR) + "/check/instances/" + model;
147147
h.readModel(filename);
148148

149149
h.setOptionValue("solver", kIpmString);
150-
// if (dev_run)
151-
printf("\nFirst call to Highs::run() with presolve:\n");
152150
h.run();
153-
154-
// if (dev_run)
155-
printf("\nSecond call to Highs::run() with presolve:\n");
156-
h.run();
157-
158-
151+
const HighsInt first_ipm_iteration_count = h.getInfo().ipm_iteration_count;
159152

153+
h.run();
154+
REQUIRE(first_ipm_iteration_count == h.getInfo().ipm_iteration_count);
160155
}

check/TestIpx.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ TEST_CASE("test-ipx", "[highs_ipx]") {
4848
lps.SetParameters(parameters);
4949

5050
// Solve the LP.
51-
Int load_status = lps.LoadModel(num_var, offset, obj, lb, ub, num_constr, Ap, Ai, Ax,
52-
rhs, constr_type);
51+
Int load_status = lps.LoadModel(num_var, offset, obj, lb, ub, num_constr, Ap,
52+
Ai, Ax, rhs, constr_type);
5353
REQUIRE(load_status == 0);
5454

5555
highs::parallel::initialize_scheduler();

src/ipm/IpxWrapper.cpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,8 @@ HighsStatus solveLpIpx(const HighsOptions& options, HighsTimer& timer,
154154
std::vector<ipx::Int> Ap, Ai;
155155
std::vector<double> objective, col_lb, col_ub, Av, rhs;
156156
std::vector<char> constraint_type;
157-
fillInIpxData(lp, num_col, num_row, offset, objective, col_lb, col_ub, Ap, Ai, Av,
158-
rhs, constraint_type);
157+
fillInIpxData(lp, num_col, num_row, offset, objective, col_lb, col_ub, Ap, Ai,
158+
Av, rhs, constraint_type);
159159
highsLogUser(options.log_options, HighsLogType::kInfo,
160160
"IPX model has %" HIGHSINT_FORMAT " rows, %" HIGHSINT_FORMAT
161161
" columns and %" HIGHSINT_FORMAT " nonzeros\n",
@@ -388,11 +388,10 @@ HighsStatus solveLpIpx(const HighsOptions& options, HighsTimer& timer,
388388
}
389389

390390
void fillInIpxData(const HighsLp& lp, ipx::Int& num_col, ipx::Int& num_row,
391-
double& offset,
392-
std::vector<double>& obj, std::vector<double>& col_lb,
393-
std::vector<double>& col_ub, std::vector<ipx::Int>& Ap,
394-
std::vector<ipx::Int>& Ai, std::vector<double>& Ax,
395-
std::vector<double>& rhs,
391+
double& offset, std::vector<double>& obj,
392+
std::vector<double>& col_lb, std::vector<double>& col_ub,
393+
std::vector<ipx::Int>& Ap, std::vector<ipx::Int>& Ai,
394+
std::vector<double>& Ax, std::vector<double>& rhs,
396395
std::vector<char>& constraint_type) {
397396
num_col = lp.num_col_;
398397
num_row = lp.num_row_;

src/ipm/IpxWrapper.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,10 @@ HighsStatus solveLpIpx(const HighsOptions& options, HighsTimer& timer,
2828
HighsCallback& callback);
2929

3030
void fillInIpxData(const HighsLp& lp, ipx::Int& num_col, ipx::Int& num_row,
31-
double& offset,
32-
std::vector<double>& obj, std::vector<double>& col_lb,
33-
std::vector<double>& col_ub, std::vector<ipx::Int>& Ap,
34-
std::vector<ipx::Int>& Ai, std::vector<double>& Ax,
35-
std::vector<double>& rhs,
31+
double& offset, std::vector<double>& obj,
32+
std::vector<double>& col_lb, std::vector<double>& col_ub,
33+
std::vector<ipx::Int>& Ap, std::vector<ipx::Int>& Ai,
34+
std::vector<double>& Ax, std::vector<double>& rhs,
3635
std::vector<char>& constraint_type);
3736

3837
HighsStatus reportIpxSolveStatus(const HighsOptions& options,

src/lp_data/Highs.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1260,10 +1260,16 @@ HighsStatus Highs::solve() {
12601260

12611261
const bool unconstrained_lp = incumbent_lp.a_matrix_.numNz() == 0;
12621262
assert(incumbent_lp.num_row_ || unconstrained_lp);
1263-
if (basis_.valid || options_.presolve == kHighsOffString ||
1264-
unconstrained_lp) {
1263+
// Even if options_.solver == kHighsChooseString in isolation will,
1264+
// untimately lead to a choice between simplex and IPM, if a basis
1265+
// is available, simplex should surely be chosen.
1266+
const bool solver_will_use_basis = options_.solver == kSimplexString ||
1267+
options_.solver == kHighsChooseString;
1268+
if ((basis_.valid || options_.presolve == kHighsOffString ||
1269+
unconstrained_lp) &&
1270+
solver_will_use_basis) {
12651271
// There is a valid basis for the problem, presolve is off, or LP
1266-
// has no constraint matrix
1272+
// has no constraint matrix, and the solver will use the basis
12671273
ekk_instance_.lp_name_ =
12681274
"LP without presolve, or with basis, or unconstrained";
12691275
// If there is a valid HiGHS basis, refine any status values that

src/presolve/ICrashX.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ HighsStatus callCrossover(const HighsOptions& options, const HighsLp& lp,
2525
std::vector<double> objective, col_lb, col_ub, Av, rhs;
2626
std::vector<char> constraint_type;
2727

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

3232
const HighsLogOptions& log_options = options.log_options;

0 commit comments

Comments
 (0)