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
boundary_transformation.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 * INTERFACE: the relevant functions are
20 *
21 * * cmaes_boundary_transformation_init(this, l_bound, u_bound, len)
22 * * cmaes_boundary_transformation_exit(this)
23 * * cmaes_boundary_transformation(this, x, y, len)
24 *
25 * implements a smooth mapping double *x -> double *y that guarantees
26 * elements of y to be within specified boundaries. The mapping is piecewise
27 * either linear or quadratic and can achieve values arbitrarily close to and
28 * on the boundaries. The middle of the domain l_bound + (u_bound-l_bound) / 2.0
29 * always maps to itself. Typically, 90% of feasible values (those not close
30 * to the boundaries) are mapped to themselves, preventing any numerical subtleties.
31 * Specifically, al, au > 0 are internally chosen offsets. The mapping
32 * [l_bound - al, u_bound + au] <-> [l_bound, u_bound] is monotonous, bijective
33 * and invertible. It is the identity within [l_bound + al, u_bound - au] and
34 * quadratic for [l_bound - 3*al, l_bound + al] (with l_bound - al -> l_bound)
35 * and for [u_bound - au, u_bound + 3*au] (with u_bound + au -> u_bound).
36 *
37 * The method is robust against very small/large boundary values, say
38 * -1e99 and/or 1e99, to emulated unbounded variables. In this case values
39 * between -1e98 and 1e98 are never changed, i.e. mapped to itself.
40 *
41 */
42
43typedef struct {
44 double const *lower_bounds; /* array of size len_of_bounds */
45 double const *upper_bounds; /* array of size len_of_bounds */
46 unsigned long len_of_bounds; /* in case, last value is recycled */
47 double *al; /* "add"-on to lower boundary preimage, same length as bounds */
48 double *au; /* add-on to upper boundary preimage, same length as bounds */
50
51/* set lower and upper bounds, the values lower_bounds[len_of_bounds - 1] and
52 * upper_bounds[len_of_bounds - 1] are recycled for any element >= len_of_bounds.
53 * If len_of_bounds == 0, no bounds are assumed. If len_of_bounds == 1, the
54 * zero pointer is allowed for lower_bounds or upper_bounds and indicates no
55 * respective bounds. "no bounds" is "emulated" using the very small/large value
56 * of DBL_MAX / -1e2 and DBL_MAX / 1e2, respectively. */
58 double const *lower_bounds, double const *upper_bounds, unsigned long len_of_bounds);
59
60/* release memory */
62
63/* on return, y is guaranteed to have all values within the boundaries.
64 * The caller inputs x and is responsible for having allocated y in that
65 * y[len-1] = x[len-1] is a valid operation. x==y is valid input, but
66 * will fail together with cmaes when x is an element of the population
67 * returned by cmaes_SamplePopulation (these elements are of type
68 * double const * for a reason).
69 * */
71 double const *x, double *y, unsigned long len); /* new value into y */
72
73/* after
74 * cmaes_boundary_transformation(b,x,y,l) ;
75 * the two consecutive calls
76 * cmaes_boundary_transformation_inverse(b,y,x,l) ; cmaes_boundary_transformation(b,x,y,l) ;
77 * have no effect on y anymore (but they might change x!).
78 * */
80 double const *y, double *x, unsigned long len); /* new value into x */
81
82/* used by function cmaes_boundary_transformation. After applying the shift,
83 * cmaes_boundary_transformation_shift_into_feasible_preimage(b,x,x,l)
84 * the two consecutive calls
85 * cmaes_boundary_transformation(b,x,y,l) ; cmaes_boundary_transformation_inverse(b,y,x,l) ;
86 * have no effect on x anymore */
88 double const *x, double *x_shifted, unsigned long len); /* new value into x_shifted */
89
90
void cmaes_boundary_transformation(cmaes_boundary_transformation_t *, double const *x, double *y, unsigned long len)
void cmaes_boundary_transformation_exit(cmaes_boundary_transformation_t *)
void cmaes_boundary_transformation_init(cmaes_boundary_transformation_t *, double const *lower_bounds, double const *upper_bounds, unsigned long len_of_bounds)
void cmaes_boundary_transformation_inverse(cmaes_boundary_transformation_t *t, double const *y, double *x, unsigned long len)
void cmaes_boundary_transformation_shift_into_feasible_preimage(cmaes_boundary_transformation_t *t, double const *x, double *x_shifted, unsigned long len)