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

Function test_crossover

check/TestCrossover.cpp:55–96  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

53}
54
55void 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
98void report(const std::string message, const HighsLp& lp,
99 const HighsSolution& solution, const HighsBasis& basis) {

Callers 1

TestCrossover.cppFile · 0.85

Calls 11

reportFunction · 0.85
passModelMethod · 0.80
crossoverMethod · 0.80
getBasisMethod · 0.80
resetGlobalSchedulerMethod · 0.80
clearMethod · 0.45
setOptionValueMethod · 0.45
runMethod · 0.45
getInfoMethod · 0.45
clearSolverMethod · 0.45
getSolutionMethod · 0.45

Tested by

no test coverage detected