159#define _CRT_SECURE_NO_WARNINGS
190 const double * sigma,
int seed,
int lambda,
191 const char * filename);
202 double const *xin,
double eps);
205 const char * append);
209 char const *s3,
char const *s4);
218static void Eigen(
int N,
double **C,
double *diag,
double **Q,
220static int Check_Eigen(
int N,
double **C,
double *diag,
double **Q);
221static void QLalgo2 (
int n,
double *d,
double *e,
double **V);
222static void Householder2(
int n,
double **V,
double *d,
double *e);
225static void FATAL(
char const *sz1,
char const *s2,
226 char const *s3,
char const *s4);
227static void ERRORMESSAGE(
char const *sz1,
char const *s2,
228 char const *s3,
char const *s4);
229static int isNoneStr(
const char * filename);
230static void Sorted_index(
const double *rgFunVal,
int *index,
int n);
231static int SignOfDiff(
const void *d1,
const void * d2);
233static double rgdouMax(
const double *rgd,
int len);
234static double rgdouMin(
const double *rgd,
int len);
235static double douMax(
double d1,
double d2);
236static double douMin(
double d1,
double d2);
237static int MaxIdx(
const double *rgd,
int len);
238static int MinIdx(
const double *rgd,
int len);
239static double myhypot(
double a,
double b);
253 time_t tm = time(NULL);
257 strncpy(s, ctime(&tm), 24);
267 "(%d,%d)-CMA-ES(mu_eff=%.1f), Ver=\"%s\", dimension=%d, diagonalIterations=%ld, randomSeed=%d (%s)",
283 const char *input_parameter_filename)
287 lambda, input_parameter_filename);
299 ERRORMESSAGE(
"cmaes_init_final called (probably) without calling cmaes_init_para first",
300 ", which will likely lead to unexpected results",0,0);
301 printf(
"Error: cmaes_init_final called (probably) without calling cmaes_init_para first\n");
304 ERRORMESSAGE(
"cmaes_init_final called twice, which will lead to a memory leak",
305 "; use cmaes_exit() first",0,0);
306 printf(
"Error: cmaes_init_final called twice, which will lead to a memory leak; use cmaes_exit first\n");
321 for (i = 0, trace = 0.; i < N; ++i)
323 t->
sigma = sqrt(trace/N);
325 t->
chiN = sqrt((
double) N) * (1. - 1./(4.*N) + 1./(21.*N*N));
334 for (dtest = 1.; dtest && dtest < 1.1 * dtest; dtest *= 2.)
335 if (dtest == dtest + 1.)
354 t->
C = (
double**)
new_void(N,
sizeof(
double*));
355 t->
B = (
double**)
new_void(N,
sizeof(
double*));
363 for (i = 0; i < N; ++i) {
371 for (i = 0; i < t->
sp.
lambda; ++i) {
379 for (i = 0; i < N; ++i)
380 for (j = 0; j < i; ++j)
381 t->
C[i][j] = t->
B[i][j] = t->
B[j][i] = 0.;
383 for (i = 0; i < N; ++i)
387 t->
C[i][i] *= t->
C[i][i];
398 for (i = 0; i < N; ++i)
402 for (i = 0; i < N; ++i)
422 const char *input_parameter_filename)
425 lambda, input_parameter_filename);
433 #pragma GCC diagnostic push
434 #pragma GCC diagnostic ignored "-Wunused-result"
442 FILE *fp = fopen( filename,
"r");
444 ERRORMESSAGE(
"cmaes_resume_distribution(): could not open '",
451 if ((res = fscanf(fp,
" resume %lg", &d)) == EOF)
460 n = i; i = 0; res = 0; rewind(fp);
462 if ((res = fscanf(fp,
" resume %lg", &d)) == EOF)
463 FATAL(
"cmaes_resume_distribution(): Unexpected error, bug",0,0,0);
470 FATAL(
"cmaes_resume_distribution(): Dimension numbers do not match",0,0,0);
474 if ((res = fscanf(fp,
" xmean %lg", &d)) == EOF)
475 FATAL(
"cmaes_resume_distribution(): 'xmean' not found",0,0,0);
484 for(i = 1; i < t->
sp.
N; ++i)
485 res += fscanf(fp,
" %lg", &t->
rgxmean[i]);
487 FATAL(
"cmaes_resume_distribution(): xmean: dimensions differ",0,0,0);
491 if ((res = fscanf(fp,
" path for sigma %lg", &d)) == EOF)
492 FATAL(
"cmaes_resume_distribution(): 'path for sigma' not found",0,0,0);
500 t->
rgps[0] = d; res = 1;
501 for(i = 1; i < t->
sp.
N; ++i)
502 res += fscanf(fp,
" %lg", &t->
rgps[i]);
504 FATAL(
"cmaes_resume_distribution(): ps: dimensions differ",0,0,0);
508 if ((res = fscanf(fp,
" path for C %lg", &d)) == EOF)
509 FATAL(
"cmaes_resume_distribution(): 'path for C' not found",0,0,0);
516 t->
rgpc[0] = d; res = 1;
517 for(i = 1; i < t->
sp.
N; ++i)
518 res += fscanf(fp,
" %lg", &t->
rgpc[i]);
520 FATAL(
"cmaes_resume_distribution(): pc: dimensions differ",0,0,0);
524 if ((res = fscanf(fp,
" sigma %lg", &d)) == EOF)
525 FATAL(
"cmaes_resume_distribution(): 'sigma' not found",0,0,0);
535 if ((res = fscanf(fp,
" covariance matrix %lg", &d)) == EOF)
536 FATAL(
"cmaes_resume_distribution(): 'covariance matrix' not found",0,0,0);
543 t->
C[0][0] = d; res = 1;
544 for (i = 1; i < t->
sp.
N; ++i)
545 for (j = 0; j <= i; ++j)
546 res += fscanf(fp,
" %lg", &t->
C[i][j]);
548 FATAL(
"cmaes_resume_distribution(): C: dimensions differ",0,0,0);
559 #pragma GCC diagnostic pop
580 for (i = 0; i < N; ++i) {
585 free( --t->
rgrgx[i]);
610 FATAL(
"cmaes_SetMean: mean cannot be set inbetween the calls of ",
611 "SamplePopulation and UpdateDistribution",0,0);
613 if (xmean != NULL && xmean != t->
rgxmean)
614 for(i = 0; i < N; ++i)
627 int iNk, i, j, N=t->
sp.
N;
630 double const *xmean = t->
rgxmean;
639 for (i = 0; i < N; ++i)
640 t->
rgD[i] = sqrt(t->
C[i][i]);
651 for (iNk = 0; iNk < t->
sp.
lambda; ++iNk)
653 for (i = 0; i < N; ++i)
660 for (i = 0; i < N; ++i) {
661 for (j = 0, sum = 0.; j < N; ++j)
662 sum += t->
B[i][j] * t->
rgdTmp[j];
682 FATAL(
"cmaes_ReSampleSingle(): Missing input double *x",0,0,0);
684 for (i = 0; i < N; ++i)
687 for (i = 0; i < N; ++i) {
688 for (j = 0, sum = 0.; j < N; ++j)
689 sum += t->
B[i][j] * t->
rgdTmp[j];
705 if (iindex < 0 || iindex >= t->
sp.
lambda) {
706 sprintf(s,
"index==%d must be between 0 and %d", iindex, t->
sp.
lambda);
707 FATAL(
"cmaes_ReSampleSingle(): Population member ",s,0,0);
709 rgx = t->
rgrgx[iindex];
711 for (i = 0; i < N; ++i)
714 for (i = 0; i < N; ++i) {
715 for (j = 0, sum = 0.; j < N; ++j)
716 sum += t->
B[i][j] * t->
rgdTmp[j];
733 for (i = 0; i < N; ++i)
736 for (i = 0; i < N; ++i) {
737 for (j = 0, sum = 0.; j < N; ++j)
738 sum += t->
B[i][j] * t->
rgdTmp[j];
755 FATAL(
"cmaes_PerturbSolutionInto(): xmean was not given",0,0,0);
757 for (i = 0; i < N; ++i)
760 for (i = 0; i < N; ++i) {
761 for (j = 0, sum = 0.; j < N; ++j)
762 sum += t->
B[i][j] * t->
rgdTmp[j];
763 rgx[i] = xmean[i] + eps * t->
sigma * sum;
774 const char * signalsFilename =
"cmaes_signals.par";
778 double startiter = evo->
gen;
781 (evo->
gen < startiter + iterations || !iterations))
787 for (i = 0; i <
cmaes_Get(evo,
"popsize"); ++i) {
812 int i, j, iNk, hsig, N=t->
sp.
N;
818 FATAL(
"cmaes_UpdateDistribution(): You need to call \n",
819 "SamplePopulation() before update can take place.",0,0);
821 FATAL(
"cmaes_UpdateDistribution(): ",
822 "Fitness function value array input is missing.",0,0);
827 ERRORMESSAGE(
"cmaes_UpdateDistribution(): unexpected state",0,0,0);
841 ERRORMESSAGE(
"Warning: sigma increased due to equal function values\n",
842 " Reconsider the formulation of the objective function",0,0);
852 for (i = 0; i <= N; ++i) {
858 for (i = 0; i < N; ++i) {
861 for (iNk = 0; iNk < t->
sp.
mu; ++iNk)
867 for (i = 0; i < N; ++i) {
869 for (j = 0, sum = 0.; j < N; ++j)
870 sum += t->
B[j][i] * t->
rgBDz[j];
890 for (i = 0; i < N; ++i) {
892 for (j = 0, sum = 0.; j < N; ++j)
893 sum += t->
B[i][j] * t->
rgdTmp[j];
897 sqrt(t->
sp.
cs * (2. - t->
sp.
cs)) * sum;
901 for (i = 0, psxps = 0.; i < N; ++i)
905 hsig = sqrt(psxps) / sqrt(1. - pow(1.-t->
sp.
cs, 2*t->
gen)) / t->
chiN
907 for (i = 0; i < N; ++i) {
924 if(psxps/N > 1.5 + 10.*sqrt(2./N)
927 double tfac = sqrt((1 +
douMax(0, log(psxps/N))) * N / psxps);
947 for (i = 0; i < N; ++i)
948 for (j = 0; j <=i; ++j) {
949 t->
C[i][j] = (1 - t->
sp.
ccov) * t->
C[i][j]
953 for (k = 0; k < t->
sp.
mu; ++k)
978 int i, j, k, N=t->
sp.
N;
985 double ccovmu =
douMin(t->
sp.
ccov * (1-1./t->
sp.
mucov)* (flgdiag ? (N+1.5) / 3. : 1.), 1.-ccov1);
991 for (i = 0; i < N; ++i)
992 for (j = flgdiag ? i : 0; j <= i; ++j) {
993 t->
C[i][j] = (1 - ccov1 - ccovmu) * t->
C[i][j]
997 for (k = 0; k < t->
sp.
mu; ++k) {
1006 for (i = 1; i < N; ++i) {
1026 for (i = 0; i < N; ++i)
1043 const char *appendwrite)
1045 const char *s =
"tmpcmaes.dat";
1051 fp = fopen( name, appendwrite);
1054 ERRORMESSAGE(
"cmaes_WriteToFile(): could not open '", name,
1055 "' with flag ", appendwrite);
1059 if (appendwrite[0] ==
'w') {
1061 fprintf(fp,
"%% # %s (randomSeed=%d, %s)\n", key, t->
sp.
seed,
getTimeStr());
1063 if (t->
gen > 0 || strncmp(name,
"outcmaesfit", 11) != 0)
1081 int i, k, N=(t ? t->
sp.
N : 0);
1083 const char *s =
"few";
1087 keyend = key + strlen(key);
1089 while (key < keyend)
1091 if (strncmp(key,
"axisratio", 9) == 0)
1093 fprintf(fp,
"%.2e", sqrt(t->
maxEW/t->
minEW));
1094 while (*key !=
'+' && *key !=
'\0' && key < keyend)
1096 fprintf(fp,
"%c", (*key==
'+') ?
'\t':
'\n');
1098 if (strncmp(key,
"idxminSD", 8) == 0)
1100 int mini=0;
for(i=N-1;i>0;--i)
if(t->
mindiagC==t->
C[i][i]) mini=i;
1101 fprintf(fp,
"%d", mini+1);
1102 while (*key !=
'+' && *key !=
'\0' && key < keyend)
1104 fprintf(fp,
"%c", (*key==
'+') ?
'\t':
'\n');
1106 if (strncmp(key,
"idxmaxSD", 8) == 0)
1108 int maxi=0;
for(i=N-1;i>0;--i)
if(t->
maxdiagC==t->
C[i][i]) maxi=i;
1109 fprintf(fp,
"%d", maxi+1);
1110 while (*key !=
'+' && *key !=
'\0' && key < keyend)
1112 fprintf(fp,
"%c", (*key==
'+') ?
'\t':
'\n');
1115 if (strncmp(key,
"B", 1) == 0)
1118 int j, *iindex=(
int*)(
new_void(N,
sizeof(
int)));
1121 for (i = 0; i < N; ++i)
1122 for (j = 0; j < N; ++j)
1123 fprintf(fp,
"%g%c", t->
B[j][iindex[N-1-i]], (j==N-1)?
'\n':
'\t');
1128 if (strncmp(key,
"C", 1) == 0)
1131 for (i = 0; i < N; ++i)
1132 for (j = 0; j <= i; ++j)
1133 fprintf(fp,
"%g%c", t->
C[i][j], (j==i)?
'\n':
'\t');
1137 if (strncmp(key,
"clock", 4) == 0)
1142 while (*key !=
'+' && *key !=
'\0' && key < keyend)
1144 fprintf(fp,
"%c", (*key==
'+') ?
'\t':
'\n');
1147 if (strncmp(key,
"stddevratio", 11) == 0)
1150 while (*key !=
'+' && *key !=
'\0' && key < keyend)
1152 fprintf(fp,
"%c", (*key==
'+') ?
'\t':
'\n');
1155 if (strncmp(key,
"coorstddev", 10) == 0
1156 || strncmp(key,
"stddev", 6) == 0)
1158 for (i = 0; i < N; ++i)
1159 fprintf(fp,
"%s%g", (i==0) ?
"":
"\t", t->
sigma*sqrt(t->
C[i][i]));
1160 while (*key !=
'+' && *key !=
'\0' && key < keyend)
1162 fprintf(fp,
"%c", (*key==
'+') ?
'\t':
'\n');
1165 if (strncmp(key,
"diag(D)", 7) == 0)
1167 for (i = 0; i < N; ++i)
1170 for (i = 0; i < N; ++i)
1171 fprintf(fp,
"%s%g", (i==0) ?
"":
"\t", t->
rgdTmp[i]);
1172 while (*key !=
'+' && *key !=
'\0' && key < keyend)
1174 fprintf(fp,
"%c", (*key==
'+') ?
'\t':
'\n');
1176 if (strncmp(key,
"dim", 3) == 0)
1178 fprintf(fp,
"%d", N);
1179 while (*key !=
'+' && *key !=
'\0' && key < keyend)
1181 fprintf(fp,
"%c", (*key==
'+') ?
'\t':
'\n');
1183 if (strncmp(key,
"eval", 4) == 0)
1186 while (*key !=
'+' && *key !=
'\0' && key < keyend)
1188 fprintf(fp,
"%c", (*key==
'+') ?
'\t':
'\n');
1190 if (strncmp(key,
"few(diag(D))", 12) == 0)
1192 int add = (int)(0.5 + (N + 1.) / 5.);
1193 for (i = 0; i < N; ++i)
1196 for (i = 0; i < N-1; i+=add)
1197 fprintf(fp,
"%s%g", (i==0) ?
"":
"\t", t->
rgdTmp[N-1-i]);
1198 fprintf(fp,
"\t%g\n", t->
rgdTmp[0]);
1201 if (strncmp(key,
"fewinfo", 7) == 0) {
1202 fprintf(fp,
" Iter Fevals Function Value Sigma ");
1203 fprintf(fp,
"MaxCoorDev MinCoorDev AxisRatio MinDii Time in eig\n");
1204 while (*key !=
'+' && *key !=
'\0' && key < keyend)
1207 if (strncmp(key,
"few", 3) == 0) {
1208 fprintf(fp,
" %4.0f ", t->
gen);
1214 while (*key !=
'+' && *key !=
'\0' && key < keyend)
1216 fprintf(fp,
"%c", (*key==
'+') ?
'\t':
'\n');
1218 if (strncmp(key,
"funval", 6) == 0 || strncmp(key,
"fitness", 6) == 0)
1221 while (*key !=
'+' && *key !=
'\0' && key < keyend)
1223 fprintf(fp,
"%c", (*key==
'+') ?
'\t':
'\n');
1225 if (strncmp(key,
"fbestever", 9) == 0)
1228 while (*key !=
'+' && *key !=
'\0' && key < keyend)
1230 fprintf(fp,
"%c", (*key==
'+') ?
'\t':
'\n');
1232 if (strncmp(key,
"fmedian", 7) == 0)
1235 while (*key !=
'+' && *key !=
'\0' && key < keyend)
1237 fprintf(fp,
"%c", (*key==
'+') ?
'\t':
'\n');
1239 if (strncmp(key,
"fworst", 6) == 0)
1242 while (*key !=
'+' && *key !=
'\0' && key < keyend)
1244 fprintf(fp,
"%c", (*key==
'+') ?
'\t':
'\n');
1246 if (strncmp(key,
"arfunval", 8) == 0 || strncmp(key,
"arfitness", 8) == 0)
1248 for (i = 0; i < N; ++i)
1249 fprintf(fp,
"%s%.10e", (i==0) ?
"" :
"\t",
1251 while (*key !=
'+' && *key !=
'\0' && key < keyend)
1253 fprintf(fp,
"%c", (*key==
'+') ?
'\t':
'\n');
1255 if (strncmp(key,
"gen", 3) == 0)
1257 fprintf(fp,
"%.0f", t->
gen);
1258 while (*key !=
'+' && *key !=
'\0' && key < keyend)
1260 fprintf(fp,
"%c", (*key==
'+') ?
'\t':
'\n');
1262 if (strncmp(key,
"iter", 4) == 0)
1264 fprintf(fp,
"%.0f", t->
gen);
1265 while (*key !=
'+' && *key !=
'\0' && key < keyend)
1267 fprintf(fp,
"%c", (*key==
'+') ?
'\t':
'\n');
1269 if (strncmp(key,
"sigma", 5) == 0)
1271 fprintf(fp,
"%.4e", t->
sigma);
1272 while (*key !=
'+' && *key !=
'\0' && key < keyend)
1274 fprintf(fp,
"%c", (*key==
'+') ?
'\t':
'\n');
1276 if (strncmp(key,
"minSD", 5) == 0)
1278 fprintf(fp,
"%.4e", sqrt(t->
mindiagC));
1279 while (*key !=
'+' && *key !=
'\0' && key < keyend)
1281 fprintf(fp,
"%c", (*key==
'+') ?
'\t':
'\n');
1283 if (strncmp(key,
"maxSD", 5) == 0)
1285 fprintf(fp,
"%.4e", sqrt(t->
maxdiagC));
1286 while (*key !=
'+' && *key !=
'\0' && key < keyend)
1288 fprintf(fp,
"%c", (*key==
'+') ?
'\t':
'\n');
1290 if (strncmp(key,
"mindii", 6) == 0)
1292 fprintf(fp,
"%.4e", sqrt(t->
minEW));
1293 while (*key !=
'+' && *key !=
'\0' && key < keyend)
1295 fprintf(fp,
"%c", (*key==
'+') ?
'\t':
'\n');
1297 if (strncmp(key,
"0", 1) == 0)
1301 fprintf(fp,
"%c", (*key==
'+') ?
'\t':
'\n');
1303 if (strncmp(key,
"lambda", 6) == 0 || strncmp(key,
"popsi", 5) == 0 || strncmp(key,
"populationsi", 12) == 0)
1306 while (*key !=
'+' && *key !=
'\0' && key < keyend)
1308 fprintf(fp,
"%c", (*key==
'+') ?
'\t':
'\n');
1310 if (strncmp(key,
"N", 1) == 0)
1312 fprintf(fp,
"%d", N);
1314 fprintf(fp,
"%c", (*key==
'+') ?
'\t':
'\n');
1316 if (strncmp(key,
"resume", 6) == 0)
1318 fprintf(fp,
"\n# resume %d\n", N);
1319 fprintf(fp,
"xmean\n");
1321 fprintf(fp,
"path for sigma\n");
1323 fprintf(fp,
"%g%s", t->
rgps[i], (i==N-1) ?
"\n":
"\t");
1324 fprintf(fp,
"path for C\n");
1326 fprintf(fp,
"%g%s", t->
rgpc[i], (i==N-1) ?
"\n":
"\t");
1327 fprintf(fp,
"sigma %g\n", t->
sigma);
1329 fprintf(fp,
"covariance matrix\n");
1331 while (*key !=
'+' && *key !=
'\0' && key < keyend)
1334 if (strncmp(key,
"xbest", 5) == 0) {
1336 fprintf(fp,
"%s%g", (i==0) ?
"":
"\t", t->
rgrgx[t->
index[0]][i]);
1337 while (*key !=
'+' && *key !=
'\0' && key < keyend)
1339 fprintf(fp,
"%c", (*key==
'+') ?
'\t':
'\n');
1341 if (strncmp(key,
"xmean", 5) == 0) {
1343 fprintf(fp,
"%s%g", (i==0) ?
"":
"\t", t->
rgxmean[i]);
1344 while (*key !=
'+' && *key !=
'\0' && key < keyend)
1346 fprintf(fp,
"%c", (*key==
'+') ?
'\t':
'\n');
1348 if (strncmp(key,
"all", 3) == 0)
1350 time_t ti = time(NULL);
1351 fprintf(fp,
"\n# --------- %s\n", asctime(localtime(&ti)));
1352 fprintf(fp,
" N %d\n", N);
1353 fprintf(fp,
" seed %d\n", t->
sp.
seed);
1354 fprintf(fp,
"function evaluations %.0f\n", t->
countevals);
1356 fprintf(fp,
"function value f(x)=%g\n", t->
rgrgx[t->
index[0]][N]);
1357 fprintf(fp,
"maximal standard deviation %g\n", t->
sigma*sqrt(t->
maxdiagC));
1358 fprintf(fp,
"minimal standard deviation %g\n", t->
sigma*sqrt(t->
mindiagC));
1359 fprintf(fp,
"sigma %g\n", t->
sigma);
1361 fprintf(fp,
"xbestever found after %.0f evaluations, function value %g\n",
1365 (i%5==4||i==N-1)?
'\n':
' ');
1366 fprintf(fp,
"xbest (of last generation, function value %g)\n",
1369 fprintf(fp,
" %12g%c", t->
rgrgx[t->
index[0]][i],
1370 (i%5==4||i==N-1)?
'\n':
' ');
1371 fprintf(fp,
"xmean \n");
1373 fprintf(fp,
" %12g%c", t->
rgxmean[i],
1374 (i%5==4||i==N-1)?
'\n':
' ');
1375 fprintf(fp,
"Standard deviation of coordinate axes (sigma*sqrt(diag(C)))\n");
1377 fprintf(fp,
" %12g%c", t->
sigma*sqrt(t->
C[i][i]),
1378 (i%5==4||i==N-1)?
'\n':
' ');
1379 fprintf(fp,
"Main axis lengths of mutation ellipsoid (sigma*diag(D))\n");
1380 for (i = 0; i < N; ++i)
1385 (i%5==4||i==N-1)?
'\n':
' ');
1386 fprintf(fp,
"Longest axis (b_i where d_ii=max(diag(D))\n");
1389 fprintf(fp,
" %12g%c", t->
B[i][k], (i%5==4||i==N-1)?
'\n':
' ');
1390 fprintf(fp,
"Shortest axis (b_i where d_ii=max(diag(D))\n");
1393 fprintf(fp,
" %12g%c", t->
B[i][k], (i%5==4||i==N-1)?
'\n':
' ');
1394 while (*key !=
'+' && *key !=
'\0' && key < keyend)
1410 else if (*key !=
'+') {
1411 ERRORMESSAGE(
"cmaes_t:WriteToFilePtr(): unrecognized key '", key,
"'", 0);
1412 while (*key !=
'+' && *key !=
'\0' && key < keyend)
1420 FATAL(
"cmaes_t:WriteToFilePtr(): BUG regarding key sequence",0,0,0);
1430 if (strncmp(s,
"axisratio", 5) == 0) {
1433 else if (strncmp(s,
"eval", 4) == 0) {
1436 else if (strncmp(s,
"fctvalue", 6) == 0
1437 || strncmp(s,
"funcvalue", 6) == 0
1438 || strncmp(s,
"funvalue", 6) == 0
1439 || strncmp(s,
"fitness", 3) == 0) {
1442 else if (strncmp(s,
"fbestever", 7) == 0) {
1445 else if (strncmp(s,
"generation", 3) == 0
1446 || strncmp(s,
"iteration", 4) == 0) {
1449 else if (strncmp(s,
"maxeval", 4) == 0
1450 || strncmp(s,
"MaxFunEvals", 8) == 0
1451 || strncmp(s,
"stopMaxFunEvals", 12) == 0) {
1454 else if (strncmp(s,
"maxgen", 4) == 0
1455 || strncmp(s,
"MaxIter", 7) == 0
1456 || strncmp(s,
"stopMaxIter", 11) == 0) {
1459 else if (strncmp(s,
"maxaxislength", 5) == 0) {
1462 else if (strncmp(s,
"minaxislength", 5) == 0) {
1465 else if (strncmp(s,
"maxstddev", 4) == 0) {
1468 else if (strncmp(s,
"minstddev", 4) == 0) {
1471 else if (strncmp(s,
"N", 1) == 0 || strcmp(s,
"n") == 0 ||
1472 strncmp(s,
"dimension", 3) == 0) {
1475 else if (strncmp(s,
"lambda", 3) == 0
1476 || strncmp(s,
"samplesize", 8) == 0
1477 || strncmp(s,
"popsize", 7) == 0) {
1480 else if (strncmp(s,
"sigma", 3) == 0) {
1483 FATAL(
"cmaes_Get(cmaes_t, char const * s): No match found for s='", s,
"'",0);
1495 for (i = 0; i < N; ++i)
1514 if (strncmp(s,
"diag(C)", 7) == 0) {
1515 for (i = 0; i < N; ++i)
1516 t->
rgout[i] = t->
C[i][i];
1520 else if (strncmp(s,
"diag(D)", 7) == 0) {
1524 else if (strncmp(s,
"stddev", 3) == 0) {
1525 for (i = 0; i < N; ++i)
1530 else if (strncmp(s,
"xbestever", 7) == 0)
1533 else if (strncmp(s,
"xbest", 5) == 0)
1536 else if (strncmp(s,
"xmean", 1) == 0)
1553 static char sTestOutString[3024];
1554 char * cp = sTestOutString;
1555 int i, cTemp, N=t->
sp.
N;
1561 cp += sprintf(cp,
"Fitness: function value %7.2e <= stopFitness (%7.2e)\n",
1572 "TolFun: function value differences %7.2e < stopTolFun=%7.2e\n",
1582 "TolFunHist: history of function value changes %7.2e stopTolFunHist=%7.2e",
1587 for(i=0, cTemp=0; i<N; ++i) {
1593 "TolX: object variable changes below %7.2e \n",
1598 for(i=0; i<N; ++i) {
1604 "TolUpX: standard deviation increased by more than %7.2e, larger initial standard deviation recommended \n",
1611 "ConditionNumber: maximal condition number %7.2e reached. maxEW=%7.2e,minEW=%7.2e,maxdiagC=%7.2e,mindiagC=%7.2e\n",
1618 for (iAchse = 0; iAchse < N; ++iAchse)
1620 fac = 0.1 * t->
sigma * t->
rgD[iAchse];
1621 for (iKoo = 0; iKoo < N; ++iKoo){
1629 "NoEffectAxis: standard deviation 0.1*%7.2e in principal axis %d without effect\n",
1636 for (iKoo = 0; iKoo < N; ++iKoo)
1639 0.2*t->
sigma*sqrt(t->
C[iKoo][iKoo]))
1644 "NoEffectCoordinate: standard deviation 0.2*%7.2e in coordinate %d without effect\n",
1645 t->
sigma*sqrt(t->
C[iKoo][iKoo]), iKoo);
1653 cp += sprintf(cp,
"MaxFunEvals: conducted function evaluations %.0f >= %g\n",
1656 cp += sprintf(cp,
"MaxIter: number of iterations %.0f >= %g\n",
1659 cp += sprintf(cp,
"Manual: stop signal read\n");
1663 for(i=0, cTemp=0; i<N; ++i) {
1664 cTemp += (sigma * sqrt(C[i][i]) < stopdx) ? 1 : 0;
1665 cTemp += (sigma * rgpc[i] < stopdx) ? 1 : 0;
1672 if (cp - sTestOutString>320)
1673 ERRORMESSAGE(
"Bug in cmaes_t:Test(): sTestOutString too short",0,0,0);
1675 if (cp != sTestOutString) {
1676 return sTestOutString;
1686 const char *s =
"cmaes_signals.par";
1688 if (filename == NULL)
1691 fp = fopen( filename,
"r");
1703 const char *keys[15];
1704 char s[199], sin1[99], sin2[129], sin3[99], sin4[99];
1705 int ikey, ckeys, nb;
1707 static int flglockprint = 0;
1708 static int flglockwrite = 0;
1709 static long countiterlastwritten;
1710 static long maxdiffitertowrite;
1713 double deltaprinttime = (double)(time(NULL)-t->
printtime);
1714 double deltawritetime = (double)(time(NULL)-t->
writetime);
1717 if (countiterlastwritten > t->
gen) {
1718 maxdiffitertowrite = 0;
1719 countiterlastwritten = 0;
1722 keys[0] =
" stop%98s %98s";
1724 keys[1] =
" print %98s %98s";
1725 keys[2] =
" write %98s %128s %98s";
1726 keys[3] =
" check%98s %98s";
1727 keys[4] =
" maxTimeFractionForEigendecompostion %98s";
1729 strcpy(sin2,
"tmpcmaes.dat");
1733 deltaprinttime = (double)time(NULL);
1734 deltawritetime = (double)time(NULL);
1736 while(fgets(s,
sizeof(s), fp) != NULL)
1738 if (s[0] ==
'#' || s[0] ==
'%')
1740 sin1[0] = sin2[0] = sin3[0] = sin4[0] =
'\0';
1741 for (ikey=0; ikey < ckeys; ++ikey)
1743 if((nb=sscanf(s, keys[ikey], sin1, sin2, sin3, sin4)) >= 1)
1747 if (strncmp(sin1,
"now", 3) == 0)
1749 else if (strncmp(sin1,
"MaxFunEvals", 11) == 0) {
1750 if (sscanf(sin2,
" %lg", &d) == 1)
1753 else if (strncmp(sin1,
"MaxIter", 4) == 0) {
1754 if (sscanf(sin2,
" %lg", &d) == 1)
1757 else if (strncmp(sin1,
"Fitness", 7) == 0) {
1758 if (sscanf(sin2,
" %lg", &d) == 1)
1764 else if (strncmp(sin1,
"TolFunHist", 10) == 0) {
1765 if (sscanf(sin2,
" %lg", &d) == 1)
1768 else if (strncmp(sin1,
"TolFun", 6) == 0) {
1769 if (sscanf(sin2,
" %lg", &d) == 1)
1772 else if (strncmp(sin1,
"TolX", 4) == 0) {
1773 if (sscanf(sin2,
" %lg", &d) == 1)
1776 else if (strncmp(sin1,
"TolUpXFactor", 4) == 0) {
1777 if (sscanf(sin2,
" %lg", &d) == 1)
1783 if (sscanf(sin2,
"%lg", &d) < 1 && deltaprinttimefirst < 1)
1785 if (deltaprinttime >= d && !flglockprint) {
1797 if (sscanf(sin3,
"%lg", &d) < 1 && deltawritetimefirst < 2)
1801 if (!flglockwrite) {
1802 if (deltawritetime >= d) {
1806 && t->
gen-countiterlastwritten > maxdiffitertowrite) {
1813 if (strncmp(sin1,
"eigen", 5) == 0) {
1814 if (sscanf(sin2,
" %lg", &d) == 1) {
1825 if (sscanf(sin1,
" %lg", &d) == 1)
1844 if (t->
gen-countiterlastwritten > maxdiffitertowrite)
1845 ++maxdiffitertowrite;
1846 countiterlastwritten = (
long int) t->
gen;
1850 flglockprint = (flglockprint > 0) ? 1 : 0;
1851 flglockwrite = (flglockwrite > 0) ? 1 : 0;
1866 int i, j, k, res = 0;
1870 for (i=0; i < N; ++i)
1871 for (j=0; j < N; ++j) {
1872 for (cc=0.,dd=0., k=0; k < N; ++k) {
1873 cc += diag[k] * Q[i][k] * Q[j][k];
1874 dd += Q[i][k] * Q[j][k];
1877 if (fabs(cc - C[i>j?i:j][i>j?j:i])/sqrt(C[i][i]*C[j][j]) > 1e-10
1878 && fabs(cc - C[i>j?i:j][i>j?j:i]) > 3e-14) {
1879 sprintf(s,
"%d %d: %.17e %.17e, %e",
1880 i, j, cc, C[i>j?i:j][i>j?j:i], cc-C[i>j?i:j][i>j?j:i]);
1881 ERRORMESSAGE(
"cmaes_t:Eigen(): imprecise result detected ",
1885 if (fabs(dd - (i==j)) > 1e-10) {
1886 sprintf(s,
"%d %d %.17e ", i, j, dd);
1887 ERRORMESSAGE(
"cmaes_t:Eigen(): imprecise result detected (Q not orthog.)",
1937 ERRORMESSAGE(
"Warning: Condition number of covariance matrix at upper limit.",
1938 " Consider a rescaling or redesign of the objective function. " ,
"",
"");
1939 printf(
"\nWarning: Condition number of covariance matrix at upper limit\n");
1951 for (i = 0; i < N; ++i)
1952 t->
rgD[i] = sqrt(t->
rgD[i]);
1964Eigen(
int N,
double **C,
double *diag,
double **Q,
double *rgtmp)
1980 FATAL(
"cmaes_t:Eigen(): input parameter double *rgtmp must be non-NULL", 0,0,0);
1984 for (i=0; i < N; ++i)
1985 for (j = 0; j <= i; ++j)
1986 Q[i][j] = Q[j][i] = C[i][j];
1990 Householder( N, Q, diag, rgtmp);
1991 QLalgo( N, diag, Q, 30*N, rgtmp+1);
2002QLalgo2 (
int n,
double *d,
double *e,
double **V) {
2021 double eps = 2.22e-16;
2024 for (i = 1; i < n; i++) {
2029 for (l = 0; l < n; l++) {
2033 if (tst1 < fabs(d[l]) + fabs(e[l]))
2034 tst1 = fabs(d[l]) + fabs(e[l]);
2037 if (fabs(e[m]) <= eps*tst1) {
2052 double p = (d[l+1] - g) / (2.0 * e[l]);
2062 d[l] = e[l] / (p + r);
2063 d[l+1] = e[l] * (p + r);
2066 for (i = l+2; i < n; i++) {
2078 double el1 = e[l+1];
2081 for (i = m-1; i >= l; i--) {
2091 p = c * d[i] - s * g;
2092 d[i+1] = h + s * (c * g + s * d[i]);
2096 for (k = 0; k < n; k++) {
2098 V[k][i+1] = s * V[k][i] + c * h;
2099 V[k][i] = c * V[k][i] - s * h;
2102 p = -s * s2 * c3 * el1 * e[l] / dl1;
2109 }
while (fabs(e[l]) > eps*tst1);
2121 for (i = 0; i < n-1; i++) {
2124 for (j = i+1; j < n; j++) {
2133 for (j = 0; j < n; j++) {
2163 for (j = 0; j < n; j++) {
2169 for (i = n-1; i > 0; i--) {
2175 for (k = 0; k < i; k++) {
2176 scale = scale + fabs(d[k]);
2180 for (j = 0; j < i; j++) {
2191 for (k = 0; k < i; k++) {
2203 for (j = 0; j < i; j++) {
2209 for (j = 0; j < i; j++) {
2212 g = e[j] + V[j][j] * f;
2213 for (k = j+1; k <= i-1; k++) {
2214 g += V[k][j] * d[k];
2215 e[k] += V[k][j] * f;
2220 for (j = 0; j < i; j++) {
2225 for (j = 0; j < i; j++) {
2228 for (j = 0; j < i; j++) {
2231 for (k = j; k <= i-1; k++) {
2232 V[k][j] -= (f * e[k] + g * d[k]);
2243 for (i = 0; i < n-1; i++) {
2245 V[n-1][i] = V[i][i];
2249 for (k = 0; k <= i; k++) {
2250 d[k] = V[k][i+1] / h;
2252 for (j = 0; j <= i; j++) {
2254 for (k = 0; k <= i; k++) {
2255 g += V[k][i+1] * V[k][j];
2257 for (k = 0; k <= i; k++) {
2258 V[k][j] -= g * d[k];
2262 for (k = 0; k <= i; k++) {
2266 for (j = 0; j < n; j++) {
2282 char *s = (
char *)
new_void(200+30*(N+2),
sizeof(
char)); s[0] =
'\0';
2284 sprintf( s+strlen(s),
"\nComplete Info\n");
2285 sprintf( s+strlen(s),
" Gen %20.12g\n", t->
gen);
2286 sprintf( s+strlen(s),
" Dimension %d\n", N);
2287 sprintf( s+strlen(s),
" sigma %e\n", t->
sigma);
2288 sprintf( s+strlen(s),
" lastminEW %e\n",
2291 sprintf( s+strlen(s),
" x-vector rgD Basis...\n");
2294 for (i = 0; i < N; ++i)
2296 sprintf( s+strlen(s),
" %20.12e", t->
rgxmean[i]);
2297 sprintf( s+strlen(s),
" %10.4e", t->
rgD[i]);
2298 for (j = 0; j < N; ++j)
2299 sprintf( s+strlen(s),
" %10.2e", t->
B[i][j]);
2341 double diffc, difft;
2346 FATAL(
"cmaes_timings_started() must be called before using timings... functions",0,0,0);
2351 diffc = (double)(t->
lastclock - lc) / CLOCKS_PER_SEC;
2357 if (diffc > 0 && difft < 1000)
2361 FATAL(
"BUG in time measurement", 0, 0, 0);
2376 ERRORMESSAGE(
"Warning: cmaes_timings_tic called twice without toc",0,0,0);
2386 ERRORMESSAGE(
"Warning: cmaes_timings_toc called without tic",0,0,0);
2414 clock_t cloc = clock();
2419 while ((
long) (cloc - clock()) == 0)
2421 inseed = (
long unsigned)labs((
long)(100*time(NULL)+clock()));
2440 while (inseed > 2e9)
2445 for (i = 39; i >= 0; --i)
2461 double x1, x2, rquad, fac;
2472 rquad = x1*x1 + x2*x2;
2473 }
while(rquad >= 1 || rquad <= 0);
2474 fac = sqrt(-2.0*log(rquad)/rquad);
2493 return (
double)(t->
aktrand)/(2.147483647e9);
2499 char const *s3,
char const *s4)
2502 fprintf(
fd,
"%s", s1);
2504 fprintf(
fd,
" %s", s2);
2506 fprintf(
fd,
" %s", s3);
2508 fprintf(
fd,
" %s", s4);
2517 const double * inxstart,
2518 const double * inrgsigma,
2521 const char * filename)
2569 t->
seed = (unsigned) inseed;
2604 if (!
isNoneStr(filename) && (!filename || strcmp(filename,
"writeonly") != 0))
2612 FATAL(
"cmaes_readpara_t(): problem dimension N undefined.\n",
2613 " (no default value available).",0,0);
2614 if (t->
xstart == NULL && inxstart == NULL && t->
typicalX == NULL) {
2615 ERRORMESSAGE(
"Error: initialX undefined. typicalX = 0.5...0.5 used.",
"",
"",
"");
2616 printf(
"\nError: initialX undefined. typicalX = 0.5...0.5 used.\n");
2620 ERRORMESSAGE(
"Error: initialStandardDeviations undefined. 0.3...0.3 used.",
"",
"",
"");
2621 printf(
"\nError: initialStandardDeviations undefined. 0.3...0.3 used.\n");
2628 if (inxstart != NULL) {
2630 t->
xstart[i] = inxstart[i];
2643 t->
rgInitialStds[i] = (inrgsigma == NULL) ? 0.3 : inrgsigma[i];
2680 const char *ss =
"cmaes_initials.par";
2684 if (filename == NULL) {
2688 fp = fopen( filename,
"r");
2690 ERRORMESSAGE(
"cmaes_ReadFromFile(): could not open '", filename,
"'",0);
2693 for (ipara=0; ipara < t->
n1para; ++ipara)
2696 while(fgets(s,
sizeof(s), fp) != NULL)
2698 if (s[0] ==
'#' || s[0] ==
'%')
2701 if (strncmp(t->
rgsformat[ipara],
" stopFitness ", 13) == 0)
2708 FATAL(
"cmaes_readpara_ReadFromFile(): No valid dimension N",0,0,0);
2709 for (ipara=0; ipara < t->
n2para; ++ipara)
2712 while(fgets(s,
sizeof(s), fp) != NULL)
2714 if (s[0] ==
'#' || s[0] ==
'%')
2719 for (i=0;i<
size&&i<t->
N;++i)
2720 if (fscanf(fp,
" %lf", &(*t->
rgp2adr[ipara])[i]) != 1)
2722 if (i<
size && i < t->N) {
2723 ERRORMESSAGE(
"cmaes_readpara_ReadFromFile ", filename,
": ",0);
2725 "' not enough values found.\n",
2726 " Remove all comments between numbers.");
2728 for (; i < t->
N; ++i)
2746 time_t ti = time(NULL);
2747 FILE *fp = fopen( filenamedest,
"a");
2750 filenamedest,
"'",0);
2754 asctime(localtime(&ti)));
2755 for (ipara=0; ipara < 1; ++ipara) {
2759 for (ipara=0; ipara < t->
n2para; ++ipara) {
2760 if(*t->
rgp2adr[ipara] == NULL)
2764 for (i=0; i<t->
N; ++i)
2765 fprintf(fp,
"%7.3g%c", (*t->
rgp2adr[ipara])[i], (i%5==4)?
'\n':
' ');
2768 for (ipara=1; ipara < t->
n1outpara; ++ipara) {
2769 if (strncmp(t->
rgsformat[ipara],
" stopFitness ", 13) == 0)
2771 fprintf(fp,
" stopFitness\n");
2777 else if (t->
rgsformat[ipara][len-1] ==
's')
2780 if (strncmp(
" fac*", t->
rgsformat[ipara], 5) == 0) {
2805 clock_t cloc = clock();
2808 FATAL(
"cmaes_readpara_SupplementDefaults() cannot be called twice.",0,0,0);
2810 while ((
int) (cloc - clock()) == 0)
2812 t->
seed = (
unsigned int)labs((
long)(100*time(NULL)+clock()));
2819 t->
lambda = 4+(int)(3*log((
double)N));
2829 if (t->
cs <= 0 || t->
cs >= 1)
2838 t1 = 2. / ((N+1.4142)*(N+1.4142));
2839 t2 = (2.*t->
mueff-1.) / ((N+2.)*(N+2.)+t->
mueff);
2840 t2 = (t2 > 1) ? 1 : t2;
2841 t2 = (1./t->
mucov) * t1 + (1.-1./t->
mucov) * t2;
2861 * (1 + 2*
douMax(0., sqrt((t->
mueff-1.)/(N+1.)) - 1))
2888 if (strcmp(mode,
"lin") == 0)
2889 for (i=0; i<t->
mu; ++i)
2891 else if (strncmp(mode,
"equal", 3) == 0)
2892 for (i=0; i<t->
mu; ++i)
2894 else if (strcmp(mode,
"log") == 0)
2895 for (i=0; i<t->
mu; ++i)
2896 t->
weights[i] = log(t->
mu+1.)-log(i+1.);
2898 for (i=0; i<t->
mu; ++i)
2899 t->
weights[i] = log(t->
mu+1.)-log(i+1.);
2902 for (i=0, s1=0, s2=0; i<t->
mu; ++i) {
2906 t->
mueff = s1*s1/s2;
2907 for (i=0; i<t->
mu; ++i)
2912 FATAL(
"cmaes_readpara_SetWeights(): invalid setting of mu or lambda",0,0,0);
2921 if (filename && (strcmp(filename,
"no") == 0
2922 || strcmp(filename,
"non") == 0
2923 || strcmp(filename,
"none") == 0))
2939 return i > j ? i : j;
2944 return i < j ? i : j;
2950 double max = rgd[0];
2951 for (i = 1; i < len; ++i)
2952 max = (max < rgd[i]) ? rgd[i] : max;
2960 double min = rgd[0];
2961 for (i = 1; i < len; ++i)
2962 min = (min > rgd[i]) ? rgd[i] : min;
2970 for(i=1, res=0; i<len; ++i)
2971 if(rgd[i] > rgd[res])
2979 for(i=1, res=0; i<len; ++i)
2980 if(rgd[i] < rgd[res])
2990 if (fabs(a) > fabs(b)) {
2992 r = fabs(a)*sqrt(1+r*r);
2993 }
else if (b != 0) {
2995 r = fabs(b)*sqrt(1+r*r);
3002 return *((
double *) d1) > *((
double *) d2) ? 1 : -1;
3010 for (i=1, iindex[0]=0; i<n; ++i) {
3011 for (j=i; j>0; --j) {
3012 if (rgFunVal[iindex[j-1]] < rgFunVal[i])
3014 iindex[j] = iindex[j-1];
3024 void *p = calloc((
unsigned) n,
size);
3026 sprintf(s,
"new_void(): calloc(%ld,%ld) failed",(
long)n,(
long)
size);
3041 double *p = (
double *) calloc((
unsigned) n,
sizeof(
double));
3043 sprintf(s,
"new_double(): calloc(%ld,%ld) failed",
3044 (
long)n,(
long)
sizeof(
double));
3055 unsigned len = (unsigned) ((ins != NULL) ? strlen(ins) : 0);
3058 FATAL(
"new_string(): input string length was larger then 1000 ",
3059 "(possibly due to uninitialized char *filename)",0,0);
3062 p = (
char *) calloc( len + 1,
sizeof(
char));
3064 sprintf(s,
"new_string(): calloc(%ld,%ld) failed",
3065 (
long)len,(
long)
sizeof(
char));
3068 for (i = 0; i < len; ++i)
3090 time_t t = time(NULL);
3093 printf(
"\n -- %s ", asctime(localtime(&t)));
3096 printf(
" *** CMA-ES ABORTED, see errcmaes.err *** \n");
3103FATAL(
char const *s1,
char const *s2,
char const *s3,
3111 char const *s3,
char const *s4)
3117 FILE *fp = fopen(
"errcmaes.err",
"a");
3119 printf(
"\nFATAL ERROR: ");
3122 printf(
"cmaes_t could not open file 'errcmaes.err'.");
3123 printf(
"\n *** CMA-ES ABORTED *** ");
3127 time_t t = time(NULL);
3128 fprintf(fp,
"\n -- %s ", asctime(localtime(&t)));
const double * cmaes_Optimize(cmaes_t *, double(*pFun)(double const *, int dim), long iterations)
double * cmaes_UpdateDistribution(cmaes_t *t, const double *rgFunVal)
void cmaes_timings_start(cmaes_timings_t *timing)
double *const * cmaes_ReSampleSingle(cmaes_t *t, int iindex)
static char * new_string(const char *)
static int Check_Eigen(int N, double **C, double *diag, double **Q)
char * cmaes_SayHello(cmaes_t *t)
static int MinIdx(const double *rgd, int len)
void cmaes_resume_distribution(cmaes_t *t, char *filename)
void cmaes_ReadSignals(cmaes_t *t, char const *filename)
void cmaes_readpara_ReadFromFile(cmaes_readpara_t *, const char *szFileName)
static int SignOfDiff(const void *d1, const void *d2)
static void Adapt_C2(cmaes_t *t, int hsig)
static void Sorted_index(const double *rgFunVal, int *index, int n)
static int MaxIdx(const double *rgd, int len)
static void Householder2(int n, double **V, double *d, double *e)
void cmaes_readpara_init(cmaes_readpara_t *, int dim, const double *xstart, const double *sigma, int seed, int lambda, const char *filename)
long cmaes_random_Start(cmaes_random_t *, long unsigned seed)
double const * cmaes_SetMean(cmaes_t *, const double *xmean)
static void ERRORMESSAGE(char const *sz1, char const *s2, char const *s3, char const *s4)
void cmaes_readpara_WriteToFile(cmaes_readpara_t *, const char *filenamedest)
double * cmaes_PerturbSolutionInto(cmaes_t *t, double *xout, double const *xin, double eps)
void cmaes_readpara_SupplementDefaults(cmaes_readpara_t *)
double * cmaes_NewDouble(int n)
double * cmaes_SampleSingleInto(cmaes_t *t, double *rgx)
static double myhypot(double a, double b)
void cmaes_readpara_SetWeights(cmaes_readpara_t *, const char *mode)
void cmaes_WriteToFile(cmaes_t *, const char *key, const char *name)
void cmaes_readpara_exit(cmaes_readpara_t *)
void cmaes_timings_tic(cmaes_timings_t *timing)
static double douSquare(double)
static void * new_void(int n, size_t size)
void cmaes_ReadFromFilePtr(cmaes_t *, FILE *fp)
double *const * cmaes_SamplePopulation(cmaes_t *t)
static double douMax(double d1, double d2)
static void assign_string(char **, const char *)
double * cmaes_GetNew(cmaes_t *t, char const *s)
double cmaes_random_Uniform(cmaes_random_t *)
double cmaes_timings_update(cmaes_timings_t *timing)
double * cmaes_GetInto(cmaes_t *t, char const *s, double *res)
static void FATAL(char const *sz1, char const *s2, char const *s3, char const *s4)
double cmaes_Get(cmaes_t *t, char const *s)
static void printErrorStrings(FILE *fd, char const *s1, char const *s2, char const *s3, char const *s4)
double * cmaes_init_final(cmaes_t *t)
double * cmaes_init(cmaes_t *t, int dimension, double *inxstart, double *inrgstddev, long int inseed, int lambda, const char *input_parameter_filename)
static int isNoneStr(const char *filename)
static double douMin(double d1, double d2)
void cmaes_WriteToFilePtr(cmaes_t *, const char *key, FILE *fp)
static const char * c_cmaes_version
void cmaes_FATAL(char const *s1, char const *s2, char const *s3, char const *s4)
double cmaes_timings_toc(cmaes_timings_t *timing)
static double rgdouMin(const double *rgd, int len)
double const * cmaes_ReSampleSingle_old(cmaes_t *t, double *rgx)
void cmaes_WriteToFileAW(cmaes_t *t, const char *key, const char *name, const char *append)
static void Eigen(int N, double **C, double *diag, double **Q, double *rgtmp)
void cmaes_init_para(cmaes_t *t, int dimension, double *inxstart, double *inrgstddev, long int inseed, int lambda, const char *input_parameter_filename)
static char * getTimeStr(void)
static void QLalgo2(int n, double *d, double *e, double **V)
static void TestMinStdDevs(cmaes_t *)
void cmaes_random_exit(cmaes_random_t *)
double cmaes_random_Gauss(cmaes_random_t *)
void cmaes_UpdateEigensystem(cmaes_t *t, int flgforce)
static double * new_double(int n)
void cmaes_exit(cmaes_t *t)
const char * cmaes_TestForTermination(cmaes_t *t)
long cmaes_random_init(cmaes_random_t *, long unsigned seed)
const double * cmaes_GetPtr(cmaes_t *t, char const *s)
static double rgdouMax(const double *rgd, int len)
void cmaes_timings_init(cmaes_timings_t *timing)
static bool stop(uint32_t session)
End only the matching session, even if its stop packet cannot be sent.
static bool range(size_t total, size_t offset, size_t length)
Check a byte span without forming a potentially overflowing end offset.
struct cmaes_readpara_t::@246072133035303104351372072164363242153236050306 stStopFitness
struct cmaes_readpara_t::@107217224144210100141365135165274176060022201164 updateCmode
double genOfEigensysUpdate
short flgEigensysIsUptodate
double dLastMinEWgroesserNull
cmaes_timings_t eigenTimings
double tictoczwischensumme