-
Notifications
You must be signed in to change notification settings - Fork 0
/
cmaes.h
executable file
·172 lines (142 loc) · 4.22 KB
/
cmaes.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
/* --------------------------------------------------------- */
/* --- File: cmaes.h ----------- Author: Nikolaus Hansen --- */
/* ---------------------- last modified: VIII 2007 --- */
/* --------------------------------- by: Nikolaus Hansen --- */
/* --------------------------------------------------------- */
/*
CMA-ES for non-linear function minimization.
Copyright (C) 1996, 2003-2007 Nikolaus Hansen.
e-mail: [email protected]
License: see file cmaes.c
*/
#ifndef NH_cmaes_h /* only include ones */
#define NH_cmaes_h
#include <time.h>
typedef struct
/* random_t
* sets up a pseudo random number generator instance
*/
{
/* Variables for Uniform() */
long int startseed;
long int aktseed;
long int aktrand;
long int *rgrand;
/* Variables for Gauss() */
short flgstored;
double hold;
} random_t;
typedef struct
/* timings_t
* time measurement, used to time eigendecomposition
*/
{
/* for outside use */
double totaltime; /* zeroed by calling re-calling timings_start */
double totaltotaltime;
double tictoctime;
double lasttictoctime;
/* local fields */
clock_t lastclock;
time_t lasttime;
clock_t ticclock;
time_t tictime;
short istic;
short isstarted;
double lastdiff;
double tictoczwischensumme;
} timings_t;
typedef struct
/* readpara_t
* collects all parameters, in particular those that are read from
* a file before to start. This should split in future?
*/
{
/* input parameter */
int N; /* problem dimension, must stay constant */
unsigned int seed;
double * xstart;
double * typicalX;
int typicalXcase;
double * rgInitialStds;
double * rgDiffMinChange;
/* termination parameters */
double stopMaxFunEvals;
double facmaxeval;
double stopMaxIter;
struct { int flg; double val; } stStopFitness;
double stopTolFun;
double stopTolFunHist;
double stopTolX;
double stopTolUpXFactor;
/* internal evolution strategy parameters */
int lambda; /* -> mu, <- N */
int mu; /* -> weights, (lambda) */
double mucov, mueff; /* <- weights */
double *weights; /* <- mu, -> mueff, mucov, ccov */
double damps; /* <- cs, maxeval, lambda */
double cs; /* -> damps, <- N */
double ccumcov; /* <- N */
double ccov; /* <- mucov, <- N */
double diagonalCov; /* number of initial iterations */
struct { int flgalways; double modulo; double maxtime; } updateCmode;
double facupdateCmode;
/* supplementary variables */
char *weigkey;
char resumefile[99];
char **rgsformat;
void **rgpadr;
char **rgskeyar;
double ***rgp2adr;
int n1para, n1outpara;
int n2para;
} readpara_t;
typedef struct
/* cmaes_t
* CMA-ES "object"
*/
{
char *version;
readpara_t sp;
random_t rand; /* random number generator */
double sigma; /* step size */
double *rgxmean; /* mean x vector, "parent" */
double *rgxbestever;
double **rgrgx; /* range of x-vectors, lambda offspring */
int *index; /* sorting index of sample pop. */
double *arFuncValueHist;
short flgIniphase; /* not really in use anymore */
short flgStop;
double chiN;
double **C; /* lower triangular matrix: i>=j for C[i][j] */
double **B; /* matrix with normalize eigenvectors in columns */
double *rgD; /* axis lengths */
double *rgpc;
double *rgps;
double *rgxold;
double *rgout;
double *rgBDz; /* for B*D*z */
double *rgdTmp; /* temporary (random) vector used in different places */
double *rgFuncValue;
double *publicFitness; /* returned by cmaes_init() */
double gen; /* Generation number */
double countevals;
double state; /* 1 == sampled, 2 == not in use anymore, 3 == updated */
double maxdiagC; /* repeatedly used for output */
double mindiagC;
double maxEW;
double minEW;
char sOutString[330]; /* 4x80 */
short flgEigensysIsUptodate;
short flgCheckEigen; /* control via signals.par */
double genOfEigensysUpdate;
timings_t eigenTimings;
double dMaxSignifKond;
double dLastMinEWgroesserNull;
short flgresumedone;
time_t printtime;
time_t writetime; /* ideally should keep track for each output file */
time_t firstwritetime;
time_t firstprinttime;
} cmaes_t;
#endif