code: def Best1Bin(inst, candidate):
      """trial solution is current best solution plus scaled difference
      of two randomly chosen candidates; mutates at random
  
      trial = best + scale*(candidate1 - candidate2)"""
      # In DESolve, Best1Bin was identical to Best1Exp.
      # But the logic of Best1Bin is different from [1]. Reimplementing here.
      r1, r2 = get_random_candidates(inst.nPop, candidate, 2)
  
      if inst._map_solver:
          trialSolution = inst.trialSolution[candidate]
      else:
          trialSolution = inst.trialSolution
      trialSolution[:] = inst.population[candidate]
  
      # Randomly chosen index between [0, ND-1] (See Eq.4 of [1] )
      n = random.randrange(inst.nDim)
  
      for i in range(inst.nDim):
          cross = random.random()
          if i == n or cross < inst.probability:
              # this component of trial vector will come from vector v
              trialSolution[i] = inst.bestSolution[i] + inst.scale * (
                  inst.population[r1][i] - inst.population[r2][i]
              )
  
      #   inst._keepSolutionWithinRangeBoundary(inst.bestSolution)
      return
  
file_path: mystic/mystic/strategy.py
imports: import random
label_desc: Use image node_id 3 for calling a global function with example usage: Best1Bin(inst, candidate) without return types