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

Function writeModelAsMps

highs/io/HMPSIO.cpp:551–593  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

549}
550
551HighsStatus 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
595HighsStatus writeMps(
596 const HighsLogOptions& log_options, const std::string& filename,

Callers 1

writeModelToFileMethod · 0.85

Calls 5

maxNameLengthFunction · 0.85
highsLogUserFunction · 0.85
findModelObjectiveNameFunction · 0.85
writeMpsFunction · 0.85
okNamesMethod · 0.80

Tested by

no test coverage detected