class_docstr: A QSA class, inherited from Optimizer.
  
  This is the designed class to define QSA-related
  variables and methods.
  
  References:
      J. Zhang et al. Queuing search algorithm: A novel metaheuristic algorithm
      for solving engineering optimization problems.
      Applied Mathematical Modelling (2018).
class_docstr_tok: ["A","QSA","class",",","inherited","from","Optimizer",".","This","is","the","designed","class","to","define","QSA-related","variables","and","methods",".","References",":","J.","Zhang","et","al",".","Queuing","search","algorithm",":","A","novel","metaheuristic","algorithm","for","solving","engineering","optimization","problems",".","Applied","Mathematical","Modelling","(","2018",")","."]
docstr: Performs the second business phase.
  
  Args:
      agents: List of agents.
      function: A Function object that will be used as the objective function.
docstr_tok: ["Performs","the","second","business","phase",".","Args",":","agents",":","List","of","agents",".","function",":","A","Function","object","that","will","be","used","as","the","objective","function","."]
code: def _business_two(
      self, agents: List[Agent], function: Function
  ) -> None:
      """Performs the second business phase.
  
      Args:
          agents: List of agents.
          function: A Function object that will be used as the objective function.
  
      """
  
      agents.sort(key=lambda x: x.fit)
  
      A_1, A_2, A_3 = (
          copy.deepcopy(agents[0]),
          copy.deepcopy(agents[1]),
          copy.deepcopy(agents[2]),
      )
  
      q_1, q_2, _ = self._calculate_queue(
          len(agents), A_1.fit, A_2.fit, A_3.fit
      )
  
      pr = [i / len(agents) for i in range(1, len(agents) + 1)]
  
      cv = A_1.fit / (A_2.fit + A_3.fit + c.EPSILON)
  
      for i, agent in enumerate(agents):
          a = copy.deepcopy(agent)
  
          if i < q_1:
              A = copy.deepcopy(A_1)
          elif q_1 <= i < q_1 + q_2:
              A = copy.deepcopy(A_2)
          else:
              A = copy.deepcopy(A_3)
  
          r1 = r.generate_uniform_random_number()
          if r1 < pr[i]:
              A_1, A_2 = np.random.choice(agents, 2, replace=False)
  
              r2 = r.generate_uniform_random_number()
              e = r.generate_gamma_random_number(1, 0.5, 1)
  
              if r2 < cv:
                  # Calculates the fluctuation (eq. 14)
                  F_1 = e * (A_1.position - A_2.position)
  
                  # Update agent's position (eq. 12)
                  a.position += F_1
              else:
                  # Calculates the fluctuation (eq. 15)
                  F_2 = e * (A.position - A_1.position)
  
                  # Update agent's position (eq. 13)
                  a.position += F_2
  
              a.fit = function(a.position)
              if a.fit < agent.fit:
                  agent.position = copy.deepcopy(a.position)
                  agent.fit = copy.deepcopy(a.fit)
  
file_path: opytimizer/opytimizer/optimizers/social/qsa.py
imports: import copy
  from typing import Any, Dict, List, Optional, Tuple
  import numpy
  import opytimizer.math.random
  import opytimizer.utils.constant
  from opytimizer.core import Optimizer
  from opytimizer.core.agent import Agent
  from opytimizer.core.function import Function
  from opytimizer.core.space import Space
  from opytimizer.utils import logging
label_desc: Use image node_id 4 for calling the QSA obj's underlying member method code with example usage: obj._business_two(agents, function) without return types