Module rangemap
source code
Defines transformations between the a fit space and the parameter space.
The parameter space maps a set of possibly bounded dimensions into a
real-valued fitness:
f: [a,b]**n |-> R
The fit space is constrained to map values in the unit box:
f': [0,1]**n |-> R
Here we can define f' using the zero-one mapper:
f' = ZeroOneMapper(f,a,b)
f'(v) = f(x)
An asymptote function maps x to [0,1], preserving at least 12 digits of
precision.
Using this mapping, the optimizer can operate in a well known space
independent of parameter precision. This allows the use of reasonable
constants for items such as a step size and initial value.
Note: we do not yet support fitness functions with analytic derivatives.
Given df/dp and mapping function f'(v) = f(M(v)) then df'/dv = df/dM dM/dv.
So the derivatives need to be multiplied by the derivative of the
parameter mapper. Not difficult computationally, but the definition of
the fitness function does not currently support this organization.
|
|
|
|
|
|
|
|
zero_one_mapper(base_function,
low,
high,
asymptote=<class 'park.fitting.rangemap.ArctanAsymptote'>)
Map function range into [0,1]**n. |
source code
|
|
|
|
|
|
|
fp_max = 2047
|
|
|
fp_min = -2047
|
|
Linearize floating point values using an exponential scale.
Convert sign*m*2^e to sign*(e+1023+m), yielding a value in [-2047,2047]
|
|
Restore floating point value from linear form on an exponential scale.
Convert sign*(e+1023+m) to sign*m*2^e, yielding a value in [-1e308,1e308]
|
zero_one_mapper(base_function,
low,
high,
asymptote=<class 'park.fitting.rangemap.ArctanAsymptote'>)
| source code
|
Map function range into [0,1]**n.
Returns a pair of functions f and inv. The function f takes an
encoded value in
encode, which takes x and returns a value
in [0,1] and decode, which takes a value in [0,1] and returns x.
Range is determined by the bounds low and high. Each dimension may be
unbounded, semi-definite or bounded. Bounded functions use a linear
mapping between low and high. Unbounded functions use an asymptote
function, which should be -1 at -inf, 0 at 0 and 1 at +inf, and
approximate the identity function between [-0.5,0.5].
This can be used to turn any unconstrained optimizer into a [0,1]
bounded optimizer by sending infeasible points to infinity.
Note: Newton-style optimizers will not work in this regime, but
instead require a hint about the direction of the unconstrained
region.
|
|
Evaluate a function with bounds checking.
This can be used to turn any unconstrained optimizer into a
constrained optimizer by sending infeasible points to infinity.
Note: Newton-style optimizers will not work in this regime, but
instead require a hint about the direction of the unconstrained
region.
Note: unused function which may be removed in future versions.
|