code: def direct_ft_minimise(
      obj,
      bounds,
      max_evals,
      return_history=False,
      eps=1e-5,
      max_iterations=None,
      alg_method=0,
      fglobal=-1e100,
      fglper=0.01,
      volper=-1.0,
      sigmaper=-1.0,
      log_file_name="",
      results_file_name="",
      vectorised=False,
      alternative_if_direct_not_loaded="pdoo",
  ):
      """
      A wrapper for the fortran implementation. The four mandatory arguments are self
      explanatory. If return_history is True it also returns the history of evaluations.
      max_iterations is the maximum number of iterations of the direct algorithm.
      I am not sure what the remaining arguments are for.
      """
      # pylint: disable=too-many-locals
      # pylint: disable=too-many-arguments
      if direct_ft_wrap is None:
          report_str = "Attempted to use direct, but fortran library could not be imported. "
          if alternative_if_direct_not_loaded is None:
              report_str += (
                  "Alternative not specified. Raising exception."
              )
              raise Exception(report_str)
          elif alternative_if_direct_not_loaded.lower().startswith(
              "rand"
          ):
              report_str += "Using random optimiser instead of direct."
              warn(report_str)
              return random_minimise(obj, bounds, max_evals, vectorised)
          elif alternative_if_direct_not_loaded.lower().startswith(
              "pdoo"
          ):
              report_str += "Using PDOO optimiser instead of direct."
              warn(report_str)
              return pdoo_minimise(obj, bounds, max_evals)
          else:
              report_str += (
                  "Unknown option for alternative_if_direct_not_loaded: %s"
                  % (alternative_if_direct_not_loaded)
              )
              raise ValueError(report_str)
  
      # Preliminaries.
      max_evals = min(
          _MAX_DIRECT_FN_EVALS, max_evals
      )  # otherwise the fortran sw complains.
      max_iterations = (
          max_evals if max_iterations is None else max_iterations
      )
      bounds = np.array(bounds, dtype=np.float64)
      lower_bounds = bounds[:, 0]
      upper_bounds = bounds[:, 1]
      if len(lower_bounds) != len(upper_bounds):
          raise ValueError(
              "The dimensionality of the lower and upper bounds should match."
          )
  
      # Create a wrapper to comply with the fortran requirements.
      def _objective_wrap(x, *_):
          """A wrapper to comply with the fortran requirements."""
          return (obj(x), 0)
  
      # Some dummy data to comply with the fortran requirements.
      iidata = np.ones(0, dtype=np.int32)
      ddata = np.ones(0, dtype=np.float64)
      cdata = np.ones([0, 40], dtype=np.uint8)
  
      # Set up results_file_name if necessary
      if return_history:
          results_file_name = (
              results_file_name
              if results_file_name
              else "direct_results_%s"
              % (datetime.now().strftime("%m%d-%H%M%S"))
          )
      # Call the function.
      min_pt, min_val, _ = direct_ft_wrap.direct(
          _objective_wrap,
          eps,
          max_evals,
          max_iterations,
          lower_bounds,
          upper_bounds,
          alg_method,
          log_file_name,
          results_file_name,
          fglobal,
          fglper,
          volper,
          sigmaper,
          iidata,
          ddata,
          cdata,
      )
      if return_history:
          history = get_direct_history(results_file_name)
          os.remove(results_file_name)
      else:
          history = None
      # return
      return min_val, min_pt, history
  
imports: from __future__ import print_function
  from __future__ import division
  from argparse import Namespace
  from datetime import datetime
  from warnings import warn
  import os
  import numpy
  from .general_utils import map_to_bounds
  from .doo import DOOFunction, pdoo_wrap
label_desc: Use image node_id 5 for calling a global function with example usage: direct_ft_minimise(obj, bounds, max_evals, return_history, eps, max_iterations, alg_method, fglobal, fglper, volper, sigmaper, log_file_name, results_file_name, vectorised, alternative_if_direct_not_loaded) and returns: min_val,  min_pt,  history, obj,  int, random_minimise, pdoo_minimise