Skip to content

Commit

Permalink
fixed default to file data function so that iteration 0 has right num…
Browse files Browse the repository at this point in the history
…ber of column even when eigenvalues are not yet available, ref CMA-ES#100, CMA-ES#107
  • Loading branch information
Emmanuel Benazera committed Jan 25, 2015
1 parent f803e66 commit 5eedc4e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
10 changes: 7 additions & 3 deletions cmastrategy.cc
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ namespace libcmaes
{
std::string sep = " ";
fplotstream << fabs(cmasols.best_candidate().get_fvalue()) << sep << cmasols.fevals() << sep << cmasols.sigma() << sep << sqrt(cmasols.max_eigenv()/cmasols.min_eigenv()) << sep;
fplotstream << cmasols.eigenvalues().transpose() << sep;
if (!cmasols.eigenvalues().size())
fplotstream << dVec::Zero(cmaparams.dim()).transpose() << sep;
else fplotstream << cmasols.eigenvalues().transpose() << sep;
if (!cmaparams.is_sep() && !cmaparams.is_vd())
fplotstream << cmasols.cov().sqrt().diagonal().transpose() << sep; // max deviation in all main axes
else if (cmaparams.is_sep())
Expand Down Expand Up @@ -85,14 +87,16 @@ namespace libcmaes
{
std::string sep = " ";
fplotstream << fabs(cmasols.best_candidate().get_fvalue()) << sep << cmasols.fevals() << sep << cmasols.sigma() << sep << sqrt(cmasols.max_eigenv()/cmasols.min_eigenv()) << sep;
fplotstream << cmasols.eigenvalues().transpose() << sep;
if (!cmasols.eigenvalues().size())
fplotstream << dVec::Zero(cmaparams.dim()).transpose() << sep;
else fplotstream << cmasols.eigenvalues().transpose() << sep;
if (!cmaparams.is_sep() && !cmaparams.is_vd())
fplotstream << cmasols.cov().sqrt().diagonal().transpose() << sep; // max deviation in all main axes
else if (cmaparams.is_sep())
fplotstream << cmasols.sepcov().cwiseSqrt().transpose() << sep;
else if (cmaparams.is_vd())
fplotstream << cmasols.sepcov().transpose() << sep; // C = D(I+vv')D, and we print out D^2 as an approx
fplotstream << cmaparams.get_gp().pheno(cmasols.xmean()).transpose();
fplotstream << cmasols.xmean().transpose();
fplotstream << sep << cmasols.elapsed_last_iter();
#ifdef HAVE_DEBUG
fplotstream << sep << cmasols._elapsed_eval << sep << cmasols._elapsed_ask << sep << cmasols._elapsed_tell << sep << cmasols._elapsed_stop;
Expand Down
4 changes: 3 additions & 1 deletion surrogatestrategy.cc
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ namespace libcmaes
{
std::string sep = " ";
fplotstream << fabs(cmasols.best_candidate().get_fvalue()) << sep << cmasols.fevals() << sep << cmasols.sigma() << sep << sqrt(cmasols.max_eigenv()/cmasols.min_eigenv()) << sep;
fplotstream << cmasols.eigenvalues().transpose() << sep;
if (!cmasols.eigenvalues().size())
fplotstream << dVec::Zero(cmaparams.dim()).transpose() << sep;
else fplotstream << cmasols.eigenvalues().transpose() << sep;
if (!cmaparams.is_sep() && !cmaparams.is_vd())
fplotstream << cmasols.cov().sqrt().diagonal().transpose() << sep; // max deviation in all main axes
else if (cmaparams.is_sep())
Expand Down

0 comments on commit 5eedc4e

Please sign in to comment.