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