parameters: (self, times, level_changes, actives,
                                           min_level, max_level)
return_statement: return ct
docstring: Adds Reservoir(times, level_changes, actives, min_level, max_level).
  
      Maintains a reservoir level within bounds. The water level starts at 0, and
      at any time, it must be between min_level and max_level.
  
      If the variable `times[i]` is assigned a value t, and `actives[i]` is
      `True`, then the current level changes by `level_changes[i]`, which is
      constant,
      at time t.
  
       Note that min level must be <= 0, and the max level must be >= 0. Please
       use fixed level_changes to simulate initial state.
  
       Therefore, at any time:
           sum(level_changes[i] * actives[i] if times[i] <= t) in [min_level,
           max_level]
  
  
      The array of boolean variables 'actives', if defined, indicates which
      actions are actually performed.
  
      Args:
        times: A list of affine expressions which specify the time of the filling
          or emptying the reservoir.
        level_changes: A list of integer values that specifies the amount of the
          emptying or filling.
        actives: a list of boolean variables. They indicates if the
          emptying/refilling events actually take place.
        min_level: At any time, the level of the reservoir must be greater or
          equal than the min level.
        max_level: At any time, the level of the reservoir must be less or equal
          than the max level.
  
      Returns:
        An instance of the `Constraint` class.
  
      Raises:
        ValueError: if max_level < min_level.
  
        ValueError: if max_level < 0.
  
        ValueError: if min_level > 0
docstring_summary: Adds Reservoir(times, level_changes, actives, min_level, max_level).
docstring_tokens: Adds Reservoir ( times level_changes actives min_level max_level ) .
function: def AddReservoirConstraintWithActive(self, times, level_changes, actives,
                                           min_level, max_level):
          """Adds Reservoir(times, level_changes, actives, min_level, max_level).
  
      Maintains a reservoir level within bounds. The water level starts at 0, and
      at any time, it must be between min_level and max_level.
  
      If the variable `times[i]` is assigned a value t, and `actives[i]` is
      `True`, then the current level changes by `level_changes[i]`, which is
      constant,
      at time t.
  
       Note that min level must be <= 0, and the max level must be >= 0. Please
       use fixed level_changes to simulate initial state.
  
       Therefore, at any time:
           sum(level_changes[i] * actives[i] if times[i] <= t) in [min_level,
           max_level]
  
  
      The array of boolean variables 'actives', if defined, indicates which
      actions are actually performed.
  
      Args:
        times: A list of affine expressions which specify the time of the filling
          or emptying the reservoir.
        level_changes: A list of integer values that specifies the amount of the
          emptying or filling.
        actives: a list of boolean variables. They indicates if the
          emptying/refilling events actually take place.
        min_level: At any time, the level of the reservoir must be greater or
          equal than the min level.
        max_level: At any time, the level of the reservoir must be less or equal
          than the max level.
  
      Returns:
        An instance of the `Constraint` class.
  
      Raises:
        ValueError: if max_level < min_level.
  
        ValueError: if max_level < 0.
  
        ValueError: if min_level > 0
      """
  
          if max_level < min_level:
              return ValueError(
                  'Reservoir constraint must have a max_level >= min_level')
  
          if max_level < 0:
              return ValueError('Reservoir constraint must have a max_level >= 0')
  
          if min_level > 0:
              return ValueError('Reservoir constraint must have a min_level <= 0')
  
          ct = Constraint(self.__model.constraints)
          model_ct = self.__model.constraints[ct.Index()]
          model_ct.reservoir.time_exprs.extend(
              [self.ParseLinearExpression(x) for x in times])
          model_ct.reservoir.level_changes.extend(level_changes)
          model_ct.reservoir.active_literals.extend(
              [self.GetOrMakeIndex(x) for x in actives])
          model_ct.reservoir.min_level = min_level
          model_ct.reservoir.max_level = max_level
          return ct
function_tokens: def AddReservoirConstraintWithActive ( self , times , level_changes , actives , min_level , max_level ) : if max_level < min_level : return ValueError ( 'Reservoir constraint must have a max_level >= min_level' ) if max_level < 0 : return ValueError ( 'Reservoir constraint must have a max_level >= 0' ) if min_level > 0 : return ValueError ( 'Reservoir constraint must have a min_level <= 0' ) ct = Constraint ( self . __model . constraints ) model_ct = self . __model . constraints [ ct . Index ( ) ] model_ct . reservoir . time_exprs . extend ( [ self . ParseLinearExpression ( x ) for x in times ] ) model_ct . reservoir . level_changes . extend ( level_changes ) model_ct . reservoir . active_literals . extend ( [ self . GetOrMakeIndex ( x ) for x in actives ] ) model_ct . reservoir . min_level = min_level model_ct . reservoir . max_level = max_level return ct