ERGO-Code/HiGHS

Assert in Highs::changeCostsInterface if set used with indices out of range

Closed this issue · 2 comments

If an attempt is made to change costs etc with a set containing an index out of range, then assert(ok(index_collection)); is triggered

Needs

bool create(HighsIndexCollection& index_collection,
const HighsInt num_set_entries, const HighsInt* set,
const HighsInt dimension)

to have distinct failures:

  • if the set is not increasing
  • if the are indices out of range
  • if num_set_entries is negative - in which case occurrences of if (num_set_entries <= 0) return HighsStatus::kOk; should only be if (num_set_entries == 0) return HighsStatus::kOk; and the negative handled as an error

Also check whether

void create(HighsIndexCollection& index_collection, const HighsInt* mask,
const HighsInt dimension)

is OK if dimension is zero (and it also needs a failure if dimension < 0)

TEST_CASE("change-col-cost", "[highs_data]") {
Highs highs;
highs.setOptionValue("output_flag", dev_run);
highs.changeColCost(0, 1);
}

Fixed by #1682