MCPcopy Create free account
hub / github.com/ERGO-Code/HiGHS / checkOptions

Function checkOptions

highs/lp_data/HighsOptions.cpp:237–357  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

235}
236
237OptionStatus checkOptions(const HighsLogOptions& report_log_options,
238 const std::vector<OptionRecord*>& option_records) {
239 bool error_found = false;
240 HighsInt num_options = option_records.size();
241 for (HighsInt index = 0; index < num_options; index++) {
242 std::string name = option_records[index]->name;
243 HighsOptionType type = option_records[index]->type;
244 // Check that there are no other options with the same name
245 for (HighsInt check_index = 0; check_index < num_options; check_index++) {
246 if (check_index == index) continue;
247 std::string check_name = option_records[check_index]->name;
248 if (check_name == name) {
249 highsLogUser(report_log_options, HighsLogType::kError,
250 "checkOptions: Option %" HIGHSINT_FORMAT
251 " (\"%s\") has the same name as "
252 "option %" HIGHSINT_FORMAT " \"%s\"\n",
253 index, name.c_str(), check_index, check_name.c_str());
254 error_found = true;
255 }
256 }
257 if (type == HighsOptionType::kBool) {
258 // Check bool option
259 OptionRecordBool& option = ((OptionRecordBool*)option_records[index])[0];
260 // Check that there are no other options with the same value pointers
261 bool* value_pointer = option.value;
262 for (HighsInt check_index = 0; check_index < num_options; check_index++) {
263 if (check_index == index) continue;
264 if (option_records[check_index]->type == HighsOptionType::kBool) {
265 OptionRecordBool& check_option =
266 ((OptionRecordBool*)option_records[check_index])[0];
267 if (check_option.value == value_pointer) {
268 highsLogUser(report_log_options, HighsLogType::kError,
269 "checkOptions: Option %" HIGHSINT_FORMAT
270 " (\"%s\") has the same "
271 "value pointer as option %" HIGHSINT_FORMAT
272 " (\"%s\")\n",
273 index, option.name.c_str(), check_index,
274 check_option.name.c_str());
275 error_found = true;
276 }
277 }
278 }
279 } else if (type == HighsOptionType::kInt) {
280 // Check HighsInt option
281 OptionRecordInt& option = ((OptionRecordInt*)option_records[index])[0];
282 if (checkOption(report_log_options, option) != OptionStatus::kOk)
283 error_found = true;
284 // Check that there are no other options with the same value pointers
285 HighsInt* value_pointer = option.value;
286 for (HighsInt check_index = 0; check_index < num_options; check_index++) {
287 if (check_index == index) continue;
288 if (option_records[check_index]->type == HighsOptionType::kInt) {
289 OptionRecordInt& check_option =
290 ((OptionRecordInt*)option_records[check_index])[0];
291 if (check_option.value == value_pointer) {
292 highsLogUser(report_log_options, HighsLogType::kError,
293 "checkOptions: Option %" HIGHSINT_FORMAT
294 " (\"%s\") has the same "

Callers 1

calledOptimizeModelMethod · 0.70

Calls 4

highsLogUserFunction · 0.85
checkOptionFunction · 0.85
c_strMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected