Skip to content

Commit 2dc77c5

Browse files
committed
chip-user-bound-scale now considers LP giving fractional solution then MIP
1 parent 38c3df0 commit 2dc77c5

File tree

1 file changed

+25
-20
lines changed

1 file changed

+25
-20
lines changed

check/TestUserScale.cpp

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ TEST_CASE("chip-user-bound-scale", "[highs_user_scale]") {
6868
Highs highs;
6969
const HighsInfo& info = highs.getInfo();
7070
const HighsSolution& solution = highs.getSolution();
71-
// highs.setOptionValue("output_flag", dev_run);
71+
highs.setOptionValue("output_flag", dev_run);
7272
highs.setOptionValue("presolve", kHighsOffString);
7373
HighsLp lp;
7474
lp.num_col_ = 2;
@@ -78,37 +78,42 @@ TEST_CASE("chip-user-bound-scale", "[highs_user_scale]") {
7878
lp.col_lower_ = {0, 0};
7979
lp.col_upper_ = {inf, inf};
8080
lp.row_lower_ = {-inf, -inf};
81-
lp.row_upper_ = {80, 120};
81+
lp.row_upper_ = {82, 125};
8282
lp.a_matrix_.start_ = {0, 2, 4};
8383
lp.a_matrix_.index_ = {0, 1, 0, 1};
8484
lp.a_matrix_.value_ = {1, 1, 2, 4};
85+
double chip_solution0 = 39;
86+
double chip_solution1 = 21.5;
8587

86-
highs.passModel(lp);
88+
// Pass twice: once for LP; once for MIP
89+
for (int k = 0; k < 2; k++) {
90+
highs.passModel(lp);
8791

88-
highs.run();
89-
REQUIRE(solution.col_value[0] == 40);
90-
REQUIRE(solution.col_value[1] == 20);
92+
highs.run();
9193

92-
highs.clearSolver();
94+
REQUIRE(solution.col_value[0] == chip_solution0);
95+
REQUIRE(solution.col_value[1] == chip_solution1);
9396

94-
REQUIRE(highs.setOptionValue("user_bound_scale", 3) ==
95-
HighsStatus::kOk);
96-
97-
highs.run();
98-
REQUIRE(solution.col_value[0] == 40);
99-
REQUIRE(solution.col_value[1] == 20);
97+
REQUIRE(highs.setOptionValue("user_bound_scale", 3) == HighsStatus::kOk);
10098

101-
highs.clearSolver();
99+
highs.clearSolver();
100+
highs.run();
101+
REQUIRE(solution.col_value[0] == chip_solution0);
102+
REQUIRE(solution.col_value[1] == chip_solution1);
102103

103-
REQUIRE(highs.setOptionValue("user_bound_scale", -3) ==
104-
HighsStatus::kOk);
104+
REQUIRE(highs.setOptionValue("user_bound_scale", -3) == HighsStatus::kOk);
105105

106-
highs.run();
107-
REQUIRE(solution.col_value[0] == 40);
108-
REQUIRE(solution.col_value[1] == 20);
106+
highs.clearSolver();
107+
highs.run();
108+
REQUIRE(solution.col_value[0] == chip_solution0);
109+
REQUIRE(solution.col_value[1] == chip_solution1);
109110

111+
// Add integrality, and change the solution
112+
lp.integrality_ = {HighsVarType::kInteger, HighsVarType::kInteger};
113+
chip_solution0 = 40;
114+
chip_solution1 = 21;
115+
}
110116
highs.resetGlobalScheduler(true);
111-
112117
}
113118

114119
TEST_CASE("user-small-cost-scale", "[highs_user_scale]") {

0 commit comments

Comments
 (0)