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

Function testAlienBasis

check/TestAlienBasis.cpp:420–614  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

418}
419
420void testAlienBasis(const bool avgas, const HighsInt seed) {
421 std::string filename;
422 std::string model;
423 if (avgas) {
424 model = "avgas";
425 } else {
426 model = "israel";
427 }
428
429 filename = std::string(HIGHS_DIR) + "/check/instances/" + model + ".mps";
430 std::stringstream ss;
431
432 Highs highs;
433 if (!dev_run) highs.setOptionValue("output_flag", false);
434
435 HighsStatus read_status = highs.readModel(filename);
436 assert(read_status == HighsStatus::kOk);
437
438 HighsLp lp = highs.getLp();
439 HighsInt num_col = lp.num_col_;
440 HighsInt num_row = lp.num_row_;
441 // Assumes that the test LP has fewer columns than rows
442 // (portrait). Lansdcape test is performed on its dual.
443 assert(num_col < num_row);
444 const HighsInt num_var = num_col + num_row;
445 HighsBasis basis;
446 basis.col_status.resize(num_col);
447 basis.row_status.resize(num_row);
448 const bool run_square_test = true;
449 if (run_square_test && !seed) {
450 ss.str(std::string());
451 ss << "AlienBasis: " << model << " square";
452 basis.debug_origin_name = ss.str();
453 // Create a full-dimension basis using struturals and then enough logicals
454 HighsBasisStatus status = HighsBasisStatus::kBasic;
455 for (HighsInt iCol = 0; iCol < num_col; iCol++) {
456 if (iCol >= num_row) status = HighsBasisStatus::kNonbasic;
457 basis.col_status[iCol] = status;
458 }
459 for (HighsInt iRow = 0; iRow < num_row; iRow++) {
460 if (num_col + iRow >= num_row) status = HighsBasisStatus::kNonbasic;
461 basis.row_status[iRow] = status;
462 }
463 REQUIRE(highs.setBasis(basis) == HighsStatus::kOk);
464 highs.run();
465 }
466 const bool run_square_random_test = true;
467 if (run_square_random_test) {
468 ss.str(std::string());
469 ss << "AlienBasis: " << model << " random-" << seed << " square";
470 basis.debug_origin_name = ss.str();
471 // Create a full-dimension basis using random selection of num_col variables
472 basis.col_status.assign(num_col, HighsBasisStatus::kNonbasic);
473 basis.row_status.assign(num_row, HighsBasisStatus::kNonbasic);
474 HighsRandom random(seed);
475 HighsInt num_basic = 0;
476 for (;;) {
477 HighsInt iVar = random.integer(num_var);

Callers 1

TestAlienBasis.cppFile · 0.85

Calls 11

strMethod · 0.80
integerMethod · 0.80
push_backMethod · 0.80
passModelMethod · 0.80
resetGlobalSchedulerMethod · 0.80
setOptionValueMethod · 0.45
readModelMethod · 0.45
resizeMethod · 0.45
setBasisMethod · 0.45
runMethod · 0.45
ensureColwiseMethod · 0.45

Tested by

no test coverage detected