Illustrated C/C++ source sheets, symbol index, API relationship graph, compiler console and debug trace

LIVE AI / FLEXIBLE SENSING / FLIGHT CONTEXT

Sensoraia API

Live AI and sensing, connected to the flight.
See, listen, inspect and return supported results while airborne.

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