ipo interior-point optimisation library


Home ·
Download ·
Documentation ·
Namespaces and #includes ·
Defining functions ·
Example of a function ·
Variables and arrays ·
Objective and constraints ·
Building a model ·
Example ·
Bugs ·

Defining functions for objective and constraints

The objective and constraints of an interior-point optimisation problem need twice continuously differentiable functions. So we need a uniform method to supply a function of a vector argument together with its gradient and Hessian. The Function class provides such a method. To create one, first create a subclass of ipo_function::Function. Define the

double operator()( gsl::vector const& vector );
method. You can also define the gradient and hessian methods. If you don’t ipo estimates the derivatives using central difference quotients. This is often less efficient and less accurate than providing explicit functions.

If your function uses vectors of fixed size, set the size parameter in the class constructor (see example) to that size. Ipo uses this information to check you have set the right number of variables.

Ipo uses the function value, gradient and Hessian evaluated at the same point. Sometimes it is more efficient to compute all three at once. If you wish to do this, create a class that is a subclass of both ipo_function::Function and ipo_function::DerivativesEstimates and define the

void setVector( gsl::vector const& vector );
method to compute values for the functionValue, functionGradient and functionHessian fields. Ipo will detect that you have done this and, when it needs all three values, will compute all three at the same time.

The gsl::vector class is documented in ccgsl. It is straightforward to extract an array of doubles from a gsl::vector. This is useful when adapting an existing function.

Note that it is not necessary to define all the subclasses of Function that you use to have the same vector argument. You can have arguments of different lengths and you don’t have to supply the variables in the same order. However, you do well to supply a full-length vector to each Function function object because ipo detects this and can run more efficiently. The exception to this rule is where a Function function object needs only one argument. Then you can pass a vector of length one without worrying about efficiency.

Last modified: Tue 02 Jul 2013 04:56 pm

SourceForge.net Logo