original_docstring: Minimize cost given minimum output constraint using binary search.
  
      Given discrete function f, find the minimum integer x such that f(x) >= vmin using
      binary search.
  
      This algorithm only works if f is monotonically increasing, or if f monontonically increases
      then monontonically decreases, but stop is given and f(stop) >= vmin.
  
      Parameters
      ----------
      f : Callable[[int], float]
          a function that takes a single integer and output a scalar value.  Must monotonically
          increase then monotonically decrease.
      vmin : float
          the minimum output value.
      start : int
          the input lower bound.
      stop : Optional[int]
          the input upper bound.  Use None for unbounded binary search.
      step : int
          the input step.  function will only be evaulated at the points start + step * N
      save : Optional[int]
          If not none, this value will be returned if no solution is found.
      nfev : int
          number of function calls already made.
  
      Returns
      -------
      result : MinCostResult
          the MinCostResult named tuple, with attributes:
  
          x : Optional[int]
              the minimum integer such that f(x) >= vmin.  If no such x exists, this will be None.
          nfev : int
              total number of function calls made.
  
      
docstring: Minimize cost given minimum output constraint using binary search.
  Given discrete function f, find the minimum integer x such that f(x) >= vmin using
  binary search.
  
  This algorithm only works if f is monotonically increasing, or if f monontonically increases
  then monontonically decreases, but stop is given and f(stop) >= vmin.
  
  Parameters
  
  f : Callable[[int], float]
  a function that takes a single integer and output a scalar value.  Must monotonically
  increase then monotonically decrease.
  vmin : float
  the minimum output value.
  start : int
  the input lower bound.
  stop : Optional[int]
  the input upper bound.  Use None for unbounded binary search.
  step : int
  the input step.  function will only be evaulated at the points start + step * N
  save : Optional[int]
  If not none, this value will be returned if no solution is found.
  nfev : int
  number of function calls already made.
  
  Returns
  
  result : MinCostResult
  the MinCostResult named tuple, with attributes.
  
  x : Optional[int]
  the minimum integer such that f(x) >= vmin.  If no such x exists, this will be None.
  nfev : int
  total number of function calls made.
docstring_tokens: Minimize cost given minimum output constraint using binary search . Given discrete function f find the minimum integer x such that f ( x ) > = vmin using binary search . This algorithm only works if f is monotonically increasing or if f monontonically increases then monontonically decreases but stop is given and f ( stop ) > = vmin . Parameters f : Callable [[ int ] float ] a function that takes a single integer and output a scalar value . Must monotonically increase then monotonically decrease . vmin : float the minimum output value . start : int the input lower bound . stop : Optional [ int ] the input upper bound . Use None for unbounded binary search . step : int the input step . function will only be evaulated at the points start + step * N save : Optional [ int ] If not none this value will be returned if no solution is found . nfev : int number of function calls already made . Returns result : MinCostResult the MinCostResult named tuple with attributes . x : Optional [ int ] the minimum integer such that f ( x ) > = vmin . If no such x exists this will be None . nfev : int total number of function calls made .
code: def minimize_cost_binary(f,  # type: Callable[[int], float]
                           vmin,  # type: float
                           start=0,  # type: int
                           stop=None,  # type: Optional[int]
                           step=1,  # type: int
                           save=None,  # type: Optional[int]
                           nfev=0,  # type: int
                           ):
      # type: (...) -> MinCostResult
      """Minimize cost given minimum output constraint using binary search.
  
      Given discrete function f, find the minimum integer x such that f(x) >= vmin using
      binary search.
  
      This algorithm only works if f is monotonically increasing, or if f monontonically increases
      then monontonically decreases, but stop is given and f(stop) >= vmin.
  
      Parameters
      ----------
      f : Callable[[int], float]
          a function that takes a single integer and output a scalar value.  Must monotonically
          increase then monotonically decrease.
      vmin : float
          the minimum output value.
      start : int
          the input lower bound.
      stop : Optional[int]
          the input upper bound.  Use None for unbounded binary search.
      step : int
          the input step.  function will only be evaulated at the points start + step * N
      save : Optional[int]
          If not none, this value will be returned if no solution is found.
      nfev : int
          number of function calls already made.
  
      Returns
      -------
      result : MinCostResult
          the MinCostResult named tuple, with attributes:
  
          x : Optional[int]
              the minimum integer such that f(x) >= vmin.  If no such x exists, this will be None.
          nfev : int
              total number of function calls made.
  
      """
      bin_iter = BinaryIterator(start, stop, step=step)
      while bin_iter.has_next():
          x_cur = bin_iter.get_next()
          v_cur = f(x_cur)
          nfev += 1
  
          if v_cur >= vmin:
              save = x_cur
              bin_iter.down()
          else:
              bin_iter.up()
      return MinCostResult(x=save, xmax=None, vmax=None, nfev=nfev)
code_tokens: def minimize_cost_binary ( f , vmin , start = 0 , stop = None , step = 1 , save = None , nfev = 0 , ) : bin_iter = BinaryIterator ( start , stop , step = step ) while bin_iter . has_next ( ) : x_cur = bin_iter . get_next ( ) v_cur = f ( x_cur ) nfev += 1 if v_cur >= vmin : save = x_cur bin_iter . down ( ) else : bin_iter . up ( ) return MinCostResult ( x = save , xmax = None , vmax = None , nfev = nfev )
short_docstring: Minimize cost given minimum output constraint using binary search.
short_docstring_tokens: Minimize cost given minimum output constraint using binary search .
comment: # type: Callable[[int], float]$SEP$# type: float$SEP$# type: int$SEP$# type: Optional[int]$SEP$# type: int$SEP$# type: Optional[int]$SEP$# type: int$SEP$# type: (...) -> MinCostResult$SEP$"""Minimize cost given minimum output constraint using binary search.
  
      Given discrete function f, find the minimum integer x such that f(x) >= vmin using
      binary search.
  
      This algorithm only works if f is monotonically increasing, or if f monontonically increases
      then monontonically decreases, but stop is given and f(stop) >= vmin.
  
      Parameters
      ----------
      f : Callable[[int], float]
          a function that takes a single integer and output a scalar value.  Must monotonically
          increase then monotonically decrease.
      vmin : float
          the minimum output value.
      start : int
          the input lower bound.
      stop : Optional[int]
          the input upper bound.  Use None for unbounded binary search.
      step : int
          the input step.  function will only be evaulated at the points start + step * N
      save : Optional[int]
          If not none, this value will be returned if no solution is found.
      nfev : int
          number of function calls already made.
  
      Returns
      -------
      result : MinCostResult
          the MinCostResult named tuple, with attributes:
  
          x : Optional[int]
              the minimum integer such that f(x) >= vmin.  If no such x exists, this will be None.
          nfev : int
              total number of function calls made.
  
      """