1Metadata-Version: 1.2 2Name: cma 3Version: 3.1.0 4Summary: CMA-ES, Covariance Matrix Adaptation Evolution Strategy for non-linear numerical optimization in Python 5Home-page: https://github.com/CMA-ES/pycma 6Author: Nikolaus Hansen 7Author-email: authors_firstname.lastname@inria.fr 8Maintainer: Nikolaus Hansen 9Maintainer-email: authors_firstname.lastname@inria.fr 10License: BSD 11Description: CMA-ES Covariance Matrix Adaptation Evolution Strategy 12 ====================================================== 13 14 A stochastic numerical optimization algorithm for difficult (non-convex, 15 ill-conditioned, multi-modal, rugged, noisy) optimization problems in 16 continuous search spaces, implemented in Python. 17 18 Typical domain of application are bound-constrained or unconstrained 19 objective functions with: 20 21 * search space dimension between, say, 5 and (a few) 100, 22 * no gradients available, 23 * at least, say, 100 times dimension function evaluations needed to 24 get satisfactory solutions, 25 * non-separable, ill-conditioned, or rugged/multi-modal landscapes. 26 27 The CMA-ES is quite reliable, however for small budgets (fewer function 28 evaluations than, say, 100 times dimension) or in very small dimensions 29 better (i.e. faster) methods are available. 30 31 The ``pycma`` module provides two independent implementations of the 32 CMA-ES algorithm in the classes ``cma.CMAEvolutionStrategy`` and 33 ``cma.purecma.CMAES``. 34 35 Installation 36 ------------ 37 There are several ways of installation: 38 39 * In the terminal command line type:: 40 41 python -m pip install cma 42 43 Typing just ``pip`` instead of ``python -m pip`` may be sufficient. Or, 44 alternatively:: 45 46 easy_install cma 47 48 The package will be downloaded and installed automatically. To 49 **upgrade** an existing installation, '``cma``' must be replaced by 50 '``-U cma``' in both cases. If you never heard of ``pip``, `see here`__. 51 52 __ http://www.pip-installer.org 53 54 * Download and unpack the ``cma-...tar.gz`` file and type:: 55 56 pip install -e cma 57 58 or:: 59 60 python setup.py install 61 62 in the ``cma-...`` folder (under Windows just 63 "``setup.py install``"). 64 65 * Under Windows one may also download the MS Windows installer. 66 67 68 Installation **might require root privileges**. In this case, try 69 the ``--user`` option of pip or prepended with ``sudo``. 70 71 The folder ``cma`` from the ``tar`` archive can also be used without 72 any installation (just ``import`` needs to find it). 73 74 Usage Example 75 ------------- 76 In a Python shell:: 77 78 >>> import cma 79 >>> help(cma) 80 <output omitted> 81 >>> es = cma.CMAEvolutionStrategy(8 * [0], 0.5) 82 (5_w,10)-aCMA-ES (mu_w=3.2,w_1=45%) in dimension 8 (seed=468976, Tue May 6 19:14:06 2014) 83 >>> help(es) # the same as help(cma.CMAEvolutionStrategy) 84 <output omitted> 85 >>> es.optimize(cma.ff.rosen) 86 Iterat #Fevals function value axis ratio sigma minstd maxstd min:sec 87 1 10 1.042661803766204e+02 1.0e+00 4.50e-01 4e-01 5e-01 0:0.0 88 2 20 7.322331708590002e+01 1.2e+00 3.89e-01 4e-01 4e-01 0:0.0 89 3 30 6.048150359372417e+01 1.2e+00 3.47e-01 3e-01 3e-01 0:0.0 90 100 1000 3.165939452385367e+00 1.1e+01 7.08e-02 2e-02 7e-02 0:0.2 91 200 2000 4.157333035296804e-01 1.9e+01 8.10e-02 9e-03 5e-02 0:0.4 92 300 3000 2.413696640005903e-04 4.3e+01 9.57e-03 3e-04 7e-03 0:0.5 93 400 4000 1.271582136805314e-11 7.6e+01 9.70e-06 8e-08 3e-06 0:0.7 94 439 4390 1.062554035878040e-14 9.4e+01 5.31e-07 3e-09 8e-08 0:0.8 95 >>> es.result_pretty() # pretty print result 96 termination on tolfun=1e-11 97 final/bestever f-value = 3.729752e-15 3.729752e-15 98 mean solution: [ 1. 1. 1. 1. 0.99999999 0.99999998 99 0.99999995 0.99999991] 100 std deviation: [ 2.84303359e-09 2.74700402e-09 3.28154576e-09 5.92961588e-09 101 1.07700123e-08 2.12590385e-08 4.09374304e-08 8.16649754e-08] 102 103 optimizes the 8-dimensional Rosenbrock function with initial solution all 104 zeros and initial ``sigma = 0.5``. 105 106 Pretty much the same can be achieved a little less "elaborate" with:: 107 108 >>> import cma 109 >>> xopt, es = cma.fmin2(cma.ff.rosen, 8 * [0], 0.5) 110 <output omitted> 111 112 And a little more elaborate exposing the **ask-and-tell interface**:: 113 114 >>> import cma 115 >>> es = cma.CMAEvolutionStrategy(12 * [0], 0.5) 116 >>> while not es.stop(): 117 ... solutions = es.ask() 118 ... es.tell(solutions, [cma.ff.rosen(x) for x in solutions]) 119 ... es.logger.add() # write data to disc to be plotted 120 ... es.disp() 121 <output omitted> 122 >>> es.result_pretty() 123 <output omitted> 124 >>> cma.plot() # shortcut for es.logger.plot() 125 126 .. figure:: http://www.cmap.polytechnique.fr/~nikolaus.hansen/rosen12.png 127 :alt: CMA-ES on Rosenbrock function in dimension 8 128 :target: http://cma.gforge.inria.fr/cmaes_sourcecode_page.html#example 129 :align: center 130 131 A single run on the 12-dimensional Rosenbrock function. 132 133 134 The ``CMAOptions`` class manages options for ``CMAEvolutionStrategy``, 135 e.g. verbosity options can be found like:: 136 137 >>> import cma 138 >>> cma.s.pprint(cma.CMAOptions('erb')) 139 {'verb_log': '1 #v verbosity: write data to files every verb_log iteration, writing can be time critical on fast to evaluate functions' 140 'verbose': '1 #v verbosity e.v. of initial/final message, -1 is very quiet, not yet implemented' 141 'verb_plot': '0 #v in fmin(): plot() is called every verb_plot iteration' 142 'verb_disp': '100 #v verbosity: display console output every verb_disp iteration' 143 'verb_filenameprefix': 'outcmaes # output filenames prefix' 144 'verb_append': '0 # initial evaluation counter, if append, do not overwrite output files' 145 'verb_time': 'True #v output timings on console'} 146 147 Options are passed like:: 148 149 >>> import cma 150 >>> es = cma.CMAEvolutionStrategy(8 * [0], 0.5, 151 {'verb_disp': 1}) # display each iteration 152 153 154 Documentations 155 -------------- 156 Read the full package documentation: 157 158 * `version 2.x`_ 159 * `version 1.x`_ 160 161 .. _`version 2.x`: http://cma.gforge.inria.fr/apidocs-pycma/ 162 .. _`version 1.x`: http://www.cmap.polytechnique.fr/~nikolaus.hansen/html-pythoncma/ 163 164 See also 165 166 * `Github page hosting this code`_ 167 * `General CMA-ES source code page`_ with practical hints 168 * `CMA-ES on Wikipedia`_ 169 170 .. _`Github page hosting this code`: https://github.com/CMA-ES/pycma 171 .. _`General CMA-ES source code page`: http://cma.gforge.inria.fr/cmaes_sourcecode_page.html 172 .. _`CMA-ES on Wikipedia`: http://en.wikipedia.org/wiki/CMA-ES 173 174 Dependencies 175 ------------ 176 177 * required: ``numpy`` -- array processing for numbers, strings, records, and objects 178 * optional (highly recommended): ``matplotlib`` -- Python plotting package (includes ``pylab``) 179 180 Use ``pip install numpy`` etc. for installation. For a Python implementation of CMA-ES with lesser dependencies see here__. 181 182 __ http://cma.gforge.inria.fr/cmaes_sourcecode_page.html#python 183 184 License: BSD 185 186Keywords: optimization,CMA-ES,cmaes 187Platform: UNKNOWN 188Classifier: Intended Audience :: Science/Research 189Classifier: Intended Audience :: Education 190Classifier: Intended Audience :: Other Audience 191Classifier: Topic :: Scientific/Engineering 192Classifier: Topic :: Scientific/Engineering :: Mathematics 193Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence 194Classifier: Operating System :: OS Independent 195Classifier: Programming Language :: Python :: 2.6 196Classifier: Programming Language :: Python :: 2.7 197Classifier: Programming Language :: Python :: 3 198Classifier: Development Status :: 4 - Beta 199Classifier: Environment :: Console 200Classifier: License :: OSI Approved :: BSD License 201Requires: numpy 202