| 601 | } |
| 602 | |
| 603 | void writeRangingFile(FILE* file, const HighsLp& lp, |
| 604 | const double objective_function_value, |
| 605 | const HighsBasis& basis, const HighsSolution& solution, |
| 606 | const HighsRanging& ranging, const HighsInt style) { |
| 607 | if (!ranging.valid) { |
| 608 | fprintf(file, "None\n"); |
| 609 | return; |
| 610 | } |
| 611 | fprintf(file, "Valid\n"); |
| 612 | std::stringstream ss; |
| 613 | assert(lp.col_names_.size() == static_cast<size_t>(lp.num_col_)); |
| 614 | assert(lp.row_names_.size() == static_cast<size_t>(lp.num_row_)); |
| 615 | const bool pretty = style == kSolutionStylePretty; |
| 616 | const char* pretty_cost_format = |
| 617 | "%6d %4s %-10.4g %-10.4g %-10.4g %-10.4g " |
| 618 | "%-10.4g %-s\n"; |
| 619 | const char* raw_cost_format = "%-s %s %s %s %s\n"; |
| 620 | |
| 621 | const char* pretty_bound_format = |
| 622 | "%6d %4s %-10.4g %-10.4g %-10.4g %-10.4g %-10.4g %-10.4g %-10.4g " |
| 623 | "%-s\n"; |
| 624 | const char* raw_bound_format = "%-s %s %s %s %s\n"; |
| 625 | |
| 626 | std::array<char, 32> dn_objective; |
| 627 | std::array<char, 32> up_objective; |
| 628 | std::array<char, 32> dn_value; |
| 629 | std::array<char, 32> up_value; |
| 630 | |
| 631 | auto objective = highsDoubleToString(objective_function_value, |
| 632 | kRangingValueToStringTolerance); |
| 633 | fprintf(file, "Objective %s\n", objective.data()); |
| 634 | if (pretty) { |
| 635 | fprintf(file, |
| 636 | "\n Cost ranging\n" |
| 637 | "Column Status DownObj Down Value " |
| 638 | " Up UpObj Name\n"); |
| 639 | } else { |
| 640 | fprintf(file, "\n# Cost ranging\n"); |
| 641 | } |
| 642 | for (HighsInt iCol = 0; iCol < lp.num_col_; iCol++) { |
| 643 | const std::string name = lp.col_names_[iCol]; |
| 644 | if (pretty) { |
| 645 | fprintf(file, pretty_cost_format, (int)iCol, |
| 646 | statusToString(basis.col_status[iCol], lp.col_lower_[iCol], |
| 647 | lp.col_upper_[iCol]) |
| 648 | .c_str(), |
| 649 | ranging.col_cost_dn.objective_[iCol], |
| 650 | ranging.col_cost_dn.value_[iCol], lp.col_cost_[iCol], |
| 651 | ranging.col_cost_up.value_[iCol], |
| 652 | ranging.col_cost_up.objective_[iCol], name.c_str()); |
| 653 | } else { |
| 654 | dn_objective = highsDoubleToString(ranging.col_cost_dn.objective_[iCol], |
| 655 | kRangingValueToStringTolerance); |
| 656 | up_objective = highsDoubleToString(ranging.col_cost_up.objective_[iCol], |
| 657 | kRangingValueToStringTolerance); |
| 658 | dn_value = highsDoubleToString(ranging.col_cost_dn.value_[iCol], |
| 659 | kRangingValueToStringTolerance); |
| 660 | up_value = highsDoubleToString(ranging.col_cost_up.value_[iCol], |
no test coverage detected