docstr: An OptionsHandler class
  
  This class offers a way to handle options. It contains
  methods to vary the options at runtime.
  Following strategies are available for the handling:
  
  * exp_decay:
      Decreases the parameter exponentially between limits.
  
  * lin_variation:
      Decreases/increases the parameter linearly between limits.
  
  * random:
      takes a uniform random value between limits
  
  * nonlin_mod:
      Decreases/increases the parameter between limits according to a nonlinear modulation index .
  
  The OptionsHandler can be called as a function to use the strategy
  that is passed at initialization to account for time-varying coefficients. An example
  for the usage:
  
  .. code-block :: python
  
      from pyswarms.backend import operators as op
      from pyswarms.backend.handlers import OptionsHandler
  
  
      oh = OptionsHandler(strategy={ "w":"exp_decay", "c1":"nonlin_mod","c2":"lin_variation"})
  
      for i in range(iters):
          # initial operations for global and local best positions
          new_options = oh(default_options, iternow=i, itermax=iters, end_opts={"c1":0.5, "c2":2.5, "w":0.4})
          # more updates using new_options
  
  .. note::
      As of pyswarms v1.3.0, you will need to create your own optimization loop to change the default ending 
      options and other arguments for each strategy in all of the handlers on this page.
  
  A more comprehensive tutorial is also present `here`_ for interested users.
  
  .. _here: https://pyswarms.readthedocs.io/en/latest/examples/tutorials/options_handler.html
  
  
  
  Attributes
  ----------
  strategy : str
      The strategy to use. To see all available strategies,
      call :code:`OptionsHandler.strategies`
docstr_tok: ["An","OptionsHandler","class","This","class","offers","a","way","to","handle","options",".","It","contains","methods","to","vary","the","options","at","runtime",".","Following","strategies","are","available","for","the","handling",":","*","exp_decay",":","Decreases","the","parameter","exponentially","between","limits",".","*","lin_variation",":","Decreases\/increases","the","parameter","linearly","between","limits",".","*","random",":","takes","a","uniform","random","value","between","limits","*","nonlin_mod",":","Decreases\/increases","the","parameter","between","limits","according","to","a","nonlinear","modulation","index",".","The","OptionsHandler","can","be","called","as","a","function","to","use","the","strategy","that","is","passed","at","initialization","to","account","for","time-varying","coefficients",".","An","example","for","the","usage",":","..","code-block",":",":","python","from","pyswarms.backend","import","operators","as","op","from","pyswarms.backend.handlers","import","OptionsHandler","oh","=","OptionsHandler","(","strategy=","{","``","w","''",":","''","exp_decay","''",",","``","c1","''",":","''","nonlin_mod","''",",","''","c2","''",":","''","lin_variation","''","}",")","for","i","in","range","(","iters",")",":","#","initial","operations","for","global","and","local","best","positions","new_options","=","oh","(","default_options",",","iternow=i",",","itermax=iters",",","end_opts=","{","``","c1","''",":0.5",",","``","c2","''",":2.5",",","``","w","''",":0.4","}",")","#","more","updates","using","new_options","..","note",":",":","As","of","pyswarms","v1.3.0",",","you","will","need","to","create","your","own","optimization","loop","to","change","the","default","ending","options","and","other","arguments","for","each","strategy","in","all","of","the","handlers","on","this","page",".","A","more","comprehensive","tutorial","is","also","present","`","here","`","_","for","interested","users",".","..","_here",":","https",":","\/\/pyswarms.readthedocs.io\/en\/latest\/examples\/tutorials\/options_handler.html","Attributes","--","--","--","--","--","strategy",":","str","The","strategy","to","use",".","To","see","all","available","strategies",",","call",":","code",":","`","OptionsHandler.strategies","`"]
code: def __init__(self, strategy):
      """An OptionsHandler class
  
      This class offers a way to handle options. It contains
      methods to vary the options at runtime.
      Following strategies are available for the handling:
  
      * exp_decay:
          Decreases the parameter exponentially between limits.
  
      * lin_variation:
          Decreases/increases the parameter linearly between limits.
  
      * random:
          takes a uniform random value between limits
  
      * nonlin_mod:
          Decreases/increases the parameter between limits according to a nonlinear modulation index .
  
      The OptionsHandler can be called as a function to use the strategy
      that is passed at initialization to account for time-varying coefficients. An example
      for the usage:
  
      .. code-block :: python
  
          from pyswarms.backend import operators as op
          from pyswarms.backend.handlers import OptionsHandler
  
  
          oh = OptionsHandler(strategy={ "w":"exp_decay", "c1":"nonlin_mod","c2":"lin_variation"})
  
          for i in range(iters):
              # initial operations for global and local best positions
              new_options = oh(default_options, iternow=i, itermax=iters, end_opts={"c1":0.5, "c2":2.5, "w":0.4})
              # more updates using new_options
  
      .. note::
          As of pyswarms v1.3.0, you will need to create your own optimization loop to change the default ending
          options and other arguments for each strategy in all of the handlers on this page.
  
      A more comprehensive tutorial is also present `here`_ for interested users.
  
      .. _here: https://pyswarms.readthedocs.io/en/latest/examples/tutorials/options_handler.html
  
  
  
      Attributes
      ----------
      strategy : str
          The strategy to use. To see all available strategies,
          call :code:`OptionsHandler.strategies`
      """
      self.strategy = strategy
      self.strategies = self._get_all_strategies()
      self.rep = Reporter(logger=logging.getLogger(__name__))
  
imports: import inspect
  import logging
  import numpy
  import math
  from copy import copy
  from ..utils.reporter import Reporter
label_desc: Use image node_id 1 to create a new OptionsHandler object from inherited base classes: HandlerMixin with example: obj = OptionsHandler(strategy)