more absl::string conversons

This commit is contained in:
Laurent Perron
2023-05-06 09:01:00 +02:00
parent 8dbc5568b9
commit ef98a2e928
6 changed files with 12 additions and 10 deletions

View File

@@ -830,7 +830,7 @@ absl::StatusOr<GScipHintResult> GScip::SuggestHint(
}
absl::StatusOr<GScipResult> GScip::Solve(
const GScipParameters& params, const std::string& legacy_params,
const GScipParameters& params, absl::string_view legacy_params,
const GScipMessageHandler message_handler) {
// A four step process:
// 1. Apply parameters.

View File

@@ -144,7 +144,7 @@ class GScip {
// this will be reflected in the value of GScipResult::gscip_output::status.
absl::StatusOr<GScipResult> Solve(
const GScipParameters& params = GScipParameters(),
const std::string& legacy_params = "",
absl::string_view legacy_params = "",
GScipMessageHandler message_handler = nullptr);
// ///////////////////////////////////////////////////////////////////////////

View File

@@ -73,7 +73,7 @@ GScipLinearRange GScipLe(const GScipLinearExpr left,
}
absl::Status GScipCreateAbs(GScip* gscip, SCIP_Var* x, SCIP_Var* abs_x,
const std::string& name) {
absl::string_view name) {
return GScipCreateMaximum(
gscip, GScipLinearExpr(abs_x),
{GScipLinearExpr(x), GScipNegate(GScipLinearExpr(x))}, name);
@@ -137,7 +137,7 @@ absl::Status GScipCreateMaximum(GScip* gscip, const GScipLinearExpr& resultant,
absl::Status GScipCreateMinimum(GScip* gscip, const GScipLinearExpr& resultant,
const std::vector<GScipLinearExpr>& terms,
const std::string& name) {
absl::string_view name) {
std::vector<GScipLinearExpr> negated_terms;
negated_terms.reserve(terms.size());
for (const GScipLinearExpr& e : terms) {

View File

@@ -43,7 +43,7 @@ namespace operations_research {
// Adds the constraint y = abs(x). May create auxiliary variables. Supports
// unbounded x.
absl::Status GScipCreateAbs(GScip* gscip, SCIP_Var* x, SCIP_Var* abs_x,
const std::string& name = "");
absl::string_view name = "");
// TODO(user): delete this type and the methods below, use a generic version
// templated on the variable type that supports operator overloads.
@@ -78,7 +78,7 @@ absl::Status GScipCreateMaximum(GScip* gscip, const GScipLinearExpr& resultant,
// in terms.
absl::Status GScipCreateMinimum(GScip* gscip, const GScipLinearExpr& resultant,
const std::vector<GScipLinearExpr>& terms,
const std::string& name = "");
absl::string_view name = "");
// Models the constraint z = 1 => lb <= ax <= ub
// If negate_indicator, then instead: z = 0 => lb <= ax <= ub

View File

@@ -20,6 +20,7 @@
#include "absl/strings/match.h"
#include "absl/strings/numbers.h"
#include "absl/strings/str_split.h"
#include "absl/strings/string_view.h"
#include "ortools/base/path.h"
#include "ortools/scheduling/rcpsp.pb.h"
#include "ortools/util/filelineiter.h"
@@ -601,13 +602,13 @@ void RcpspParser::ProcessPattersonLine(const std::string& line) {
}
}
int RcpspParser::strtoint32(const std::string& word) {
int RcpspParser::strtoint32(absl::string_view word) {
int result;
CHECK(absl::SimpleAtoi(word, &result));
return result;
}
int64_t RcpspParser::strtoint64(const std::string& word) {
int64_t RcpspParser::strtoint64(absl::string_view word) {
int64_t result;
CHECK(absl::SimpleAtoi(word, &result));
return result;

View File

@@ -20,6 +20,7 @@
#include <string>
#include <vector>
#include "absl/strings/string_view.h"
#include "ortools/base/integral_types.h"
#include "ortools/scheduling/rcpsp.pb.h"
@@ -63,8 +64,8 @@ class RcpspParser {
// Sets the number of declared tasks, and initialize data structures
// accordingly.
void SetNumDeclaredTasks(int t);
int strtoint32(const std::string& word);
int64_t strtoint64(const std::string& word);
int strtoint32(absl::string_view word);
int64_t strtoint64(absl::string_view word);
std::string basedata_;
int64_t seed_;