original_docstring: Minimize cost given minimum output constraint using binary search.
  
      Given discrete function f and an interval, find minimum input 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, 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 : float
          the input lower bound.
      stop : float
          the input upper bound.
      tol : float
          output tolerance.
      save : Optional[float]
          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[float]
              the minimum x 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 and an interval, find minimum input 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, 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 : float
  the input lower bound.
  stop : float
  the input upper bound.
  tol : float
  output tolerance.
  save : Optional[float]
  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[float]
  the minimum x 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 and an interval find minimum input 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 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 : float the input lower bound . stop : float the input upper bound . tol : float output tolerance . save : Optional [ float ] 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 [ float ] the minimum x 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_float(f,  # type: Callable[[float], float]
                                 vmin,  # type: float
                                 start,  # type: float
                                 stop,  # type: float
                                 tol=1e-8,  # type: float
                                 save=None,  # type: Optional[float]
                                 nfev=0,  # type: int
                                 ):
      # type: (...) -> MinCostResult
      """Minimize cost given minimum output constraint using binary search.
  
      Given discrete function f and an interval, find minimum input 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, 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 : float
          the input lower bound.
      stop : float
          the input upper bound.
      tol : float
          output tolerance.
      save : Optional[float]
          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[float]
              the minimum x such that f(x) >= vmin.  If no such x exists, this will be None.
          nfev : int
              total number of function calls made.
  
      """
      bin_iter = FloatBinaryIterator(start, stop, tol=tol)
      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_float ( f , vmin , start , stop , tol = 1e-8 , save = None , nfev = 0 , ) : bin_iter = FloatBinaryIterator ( start , stop , tol = tol ) 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[[float], float]$SEP$# type: float$SEP$# type: float$SEP$# type: float$SEP$# type: float$SEP$# type: Optional[float]$SEP$# type: int$SEP$# type: (...) -> MinCostResult$SEP$"""Minimize cost given minimum output constraint using binary search.
  
      Given discrete function f and an interval, find minimum input 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, 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 : float
          the input lower bound.
      stop : float
          the input upper bound.
      tol : float
          output tolerance.
      save : Optional[float]
          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[float]
              the minimum x such that f(x) >= vmin.  If no such x exists, this will be None.
          nfev : int
              total number of function calls made.
  
      """