| 53 | } |
| 54 | |
| 55 | void test_crossover(Highs& highs, HighsLp& lp) { |
| 56 | HighsStatus return_status; |
| 57 | highs.clear(); |
| 58 | highs.setOptionValue("output_flag", dev_run); |
| 59 | // highs.setOptionValue("output_flag", false); |
| 60 | return_status = highs.passModel(lp); |
| 61 | REQUIRE(return_status == HighsStatus::kOk); |
| 62 | highs.run(); |
| 63 | const std::vector<double> from_primal_value = {2, 1}; |
| 64 | HighsModelStatus model_status = highs.getModelStatus(); |
| 65 | const HighsInfo& info = highs.getInfo(); |
| 66 | const double require_optimal_objective = info.objective_function_value; |
| 67 | |
| 68 | highs.clearSolver(); |
| 69 | // Set solution to interior of optimal face |
| 70 | HighsSolution solution; |
| 71 | solution.col_value = from_primal_value; |
| 72 | HighsBasis basis; |
| 73 | report("Before crossover", lp, solution, basis); |
| 74 | return_status = highs.crossover(solution); |
| 75 | if (model_status == HighsModelStatus::kOptimal) { |
| 76 | REQUIRE(return_status == HighsStatus::kOk); |
| 77 | REQUIRE(highs.getModelStatus() == model_status); |
| 78 | REQUIRE(require_optimal_objective == info.objective_function_value); |
| 79 | } else if (model_status == HighsModelStatus::kInfeasible) { |
| 80 | // Crossover returns "imprecise" => HighsStatus::kWarning and |
| 81 | // HighsModelStatus::kUnknown |
| 82 | REQUIRE(return_status == HighsStatus::kWarning); |
| 83 | REQUIRE(highs.getModelStatus() == HighsModelStatus::kUnknown); |
| 84 | } else if (model_status == HighsModelStatus::kUnbounded) { |
| 85 | // Crossover returns "imprecise" => HighsStatus::kWarning and |
| 86 | // HighsModelStatus::kUnknown |
| 87 | REQUIRE(return_status == HighsStatus::kWarning); |
| 88 | REQUIRE(highs.getModelStatus() == HighsModelStatus::kUnknown); |
| 89 | } else { |
| 90 | assert(1 == 0); |
| 91 | } |
| 92 | report("After crossover", lp, solution, basis); |
| 93 | report("From Highs", lp, highs.getSolution(), highs.getBasis()); |
| 94 | |
| 95 | highs.resetGlobalScheduler(true); |
| 96 | } |
| 97 | |
| 98 | void report(const std::string message, const HighsLp& lp, |
| 99 | const HighsSolution& solution, const HighsBasis& basis) { |
no test coverage detected