Package park :: Package fitting :: Module rangemap :: Class ZeroOneMapper

Class ZeroOneMapper

source code


Map function range into [0,1]**n.

Given f: [a,b] -> R Defines f': [0,1] -> R

The method encode(x) returns a value in [0,1] The method decode(v) returns a value in [a,b] The method __call__(v) returns f(decode(v))

For indefinite and semidefinte ranges, an asymptote transformation is needed. Normally this is park.rangemap.Asymptote which supports the full floating point range of values, but is limited to about 12 digits of precision. The arctan function can also be used (see park.rangemap.ArctanAsymptote).

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.

Instance Methods
 
__init__(self, base_function, low, high, asymptote=<class park.fitting.rangemap.Asymptote at 0x6a4e6f0>, range_check=False)
Function range mapper.
source code
 
decode(v)
Transform from range [0,1] to [a,b].
source code
 
encode(x)
Transform from range [a,b] to [0,1].
source code

Inherited from object: __delattr__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __str__

Properties

Inherited from object: __class__

Method Details

__init__(self, base_function, low, high, asymptote=<class park.fitting.rangemap.Asymptote at 0x6a4e6f0>, range_check=False)
(Constructor)

source code 

Function range mapper. See park.rangemap.ZeroOneMapper for details.

base_function is the function being wrapped.

low[k],high[k] is the range of values for each fitting parameter k.

range_check is True if calls to the mapper may include out of range values. In this case, f(v) returns inf for out of range values and encode/decode raise exceptions.

asymptote is the asymptote function to use when linearizing indefinite ranges.

Overrides: object.__init__