minimize.h File Reference

One-dimensional minimization routines. More...

#include <o2scl/err_hnd.h>

Go to the source code of this file.


Detailed Description

Definition in file minimize.h.


Data Structures

class  minimize
 One-dimensional minimization [abstract base]. More...
class  minimize_bkt
 One-dimensional bracketing minimization [abstract base]. More...
class  minimize_de
 One-dimensional minimization using derivatives [abstract base]. More...

Functions

double constraint (double x, double center, double width, double height)
 Constrain x to be within width of the value given by center.
double cont_constraint (double x, double center, double width, double height, double tightness=40.0, double exp_arg_limit=50.0)
 Constrain x to be within width of the value given by center.
double lower_bound (double x, double center, double width, double height)
 Constrain x to be greater than the value given by center.
double cont_lower_bound (double x, double center, double width, double height, double tightness=40.0, double exp_arg_limit=50.0)
 Constrain x to be greater than the value given by center.

Function Documentation

double constraint ( double  x,
double  center,
double  width,
double  height 
) [inline]

Defining $ c= $ center, $ w= $ width, $ h= $ height, this returns the value $ h (1+|x-c-w|/w) $ if $ x>c+w $ and $ h (1+|x-c+w|/w) $ if $ x<c-w $ . The value near $ x=c-w $ or $ x=c+w $ is $ h $ (the value of the function exactly at these points is zero) and the value at $ x=c-2w $ or $ x=c+2w $ is $ 2 h $ .

It is important to note that, for large distances of x from center, this only scales linearly. If you are trying to constrain a function which decreases more than linearly by making x far from center, then a minimizer may ignore this constraint.

Definition at line 378 of file minimize.h.

double cont_constraint ( double  x,
double  center,
double  width,
double  height,
double  tightness = 40.0,
double  exp_arg_limit = 50.0 
) [inline]

Defining $ c= $ center, $ w= $ width, $ h= $ height, $ t= $ tightness, and $ \ell= $ exp_arg_limit, this returns the value

\[ h \left(\frac{x-c}{w}\right)^2 \left[ 1+ e^{t\left(x-c+w\right)\left(c+w-x\right)/w^2} \right]^{-1} \]

This function is continuous and differentiable. Note that if $ x=c $ , then the function returns zero.

The exponential is handled gracefully by assuming that anything smaller than $ \exp(-\ell) $ is zero. This creates a small discontinuity which can be removed with the sufficiently large value of $ \ell $.

It is important to note that, for large distances of x from center, this scales quadratically. If you are trying to constrain a function which decreases faster than quadratically by making x far from center, then a minimizer may ignore this constraint.

In the limit $ t \rightarrow \infty $, this function converges towards the squared value of constraint(), except exactly at the points $ x=c-w $ and $ x=c+w $.

Definition at line 419 of file minimize.h.

double cont_lower_bound ( double  x,
double  center,
double  width,
double  height,
double  tightness = 40.0,
double  exp_arg_limit = 50.0 
) [inline]

Defining $ c= $ center, $ w= $ width, $ h= $ height, $ t= $ tightness, and $ \ell= $ exp_arg_limit, this returns $ h(c-x+w)/(w+w\exp(t(x-c)/w)) $ and has the advantage of being a continuous and differentiable function. The value of the function exactly at $ x=c $ is $ h/2 $, but for $ x $ just below $ c $ the function is $ h $ and just above $ c $ the function is quite small.

The exponential is handled gracefully by assuming that anything smaller than $ \exp(-\ell) $ is zero. This creates a small discontinuity which can be removed with the sufficiently large value of $ \ell $.

It is important to note that, for large distances of x from center, this only scales linearly. If you are trying to constrain a function which decreases more than linearly by making x far from center, then a minimizer may ingore this constraint.

In the limit $ t \rightarrow \infty $, this function converges towards lower_bound(), except exactly at the point $ x=c $.

Definition at line 482 of file minimize.h.

double lower_bound ( double  x,
double  center,
double  width,
double  height 
) [inline]

Defining $ c= $ center, $ w= $ width, $ h= $ height, this returns $ h(1+|x-c|/w) $ if $ x<c $ and zero otherwise. The value at $ x=c $ is $ h $ , while the value at $ x=c-w $ is $ 2 h $ .

It is important to note that, for large distances of x from center, this only scales linearly. If you are trying to constrain a function which decreases more than linearly by making x far from center, then a minimizer may ignore this constraint.

Definition at line 447 of file minimize.h.


Documentation generated with Doxygen and provided under the GNU Free Documentation License. See License Information for details.

Project hosting provided by SourceForge.net Logo, O2scl Sourceforge Project Page