code: def local_optimize(cost, x0, lb, ub):
      from mystic.solvers import PowellDirectionalSolver
      from mystic.termination import (
          NormalizedChangeOverGeneration as NCOG,
      )
      from mystic.monitors import VerboseMonitor, Monitor
  
      maxiter = 1000
      maxfun = 1e6
      convergence_tol = 1e-4
  
      # stepmon = VerboseMonitor(100)
      stepmon = Monitor()
      evalmon = Monitor()
  
      ndim = len(lb)
  
      solver = PowellDirectionalSolver(ndim)
      solver.SetInitialPoints(x0)
      solver.SetStrictRanges(min=lb, max=ub)
      solver.SetEvaluationLimits(maxiter, maxfun)
      solver.SetEvaluationMonitor(evalmon)
      solver.SetGenerationMonitor(stepmon)
  
      tol = convergence_tol
      solver.Solve(cost, termination=NCOG(tol))
  
      solved_params = solver.bestSolution
      solved_energy = solver.bestEnergy
      func_evals = solver.evaluations
      return solved_params, solved_energy, func_evals
  
imports: from mystic.math.grid import samplepts
  from surrogate import ballistic_limit
label_desc: Use image node_id 2 for calling a global function with example usage: local_optimize(cost, x0, lb, ub) and returns: solved_params,  solved_energy,  func_evals