class_docstr: Unit test class for general utilities. 
class_docstr_tok: ["Unit","test","class","for","general","utilities","."]
docstr: Tests an optimiser method. 
docstr_tok: ["Tests","an","optimiser","method","."]
code: def _test_optimise_method(
      self, minimise_method, maximise_method, test_success=True
  ):
      """Tests an optimiser method."""
      num_min_successes = 0
      num_max_successes = 0
      for prob in self.problems:
          # First the minimimum
          if prob.min_val is not None:
              min_val_soln, min_pt_soln, _ = minimise_method(
                  prob.obj, prob.bounds, self.max_evals
              )
              val_diff = abs(prob.min_val - min_val_soln)
              point_diff = np.linalg.norm(prob.min_pt - min_pt_soln)
              self.report(
                  prob.descr
                  + "(min):: true-val: %0.4f, soln: %0.4f, diff: %0.4f."
                  % (prob.min_val, min_val_soln, val_diff),
                  "test_result",
              )
              self.report(
                  prob.descr
                  + "(min):: true-pt: %s, soln: %s, diff: %0.4f."
                  % (prob.min_pt, min_pt_soln, point_diff),
                  "test_result",
              )
              min_is_successful = (
                  val_diff < 1e-3 and point_diff < 1e-3 * prob.dim
              )
              num_min_successes += min_is_successful
          else:
              num_min_successes += 1
          # Now the maximum
          if prob.max_val is not None:
              max_val_soln, max_pt_soln, _ = maximise_method(
                  prob.obj, prob.bounds, self.max_evals
              )
              val_diff = abs(prob.max_val - max_val_soln)
              point_diff = np.linalg.norm(prob.max_pt - max_pt_soln)
              self.report(
                  prob.descr
                  + "(max):: true-val: %0.4f, soln: %0.4f, diff: %0.4f."
                  % (prob.max_val, max_val_soln, val_diff),
                  "test_result",
              )
              self.report(
                  prob.descr
                  + "(max):: true-pt: %s, soln: %s, diff: %0.4f."
                  % (prob.max_pt, max_pt_soln, point_diff),
                  "test_result",
              )
              max_is_successful = (
                  val_diff < 1e-3 and point_diff < 1e-3 * prob.dim
              )
              num_max_successes += max_is_successful
          else:
              num_max_successes += max_is_successful
      # Check if successful
      if test_success:
          assert num_min_successes == len(self.problems)
          assert num_max_successes == len(self.problems)
  
imports: from __future__ import absolute_import
  import os
  import time
  from argparse import Namespace
  import numpy
  from .ancillary_utils import is_nondecreasing
  from .base_test_class import BaseTestClass, execute_tests
  from .euclidean_synthetic_functions import get_mf_hartmann_function_data
  from .None import oper_utils
label_desc: Use image node_id 4 for calling the OptimisersTestCase obj's underlying member method code with example usage: obj._test_optimise_method(minimise_method, maximise_method, test_success) without return types