| 3627 | } |
| 3628 | |
| 3629 | HighsStatus Highs::writeSolution(const std::string& filename, |
| 3630 | const HighsInt style) { |
| 3631 | HighsStatus return_status = HighsStatus::kOk; |
| 3632 | HighsStatus call_status; |
| 3633 | FILE* file; |
| 3634 | HighsFileType file_type; |
| 3635 | call_status = openWriteFile(filename, "writeSolution", file, file_type); |
| 3636 | return_status = interpretCallStatus(options_.log_options, call_status, |
| 3637 | return_status, "openWriteFile"); |
| 3638 | if (return_status == HighsStatus::kError) return return_status; |
| 3639 | call_status = normaliseNames(this->options_.log_options, this->model_.lp_); |
| 3640 | return_status = interpretCallStatus(options_.log_options, call_status, |
| 3641 | return_status, "normaliseNames"); |
| 3642 | assert(call_status != HighsStatus::kError); |
| 3643 | |
| 3644 | // Report to user that solution is being written |
| 3645 | if (filename != "") |
| 3646 | highsLogUser(options_.log_options, HighsLogType::kInfo, |
| 3647 | "Writing the solution to %s\n", filename.c_str()); |
| 3648 | writeSolutionFile(file, options_, model_, basis_, solution_, info_, |
| 3649 | model_status_, style); |
| 3650 | if (style == kSolutionStyleSparse) |
| 3651 | return returnFromWriteSolution(file, return_status); |
| 3652 | if (style == kSolutionStyleRaw) { |
| 3653 | fprintf(file, "\n# Basis\n"); |
| 3654 | writeBasisFile(file, options_, model_.lp_, basis_); |
| 3655 | } |
| 3656 | if (options_.ranging == kHighsOnString) { |
| 3657 | if (model_.isMip() || model_.isQp()) { |
| 3658 | highsLogUser(options_.log_options, HighsLogType::kError, |
| 3659 | "Cannot determine ranging information for MIP or QP\n"); |
| 3660 | return_status = HighsStatus::kError; |
| 3661 | return returnFromWriteSolution(file, return_status); |
| 3662 | } |
| 3663 | return_status = |
| 3664 | interpretCallStatus(options_.log_options, this->getRangingInterface(), |
| 3665 | return_status, "getRangingInterface"); |
| 3666 | if (return_status == HighsStatus::kError) |
| 3667 | return returnFromWriteSolution(file, return_status); |
| 3668 | fprintf(file, "\n# Ranging\n"); |
| 3669 | writeRangingFile(file, model_.lp_, info_.objective_function_value, basis_, |
| 3670 | solution_, ranging_, style); |
| 3671 | } |
| 3672 | return returnFromWriteSolution(file, return_status); |
| 3673 | } |
| 3674 | |
| 3675 | HighsStatus Highs::readSolution(const std::string& filename, |
| 3676 | const HighsInt style) { |