From 330a4d9508ed0547a71a5617ea5fb2c6702060e4 Mon Sep 17 00:00:00 2001 From: Laurent Perron Date: Mon, 6 Nov 2023 18:08:34 +0100 Subject: [PATCH] polish --- .../proto_solver/sat_proto_solver.cc | 8 ++++++++ ortools/linear_solver/python/model_builder.py | 16 +++++++--------- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/ortools/linear_solver/proto_solver/sat_proto_solver.cc b/ortools/linear_solver/proto_solver/sat_proto_solver.cc index cc891d5887..e6ee312e32 100644 --- a/ortools/linear_solver/proto_solver/sat_proto_solver.cc +++ b/ortools/linear_solver/proto_solver/sat_proto_solver.cc @@ -26,15 +26,23 @@ #include #include +#include "absl/log/check.h" +#include "absl/status/status.h" #include "absl/status/statusor.h" +#include "absl/strings/str_cat.h" #include "absl/types/span.h" +#include "ortools/base/logging.h" +#include "ortools/glop/preprocessor.h" #include "ortools/linear_solver/linear_solver.pb.h" #include "ortools/linear_solver/model_validator.h" #include "ortools/linear_solver/proto_solver/sat_solver_utils.h" +#include "ortools/lp_data/lp_data.h" +#include "ortools/lp_data/lp_types.h" #include "ortools/port/proto_utils.h" #include "ortools/sat/cp_model.pb.h" #include "ortools/sat/cp_model_solver.h" #include "ortools/sat/lp_utils.h" +#include "ortools/sat/model.h" #include "ortools/sat/parameters_validation.h" #include "ortools/sat/sat_parameters.pb.h" #include "ortools/util/logging.h" diff --git a/ortools/linear_solver/python/model_builder.py b/ortools/linear_solver/python/model_builder.py index 3ad6388068..1086ba434d 100644 --- a/ortools/linear_solver/python/model_builder.py +++ b/ortools/linear_solver/python/model_builder.py @@ -464,9 +464,9 @@ def _add_enforced_linear_constraint_to_helper( Args: bounded_expr: The bounded expression used to create the constraint. + helper: The helper to create the constraint. var: the variable used in the indicator value: the value used in the indicator - helper: The helper to create the constraint. name: The name of the constraint to be created. Returns: @@ -531,7 +531,7 @@ class VarEqVar(_BoundedLinearExpr): def _add_enforced_linear_constraint( self, helper: mbh.ModelBuilderHelper, - var: "Variable", + var: Variable, value: bool, name: str, ) -> "EnforcedLinearConstraint": @@ -566,17 +566,15 @@ class BoundedLinearExpression(_BoundedLinearExpr): def __str__(self) -> str: if self.__lb > -math.inf and self.__ub < math.inf: if self.__lb == self.__ub: - return str(self.__expr) + " == " + str(self.__lb) + return f"{self.__expr} == {self.__lb}" else: - return ( - str(self.__lb) + " <= " + str(self.__expr) + " <= " + str(self.__ub) - ) + return f"{self.__lb} <= {self.__expr} <= {self.__ub}" elif self.__lb > -math.inf: - return str(self.__expr) + " >= " + str(self.__lb) + return f"{self.__expr} >= {self.__lb}" elif self.__ub < math.inf: - return str(self.__expr) + " <= " + str(self.__ub) + return f"{self.__expr} <= {self.__ub}" else: - return str(self.__expr) + " free" + return f"{self.__expr} free" def __repr__(self): return self.__str__()