| 651 | } |
| 652 | |
| 653 | void runSetLpSolution(const std::string model) { |
| 654 | HighsStatus return_status; |
| 655 | Highs highs; |
| 656 | std::string model_file = |
| 657 | std::string(HIGHS_DIR) + "/check/instances/" + model + ".mps"; |
| 658 | const HighsInfo& info = highs.getInfo(); |
| 659 | if (dev_run) printf("\nSolving %s from scratch\n", model.c_str()); |
| 660 | highs.setOptionValue("output_flag", dev_run); |
| 661 | if (dev_run) highs.setOptionValue("log_dev_level", 1); |
| 662 | |
| 663 | highs.readModel(model_file); |
| 664 | highs.run(); |
| 665 | HighsInt simplex_iteration_count0 = info.simplex_iteration_count; |
| 666 | HighsSolution solution = highs.getSolution(); |
| 667 | highs.clear(); |
| 668 | if (dev_run) printf("\nSolving from saved solution\n"); |
| 669 | highs.setOptionValue("output_flag", dev_run); |
| 670 | if (dev_run) highs.setOptionValue("log_dev_level", 1); |
| 671 | highs.readModel(model_file); |
| 672 | |
| 673 | // solution.col_value.assign(highs.getNumCol(), 0); |
| 674 | |
| 675 | return_status = highs.setSolution(solution); |
| 676 | REQUIRE(return_status == HighsStatus::kOk); |
| 677 | |
| 678 | highs.run(); |
| 679 | // Use a reduction in iteration count as a sanity check that |
| 680 | // starting from the optimal solution has worked |
| 681 | HighsInt simplex_iteration_count1 = info.simplex_iteration_count; |
| 682 | if (dev_run) |
| 683 | printf( |
| 684 | "For model %s: iteration counts are %d from logical basis and %d from " |
| 685 | "optimal solution\n", |
| 686 | model.c_str(), (int)simplex_iteration_count0, |
| 687 | (int)simplex_iteration_count1); |
| 688 | REQUIRE(simplex_iteration_count1 < simplex_iteration_count0); |
| 689 | |
| 690 | // Now write a sparse solution, and read it in to hot start |
| 691 | HighsInt write_solution_style = kSolutionStyleSparse; |
| 692 | std::string solution_file = model + ".sol"; |
| 693 | if (dev_run) printf("Writing sparse solution to %s\n", solution_file.c_str()); |
| 694 | if (dev_run) return_status = highs.writeSolution(""); |
| 695 | return_status = highs.writeSolution(solution_file, write_solution_style); |
| 696 | REQUIRE(return_status == HighsStatus::kOk); |
| 697 | |
| 698 | highs.clear(); |
| 699 | highs.setOptionValue("output_flag", dev_run); |
| 700 | if (dev_run) highs.setOptionValue("log_dev_level", 1); |
| 701 | |
| 702 | highs.readModel(model_file); |
| 703 | if (dev_run) |
| 704 | printf("Reading sparse solution from %s\n", solution_file.c_str()); |
| 705 | return_status = highs.readSolution(solution_file); |
| 706 | REQUIRE(return_status == HighsStatus::kOk); |
| 707 | |
| 708 | if (dev_run) printf("Solving model from sparse solution read from file\n"); |
| 709 | HighsStatus run_status = highs.run(); |
| 710 | REQUIRE(run_status == HighsStatus::kOk); |
no test coverage detected