Skip to content

Commit

Permalink
call model file writer functions from linear solver
Browse files Browse the repository at this point in the history
  • Loading branch information
omer-candan committed Jul 8, 2024
1 parent 6d135d8 commit 6c5ff24
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
19 changes: 19 additions & 0 deletions ortools/linear_solver/linear_solver.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1868,6 +1868,25 @@ bool MPSolver::ExportModelAsMpsFormat(bool fixed_format, bool obfuscate,
return status_or.ok();
}

bool MPSolver::WriteModelAsLpFormat(const std::string& file_path,
bool obfuscate) const {
MPModelProto proto;
ExportModelToProto(&proto);
MPModelExportOptions options;
options.obfuscate = obfuscate;
return operations_research::WriteModelAsLpFormat(proto, file_path, options);
}

bool MPSolver::WriteModelAsMpsFormat(const std::string& file_path,
bool fixed_format,
bool obfuscate) const {
MPModelProto proto;
ExportModelToProto(&proto);
MPModelExportOptions options;
options.obfuscate = obfuscate;
return operations_research::WriteModelAsMpsFormat(proto, file_path, options);
}

void MPSolver::SetHint(std::vector<std::pair<const MPVariable*, double>> hint) {
for (const auto& var_value_pair : hint) {
CHECK(OwnsVariable(var_value_pair.first))
Expand Down
4 changes: 4 additions & 0 deletions ortools/linear_solver/linear_solver.h
Original file line number Diff line number Diff line change
Expand Up @@ -669,6 +669,10 @@ class MPSolver {
bool ExportModelAsLpFormat(bool obfuscate, std::string* model_str) const;
bool ExportModelAsMpsFormat(bool fixed_format, bool obfuscate,
std::string* model_str) const;

bool WriteModelAsLpFormat(const std::string& file_path, bool obfuscate) const;
bool WriteModelAsMpsFormat(const std::string& file_path, bool fixed_format,
bool obfuscate) const;

/**
* Sets the number of threads to use by the underlying solver.
Expand Down

0 comments on commit 6c5ff24

Please sign in to comment.