class_docstr: Backtracking Exploit
  
  This exploit is inspired from PBT with backtracking proposed in [1].
  Instead of using all trials at the same level of fidelity as in
  ``TruncateExploit``, it selects
  the best trials from each lineage (worker), one per lineage. The objective of the
  best trial is compared to the objective of the trial under analysis, and if the ratio
  is higher than some threshold the current trial is not promoted. A trial from the pool
  of best trials is selected randomly.
  
  The backtracking threshold
  defined by [1] is unstable however and cause division error by 0 when the best candidate trial
  has an objective of 0. Also, if we select trials at any fidelity levels, we would
  likely drop any trial at a low fidelity in favor of best trials at high fidelity.
  This class use a quantile threshold instead of the ratio in [1] to determine if a trial should
  be continued at next fidelity level. The candidates for forking are select from
  best trials from all running lineages (workers), like proposed in [1], but limited to trials
  up to the fidelity level of the current trial under analysis.
  
  [1] Zhang, Baohe, Raghu Rajan, Luis Pineda, Nathan Lambert, André Biedenkapp, Kurtland Chua,
  Frank Hutter, and Roberto Calandra. "On the importance of hyperparameter optimization for
  model-based reinforcement learning." In International Conference on Artificial Intelligence and
  Statistics, pp. 4015-4023. PMLR, 2021.
class_docstr_tok: ["Backtracking","Exploit","This","exploit","is","inspired","from","PBT","with","backtracking","proposed","in","[","1","]",".","Instead","of","using","all","trials","at","the","same","level","of","fidelity","as","in","``","TruncateExploit","``",",","it","selects","the","best","trials","from","each","lineage","(","worker",")",",","one","per","lineage",".","The","objective","of","the","best","trial","is","compared","to","the","objective","of","the","trial","under","analysis",",","and","if","the","ratio","is","higher","than","some","threshold","the","current","trial","is","not","promoted",".","A","trial","from","the","pool","of","best","trials","is","selected","randomly",".","The","backtracking","threshold","defined","by","[","1","]","is","unstable","however","and","cause","division","error","by","0","when","the","best","candidate","trial","has","an","objective","of","0",".","Also",",","if","we","select","trials","at","any","fidelity","levels",",","we","would","likely","drop","any","trial","at","a","low","fidelity","in","favor","of","best","trials","at","high","fidelity",".","This","class","use","a","quantile","threshold","instead","of","the","ratio","in","[","1","]","to","determine","if","a","trial","should","be","continued","at","next","fidelity","level",".","The","candidates","for","forking","are","select","from","best","trials","from","all","running","lineages","(","workers",")",",","like","proposed","in","[","1","]",",","but","limited","to","trials","up","to","the","fidelity","level","of","the","current","trial","under","analysis",".","[","1","]","Zhang",",","Baohe",",","Raghu","Rajan",",","Luis","Pineda",",","Nathan","Lambert",",","Andr\u00e9","Biedenkapp",",","Kurtland","Chua",",","Frank","Hutter",",","and","Roberto","Calandra",".","``","On","the","importance","of","hyperparameter","optimization","for","model-based","reinforcement","learning",".","''","In","International","Conference","on","Artificial","Intelligence","and","Statistics",",","pp",".","4015-4023",".","PMLR",",","2021","."]
docstr: Select other trial if current one not good enough
  
  If the given trial is under a ``self.truncation_quantile`` compared to all other best
  trials with lower or equal fidelity level,
  then a new candidate trial is selected for forking.
  The new candidate is selected from a pool of best ``self.candidate_pool_ratio``\% of the
  best trials with lower or equal fidelity level. See class description for more
  explanation on the rationale.
  
  If there are less than ``self.min_forking_population`` trials that have reached the fidelity
  level as the passed trial, then `None` is return to signal that we should reconsider this
  trial later on when more trials are completed at this fidelity level.
  
  Parameters
  ----------
  rng: numpy.random.Generator
      A random number generator. It is not contained in ``BaseExploit`` because the exploit
      class must be stateless.
  trial: Trial
      The :py:class:`orion.core.worker.trial.Trial` that is currently under examination.
  lineages: Lineages
      All :py:class:`orion.algo.pbt.pbt.Lineages` created by the population based training
      algorithm that is using this exploit class.
  
  Returns
  -------
  ``None``
      The exploit class signals that there are not enough completed trials in lineages to make
      a decision for current trial.
  ``Trial``
      If the returned trial is the same as the one received as argument, it means that
      population based training should continue with same parameters.
      If another trial from the lineages is returned, it means that population based training
      should try to explore new parameters.
docstr_tok: ["Select","other","trial","if","current","one","not","good","enough","If","the","given","trial","is","under","a","``","self.truncation_quantile","``","compared","to","all","other","best","trials","with","lower","or","equal","fidelity","level",",","then","a","new","candidate","trial","is","selected","for","forking",".","The","new","candidate","is","selected","from","a","pool","of","best","``","self.candidate_pool_ratio","``","\\","%","of","the","best","trials","with","lower","or","equal","fidelity","level",".","See","class","description","for","more","explanation","on","the","rationale",".","If","there","are","less","than","``","self.min_forking_population","``","trials","that","have","reached","the","fidelity","level","as","the","passed","trial",",","then","`","None","`","is","return","to","signal","that","we","should","reconsider","this","trial","later","on","when","more","trials","are","completed","at","this","fidelity","level",".","Parameters","--","--","--","--","--","rng",":","numpy.random.Generator","A","random","number","generator",".","It","is","not","contained","in","``","BaseExploit","``","because","the","exploit","class","must","be","stateless",".","trial",":","Trial","The",":","py",":","class",":","`","orion.core.worker.trial.Trial","`","that","is","currently","under","examination",".","lineages",":","Lineages","All",":","py",":","class",":","`","orion.algo.pbt.pbt.Lineages","`","created","by","the","population","based","training","algorithm","that","is","using","this","exploit","class",".","Returns","--","--","--","-","``","None","``","The","exploit","class","signals","that","there","are","not","enough","completed","trials","in","lineages","to","make","a","decision","for","current","trial",".","``","Trial","``","If","the","returned","trial","is","the","same","as","the","one","received","as","argument",",","it","means","that","population","based","training","should","continue","with","same","parameters",".","If","another","trial","from","the","lineages","is","returned",",","it","means","that","population","based","training","should","try","to","explore","new","parameters","."]
code: def __call__(self, rng, trial, lineages):
      """Select other trial if current one not good enough
  
      If the given trial is under a ``self.truncation_quantile`` compared to all other best
      trials with lower or equal fidelity level,
      then a new candidate trial is selected for forking.
      The new candidate is selected from a pool of best ``self.candidate_pool_ratio``\\% of the
      best trials with lower or equal fidelity level. See class description for more
      explanation on the rationale.
  
      If there are less than ``self.min_forking_population`` trials that have reached the fidelity
      level as the passed trial, then `None` is return to signal that we should reconsider this
      trial later on when more trials are completed at this fidelity level.
  
      Parameters
      ----------
      rng: numpy.random.Generator
          A random number generator. It is not contained in ``BaseExploit`` because the exploit
          class must be stateless.
      trial: Trial
          The :py:class:`orion.core.worker.trial.Trial` that is currently under examination.
      lineages: Lineages
          All :py:class:`orion.algo.pbt.pbt.Lineages` created by the population based training
          algorithm that is using this exploit class.
  
      Returns
      -------
      ``None``
          The exploit class signals that there are not enough completed trials in lineages to make
          a decision for current trial.
      ``Trial``
          If the returned trial is the same as the one received as argument, it means that
          population based training should continue with same parameters.
          If another trial from the lineages is returned, it means that population based training
          should try to explore new parameters.
  
      """
  
      elites = lineages.get_elites(max_depth=trial)
      return self._truncate(rng, trial, elites + [trial])
  
imports: import logging
  import numpy
  from orion.core.utils import GenericFactory
label_desc: Use image node_id 1 for calling the BacktrackExploit obj's underlying member method code with example usage: obj.__call__(rng, trial, lineages) and returns: self