class_docstr: .. include:: /global.rst
  
  Please refer to |randomsearch| for more details about this algorithm.
class_docstr_tok: ["..","include",":",":","\/global.rst","Please","refer","to","|randomsearch|","for","more","details","about","this","algorithm","."]
code: def optimize(self, f, maximize=True, pmap=map):
      def generate_rand_args(len=1):
          #            return [uniform_in_bounds(self.bounds)]
          return [
              [random.uniform(bounds[0], bounds[1]) for _ in range(len)]
              for _, bounds in self.bounds.items()
          ]
  
      best_pars = None
      f = static_key_order(self.bounds.keys())(f)
  
      if maximize:
          comp = lambda score, best: score > best
      else:
          comp = lambda score, best: score < best
  
      tuples = generate_rand_args(self.num_evals)
      scores = pmap(f, *tuples)
      scores = map(util.score, scores)
  
      if maximize:
          comp = max
      else:
          comp = min
      best_idx, _ = comp(enumerate(scores), key=op.itemgetter(1))
      best_pars = op.itemgetter(best_idx)(list(zip(*tuples)))
      return (
          dict([(k, v) for k, v in zip(self.bounds.keys(), best_pars)]),
          None,
      )
  
file_path: optunity/wrappers/R/inst/optunity/solvers/RandomSearch.py
imports: import operator
  import random
  from ..functions import static_key_order
  from .solver_registry import register_solver
  from .util import Solver, _copydoc, shrink_bounds, uniform_in_bounds
  from .None import util
label_desc: Use image node_id 7 for calling the RandomSearch obj's underlying member method code with example usage: obj.optimize(f, maximize, pmap) and returns: dict,  None, unknown