Skip to content

Commit 5336f92

Browse files
committed
Unit tests pass quietly
1 parent 70e3fb2 commit 5336f92

File tree

4 files changed

+60
-40
lines changed

4 files changed

+60
-40
lines changed

check/TestUserScale.cpp

Lines changed: 50 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#include "Highs.h"
55
#include "catch.hpp"
66

7-
const bool dev_run = true;//false;
7+
const bool dev_run = false;
88
const double inf = kHighsInf;
99

1010
bool doubleEqual0(const double v0, const double v1) {
@@ -67,7 +67,7 @@ TEST_CASE("user-small-cost-scale", "[highs_user_scale]") {
6767
Highs highs;
6868
const HighsInfo& info = highs.getInfo();
6969
const HighsSolution& solution = highs.getSolution();
70-
// highs.setOptionValue("output_flag", dev_run);
70+
highs.setOptionValue("output_flag", dev_run);
7171
highs.setOptionValue("presolve", kHighsOffString);
7272
HighsLp lp;
7373
lp.num_col_ = 2;
@@ -283,7 +283,7 @@ TEST_CASE("ill-scaled-model", "[highs_user_scale]") {
283283
h.run();
284284
}
285285

286-
const bool all_test = true;//false;//
286+
const bool all_test = true; // false;//
287287
const bool lp_test = all_test || true;
288288
const bool mip_test = all_test || false;
289289
const bool qp_test = all_test || false;
@@ -306,8 +306,9 @@ TEST_CASE("ill-scaled-model", "[highs_user_scale]") {
306306
if (lp_test) {
307307
if (ok_test) {
308308
if (dev_run)
309-
printf(
310-
"\n================\nill-scaled-model: LP test\n================\n");
309+
printf(
310+
"\n================\nill-scaled-model: LP "
311+
"test\n================\n");
311312
testLp(h, ok_cost, ok_col_lower, ok_bound);
312313
}
313314
if (small_cost_test) {
@@ -318,24 +319,28 @@ TEST_CASE("ill-scaled-model", "[highs_user_scale]") {
318319
testLp(h, small_cost, small_col_lower, ok_bound);
319320
}
320321
if (dev_run)
321-
printf(
322-
"\n================\nill-scaled-model: LP test - large costs\n================\n");
323-
testLp(h, large_cost, small_col_lower, ok_bound);
322+
printf(
323+
"\n================\nill-scaled-model: LP test - large "
324+
"costs\n================\n");
325+
testLp(h, large_cost, small_col_lower, ok_bound);
324326
if (dev_run)
325-
printf(
326-
"\n================\nill-scaled-model: LP test - large bounds\n================\n");
327-
testLp(h, ok_cost, small_col_lower, large_bound);
327+
printf(
328+
"\n================\nill-scaled-model: LP test - large "
329+
"bounds\n================\n");
330+
testLp(h, ok_cost, small_col_lower, large_bound);
328331
if (dev_run)
329-
printf(
330-
"\n================\nill-scaled-model: LP test - large costs and bounds\n================\n");
331-
testLp(h, large_cost, small_col_lower, large_bound);
332+
printf(
333+
"\n================\nill-scaled-model: LP test - large costs and "
334+
"bounds\n================\n");
335+
testLp(h, large_cost, small_col_lower, large_bound);
332336
}
333337

334338
if (mip_test) {
335339
if (ok_test) {
336340
if (dev_run)
337-
printf(
338-
"\n================\nill-scaled-model: MIP test\n================\n");
341+
printf(
342+
"\n================\nill-scaled-model: MIP "
343+
"test\n================\n");
339344
testMip(h, ok_cost, ok_col_lower, ok_bound);
340345
}
341346

@@ -347,31 +352,46 @@ TEST_CASE("ill-scaled-model", "[highs_user_scale]") {
347352
testMip(h, small_cost, small_col_lower, ok_bound);
348353
}
349354
if (dev_run)
350-
printf(
351-
"\n================\nill-scaled-model: MIP test - large costs\n================\n");
352-
testMip(h, large_cost, small_col_lower, ok_bound);
355+
printf(
356+
"\n================\nill-scaled-model: MIP test - large "
357+
"costs\n================\n");
358+
testMip(h, large_cost, small_col_lower, ok_bound);
353359
if (dev_run)
354-
printf(
355-
"\n================\nill-scaled-model: MIP test - large bounds\n================\n");
356-
testMip(h, ok_cost, small_col_lower, large_bound);
360+
printf(
361+
"\n================\nill-scaled-model: MIP test - large "
362+
"bounds\n================\n");
363+
testMip(h, ok_cost, small_col_lower, large_bound);
364+
if (dev_run)
365+
printf(
366+
"\n================\nill-scaled-model: MIP test - large costs and "
367+
"bounds\n================\n");
368+
testMip(h, large_cost, small_col_lower, large_bound);
357369
}
358370

359371
if (qp_test) {
360372
if (ok_test) {
361373
if (dev_run)
362-
printf(
363-
"\n================\nill-scaled-model: QP test\n================\n");
374+
printf(
375+
"\n================\nill-scaled-model: QP "
376+
"test\n================\n");
364377
testQp(h, ok_cost, ok_hessian, ok_col_lower, ok_bound);
365378
}
366379
// QP solver can't handle small costs and Hessian
367380
if (dev_run)
368-
printf(
369-
"\n================\nill-scaled-model: QP test - large costs\n================\n");
370-
testQp(h, large_cost, ok_hessian, ok_col_lower, ok_bound);
381+
printf(
382+
"\n================\nill-scaled-model: QP test - large "
383+
"costs\n================\n");
384+
testQp(h, large_cost, ok_hessian, ok_col_lower, ok_bound);
371385
if (dev_run)
372-
printf(
373-
"\n================\nill-scaled-model: QP test - large bounds\n================\n");
374-
testQp(h, ok_cost, ok_hessian, small_col_lower, large_bound);
386+
printf(
387+
"\n================\nill-scaled-model: QP test - large "
388+
"bounds\n================\n");
389+
testQp(h, ok_cost, ok_hessian, small_col_lower, large_bound);
390+
if (dev_run)
391+
printf(
392+
"\n================\nill-scaled-model: QP test - large costs and "
393+
"bounds\n================\n");
394+
testQp(h, large_cost, large_hessian, small_col_lower, large_bound);
375395
}
376396

377397
h.resetGlobalScheduler(true);

highs/lp_data/Highs.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -963,7 +963,8 @@ HighsStatus Highs::run() {
963963
// and user_bound_scale
964964
assessExcessiveObjectiveBoundScaling(this->options_.log_options, this->model_,
965965
user_scale_data);
966-
this->writeModel("");
966+
// Used when deveoping unit tests in TestUserScale.cpp
967+
// this->writeModel("");
967968
HighsStatus status;
968969
if (!this->multi_linear_objective_.size()) {
969970
status = this->optimizeModel();

highs/lp_data/HighsSolve.cpp

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -549,13 +549,11 @@ void assessExcessiveObjectiveBoundScaling(const HighsLogOptions log_options,
549549
assert(base == 2 || base == 10);
550550
HighsInt rounded_log = 0;
551551
if (base == 2) {
552-
rounded_log = value < 1 ?
553-
std::floor(std::log2(value)) :
554-
std::ceil(std::log2(value));
552+
rounded_log = value < 1 ? std::floor(std::log2(value))
553+
: std::ceil(std::log2(value));
555554
} else {
556-
rounded_log = value < 1 ?
557-
std::floor(std::log10(value)) :
558-
std::ceil(std::log10(value));
555+
rounded_log = value < 1 ? std::floor(std::log10(value))
556+
: std::ceil(std::log10(value));
559557
}
560558
return rounded_log;
561559
};
@@ -569,7 +567,7 @@ void assessExcessiveObjectiveBoundScaling(const HighsLogOptions log_options,
569567
// Determine the order of magnitude of the suggested bound scaling -
570568
// just for logging
571569
HighsInt suggested_bound_scale_order_of_magnitude =
572-
outerRoundedLog(suggested_bound_scaling, 10);
570+
outerRoundedLog(suggested_bound_scaling, 10);
573571
// Applying the suggested bound scaling requires the costs and
574572
// matrix columns of non-continuous variables to be scaled, and any
575573
// Hessian entries are also scaled
@@ -598,7 +596,8 @@ void assessExcessiveObjectiveBoundScaling(const HighsLogOptions log_options,
598596
small_objective_coefficient, large_objective_coefficient);
599597
// Determine the suggested (new) value for user_objective_scale,
600598
// allowing for the fact that the current value has been applied
601-
HighsInt dl_user_objective_scale = outerRoundedLog(suggested_objective_scaling, 2);
599+
HighsInt dl_user_objective_scale =
600+
outerRoundedLog(suggested_objective_scaling, 2);
602601
user_scale_data.suggested_user_objective_scale =
603602
user_scale_data.user_objective_scale + dl_user_objective_scale;
604603
// Determine the order of magnitude of the suggested objective scaling -

highs/pdlp/CupdlpWrapper.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ HighsStatus solveLpCupdlp(const HighsOptions& options, HighsTimer& timer,
230230
assert(111 == 777);
231231
}
232232
#if CUPDLP_DEBUG
233-
analysePdlpSolution(options, lp, highs_solution);
233+
if (local_log_level > 0) analysePdlpSolution(options, lp, highs_solution);
234234
#endif
235235
} else {
236236
// Failure return from LP_SolvePDHG

0 commit comments

Comments
 (0)