class_docstr: Penalty 2 objective function.
  
  This class defines the Penalty 2 [1]_ global optimization problem. This is a
  multimodal minimization problem defined as follows:
  
  .. math::
  
      f_{\text{Penalty02}}(x) = 0.1 \left\{\sin^2(3\pi x_1) + \sum_{i=1}^{n-1}
      (x_i - 1)^2 \left[1 + \sin^2(3\pi x_{i+1}) \right ]
      + (x_n - 1)^2 \left [1 + \sin^2(2 \pi x_n) \right ]\right \}
      + \sum_{i=1}^n u(x_i, 5, 100, 4)
  
  Where, in this exercise:
  
  .. math::
  
      u(x_i, a, k, m) = 
      \begin{cases}
      k(x_i - a)^m & \textrm{if} \hspace{5pt} x_i > a \\
      0 & \textrm{if} \hspace{5pt} -a \leq x_i \leq a \\
      k(-x_i - a)^m & \textrm{if} \hspace{5pt} x_i < -a \\
      \end{cases}
  
  
  Here, :math:`n` represents the number of dimensions and
  :math:`x_i \in [-50, 50]` for :math:`i = 1, ..., n`.
  
  *Global optimum*: :math:`f(x) = 0` for :math:`x_i = 1` for
  :math:`i = 1, ..., n`
  
  .. [1] Gavana, A. Global Optimization Benchmarks and AMPGO retrieved 2015
class_docstr_tok: ["Penalty","2","objective","function",".","This","class","defines","the","Penalty","2","[","1","]","_","global","optimization","problem",".","This","is","a","multimodal","minimization","problem","defined","as","follows",":","..","math",":",":","f_","{","\\text","{","Penalty02","}","}","(","x",")","=","0.1","\\left\\","{","\\sin^2","(","3\\pi","x_1",")","+","\\sum_","{","i=1","}","^","{","n-1","}","(","x_i","-","1",")","^2","\\left","[","1","+","\\sin^2","(","3\\pi","x_","{","i+1","}",")","\\right","]","+","(","x_n","-","1",")","^2","\\left","[","1","+","\\sin^2","(","2","\\pi","x_n",")","\\right","]","\\right","\\","}","+","\\sum_","{","i=1","}","^n","u","(","x_i",",","5",",","100",",","4",")","Where",",","in","this","exercise",":","..","math",":",":","u","(","x_i",",","a",",","k",",","m",")","=","\\begin","{","cases","}","k","(","x_i","-","a",")","^m","&","\\textrm","{","if","}","\\hspace","{","5pt","}","x_i",">","a","\\\\","0","&","\\textrm","{","if","}","\\hspace","{","5pt","}","-a","\\leq","x_i","\\leq","a","\\\\","k","(","-x_i","-","a",")","^m","&","\\textrm","{","if","}","\\hspace","{","5pt","}","x_i","<","-a","\\\\","\\end","{","cases","}","Here",",",":","math",":","`","n","`","represents","the","number","of","dimensions","and",":","math",":","`","x_i","\\in","[","-50",",","50","]","`","for",":","math",":","`","i","=","1",",","...",",","n","`",".","*","Global","optimum","*",":",":","math",":","`","f","(","x",")","=","0","`","for",":","math",":","`","x_i","=","1","`","for",":","math",":","`","i","=","1",",","...",",","n","`","..","[","1","]","Gavana",",","A",".","Global","Optimization","Benchmarks","and","AMPGO","retrieved","2015"]
code: def fun(self, x, *args):
      self.nfev += 1
  
      a, b, c = 5.0, 100.0, 4.0
  
      xx = abs(x)
      u = where(xx > a, b * (xx - a) ** c, 0.0)
  
      return sum(u) + 0.1 * (
          10 * sin(3.0 * pi * x[0]) ** 2.0
          + sum(
              (x[:-1] - 1.0) ** 2.0 * (1.0 + sin(3 * pi * x[1:]) ** 2.0)
          )
          + (x[-1] - 1) ** 2.0 * (1 + sin(2 * pi * x[-1]) ** 2.0)
      )
  
imports: from numpy import abs, sum, sin, cos, sqrt, log, prod, where, pi, exp, arange, floor, log10, atleast_2d, zeros
  from .go_benchmark import Benchmark
label_desc: Use image node_id 2 for calling the Penalty02 obj's underlying member method code with example usage: obj.fun(x) and returns: unknown