class_docstr: Implementation that contains the main Bayesian optimization loop.
  
  Parameters
  ----------
  scenario : Scenario
      The scenario object, holding all environmental information.
  runner : AbstractRunner
      The runner (containing the target function) is called internally to judge a trial's performance.
  runhistory : Runhistory
      The runhistory stores all trials.
  intensifier : AbstractIntensifier
      The intensifier decides which trial (combination of configuration, seed, budget and instance) should be run
      next.
  overwrite: bool, defaults to False
      When True, overwrites the run results if a previous run is found that is
      inconsistent in the meta data with the current setup. If ``overwrite`` is set to False, the user is asked
      for the exact behaviour (overwrite completely, save old run, or use old results).
  
  Warning
  -------
  This model should be initialized by a facade only.
class_docstr_tok: ["Implementation","that","contains","the","main","Bayesian","optimization","loop",".","Parameters","--","--","--","--","--","scenario",":","Scenario","The","scenario","object",",","holding","all","environmental","information",".","runner",":","AbstractRunner","The","runner","(","containing","the","target","function",")","is","called","internally","to","judge","a","trial","'s","performance",".","runhistory",":","Runhistory","The","runhistory","stores","all","trials",".","intensifier",":","AbstractIntensifier","The","intensifier","decides","which","trial","(","combination","of","configuration",",","seed",",","budget","and","instance",")","should","be","run","next",".","overwrite",":","bool",",","defaults","to","False","When","True",",","overwrites","the","run","results","if","a","previous","run","is","found","that","is","inconsistent","in","the","meta","data","with","the","current","setup",".","If","``","overwrite","``","is","set","to","False",",","the","user","is","asked","for","the","exact","behaviour","(","overwrite","completely",",","save","old","run",",","or","use","old","results",")",".","Warning","--","--","--","-","This","model","should","be","initialized","by","a","facade","only","."]
docstr: Adds results from the runner to the runhistory. Although most of the functionality could be written
  in the tell method, we separate it here to make it accessible for the automatic optimization procedure only.
code: def _add_results(self) -> None:
      """Adds results from the runner to the runhistory. Although most of the functionality could be written
      in the tell method, we separate it here to make it accessible for the automatic optimization procedure only.
      """
      # Check if there is any result
      for trial_info, trial_value in self._runner.iter_results():
          # Add the results of the run to the run history
          self.tell(trial_info, trial_value)
  
          # We expect the first run to always succeed.
          if (
              self.runhistory.finished == 0
              and trial_value.status == StatusType.CRASHED
          ):
              additional_info = ""
              if "traceback" in trial_value.additional_info:
                  additional_info = (
                      "\n\n" + trial_value.additional_info["traceback"]
                  )
  
              raise FirstRunCrashedException(
                  "The first run crashed. Please check your setup again."
                  + additional_info
              )
  
          # Update SMAC stats
          self._used_target_function_walltime += float(trial_value.time)
  
          # Gracefully end optimization if termination cost is reached
          if self._scenario.termination_cost_threshold != np.inf:
              cost = self.runhistory.average_cost(trial_info.config)
  
              if not isinstance(cost, list):
                  cost = [cost]
  
              if not isinstance(
                  self._scenario.termination_cost_threshold, list
              ):
                  cost_threshold = [
                      self._scenario.termination_cost_threshold
                  ]
              else:
                  cost_threshold = (
                      self._scenario.termination_cost_threshold
                  )
  
              if len(cost) != len(cost_threshold):
                  raise RuntimeError(
                      "You must specify a termination cost threshold for each objective."
                  )
  
              if all(
                  cost[i] < cost_threshold[i] for i in range(len(cost))
              ):
                  logger.info(
                      "Cost threshold was reached. Abort is requested."
                  )
                  self._stop = True
  
imports: from __future__ import annotations
  from typing import Any
  import json
  import time
  from pathlib import Path
  import numpy
  from ConfigSpace import Configuration
  from numpy import ndarray
  from smac.acquisition.function.abstract_acquisition_function import AbstractAcquisitionFunction
  from smac.callback.callback import Callback
  from smac.intensifier.abstract_intensifier import AbstractIntensifier
  from smac.model.abstract_model import AbstractModel
  from smac.runhistory import StatusType, TrialInfo, TrialValue
  from smac.runhistory.runhistory import RunHistory
  from smac.runner import FirstRunCrashedException
  from smac.runner.abstract_runner import AbstractRunner
  from smac.runner.dask_runner import DaskParallelRunner
  from smac.scenario import Scenario
  from smac.utils.data_structures import recursively_compare_dicts
  from smac.utils.logging import get_logger
label_desc: Use image node_id 19 for calling the SMBO obj's underlying member method code with example usage: obj._add_results() without return types