Skip to content

Commit e01a1fe

Browse files
committed
internal renaming
1 parent d77feb4 commit e01a1fe

File tree

3 files changed

+35
-36
lines changed

3 files changed

+35
-36
lines changed

ortools/sat/python/linear_expr.cc

+11-11
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,8 @@ LinearExpr* LinearExpr::WeightedSumInt(const std::vector<LinearExpr*>& exprs,
9393
return new IntWeightedSum(exprs, coeffs, 0);
9494
}
9595

96-
LinearExpr* LinearExpr::WeightedSumDouble(const std::vector<LinearExpr*>& exprs,
97-
const std::vector<double>& coeffs) {
96+
LinearExpr* LinearExpr::WeightedSumFloat(const std::vector<LinearExpr*>& exprs,
97+
const std::vector<double>& coeffs) {
9898
if (exprs.empty()) return new FloatConstant(0.0);
9999
if (exprs.size() == 1) {
100100
return new FloatAffine(exprs[0], coeffs[0], 0.0);
@@ -140,7 +140,7 @@ LinearExpr* LinearExpr::MixedWeightedSumInt(
140140
return new IntWeightedSum(lin_exprs, lin_coeffs, int_cst);
141141
}
142142

143-
LinearExpr* LinearExpr::MixedWeightedSumDouble(
143+
LinearExpr* LinearExpr::MixedWeightedSumFloat(
144144
const std::vector<ExprOrValue>& exprs, const std::vector<double>& coeffs) {
145145
std::vector<LinearExpr*> lin_exprs;
146146
std::vector<double> lin_coeffs;
@@ -166,7 +166,7 @@ LinearExpr* LinearExpr::TermInt(LinearExpr* expr, int64_t coeff) {
166166
return new IntAffine(expr, coeff, 0);
167167
}
168168

169-
LinearExpr* LinearExpr::TermDouble(LinearExpr* expr, double coeff) {
169+
LinearExpr* LinearExpr::TermFloat(LinearExpr* expr, double coeff) {
170170
return new FloatAffine(expr, coeff, 0.0);
171171
}
172172

@@ -176,8 +176,8 @@ LinearExpr* LinearExpr::AffineInt(LinearExpr* expr, int64_t coeff,
176176
return new IntAffine(expr, coeff, offset);
177177
}
178178

179-
LinearExpr* LinearExpr::AffineDouble(LinearExpr* expr, double coeff,
180-
double offset) {
179+
LinearExpr* LinearExpr::AffineFloat(LinearExpr* expr, double coeff,
180+
double offset) {
181181
if (coeff == 1.0 && offset == 0.0) return expr;
182182
return new FloatAffine(expr, coeff, offset);
183183
}
@@ -186,7 +186,7 @@ LinearExpr* LinearExpr::ConstantInt(int64_t value) {
186186
return new IntConstant(value);
187187
}
188188

189-
LinearExpr* LinearExpr::ConstantDouble(double value) {
189+
LinearExpr* LinearExpr::ConstantFloat(double value) {
190190
return new FloatConstant(value);
191191
}
192192

@@ -199,7 +199,7 @@ LinearExpr* LinearExpr::AddInt(int64_t cst) {
199199
return new IntAffine(this, 1, cst);
200200
}
201201

202-
LinearExpr* LinearExpr::AddDouble(double cst) {
202+
LinearExpr* LinearExpr::AddFloat(double cst) {
203203
if (cst == 0.0) return this;
204204
return new FloatAffine(this, 1.0, cst);
205205
}
@@ -213,7 +213,7 @@ LinearExpr* LinearExpr::SubInt(int64_t cst) {
213213
return new IntAffine(this, 1, -cst);
214214
}
215215

216-
LinearExpr* LinearExpr::SubDouble(double cst) {
216+
LinearExpr* LinearExpr::SubFloat(double cst) {
217217
if (cst == 0.0) return this;
218218
return new FloatAffine(this, 1.0, -cst);
219219
}
@@ -222,7 +222,7 @@ LinearExpr* LinearExpr::RSubInt(int64_t cst) {
222222
return new IntAffine(this, -1, cst);
223223
}
224224

225-
LinearExpr* LinearExpr::RSubDouble(double cst) {
225+
LinearExpr* LinearExpr::RSubFloat(double cst) {
226226
return new FloatAffine(this, -1.0, cst);
227227
}
228228

@@ -232,7 +232,7 @@ LinearExpr* LinearExpr::MulInt(int64_t cst) {
232232
return new IntAffine(this, cst, 0);
233233
}
234234

235-
LinearExpr* LinearExpr::MulDouble(double cst) {
235+
LinearExpr* LinearExpr::MulFloat(double cst) {
236236
if (cst == 0.0) return new IntConstant(0);
237237
if (cst == 1.0) return this;
238238
return new FloatAffine(this, cst, 0.0);

ortools/sat/python/linear_expr.h

+10-11
Original file line numberDiff line numberDiff line change
@@ -65,30 +65,29 @@ class LinearExpr {
6565
static LinearExpr* MixedSum(const std::vector<ExprOrValue>& exprs);
6666
static LinearExpr* WeightedSumInt(const std::vector<LinearExpr*>& exprs,
6767
const std::vector<int64_t>& coeffs);
68-
static LinearExpr* WeightedSumDouble(const std::vector<LinearExpr*>& exprs,
69-
const std::vector<double>& coeffs);
68+
static LinearExpr* WeightedSumFloat(const std::vector<LinearExpr*>& exprs,
69+
const std::vector<double>& coeffs);
7070
static LinearExpr* MixedWeightedSumInt(const std::vector<ExprOrValue>& exprs,
7171
const std::vector<int64_t>& coeffs);
72-
static LinearExpr* MixedWeightedSumDouble(
72+
static LinearExpr* MixedWeightedSumFloat(
7373
const std::vector<ExprOrValue>& exprs, const std::vector<double>& coeffs);
7474
static LinearExpr* TermInt(LinearExpr* expr, int64_t coeff);
75-
static LinearExpr* TermDouble(LinearExpr* expr, double coeff);
75+
static LinearExpr* TermFloat(LinearExpr* expr, double coeff);
7676
static LinearExpr* AffineInt(LinearExpr* expr, int64_t coeff, int64_t offset);
77-
static LinearExpr* AffineDouble(LinearExpr* expr, double coeff,
78-
double offset);
77+
static LinearExpr* AffineFloat(LinearExpr* expr, double coeff, double offset);
7978
static LinearExpr* ConstantInt(int64_t value);
80-
static LinearExpr* ConstantDouble(double value);
79+
static LinearExpr* ConstantFloat(double value);
8180

8281
LinearExpr* Add(LinearExpr* expr);
8382
LinearExpr* AddInt(int64_t cst);
84-
LinearExpr* AddDouble(double cst);
83+
LinearExpr* AddFloat(double cst);
8584
LinearExpr* Sub(LinearExpr* expr);
8685
LinearExpr* SubInt(int64_t cst);
87-
LinearExpr* SubDouble(double cst);
86+
LinearExpr* SubFloat(double cst);
8887
LinearExpr* RSubInt(int64_t cst);
89-
LinearExpr* RSubDouble(double cst);
88+
LinearExpr* RSubFloat(double cst);
9089
LinearExpr* MulInt(int64_t cst);
91-
LinearExpr* MulDouble(double cst);
90+
LinearExpr* MulFloat(double cst);
9291
LinearExpr* Neg();
9392

9493
BoundedLinearExpression* Eq(LinearExpr* rhs);

ortools/sat/python/swig_helper.cc

+14-14
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ PYBIND11_MODULE(swig_helper, m) {
401401
PyExc_ValueError,
402402
"The number of expressions and coefficients must match.");
403403
}
404-
return LinearExpr::WeightedSumDouble(exprs, coeffs);
404+
return LinearExpr::WeightedSumFloat(exprs, coeffs);
405405
},
406406
py::return_value_policy::automatic, py::keep_alive<0, 1>())
407407
.def_static(
@@ -425,27 +425,27 @@ PYBIND11_MODULE(swig_helper, m) {
425425
PyExc_ValueError,
426426
"The number of expressions and coefficients must match.");
427427
}
428-
return LinearExpr::MixedWeightedSumDouble(exprs, coeffs);
428+
return LinearExpr::MixedWeightedSumFloat(exprs, coeffs);
429429
},
430430
py::return_value_policy::automatic, py::keep_alive<0, 1>())
431431
// Make sure to keep the order of the overloads: int before float as an
432432
// an integer value will be silently converted to a float.
433433
.def_static("term", &LinearExpr::TermInt, arg("expr").none(false),
434434
arg("coeff"), "Returns expr * coeff.",
435435
py::return_value_policy::automatic, py::keep_alive<0, 1>())
436-
.def_static("term", &LinearExpr::TermDouble, arg("expr").none(false),
436+
.def_static("term", &LinearExpr::TermFloat, arg("expr").none(false),
437437
arg("coeff"), "Returns expr * coeff.",
438438
py::return_value_policy::automatic, py::keep_alive<0, 1>())
439439
.def_static("affine", &LinearExpr::AffineInt, arg("expr").none(false),
440440
arg("coeff"), arg("offset"), "Returns expr * coeff + offset.",
441441
py::return_value_policy::automatic, py::keep_alive<0, 1>())
442-
.def_static("affine", &LinearExpr::AffineDouble, arg("expr").none(false),
442+
.def_static("affine", &LinearExpr::AffineFloat, arg("expr").none(false),
443443
arg("coeff"), arg("offset"), "Returns expr * coeff + offset.",
444444
py::return_value_policy::automatic, py::keep_alive<0, 1>())
445445
.def_static("constant", &LinearExpr::ConstantInt, arg("value"),
446446
"Returns a constant linear expression.",
447447
py::return_value_policy::automatic)
448-
.def_static("constant", &LinearExpr::ConstantDouble, arg("value"),
448+
.def_static("constant", &LinearExpr::ConstantFloat, arg("value"),
449449
"Returns a constant linear expression.",
450450
py::return_value_policy::automatic)
451451
// Pre PEP8 compatibility layer.
@@ -474,13 +474,13 @@ PYBIND11_MODULE(swig_helper, m) {
474474
PyExc_ValueError,
475475
"The number of expressions and coefficients must match.");
476476
}
477-
return LinearExpr::MixedWeightedSumDouble(exprs, coeffs);
477+
return LinearExpr::MixedWeightedSumFloat(exprs, coeffs);
478478
},
479479
py::return_value_policy::automatic, py::keep_alive<0, 1>())
480480
.def_static("Term", &LinearExpr::TermInt, arg("expr").none(false),
481481
arg("coeff"), "Returns expr * coeff.",
482482
py::return_value_policy::automatic, py::keep_alive<0, 1>())
483-
.def_static("Term", &LinearExpr::TermDouble, arg("expr").none(false),
483+
.def_static("Term", &LinearExpr::TermFloat, arg("expr").none(false),
484484
arg("coeff"), "Returns expr * coeff.",
485485
py::return_value_policy::automatic, py::keep_alive<0, 1>())
486486
// Methods.
@@ -495,30 +495,30 @@ PYBIND11_MODULE(swig_helper, m) {
495495
py::keep_alive<0, 2>())
496496
.def("__add__", &LinearExpr::AddInt, arg("cst"),
497497
py::return_value_policy::automatic, py::keep_alive<0, 1>())
498-
.def("__add__", &LinearExpr::AddDouble, arg("cst"),
498+
.def("__add__", &LinearExpr::AddFloat, arg("cst"),
499499
py::return_value_policy::automatic, py::keep_alive<0, 1>())
500500
.def("__radd__", &LinearExpr::AddInt, arg("cst"),
501501
py::return_value_policy::automatic, py::keep_alive<0, 1>())
502-
.def("__radd__", &LinearExpr::AddDouble, arg("cst"),
502+
.def("__radd__", &LinearExpr::AddFloat, arg("cst"),
503503
py::return_value_policy::automatic, py::keep_alive<0, 1>())
504504
.def("__sub__", &LinearExpr::Sub, arg("other").none(false),
505505
py::return_value_policy::automatic, py::keep_alive<0, 1>(),
506506
py::keep_alive<0, 2>())
507507
.def("__sub__", &LinearExpr::SubInt, arg("cst"),
508508
py::return_value_policy::automatic, py::keep_alive<0, 1>())
509-
.def("__sub__", &LinearExpr::SubDouble, arg("cst"),
509+
.def("__sub__", &LinearExpr::SubFloat, arg("cst"),
510510
py::return_value_policy::automatic, py::keep_alive<0, 1>())
511511
.def("__rsub__", &LinearExpr::RSubInt, arg("cst"),
512512
py::return_value_policy::automatic, py::keep_alive<0, 1>())
513-
.def("__rsub__", &LinearExpr::RSubDouble, arg("cst"),
513+
.def("__rsub__", &LinearExpr::RSubFloat, arg("cst"),
514514
py::return_value_policy::automatic, py::keep_alive<0, 1>())
515515
.def("__mul__", &LinearExpr::MulInt, arg("cst"),
516516
py::return_value_policy::automatic, py::keep_alive<0, 1>())
517-
.def("__mul__", &LinearExpr::MulDouble, arg("cst"),
517+
.def("__mul__", &LinearExpr::MulFloat, arg("cst"),
518518
py::return_value_policy::automatic, py::keep_alive<0, 1>())
519519
.def("__rmul__", &LinearExpr::MulInt, arg("cst"),
520520
py::return_value_policy::automatic, py::keep_alive<0, 1>())
521-
.def("__rmul__", &LinearExpr::MulDouble, arg("cst"),
521+
.def("__rmul__", &LinearExpr::MulFloat, arg("cst"),
522522
py::return_value_policy::automatic, py::keep_alive<0, 1>())
523523
.def("__neg__", &LinearExpr::Neg, py::return_value_policy::automatic,
524524
py::keep_alive<0, 1>())
@@ -724,7 +724,7 @@ PYBIND11_MODULE(swig_helper, m) {
724724
This method implements the logical negation of a Boolean variable.
725725
It is only valid if the variable has a Boolean domain (0 or 1).
726726
727-
Note that this method is nilpotent: `x.negated().negated() == x`.
727+
Note that this method is nilpotent: `x.negated().negated() == x`.
728728
)doc")
729729
.def("__invert__", &Literal::negated,
730730
"Returns the negation of the current literal.")

0 commit comments

Comments
 (0)