code: def test_no_stragglers_lower_is_better():
      """
      Basic scenario where everything is finished. In that case we expect
      ASHA to add 3 to rung0, promote 1 to rung1, add 3 to rung0, promote one to
      rung1, add 3 to rung0, promote 1 to rung1, promote 1 to rung2.
      """
      parameters = [sherpa.Continuous("myparam", [0, 1])]
  
      algorithm = successive_halving.SuccessiveHalving(
          r=1, R=9, eta=3, s=0, max_finished_configs=1
      )
  
      study = sherpa.Study(
          parameters=parameters,
          algorithm=algorithm,
          lower_is_better=True,
          disable_dashboard=True,
      )
  
      rung_0_ids = [1, 2, 3, 5, 6, 7, 9, 10, 11]
      rung_1_ids = [4, 8, 12]
      rung_2_ids = [13]
  
      rung_0_promoted_ids = [1, 2, 3]
      rung_1_promoted_ids = [4]
  
      # Using trial.id as objective, hence the trials with the lowest trial ids
      # in the rung should get promoted, for rung 0 that is 1,2,3, for rung 1
      # 4
  
      for trial in study:
          if trial.id in rung_0_ids:
              assert trial.parameters["load_from"] == ""
              assert trial.parameters["save_to"] in map(str, rung_0_ids)
              assert trial.parameters["rung"] == 0
              assert trial.parameters["resource"] == 1
  
          elif trial.id in rung_1_ids:
              assert trial.parameters["load_from"] in map(
                  str, rung_0_promoted_ids
              )
              assert trial.parameters["save_to"] in map(str, rung_1_ids)
              assert trial.parameters["rung"] == 1
              assert trial.parameters["resource"] == 3
  
          elif trial.id in rung_2_ids:
              assert trial.parameters["load_from"] in map(
                  str, rung_1_promoted_ids
              )
              assert trial.parameters["save_to"] in map(str, rung_2_ids)
              assert trial.parameters["rung"] == 2
              assert trial.parameters["resource"] == 9
  
          study.add_observation(
              trial=trial, iteration=1, objective=float(trial.id)
          )
          study.finalize(trial)
  
file_path: sherpa/tests/test_successive_halving.py
imports: from __future__ import absolute_import
  import collections
  from sherpa.algorithms import successive_halving
  from testing_utils import *
label_desc: Use image node_id 1 for calling a global function with example usage: test_no_stragglers_lower_is_better() without return types