diff --git a/ortools/algorithms/set_cover_heuristics.cc b/ortools/algorithms/set_cover_heuristics.cc index 4208c90e17..dc6377b893 100644 --- a/ortools/algorithms/set_cover_heuristics.cc +++ b/ortools/algorithms/set_cover_heuristics.cc @@ -122,8 +122,8 @@ bool GreedySolutionGenerator::NextSolution( return NextSolution(focus, inv_->model()->subset_costs()); } -bool GreedySolutionGenerator::NextSolution( - const std::vector& focus, const SubsetCostVector& costs) { +bool GreedySolutionGenerator::NextSolution(absl::Span focus, + const SubsetCostVector& costs) { DCHECK(inv_->CheckConsistency()); inv_->ClearTrace(); SubsetCostVector elements_per_cost(costs.size(), 0.0); diff --git a/ortools/algorithms/set_cover_heuristics.h b/ortools/algorithms/set_cover_heuristics.h index 154724cf61..c8440bf64e 100644 --- a/ortools/algorithms/set_cover_heuristics.h +++ b/ortools/algorithms/set_cover_heuristics.h @@ -174,7 +174,7 @@ class GreedySolutionGenerator { bool NextSolution(const std::vector& focus); // Same with a different set of costs. - bool NextSolution(const std::vector& focus, + bool NextSolution(absl::Span focus, const SubsetCostVector& costs); private: diff --git a/ortools/glop/lu_factorization.cc b/ortools/glop/lu_factorization.cc index 8deed0b61c..e50e9f9d3d 100644 --- a/ortools/glop/lu_factorization.cc +++ b/ortools/glop/lu_factorization.cc @@ -133,7 +133,7 @@ namespace { // norm of the given column, otherwise do the same with a sparse version. In // both cases column is cleared. Fractional ComputeSquaredNormAndResetToZero( - const std::vector& non_zeros, absl::Span column) { + absl::Span non_zeros, absl::Span column) { Fractional sum = 0.0; if (non_zeros.empty()) { sum = SquaredNormAndResetToZero(column); diff --git a/ortools/linear_solver/model_exporter.cc b/ortools/linear_solver/model_exporter.cc index 51d75611d6..cdccf8b241 100644 --- a/ortools/linear_solver/model_exporter.cc +++ b/ortools/linear_solver/model_exporter.cc @@ -149,11 +149,11 @@ class MPModelProtoExporter { // Appends a pair name, value to "output", formatted to comply with the MPS // standard. - void AppendMpsPair(const std::string& name, double value, + void AppendMpsPair(absl::string_view name, double value, std::string* output) const; // Appends the head of a line, consisting of an id and a name to output. - void AppendMpsLineHeader(const std::string& id, const std::string& name, + void AppendMpsLineHeader(absl::string_view id, absl::string_view name, std::string* output) const; // Same as AppendMpsLineHeader. Appends an extra new-line at the end the @@ -674,13 +674,13 @@ bool MPModelProtoExporter::ExportModelAsLpFormat( return true; } -void MPModelProtoExporter::AppendMpsPair(const std::string& name, double value, +void MPModelProtoExporter::AppendMpsPair(absl::string_view name, double value, std::string* output) const { absl::StrAppendFormat(output, *mps_format_, name, DoubleToString(value)); } -void MPModelProtoExporter::AppendMpsLineHeader(const std::string& id, - const std::string& name, +void MPModelProtoExporter::AppendMpsLineHeader(absl::string_view id, + absl::string_view name, std::string* output) const { absl::StrAppendFormat(output, *mps_header_format_, id, name); } diff --git a/ortools/linear_solver/python/model_builder.py b/ortools/linear_solver/python/model_builder.py index bca0e6df2c..9d9dc8f7c6 100644 --- a/ortools/linear_solver/python/model_builder.py +++ b/ortools/linear_solver/python/model_builder.py @@ -1599,11 +1599,31 @@ def import_from_mps_file(self, mps_file: str) -> bool: return self.__helper.import_from_mps_file(mps_file) def import_from_lp_string(self, lp_string: str) -> bool: - """Reads a model from a LP string.""" + """Reads a model from a LP string. + + Note that this code is very limited, and will not support any real lp. + It is only intented to be use to parse test lp problems. + + Args: + lp_string: The LP string to import. + + Returns: + True if the import was successful. + """ return self.__helper.import_from_lp_string(lp_string) def import_from_lp_file(self, lp_file: str) -> bool: - """Reads a model from a .lp file.""" + """Reads a model from a .lp file. + + Note that this code is very limited, and will not support any real lp. + It is only intented to be use to parse test lp problems. + + Args: + lp_file: The LP file to import. + + Returns: + True if the import was successful. + """ return self.__helper.import_from_lp_file(lp_file) def import_from_proto_file(self, proto_file: str) -> bool: