title: How to apply CMA-ES optimization to an arbitrary user defined objective function in Python?
body: <p>I am new in using Python. These days I am trying to learn new optimization algorithms and python.</p>
  
  <p>CMA-ES optimization algorithm source code in Python can be found here:
  <a href="https://www.lri.fr/~hansen/cma.py" rel="nofollow">CMA-ES.py</a></p>
  
  <p>I have had all the necessary Python packages installed (numpy,matplotlib, winpython, and so on). It is also easy to run the testing functions provided by the source code, e.g.,</p>
  
  <pre><code>            &gt;&gt;&gt; import cma
              &gt;&gt;&gt; res = cma.fmin(cma.fcts.rosen, 4*[-1],1, ftarget=1e-6, restarts=3, verb_time=0, verb_disp=500, seed=3)
  </code></pre>
  
  <p>The desired customized objective function is from the nonlinear least square fittiing of data:</p>
  
  <p>Data sets: 23x3</p>
  
  <pre><code>x        y      z
  ----------------------
  1100.21 57.66   1.8
  1157.88 57.79   1.7
  1272.85 58.03   1.67
  1330.34 58.22   1.67
  1389.   57.69   1.7
  1590.   57.01   1.67
  1820.   55.42   1.6
  2049.   59.35   1.5
  2308.   58.32   1.56
  2596.   57.28   1.6
  2711.   57.13   1.368
  2826.   55.61   1.33
  2883.   54.79   1.315
  2940.   53.78   1.325
  3001.   54.41   1.3
  3117.   55.93   1.2495
  3291.   57.15   1.28
  3377.   58.05   1.25
  3522.   58.41   1.31
  3725.   57.61   1.31
  3899.   53.55   1.195
  4015.   51.22   1.178
  4188.   50.89   1.185
  </code></pre>
  
  <p>nonlinear model : a(1)--a(5) are parameters:</p>
  
  <pre><code> z = a(1)*y^a(2)*x^a(3)+a(4)*x^a(5)
  </code></pre>