CNLMath : Optimization : Usage Notes
Usage Notes
Unconstrained Minimization
The unconstrained minimization problem can be stated as follows:
where f : n  is continuous and has derivatives of all orders required by the algorithms. The functions for unconstrained minimization are grouped into three categories: univariate functions, multivariate functions, and nonlinear least-squares functions.
For the univariate functions, it is assumed that the function is unimodal within the specified interval. For discussion on unimodality, see Brent (1973).
A quasi-Newton method is used for the multivariate function imsl_f_min_uncon_multivar. The default is to use a finite-difference approximation of the gradient of f(x). Here, the gradient is defined to be the vector
However, when the exact gradient can be easily provided, the keyword IMSL_GRAD should be used.
The nonlinear least-squares function uses a modified Levenberg-Marquardt algorithm. The most common application of the function is the nonlinear data-fitting problem where the user is trying to fit the data with a nonlinear model.
These functions are designed to find only a local minimum point. However, a function may have many local minima. Try different initial points and intervals to obtain a better local solution.
Double-precision arithmetic is recommended for the functions when the user provides only the function values.
Linearly Constrained Minimization
The linearly constrained minimization problem can be stated as follows:
where f : Rn  R, A1 and A2 are coefficient matrices, and b1 and b2 are vectors. If f(x) is linear, then the problem is a linear programming problem. If f(x) is quadratic, the problem is a quadratic programming problem.
The function imsl_f_linear_programming uses an active set strategy to solve linear programming problems, and is intended as a replacement for the function imsl_f_lin_prog. The two functions have similar interfaces, which should help facilitate migration from imsl_f_lin_prog to imsl_f_linear_programming. In general, the function imsl_f_linear_programming should be expected to perform more efficiently than imsl_f_lin_prog. Both imsl_f_linear_programming and imsl_f_lin_prog are intended for use with small- to medium-sized linear programming problems. No sparsity is assumed since the coefficients are stored in full matrix form.
Function imsl_f_transport solves a transportation problem, which is a very sparse linear programming application.
Function imsl_d_sparse_lin_prog uses an infeasible primal-dual interior-point method to solve sparse linear programming problems of all sizes. The constraint matrix is stored in sparse coordinate storage format.
The function imsl_f_quadratic_prog is designed to solve convex quadratic programming problems using a dual quadratic programming algorithm. If the given Hessian is not positive definite, then imsl_f_quadratic_prog modifies it to be positive definite. In this case, output should be interpreted with care because the problem has been changed slightly. Here, the Hessian of f(x) is defined to be the n × n matrix
Function imsl_d_sparse_quadratic_prog uses an infeasible primal-dual interior-point method to solve sparse convex quadratic programming problems of all sizes. The constraint matrix and the Hessian are stored in sparse coordinate storage format.
Nonlinearly Constrained Minimization
The nonlinearly constrained minimization problem can be stated as follows:
where f : Rn  R and gi : Rn  R, for i = 1, 2, , m.
The function imsl_f_constrained_nlp uses a sequential equality constrained quadratic programming algorithm to solve this problem. A more complete discussion of this algorithm can be found in the documentation.
Return Values from User-Supplied Functions
All values returned by user-supplied functions must be valid real numbers. It is the user’s responsibility to check that the values returned by a user-supplied function do not contain NaN, infinity, or negative infinity values.
 
#include <imsl.h>
#include <math.h>
void fcn(int, int, float[], float[]);
void main()
{
int m=3, n=1;
float *result, fx[3];
float xguess[]={1.0};
result = imsl_f_nonlin_least_squares(fcn, m, n, IMSL_XGUESS, xguess, 0);
fcn(m, n, result, fx);
/* Print results */
imsl_f_write_matrix("The solution is", 1, 1, result, 0);
imsl_f_write_matrix("The function values are", 1, 3, fx, 0);
} /* End of main */
 
void fcn(int m, int n, float x[], float f[])
{
int i;
float y[3] = {2.0, 4.0, 3.0};
float t[3] = {1.0, 2.0, 3.0};
for (i=0; i<m; i++)
{
/* check for x=0
do not want to return infinity to nonlin_least_squares */
if (x[0] == 0.0) {
f[i] = 10000.;
} else {
f[i] = t[i]/x[0] - y[i];
}
}
 
} /* End of function */