diff --git a/ortools/flatzinc/ortools.msc.in b/ortools/flatzinc/ortools.msc.in index f954d1553d..1cc19d526b 100644 --- a/ortools/flatzinc/ortools.msc.in +++ b/ortools/flatzinc/ortools.msc.in @@ -8,7 +8,7 @@ "tags": ["ortools", "cp", "lcg", "int"], "stdFlags": ["-a", "-f", "-p", "-r", "-s", "-v"], "extraFlags": [ - ["--params", "Provide parameters interpreted as a text SatParameters proto", "string", ""], + ["--params", "Provide parameters interpreted as a text SatParameters proto", "string", ""] ], "supportsMzn": false, "supportsFzn": true, diff --git a/ortools/java/com/google/ortools/modelbuilder/ModelSolver.java b/ortools/java/com/google/ortools/modelbuilder/ModelSolver.java index 9016384996..bb2de343fb 100644 --- a/ortools/java/com/google/ortools/modelbuilder/ModelSolver.java +++ b/ortools/java/com/google/ortools/modelbuilder/ModelSolver.java @@ -119,7 +119,8 @@ public final class ModelSolver { } /** - * Checks that the solver has found a solution, and returns the ual value of the given constraint. + * Checks that the solver has found a solution, and returns the dual value of the given + * constraint. */ public double getDualValue(LinearConstraint ct) { if (!helper.hasSolution()) { diff --git a/ortools/linear_solver/python/model_builder.py b/ortools/linear_solver/python/model_builder.py index 0315ef1680..427ce7a148 100644 --- a/ortools/linear_solver/python/model_builder.py +++ b/ortools/linear_solver/python/model_builder.py @@ -47,6 +47,7 @@ IntegerT = Union[numbers.Integral, np.integer] LinearExprT = Union['LinearExpr', NumberT] ConstraintT = Union['VarCompVar', 'BoundedLinearExpression', bool] ShapeT = Union[IntegerT, Sequence[IntegerT]] +VariablesT = Union['VariableContainer', 'Variable'] NumpyFuncT = Callable[[ 'VariableContainer', Optional[Union[NumberT, npt.NDArray[np.number], Sequence[NumberT]]], @@ -578,10 +579,7 @@ class VariableContainer(mixins.NDArrayOperatorsMixin): def variable_indices(self) -> npt.NDArray[np.int32]: return self.__variable_indices - def __getitem__( - self, - pos: SliceT, - ) -> Union['VariableContainer', Variable]: + def __getitem__(self, pos: SliceT) -> VariablesT: # delegate the treatment of the 'pos' query to __variable_indices. index_or_slice: Union[np.int32, npt.NDArray[np.int32]] = ( self.__variable_indices[pos]) @@ -590,11 +588,7 @@ class VariableContainer(mixins.NDArrayOperatorsMixin): else: return VariableContainer(self.__helper, index_or_slice) - def index_at( - self, - pos: Union[slice, int, List[int], Tuple[Union[int, slice, List[int]], - ...]], - ) -> Union[np.int32, npt.NDArray[np.int32]]: + def index_at(self, pos: SliceT) -> Union[np.int32, npt.NDArray[np.int32]]: """Returns the index of the variable at the position 'pos'.""" return self.__variable_indices[pos] @@ -616,6 +610,10 @@ class VariableContainer(mixins.NDArrayOperatorsMixin): """Returns the number of variables in the numpy array.""" return self.__variable_indices.size + def ravel(self) -> 'VariableContainer': + """returns the ravel array of variables.""" + return VariableContainer(self.__helper, self.__variable_indices.ravel()) + def flatten(self) -> 'VariableContainer': """returns the flattened array of variables.""" return VariableContainer(self.__helper, diff --git a/ortools/linear_solver/wrappers/model_builder_helper.cc b/ortools/linear_solver/wrappers/model_builder_helper.cc index 8fad58ccb7..55714c698d 100644 --- a/ortools/linear_solver/wrappers/model_builder_helper.cc +++ b/ortools/linear_solver/wrappers/model_builder_helper.cc @@ -347,6 +347,8 @@ void ModelSolverHelper::Solve(const ModelBuilderHelper& model) { model_of_last_solve_ = &model.model(); activities_.assign(model.num_constraints(), std::numeric_limits::quiet_NaN()); + } else { + activities_.clear(); } }