Skip to content

Commit 0c454cb

Browse files
committed
Make kSubSolverSimplex(No)Basis, kSubSolverDualSimplex(No)Basis
1 parent a20d07e commit 0c454cb

File tree

1 file changed

+27
-12
lines changed

1 file changed

+27
-12
lines changed

highs/simplex/HApp.h

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -43,16 +43,18 @@ inline HighsStatus returnFromSolveLpSimplex(HighsLpSolverObject& solver_object,
4343
// Identify which clock to stop. Can't inspect the basis, as there
4444
// will generally be one after simplex, so have to deduce whether
4545
// there was one before
46-
const HighsInt sub_solver_ix =
47-
solver_object.sub_solver_call_time_.run_time[kSubSolverSimplexBasis] < 0
48-
? kSubSolverSimplexBasis
49-
: kSubSolverSimplexNoBasis;
50-
const HighsInt sub_solver_not_ix = sub_solver_ix == kSubSolverSimplexBasis
51-
? kSubSolverSimplexNoBasis
52-
: kSubSolverSimplexBasis;
53-
assert(solver_object.sub_solver_call_time_.run_time[sub_solver_not_ix] >= 0);
54-
(void)sub_solver_not_ix;
55-
assert(solver_object.sub_solver_call_time_.run_time[sub_solver_ix] < 0);
46+
HighsInt sub_solver_ix = -1;
47+
if (solver_object.sub_solver_call_time_.run_time[kSubSolverSimplexBasis] < 0) sub_solver_ix = kSubSolverSimplexBasis;
48+
if (solver_object.sub_solver_call_time_.run_time[kSubSolverSimplexNoBasis] < 0) sub_solver_ix = kSubSolverSimplexNoBasis;
49+
if (solver_object.sub_solver_call_time_.run_time[kSubSolverPrimalSimplexBasis] < 0) sub_solver_ix = kSubSolverPrimalSimplexBasis;
50+
if (solver_object.sub_solver_call_time_.run_time[kSubSolverPrimalSimplexNoBasis] < 0) sub_solver_ix = kSubSolverPrimalSimplexNoBasis;
51+
// Ensure that one clock has been identified
52+
assert(sub_solver_ix >= 0);
53+
// Check that only one clock was started
54+
if (sub_solver_ix != kSubSolverSimplexBasis) assert(solver_object.sub_solver_call_time_.run_time[kSubSolverSimplexBasis] >= 0);
55+
if (sub_solver_ix != kSubSolverSimplexNoBasis) assert(solver_object.sub_solver_call_time_.run_time[kSubSolverSimplexNoBasis] >= 0);
56+
if (sub_solver_ix != kSubSolverPrimalSimplexBasis) assert(solver_object.sub_solver_call_time_.run_time[kSubSolverPrimalSimplexBasis] >= 0);
57+
if (sub_solver_ix != kSubSolverPrimalSimplexNoBasis) assert(solver_object.sub_solver_call_time_.run_time[kSubSolverPrimalSimplexNoBasis] >= 0);
5658
// Update the call count and run time
5759
solver_object.sub_solver_call_time_.num_call[sub_solver_ix]++;
5860
solver_object.sub_solver_call_time_.run_time[sub_solver_ix] +=
@@ -117,8 +119,21 @@ inline HighsStatus solveLpSimplex(HighsLpSolverObject& solver_object) {
117119
assert(retained_ekk_data_ok);
118120
return_status = HighsStatus::kError;
119121
}
120-
const HighsInt sub_solver_ix =
121-
basis.valid ? kSubSolverSimplexBasis : kSubSolverSimplexNoBasis;
122+
HighsInt sub_solver_ix = -1;
123+
if (options.simplex_strategy == kSimplexStrategyPrimal) {
124+
if (basis.valid) {
125+
sub_solver_ix = kSubSolverPrimalSimplexBasis;
126+
} else {
127+
sub_solver_ix = kSubSolverPrimalSimplexNoBasis;
128+
}
129+
} else {
130+
if (basis.valid) {
131+
sub_solver_ix = kSubSolverSimplexBasis;
132+
} else {
133+
sub_solver_ix = kSubSolverSimplexNoBasis;
134+
}
135+
}
136+
assert(sub_solver_ix >= 0);
122137
assert(solver_object.sub_solver_call_time_.run_time.size() > 0);
123138
solver_object.sub_solver_call_time_.run_time[sub_solver_ix] =
124139
-solver_object.timer_.read();

0 commit comments

Comments
 (0)