Skip to content

Commit d228989

Browse files
committed
All temporary files are unique to the unit test
1 parent 4922c29 commit d228989

File tree

10 files changed

+41
-26
lines changed

10 files changed

+41
-26
lines changed

check/TestBasis.cpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@
77
const bool dev_run = false;
88
HighsBasis basis_data;
99

10-
void testBasisReloadModel(Highs& highs, const std::string& basis_file, const bool from_file);
11-
void testBasisRestart(Highs& highs, const std::string& basis_file, const bool from_file);
10+
void testBasisReloadModel(Highs& highs, const std::string& basis_file,
11+
const bool from_file);
12+
void testBasisRestart(Highs& highs, const std::string& basis_file,
13+
const bool from_file);
1214

1315
// No commas in test case name.
1416
TEST_CASE("Basis-file", "[highs_basis_file]") {
@@ -22,7 +24,6 @@ TEST_CASE("Basis-file", "[highs_basis_file]") {
2224
std::string model1_file =
2325
std::string(HIGHS_DIR) + "/check/instances/avgas.mps";
2426

25-
2627
Highs highs;
2728
if (!dev_run) {
2829
highs.setOptionValue("output_flag", false);
@@ -184,7 +185,8 @@ TEST_CASE("Basis-singular", "[highs_basis_data]") {
184185
}
185186

186187
// No commas in test case name.
187-
void testBasisReloadModel(Highs& highs, const std::string& basis_file, const bool from_file) {
188+
void testBasisReloadModel(Highs& highs, const std::string& basis_file,
189+
const bool from_file) {
188190
// Checks that no simplex iterations are required if a saved optimal
189191
// basis is used for the original LP after solving a different LP
190192
HighsStatus return_status;
@@ -232,7 +234,8 @@ void testBasisReloadModel(Highs& highs, const std::string& basis_file, const boo
232234
REQUIRE(highs.getInfo().simplex_iteration_count == 0);
233235
}
234236

235-
void testBasisRestart(Highs& highs, const std::string& basis_file, const bool from_file) {
237+
void testBasisRestart(Highs& highs, const std::string& basis_file,
238+
const bool from_file) {
236239
// Checks that no simplex iterations are required if a saved optimal
237240
// basis is used for the original LP after changing a bound, solving
238241
// - so that the internal basis changes - and then restoring the

check/TestCheckSolution.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88

99
const bool dev_run = false;
1010

11-
void runWriteReadCheckSolution(Highs& highs, const std::string& test_name, const std::string& model,
11+
void runWriteReadCheckSolution(Highs& highs, const std::string& test_name,
12+
const std::string& model,
1213
const HighsModelStatus require_model_status,
1314
const HighsInt write_solution_style);
1415

@@ -449,7 +450,7 @@ TEST_CASE("read-miplib-solution", "[highs_check_solution]") {
449450
}
450451

451452
void runWriteReadCheckSolution(Highs& highs, const std::string& test_name,
452-
const std::string& model,
453+
const std::string& model,
453454
const HighsModelStatus require_model_status,
454455
const HighsInt write_solution_style) {
455456
HighsStatus run_status;

check/TestLpSolvers.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -406,10 +406,11 @@ bool fileExists(const std::string& file_name) {
406406
}
407407

408408
TEST_CASE("highs-files-lp", "[highs_lp_solver]") {
409+
const std::string test_name = Catch::getResultCapture().getCurrentTestName();
410+
const std::string write_solution_file = test_name + ".sol";
411+
const std::string write_basis_file = test_name + ".bas";
412+
const std::string write_model_file = test_name + ".mps";
409413
Highs h;
410-
std::string write_solution_file = "lp-temp.sol";
411-
std::string write_basis_file = "lp-temp.bas";
412-
std::string write_model_file = "lp-temp.mps";
413414
h.setOptionValue("output_flag", dev_run);
414415
std::string model_file =
415416
std::string(HIGHS_DIR) + "/check/instances/avgas.mps";
@@ -443,10 +444,11 @@ TEST_CASE("highs-files-lp", "[highs_lp_solver]") {
443444
}
444445

445446
TEST_CASE("highs-files-mip", "[highs_lp_solver]") {
447+
const std::string test_name = Catch::getResultCapture().getCurrentTestName();
448+
const std::string write_solution_file = test_name + ".sol";
449+
const std::string write_basis_file = test_name + ".bas";
450+
const std::string write_model_file = test_name + ".mps";
446451
Highs h;
447-
std::string write_solution_file = "mip-temp.sol";
448-
std::string write_basis_file = "mip-temp.bas";
449-
std::string write_model_file = "mip-temp.mps";
450452
h.setOptionValue("output_flag", dev_run);
451453
std::string model_file =
452454
std::string(HIGHS_DIR) + "/check/instances/flugpl.mps";

check/TestMipSolver.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -509,6 +509,8 @@ TEST_CASE("MIP-infeasible-start", "[highs_test_mip_solver]") {
509509
TEST_CASE("get-integrality", "[highs_test_mip_solver]") {}
510510

511511
TEST_CASE("MIP-bounds", "[highs_test_mip_solver]") {
512+
const std::string test_name = Catch::getResultCapture().getCurrentTestName();
513+
const std::string test_mps = test_name + ".mps";
512514
// Introduced due to #1325 observing that LI and UI are needed
513515
HighsLp lp;
514516
lp.num_col_ = 6;
@@ -536,7 +538,6 @@ TEST_CASE("MIP-bounds", "[highs_test_mip_solver]") {
536538
const double obj0 = highs.getObjectiveValue();
537539
if (dev_run) printf("Optimum at first run: %g\n", obj0);
538540
// now write out to MPS and load again
539-
const std::string test_mps = "test.mps";
540541
highs.writeModel(test_mps);
541542
highs.readModel(test_mps);
542543
highs.run();
@@ -549,8 +550,9 @@ TEST_CASE("MIP-bounds", "[highs_test_mip_solver]") {
549550
}
550551

551552
TEST_CASE("MIP-get-saved-solutions", "[highs_test_mip_solver]") {
553+
const std::string test_name = Catch::getResultCapture().getCurrentTestName();
554+
const std::string solution_file = test_name + ".sol";
552555
const std::string model = "flugpl";
553-
const std::string solution_file = "MipImproving.sol";
554556
const std::string model_file =
555557
std::string(HIGHS_DIR) + "/check/instances/" + model + ".mps";
556558
Highs highs;
@@ -617,7 +619,8 @@ TEST_CASE("MIP-max-offset-test", "[highs_test_mip_solver]") {
617619
}
618620

619621
TEST_CASE("MIP-get-saved-solutions-presolve", "[highs_test_mip_solver]") {
620-
const std::string solution_file = "MipImproving.sol";
622+
const std::string test_name = Catch::getResultCapture().getCurrentTestName();
623+
const std::string solution_file = test_name + ".sol";
621624
Highs highs;
622625
highs.setOptionValue("output_flag", dev_run);
623626
highs.setOptionValue("mip_improving_solution_save", true);
@@ -835,14 +838,13 @@ TEST_CASE("issue-2204", "[highs_test_mip_solver]") {
835838
}
836839

837840
TEST_CASE("ZI Round and Shifting Heuristics", "[highs_test_mip_solver]") {
838-
std::string model_file =
839-
std::string(HIGHS_DIR) + "/check/instances/rgn.mps";
841+
std::string model_file = std::string(HIGHS_DIR) + "/check/instances/rgn.mps";
840842

841843
Highs highs;
842844
highs.setOptionValue("output_flag", dev_run);
843845
// Enable both heuristics
844846
highs.setOptionValue("mip_heuristic_run_zi_round", true);
845-
highs.setOptionValue("mip_heuristic_run_shifting", true);
847+
highs.setOptionValue("mip_heuristic_run_shifting", true);
846848
highs.readModel(model_file);
847849
const HighsModelStatus require_model_status = HighsModelStatus::kOptimal;
848850
const double optimal_objective = 82.19999924;

check/TestNames.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
const bool dev_run = false;
88
TEST_CASE("highs-names", "[highs_names]") {
9+
const std::string test_name = Catch::getResultCapture().getCurrentTestName();
10+
const std::string solution_file = test_name + ".sol";
911
std::string name;
1012
const std::string model = "avgas";
1113
const std::string model_file =
@@ -109,7 +111,6 @@ TEST_CASE("highs-names", "[highs_names]") {
109111
local_lp.col_names_.clear();
110112
local_lp.row_names_.clear();
111113
highs.passModel(local_lp);
112-
const std::string solution_file = "temp.sol";
113114
REQUIRE(highs.writeSolution(solution_file, 1) == HighsStatus::kOk);
114115

115116
// Cannot get name of column or row 0

check/TestOptions.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ TEST_CASE("external-options", "[highs_options]") {
7979
}
8080

8181
TEST_CASE("internal-options", "[highs_options]") {
82+
const std::string test_name = Catch::getResultCapture().getCurrentTestName();
83+
const std::string model_file = test_name + ".mps";
8284
HighsOptions options;
8385
HighsLogOptions report_log_options = options.log_options;
8486
if (!dev_run) options.output_flag = false;
@@ -209,7 +211,6 @@ TEST_CASE("internal-options", "[highs_options]") {
209211
options.log_options, options.records, "ml.mps");
210212
REQUIRE(return_status == OptionStatus::kIllegalValue);
211213

212-
std::string model_file = "ml.mps";
213214
return_status =
214215
setLocalOptionValue(report_log_options, kPresolveString,
215216
options.log_options, options.records, model_file);
@@ -260,6 +261,8 @@ TEST_CASE("internal-options", "[highs_options]") {
260261
}
261262

262263
TEST_CASE("highs-options", "[highs_options]") {
264+
const std::string test_name = Catch::getResultCapture().getCurrentTestName();
265+
const std::string options_file = test_name + ".set";
263266
Highs highs;
264267
if (!dev_run) highs.setOptionValue("output_flag", false);
265268
HighsStatus return_status = highs.writeOptions("Highs.set");
@@ -446,7 +449,6 @@ TEST_CASE("highs-options", "[highs_options]") {
446449
return_status = highs.setOptionValue(kModelFileString, model_file);
447450
REQUIRE(return_status == HighsStatus::kError);
448451

449-
std::string options_file = "Highs.set";
450452
return_status = highs.writeOptions(options_file);
451453
REQUIRE(return_status == HighsStatus::kOk);
452454

check/TestPresolve.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -577,7 +577,8 @@ TEST_CASE("postsolve-reduced-to-empty", "[highs_test_presolve]") {
577577
}
578578

579579
TEST_CASE("write-presolved-model", "[highs_test_presolve]") {
580-
std::string presolved_model_file = "temp.mps";
580+
const std::string test_name = Catch::getResultCapture().getCurrentTestName();
581+
const std::string presolved_model_file = test_name + ".mps";
581582
std::string model_file =
582583
std::string(HIGHS_DIR) + "/check/instances/afiro.mps";
583584
Highs highs;

check/TestQpSolver.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ TEST_CASE("qp-infeasible", "[qpsolver]") {
3333
}
3434

3535
TEST_CASE("qpsolver", "[qpsolver]") {
36+
const std::string test_name = Catch::getResultCapture().getCurrentTestName();
3637
double required_objective_function_value;
3738
double required_x0;
3839
double required_x1;
@@ -116,7 +117,7 @@ TEST_CASE("qpsolver", "[qpsolver]") {
116117
REQUIRE(return_status == HighsStatus::kOk);
117118

118119
// Test writeModel by writing out qjh.mps...
119-
filename = "qjh.mps";
120+
filename = test_name + ".mps";
120121
highs.writeModel(filename);
121122

122123
// ... and reading it in again

check/TestSemiVariables.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,8 @@ TEST_CASE("semi-variable-inconsistent-bounds", "[highs_test_semi_variables]") {
273273
}
274274

275275
TEST_CASE("semi-variable-inf-upper", "[highs_test_semi_variables]") {
276+
const std::string test_name = Catch::getResultCapture().getCurrentTestName();
277+
const std::string test_mps = test_name + ".mps";
276278
// Introduced due to a semi-variable possibly having an infinite
277279
// upper bound that needs to be written to MPS in order to define
278280
// variable type
@@ -287,7 +289,6 @@ TEST_CASE("semi-variable-inf-upper", "[highs_test_semi_variables]") {
287289
if (dev_run) printf("Optimum at first run: %g\n", obj0);
288290

289291
// now write out to MPS and load again
290-
const std::string test_mps = "test.mps";
291292
highs.writeModel(test_mps);
292293
highs.readModel(test_mps);
293294
highs.run();

highs/io/HMpsFF.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,8 @@ class HMpsFF {
164164

165165
enum class Boundtype { kLe, kEq, kGe }; //, kFr };
166166

167-
// see https://docs.mosek.com/latest_kkt/capi/mps-format.html#csection-optional
167+
// see
168+
// https://docs.mosek.com/latest_kkt/capi/mps-format.html#csection-optional
168169
enum class ConeType { kZero, kQuad, kRQuad, kPExp, kPPow, kDExp, kDPow };
169170

170171
std::string objective_name;

0 commit comments

Comments
 (0)