minor fixes
This commit is contained in:
@@ -21,6 +21,7 @@
|
||||
#include <vector>
|
||||
|
||||
#include "absl/strings/str_join.h"
|
||||
#include "absl/strings/string_view.h"
|
||||
#include "ortools/base/logging.h"
|
||||
#include "ortools/linear_solver/linear_solver.h"
|
||||
|
||||
@@ -87,7 +88,7 @@ double LinearExpr::SolutionValue() const {
|
||||
|
||||
namespace {
|
||||
|
||||
void AppendTerm(const double coef, const std::string& var_name,
|
||||
void AppendTerm(const double coef, absl::string_view var_name,
|
||||
const bool is_first, std::string* s) {
|
||||
if (is_first) {
|
||||
if (coef == 1.0) {
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
#include "absl/strings/match.h"
|
||||
#include "absl/strings/str_cat.h"
|
||||
#include "absl/strings/str_format.h"
|
||||
#include "absl/strings/string_view.h"
|
||||
#include "ortools/base/commandlineflags.h"
|
||||
#include "ortools/base/logging.h"
|
||||
#include "ortools/base/map_util.h"
|
||||
@@ -50,7 +51,7 @@ class LineBreaker {
|
||||
// - Lines are split so that their length doesn't exceed the max length;
|
||||
// unless a single string given to Append() exceeds that length (in which
|
||||
// case it will be put alone on a single unsplit line).
|
||||
void Append(const std::string& s);
|
||||
void Append(absl::string_view s);
|
||||
|
||||
// Returns true if string s will fit on the current line without adding a
|
||||
// carriage return.
|
||||
@@ -70,7 +71,7 @@ class LineBreaker {
|
||||
std::string output_;
|
||||
};
|
||||
|
||||
void LineBreaker::Append(const std::string& s) {
|
||||
void LineBreaker::Append(absl::string_view s) {
|
||||
line_size_ += s.size();
|
||||
if (line_size_ > max_line_size_) {
|
||||
line_size_ = s.size();
|
||||
@@ -258,15 +259,15 @@ namespace {
|
||||
class NameManager {
|
||||
public:
|
||||
NameManager() : names_set_(), last_n_(1) {}
|
||||
std::string MakeUniqueName(const std::string& name);
|
||||
std::string MakeUniqueName(absl::string_view name);
|
||||
|
||||
private:
|
||||
absl::flat_hash_set<std::string> names_set_;
|
||||
int last_n_;
|
||||
};
|
||||
|
||||
std::string NameManager::MakeUniqueName(const std::string& name) {
|
||||
std::string result = name;
|
||||
std::string NameManager::MakeUniqueName(absl::string_view name) {
|
||||
std::string result(name);
|
||||
// Find the 'n' so that "name_n" does not already exist.
|
||||
int n = last_n_;
|
||||
while (!names_set_.insert(result).second) {
|
||||
|
||||
@@ -215,8 +215,8 @@ void ModelBuilderHelper::SafeAddConstraintTerm(int ct_index, int var_index,
|
||||
return;
|
||||
}
|
||||
}
|
||||
// If we reach this point, the variable does not exist in the constraint
|
||||
// yet, so we add it to the constraint as a new term.
|
||||
// If we reach this point, the variable does not exist in the constraint yet,
|
||||
// so we add it to the constraint as a new term.
|
||||
ct_proto->add_var_index(var_index);
|
||||
ct_proto->add_coefficient(coeff);
|
||||
}
|
||||
@@ -235,8 +235,8 @@ void ModelBuilderHelper::SetConstraintCoefficient(int ct_index, int var_index,
|
||||
return;
|
||||
}
|
||||
}
|
||||
// If we reach this point, the variable does not exist in the constraint
|
||||
// yet, so we add it to the constraint as a new term.
|
||||
// If we reach this point, the variable does not exist in the constraint yet,
|
||||
// so we add it to the constraint as a new term.
|
||||
ct_proto->add_var_index(var_index);
|
||||
ct_proto->add_coefficient(coeff);
|
||||
}
|
||||
@@ -328,8 +328,8 @@ void ModelBuilderHelper::SafeAddEnforcedConstraintTerm(int ct_index,
|
||||
return;
|
||||
}
|
||||
}
|
||||
// If we reach this point, the variable does not exist in the constraint
|
||||
// yet, so we add it to the constraint as a new term.
|
||||
// If we reach this point, the variable does not exist in the constraint yet,
|
||||
// so we add it to the constraint as a new term.
|
||||
ct_proto->add_var_index(var_index);
|
||||
ct_proto->add_coefficient(coeff);
|
||||
}
|
||||
@@ -352,8 +352,8 @@ void ModelBuilderHelper::SetEnforcedConstraintCoefficient(int ct_index,
|
||||
return;
|
||||
}
|
||||
}
|
||||
// If we reach this point, the variable does not exist in the constraint
|
||||
// yet, so we add it to the constraint as a new term.
|
||||
// If we reach this point, the variable does not exist in the constraint yet,
|
||||
// so we add it to the constraint as a new term.
|
||||
ct_proto->add_var_index(var_index);
|
||||
ct_proto->add_coefficient(coeff);
|
||||
}
|
||||
|
||||
@@ -468,7 +468,7 @@ class XpressInterface : public MPSolverInterface {
|
||||
std::vector<int> mutable initial_variables_basis_status_;
|
||||
std::vector<int> mutable initial_constraint_basis_status_;
|
||||
|
||||
// Set up the right-hand side of a constraint from its lower and upper bound.
|
||||
// Setup the right-hand side of a constraint from its lower and upper bound.
|
||||
static void MakeRhs(double lb, double ub, double& rhs, char& sense,
|
||||
double& range);
|
||||
|
||||
@@ -970,7 +970,7 @@ void XpressInterface::SetVariableInteger(int var_index, bool integer) {
|
||||
}
|
||||
}
|
||||
|
||||
// Set up the right-hand side of a constraint.
|
||||
// Setup the right-hand side of a constraint.
|
||||
void XpressInterface::MakeRhs(double lb, double ub, double& rhs, char& sense,
|
||||
double& range) {
|
||||
if (lb == ub) {
|
||||
@@ -1366,7 +1366,7 @@ void XpressInterface::ExtractNewVariables() {
|
||||
obj[j] = solver_->objective_->GetCoefficient(var);
|
||||
}
|
||||
|
||||
// Arrays for modifying the problem are set up. Update the index
|
||||
// Arrays for modifying the problem are setup. Update the index
|
||||
// of variables that will get extracted now. Updating indices
|
||||
// _before_ the actual extraction makes things much simpler in
|
||||
// case we support incremental extraction.
|
||||
@@ -1416,7 +1416,7 @@ void XpressInterface::ExtractNewVariables() {
|
||||
unique_ptr<int[]> cmatind(new int[nonzeros]);
|
||||
unique_ptr<double[]> cmatval(new double[nonzeros]);
|
||||
|
||||
// Here is how cmatbeg[] is set up:
|
||||
// Here is how cmatbeg[] is setup:
|
||||
// - it is initialized as
|
||||
// [ 0, 0, collen[0], collen[0]+collen[1], ... ]
|
||||
// so that cmatbeg[j+1] tells us where in cmatind[] and
|
||||
|
||||
@@ -741,8 +741,8 @@ TEST(XpressInterface, Write) {
|
||||
OBJSENSE MAXIMIZE
|
||||
ROWS
|
||||
N __OBJ___
|
||||
L R1
|
||||
L R2
|
||||
L R1
|
||||
L R2
|
||||
COLUMNS
|
||||
C1 __OBJ___ 1
|
||||
C1 R1 3
|
||||
|
||||
Reference in New Issue
Block a user