Skip to content

Commit 3e51968

Browse files
committed
Added Highs_changeRowsBoundsByRange to C API
1 parent ea5c78c commit 3e51968

File tree

4 files changed

+36
-11
lines changed

4 files changed

+36
-11
lines changed

check/TestCallbacks.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ TEST_CASE("highs-callback-logging", "[highs_callback]") {
295295
highs.startCallback(kCallbackLogging);
296296
highs.readModel(filename);
297297
highs.run();
298-
298+
299299
highs.resetGlobalScheduler(true);
300300
}
301301

@@ -312,7 +312,7 @@ TEST_CASE("highs-callback-solution-basis-logging", "[highs_callback]") {
312312
highs.startCallback(kCallbackLogging);
313313
if (dev_run) highs.writeSolution("", kSolutionStylePretty);
314314
if (dev_run) highs.writeBasis("");
315-
315+
316316
highs.resetGlobalScheduler(true);
317317
}
318318

@@ -329,7 +329,7 @@ TEST_CASE("highs-callback-simplex-interrupt", "[highs_callback]") {
329329
REQUIRE(highs.getModelStatus() == HighsModelStatus::kInterrupt);
330330
REQUIRE(highs.getInfo().simplex_iteration_count >
331331
adlittle_simplex_iteration_limit);
332-
332+
333333
highs.resetGlobalScheduler(true);
334334
}
335335

@@ -346,7 +346,7 @@ TEST_CASE("highs-callback-ipm-interrupt", "[highs_callback]") {
346346
REQUIRE(status == HighsStatus::kWarning);
347347
REQUIRE(highs.getModelStatus() == HighsModelStatus::kInterrupt);
348348
REQUIRE(highs.getInfo().ipm_iteration_count > adlittle_ipm_iteration_limit);
349-
349+
350350
highs.resetGlobalScheduler(true);
351351
}
352352

@@ -362,7 +362,7 @@ TEST_CASE("highs-callback-mip-interrupt", "[highs_callback]") {
362362
REQUIRE(status == HighsStatus::kWarning);
363363
REQUIRE(highs.getModelStatus() == HighsModelStatus::kInterrupt);
364364
REQUIRE(highs.getInfo().objective_function_value > egout_optimal_objective);
365-
365+
366366
highs.resetGlobalScheduler(true);
367367
}
368368

@@ -377,7 +377,7 @@ TEST_CASE("highs-callback-mip-improving", "[highs_callback]") {
377377
highs.startCallback(kCallbackMipImprovingSolution);
378378
highs.readModel(filename);
379379
highs.run();
380-
380+
381381
highs.resetGlobalScheduler(true);
382382
}
383383

@@ -391,7 +391,7 @@ TEST_CASE("highs-callback-mip-data", "[highs_callback]") {
391391
highs.startCallback(kCallbackMipLogging);
392392
highs.readModel(filename);
393393
highs.run();
394-
394+
395395
highs.resetGlobalScheduler(true);
396396
}
397397

@@ -413,7 +413,7 @@ TEST_CASE("highs-callback-mip-solution", "[highs_callback]") {
413413
highs.setCallback(userMipSolutionCallback, p_user_callback_data);
414414
highs.startCallback(kCallbackMipSolution);
415415
highs.run();
416-
416+
417417
highs.resetGlobalScheduler(true);
418418
}
419419

@@ -425,7 +425,7 @@ TEST_CASE("highs-callback-mip-cut-pool", "[highs_callback]") {
425425
highs.setCallback(userMipCutPoolCallback);
426426
highs.startCallback(kCallbackMipGetCutPool);
427427
highs.run();
428-
428+
429429
highs.resetGlobalScheduler(true);
430430
}
431431

@@ -469,6 +469,6 @@ TEST_CASE("highs-callback-mip-user-solution", "[highs_callback]") {
469469
std::max(1.0, std::fabs(objective_function_value0));
470470
REQUIRE(objective_diff < 1e-12);
471471
}
472-
472+
473473
highs.resetGlobalScheduler(true);
474474
}

check/TestIpm.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,5 +162,4 @@ TEST_CASE("test-2087", "[highs_ipm]") {
162162
REQUIRE(first_ipm_iteration_count == h.getInfo().ipm_iteration_count);
163163

164164
h.resetGlobalScheduler(true);
165-
166165
}

highs/interfaces/highs_c_api.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -928,6 +928,14 @@ HighsInt Highs_changeRowBounds(void* highs, const HighsInt row,
928928
return (HighsInt)((Highs*)highs)->changeRowBounds(row, lower, upper);
929929
}
930930

931+
HighsInt Highs_changeRowsBoundsByRange(void* highs, const HighsInt from_row,
932+
const HighsInt to_row,
933+
const double* lower,
934+
const double* upper) {
935+
return (HighsInt)((Highs*)highs)
936+
->changeRowsBounds(from_row, to_row, lower, upper);
937+
}
938+
931939
HighsInt Highs_changeRowsBoundsBySet(void* highs,
932940
const HighsInt num_set_entries,
933941
const HighsInt* set, const double* lower,

highs/interfaces/highs_c_api.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1671,6 +1671,24 @@ HighsInt Highs_changeColsBoundsByMask(void* highs, const HighsInt* mask,
16711671
HighsInt Highs_changeRowBounds(void* highs, const HighsInt row,
16721672
const double lower, const double upper);
16731673

1674+
/**
1675+
* Change the variable bounds of multiple adjacent rows.
1676+
*
1677+
* @param highs A pointer to the Highs instance.
1678+
* @param from_row The index of the first row whose bound changes.
1679+
* @param to_row The index of the last row whose bound changes.
1680+
* @param lower An array of length [to_row - from_row + 1] with the new
1681+
* lower bounds.
1682+
* @param upper An array of length [to_row - from_row + 1] with the new
1683+
* upper bounds.
1684+
*
1685+
* @returns A `kHighsStatus` constant indicating whether the call succeeded.
1686+
*/
1687+
HighsInt Highs_changeRowsBoundsByRange(void* highs, const HighsInt from_row,
1688+
const HighsInt to_row,
1689+
const double* lower,
1690+
const double* upper);
1691+
16741692
/**
16751693
* Change the bounds of multiple rows given by an array of indices.
16761694
*

0 commit comments

Comments
 (0)