3939
4040* [`Constraint`](#cp_model.Constraint): A few utility methods for modifying
4141 constraints created by `CpModel`.
42- * [`LinearExpr`](#lineacp_model .LinearExpr): Methods for creating constraints
42+ * [`LinearExpr`](#cp_model .LinearExpr): Methods for creating constraints
4343 and the objective from large arrays of coefficients.
4444
4545Other methods and functions listed are primarily used for developing OR-Tools,
8686
8787# CpSolver status (exported to avoid importing cp_model_cp2).
8888UNKNOWN = cmh .CpSolverStatus .UNKNOWN
89- UNKNOWN = cmh .CpSolverStatus .UNKNOWN
9089MODEL_INVALID = cmh .CpSolverStatus .MODEL_INVALID
9190FEASIBLE = cmh .CpSolverStatus .FEASIBLE
9291INFEASIBLE = cmh .CpSolverStatus .INFEASIBLE
@@ -829,6 +828,18 @@ def add_reservoir_constraint(
829828 ValueError: if min_level > 0
830829 """
831830
831+ if max_level < min_level :
832+ raise ValueError ("Reservoir constraint must have a max_level >= min_level" )
833+
834+ if max_level < 0 :
835+ raise ValueError ("Reservoir constraint must have a max_level >= 0" )
836+
837+ if min_level > 0 :
838+ raise ValueError ("Reservoir constraint must have a min_level <= 0" )
839+
840+ if not times :
841+ raise ValueError ("Reservoir constraint must have a non-empty times array" )
842+
832843 return self ._add_reservoir (
833844 times ,
834845 level_changes ,
@@ -1570,12 +1581,14 @@ def maximize(self, obj: ObjLinearExprT):
15701581 self ._set_objective (obj , maximize = True )
15711582
15721583 def has_objective (self ) -> bool :
1584+ """Returns true if the model has an objective (integer or floating point)."""
15731585 return (
15741586 self .model_proto .has_objective ()
15751587 or self .model_proto .has_floating_point_objective ()
15761588 )
15771589
15781590 def clear_objective (self ):
1591+ """Clears the objective of the model."""
15791592 self .model_proto .clear_objective ()
15801593 self .model_proto .clear_floating_point_objective ()
15811594
@@ -2126,7 +2139,7 @@ def boolean_value(self, lit: LiteralT) -> bool:
21262139 return self .BooleanValue (lit )
21272140
21282141 def value (self , expression : LinearExprT ) -> int :
2129- """Evaluates an linear expression in the current solution.
2142+ """Evaluates a linear expression in the current solution.
21302143
21312144 Args:
21322145 expression: a linear expression of the model.
@@ -2143,13 +2156,13 @@ def value(self, expression: LinearExprT) -> int:
21432156 return self .Value (expression )
21442157
21452158 def float_value (self , expression : LinearExprT ) -> float :
2146- """Evaluates an linear expression in the current solution.
2159+ """Evaluates a linear expression in the current solution.
21472160
21482161 Args:
21492162 expression: a linear expression of the model.
21502163
21512164 Returns:
2152- An integer value equal to the evaluation of the linear expression
2165+ A float value equal to the evaluation of the linear expression
21532166 against the current solution.
21542167
21552168 Raises:
@@ -2219,7 +2232,7 @@ def num_binary_propagations(self) -> int:
22192232
22202233 @property
22212234 def deterministic_time (self ) -> float :
2222- """Returns the determistic time in seconds since the creation of the solver."""
2235+ """Returns the deterministic time in seconds since the creation of the solver."""
22232236 if not self .has_response ():
22242237 raise RuntimeError ("solve() has not been called." )
22252238 return self .DeterministicTime ()
0 commit comments