class_docstr: Wrapper for DIRECT optimization method. It works partitioning iteratively the domain
  of the function. Only requires f and the box constraints to work.
class_docstr_tok: ["Wrapper","for","DIRECT","optimization","method",".","It","works","partitioning","iteratively","the","domain","of","the","function",".","Only","requires","f","and","the","box","constraints","to","work","."]
docstr: :param x0: initial point for a local optimizer.
  :param f: function to optimize.
  :param df: gradient of the function to optimize.
  :param f_df: returns both the function to optimize and its gradient.
docstr_tok: [":","param","x0",":","initial","point","for","a","local","optimizer",".",":","param","f",":","function","to","optimize",".",":","param","df",":","gradient","of","the","function","to","optimize",".",":","param","f_df",":","returns","both","the","function","to","optimize","and","its","gradient","."]
code: def optimize(self, x0, f=None, df=None, f_df=None):
      """
      :param x0: initial point for a local optimizer.
      :param f: function to optimize.
      :param df: gradient of the function to optimize.
      :param f_df: returns both the function to optimize and its gradient.
      """
      # Based on the documentation of DIRECT, it does not seem we can pass through an initial point x0
      try:
          from DIRECT import solve
  
          def DIRECT_f_wrapper(f):
              def g(x, user_data):
                  return f(np.array([x])), 0
  
              return g
  
          lB = np.asarray(self.bounds)[:, 0]
          uB = np.asarray(self.bounds)[:, 1]
          x, _, _ = solve(
              DIRECT_f_wrapper(f), lB, uB, maxT=self.maxiter
          )
          return np.atleast_2d(x), f(np.atleast_2d(x))
      except ImportError:
          print(
              "Cannot find DIRECT library, please install it to use this option."
          )
          raise
  
imports: import numpy
  from ..core.errors import InvalidVariableNameError
label_desc: Use image node_id 2 for calling the OptDirect obj's underlying member method code with example usage: obj.optimize(x0, f, df, f_df) and returns: np,  f, g, f,  int