CMA-ES / libcmaes

libcmaes is a multithreaded C++11 library with Python bindings for high performance blackbox stochastic optimization using the CMA-ES algorithm for Covariance Matrix Adaptation Evolution Strategy
Other
321 stars 78 forks source link

Print options #131

Open agrayver opened 9 years ago

agrayver commented 9 years ago

Currently, setting quiet flag to false, library prints basic info every iteration. So much informations is often not required. Being able to specify how often (e.g. every Nth iteration) library prints information would make it easy to monitor convergence.

I know there is a possibility to implement my own progress function and output data as often or seldom as I want, but I wonder if developers think providing such built-in option is feasible?

beniz commented 9 years ago

Yes, the doc tells you how to write your own progress function, see here: https://github.com/beniz/libcmaes/wiki/Using-a-custom-progress-function

As for now, if you want to print something every n-th steps, you need to do this from within your own progress function, using the number of iterations reported by the CMASolutions object.

The default progress function, if you would like to use it as a starting point, is here: https://github.com/beniz/libcmaes/blob/master/src/cmastrategy.cc#L38

To print a header line, you'd have to check for the first iteration, which is 0.

EDIT: and yes, it could be easily built-in, adding another option. As for just right now, you'd be better of using the method above.

beniz commented 9 years ago

Also, if you use the default function to print every nth iteration, you can submit the change as a PR, which would then be reviewed and merged!

nikohansen commented 9 years ago

+1 for a control parameter to control console output every n-th iteration. Ideally this parameter can be changed while the optimization is running. This is how my preferred output looks like:

(6_w,13)-aCMA-ES (mu_w=4.0,w_1=38%) in dimension 22 (seed=629446, Thu Mar 11 13:07:54 2015)
Iterat #Fevals   function value  axis ratio  sigma  min&max std  t[m:s]
    1     13 5.411937838159890e+05 1.0e+00 9.19e-01  9e-01  9e-01 0:0.0
    2     26 3.249785714710627e+05 1.1e+00 8.87e-01  9e-01  9e-01 0:0.0
    3     39 2.215974166274816e+05 1.1e+00 8.33e-01  8e-01  9e-01 0:0.0
  100   1300 1.610410617492171e+04 4.0e+00 1.50e-01  6e-02  2e-01 0:0.3
  200   2600 1.115023211688774e+03 1.1e+01 2.75e-02  5e-03  3e-02 0:0.6
  300   3900 4.001037580746567e+02 2.8e+01 2.12e-02  2e-03  5e-02 0:0.9
  400   5200 6.785544679519067e+01 8.7e+01 2.39e-02  1e-03  9e-02 0:1.2
  500   6500 3.728596094314725e+01 1.2e+02 6.35e-03  3e-04  2e-02 0:1.5
  600   7800 1.745435649840712e+01 2.1e+02 1.37e-02  4e-04  6e-02 0:1.7
  700   9100 7.298744862524692e+00 3.4e+02 1.45e-02  3e-04  8e-02 0:2.0
  800  10400 1.781038979900586e+00 4.9e+02 9.81e-03  1e-04  5e-02 0:2.3
  900  11700 9.310093448690075e-03 6.0e+02 1.94e-03  2e-05  1e-02 0:2.6
 1000  13000 5.298215441718934e-04 6.9e+02 1.68e-04  1e-06  9e-04 0:2.9
Iterat #Fevals   function value  axis ratio  sigma  min&max std  t[m:s]
 1100  14300 1.820376102055338e-06 8.9e+02 4.10e-05  3e-07  2e-04 0:3.2
 1200  15600 8.437097700224028e-11 9.6e+02 3.80e-07  2e-09  2e-06 0:3.5
 1285  16705 3.395813950161877e-14 1.1e+03 9.82e-09  4e-11  4e-08 0:3.7
termination on tolfun=1e-11 (Thu Mar  5 13:07:58 2015)
final/bestever f-value = 2.187968e-14 2.187968e-14
incumbent solution: [ -3.67001754e-08   1.32298206e-08   2.86745703e-09   2.65430021e-08
  -8.19903078e-09   7.65731639e-09  -1.90743894e-09   1.91265917e-09 ...]
std deviations: [  4.24406277e-08   3.07314735e-08   2.21571269e-08   1.39661633e-08
   1.23903235e-08   7.99126636e-09   6.43127205e-09   4.14453821e-09 ...]

The first three iterations and the last iteration are always shown, independently of the control parameter.