| 549 | } |
| 550 | |
| 551 | HighsStatus writeModelAsMps(const HighsOptions& options, |
| 552 | const std::string& filename, |
| 553 | const HighsModel& model, const bool free_format) { |
| 554 | bool warning_found = false; |
| 555 | const HighsLp& lp = model.lp_; |
| 556 | |
| 557 | const bool ok_names = lp.okNames(); |
| 558 | assert(ok_names); |
| 559 | if (!ok_names) return HighsStatus::kError; |
| 560 | |
| 561 | const HighsHessian& hessian = model.hessian_; |
| 562 | |
| 563 | HighsInt max_name_length = maxNameLength(lp); |
| 564 | bool use_free_format = free_format; |
| 565 | if (!free_format) { |
| 566 | if (max_name_length > 8) { |
| 567 | highsLogUser(options.log_options, HighsLogType::kWarning, |
| 568 | "Maximum name length is %" HIGHSINT_FORMAT |
| 569 | " so using free format rather " |
| 570 | "than fixed format\n", |
| 571 | max_name_length); |
| 572 | use_free_format = true; |
| 573 | warning_found = true; |
| 574 | } |
| 575 | } |
| 576 | // Set a local objective name, creating one if necessary |
| 577 | const std::string local_objective_name = |
| 578 | findModelObjectiveName(&lp, &hessian); |
| 579 | // If there is Hessian data to write out, writeMps assumes that hessian is |
| 580 | // triangular |
| 581 | if (hessian.dim_) assert(hessian.format_ == HessianFormat::kTriangular); |
| 582 | |
| 583 | HighsStatus write_status = writeMps( |
| 584 | options.log_options, filename, lp.model_name_, lp.num_row_, lp.num_col_, |
| 585 | hessian.dim_, lp.sense_, lp.offset_, lp.col_cost_, lp.col_lower_, |
| 586 | lp.col_upper_, lp.row_lower_, lp.row_upper_, lp.a_matrix_.start_, |
| 587 | lp.a_matrix_.index_, lp.a_matrix_.value_, hessian.start_, hessian.index_, |
| 588 | hessian.value_, lp.integrality_, local_objective_name, lp.col_names_, |
| 589 | lp.row_names_, use_free_format); |
| 590 | if (write_status == HighsStatus::kOk && warning_found) |
| 591 | return HighsStatus::kWarning; |
| 592 | return write_status; |
| 593 | } |
| 594 | |
| 595 | HighsStatus writeMps( |
| 596 | const HighsLogOptions& log_options, const std::string& filename, |
no test coverage detected