code: def optimize(
      solver_config, constraints, default, call_log, maximize, max_evals
  ):
      """Emulates :func:`optunity.optimize`."""
      replacements = comm._find_replacements(
          _illegal_keys, solver_config
      )
      solver_config = comm._replace_keys(solver_config, replacements)
      constraints = comm._replace_keys(constraints, replacements)
  
      # prepare objective function
      mgr = comm.EvalManager(replacements=replacements)
      func = prepare_fun(mgr, constraints, default, call_log)
  
      # make the solver
      try:
          solver = optunity.make_solver(**solver_config)
      except (ValueError, KeyError) as e:
          msg = {"error_msg": "Unable to instantiate solver: " + str(e)}
          comm.send(comm.json_encode(msg))
          print(solver_config, file=sys.stderr)
          exit(1)
  
      # solve problem
      try:
          solution, rslt = optunity.optimize(
              solver,
              func,
              maximize=maximize,
              max_evals=max_evals,
              pmap=mgr.pmap,
          )
      except EOFError:
          msg = {"error_msg": "Broken pipe."}
          comm.send(comm.json_encode(msg))
          exit(1)
  
      # send solution and exit
      result = rslt._asdict()
      result["solution"] = solution
      result_json = comm.json_encode(result)
      comm.send(result_json)
      exit(0)
  
file_path: optunity/wrappers/R/inst/optunity/standalone.py
imports: from __future__ import print_function
  import sys
  import keyword
  from .None import communication
  from .None import functions
  import optunity
label_desc: Use image node_id 7 for calling a global function with example usage: optimize(solver_config, constraints, default, call_log, maximize, max_evals) without return types