code: def maximise_function(
      func,
      domain,
      max_capital,
      opt_method="bo",
      worker_manager="default",
      num_workers=1,
      capital_type="num_evals",
      config=None,
      options=None,
      reporter="default",
  ):
      """
      Maximises a function 'func' over the domain 'domain'.
      Inputs:
        func: The function to be maximised.
        domain: The domain over which the function should be maximised, should be an
                instance of the Domain class in exd/domains.py.
                If domain is a list of the form [[l1, u1], [l2, u2], ...] where li < ui,
                then we will create a Euclidean domain with lower bounds li and upper bounds
                ui along each dimension.
        max_capital: The maximum capital (time budget or number of evaluations) available
                     for optimisation.
        opt_method: The method used for optimisation. Could be one of bo, rand, ga, ea,
                    direct, or pdoo. Default is bo.
                    bo - Bayesian optimisation, ea/ga: Evolutionary algorithm,
                    rand - Random search, direct: Dividing Rectangles, pdoo: PDOO
        worker_manager: Should be an instance of WorkerManager (see exd/worker_manager.py)
                        or a string with one of the following values
                        {'default', 'synthetic', 'multiprocessing', 'scheduling'}.
        num_workers: The number of parallel workers (i.e. number of evaluations to carry
                     out in parallel).
        capital_type: The type of capital. Should be one of 'return_value' or 'realtime'.
                      Default is return_value which indicates we will use the value returned
                      by fidel_cost_func. If realtime, we will use wall clock time.
        config: Contains configuration parameters that are typically returned by
                exd.cp_domain_utils.load_config_file. config can be None only if domain
                is a EuclideanDomain object.
        options: Additional hyper-parameters for optimisation, as a namespace.
        reporter: A stream to print progress made during optimisation, or one of the
                  following strings 'default', 'silent'. If 'silent', then it suppresses
                  all outputs. If 'default', writes to stdout.
        * Alternatively, domain could be None if config is either a path_name to a
          configuration file or has configuration parameters.
      Returns:
        opt_val: The maximum value found during the optimisatio procdure.
        opt_pt: The corresponding optimum point.
        history: A record of the optimisation procedure which include the point evaluated
                 and the values at each time step.
      """
      # Preprocess domain and config arguments
      raw_func = func
      (
          domain,
          preproc_func_list,
          config,
          converted_cp_to_euclidean,
      ) = preprocess_arguments(domain, [func], config)
      func = preproc_func_list[0]
      # Load arguments depending on domain type
      if domain.get_type() == "euclidean":
          func_caller = EuclideanFunctionCaller(
              func, domain, vectorised=False, config=config
          )
      else:
          func_caller = CPFunctionCaller(
              func,
              domain,
              raw_func=raw_func,
              domain_orderings=config.domain_orderings,
              config=config,
          )
      # load options
      options = load_options_for_method(
          opt_method, "opt", domain, capital_type, options
      )
      # Create worker manager and function caller
      worker_manager = get_worker_manager_from_type(
          num_workers=num_workers,
          worker_manager_type=worker_manager,
          capital_type=capital_type,
      )
      # Optimise function here -----------------------------------------------------------
      if opt_method == "bo":
          options = preprocess_options_for_gp_bandits(
              options, config, "opt", converted_cp_to_euclidean
          )
          opt_val, opt_pt, history = gpb_from_func_caller(
              func_caller,
              worker_manager,
              max_capital,
              is_mf=False,
              options=options,
              reporter=reporter,
          )
      elif opt_method in ["ga", "ea"]:
          opt_val, opt_pt, history = cp_ga_optimiser_from_proc_args(
              func_caller,
              domain,
              worker_manager,
              max_capital,
              options=options,
              reporter=reporter,
          )
      elif opt_method == "rand":
          opt_val, opt_pt, history = random_optimiser_from_func_caller(
              func_caller,
              worker_manager,
              max_capital,
              options=options,
              reporter=reporter,
          )
      elif opt_method == "direct":
          opt_val, opt_pt, history = direct_ft_maximise(
              func, domain.bounds, int(max_capital), return_history=True
          )
      elif opt_method == "pdoo":
          opt_val, opt_pt, history = pdoo_maximise_from_args(
              func, domain.bounds, int(max_capital), return_history=True
          )
      # Post processing
      if domain.get_type() == "euclidean" and config is None:
          if opt_method not in ["direct", "pdoo"]:
              opt_pt = func_caller.get_raw_domain_coords(opt_pt)
              history.curr_opt_points = [
                  func_caller.get_raw_domain_coords(pt)
                  for pt in history.curr_opt_points
              ]
              history.query_points = [
                  func_caller.get_raw_domain_coords(pt)
                  for pt in history.query_points
              ]
      else:
          opt_pt = get_raw_from_processed_via_config(opt_pt, config)
          history.curr_opt_points_raw = [
              get_raw_from_processed_via_config(pt, config)
              for pt in history.curr_opt_points
          ]
          history.query_points_raw = [
              get_raw_from_processed_via_config(pt, config)
              for pt in history.query_points
          ]
      return opt_val, opt_pt, history
  
file_path: dragonfly/dragonfly/apis/opt.py
imports: from .api_utils import get_worker_manager_from_type, load_options_for_method, post_process_history_for_minimisation, preprocess_arguments, preprocess_multifidelity_arguments, preprocess_options_for_gp_bandits
  from ..exd.experiment_caller import EuclideanFunctionCaller, CPFunctionCaller
  from ..exd.cp_domain_utils import get_raw_from_processed_via_config
  from ..opt.cp_ga_optimiser import cp_ga_optimiser_from_proc_args
  from ..opt.gp_bandit import gpb_from_func_caller
  from ..opt.random_optimiser import random_optimiser_from_func_caller, mf_random_optimiser_from_func_caller
  from ..utils.oper_utils import direct_ft_maximise
  from ..utils.doo import pdoo_maximise_from_args
label_desc: Use image node_id 2 for calling a global function with example usage: maximise_function(func, domain, max_capital, opt_method, worker_manager, num_workers, capital_type, config, options, reporter) and returns: opt_val,  opt_pt,  history