NAG CPP Interface
nagcpp::opt::handle_set_nlnls (e04rm)

1 Purpose

handle_set_nlnls is a part of the NAG optimization modelling suite and defines the number of residuals in a sum of squares objective function (nonlinear least squares problems) and, optionally, the sparsity structure of their first derivatives.

2 Specification

#include "e04/nagcpp_e04rm.hpp"
#include "e04/nagcpp_class_CommE04RA.hpp"
template <typename COMM, typename IROWRD, typename ICOLRD>

void function handle_set_nlnls(COMM &comm, const types::f77_integer nres, const IROWRD &irowrd, const ICOLRD &icolrd, OptionalE04RM opt)
template <typename COMM, typename IROWRD, typename ICOLRD>

void function handle_set_nlnls(COMM &comm, const types::f77_integer nres, const IROWRD &irowrd, const ICOLRD &icolrd)

3 Description

After the initialization function handle_​init has been called and unless the objective function has already been defined, handle_set_nlnls may be used to declare the objective function of the optimization problem as a sum of squares. It will typically be used in data fitting or calibration problems of the form
minimize xn f(x)= j=1 mr rj (x) 2    subject to lxxux ,     
where x is an n-dimensional variable vector and ri(x) are nonlinear residuals (see Section 2.2.3 in the E04 Chapter Introduction). The values of the residuals, and possibly their derivatives, will be communicated to the solver by a user-supplied function. handle_set_nlnls also allows the structured first derivative matrix
[ rj(x) xi ] i=1,,n , ​ j=1,,mr  
to be declared as being dense or sparse. If declared as sparse, its sparsity structure must be specified here.
See Section 3.1 in the E04 Chapter Introduction for more details about the NAG optimization modelling suite.

4 References

None.

5 Arguments

1: comm CommE04RA Input/Output
Communication structure. An object of either the derived class CommE04RA or its base class NoneCopyableComm can be supplied. It is recommended that the derived class is used. If the base class is supplied it must first be initialized via a call to opt::handle_init (e04ra).
2: nres types::f77_integer Input
On entry: mr, the number of residuals in the objective function.
If nres=0, no objective function will be defined and irowrd and icolrd will not be referenced.
Constraint: nres0.
3: irowrd(nnzrd) types::f77_integer array Input
On entry: arrays irowrd and icolrd store the sparsity structure (pattern) of the first derivative matrix as nnzrd nonzeros in coordinate storage (CS) format (see Section 2.1.1 in the F11 Chapter Introduction). The matrix has dimensions n×mr. irowrd specifies one-based row indices and icolrd specifies one-based column indices. No particular order of elements is expected, but elements should not repeat and the same order should be used when the first derivative matrix is evaluated for the solver.
If irowrd and icolrd are both nullptr then the first derivative matrix is considered dense and irowrd and icolrd will not be referenced. The ordering is assumed to be column-wise, namely the function will behave as if nnzrd=n×mr and the vectors irowrd and icolrd filled as:
  • irowrd=(1,2,,n,1,2,,n,,1,2,,n);
  • icolrd=(1,1,,1,2,2,,2,,mr,mr,,mr).
Constraints:
  • 1irowrd(l-1)n, for l=1,2,,nnzrd;
  • 1icolrd(l-1)nres, for l=1,2,,nnzrd.
4: icolrd(nnzrd) types::f77_integer array Input
On entry: arrays irowrd and icolrd store the sparsity structure (pattern) of the first derivative matrix as nnzrd nonzeros in coordinate storage (CS) format (see Section 2.1.1 in the F11 Chapter Introduction). The matrix has dimensions n×mr. irowrd specifies one-based row indices and icolrd specifies one-based column indices. No particular order of elements is expected, but elements should not repeat and the same order should be used when the first derivative matrix is evaluated for the solver.
If irowrd and icolrd are both nullptr then the first derivative matrix is considered dense and irowrd and icolrd will not be referenced. The ordering is assumed to be column-wise, namely the function will behave as if nnzrd=n×mr and the vectors irowrd and icolrd filled as:
  • irowrd=(1,2,,n,1,2,,n,,1,2,,n);
  • icolrd=(1,1,,1,2,2,,2,,mr,mr,,mr).
Constraints:
  • 1irowrd(l-1)n, for l=1,2,,nnzrd;
  • 1icolrd(l-1)nres, for l=1,2,,nnzrd.
5: opt OptionalE04RM Input/Output
Optional parameter container, derived from Optional.

5.1Additional Quantities

1: nnzrd
The number of nonzeros in the first derivative matrix.

6 Exceptions and Warnings

Errors or warnings detected by the function:
All errors and warnings have an associated numeric error code field, errorid, stored either as a member of the thrown exception object (see errorid), or as a member of opt.ifail, depending on how errors and warnings are being handled (see Error Handling for more details).
Raises: ErrorException
errorid=9
All of the following must be provided if one is provided:
irowrd, icolrd.
errorid=1
comm::handle has not been initialized.
errorid=1
comm::handle does not belong to the NAG optimization modelling suite,
has not been initialized properly or is corrupted.
errorid=1
comm::handle has not been initialized properly or is corrupted.
errorid=2
The problem cannot be modified in this phase any more, the solver
has already been called.
errorid=2
The Hessians of nonlinear functions have already been defined,
a nonlinear objective cannot be added.
errorid=3
The objective function has already been defined.
errorid=6
On entry, nres = value.
Constraint: nres 0.
errorid=6
On entry, nnzrd = value.
Constraint: nnzrd > 0.
errorid=8
On entry, i=value, irowrd[i-1]=value and
n=value.
Constraint: 1irowrd[i-1]n.
errorid=8
On entry, i=value, icolrd[i-1]=value and
nres = value.
Constraint: 1icolrd[i-1]nres.
errorid=8
On entry, more than one element of first derivative matrix has row index
value and column index value.
Constraint: each element of first derivative matrix must have a unique
row and column index.
errorid=10601
On entry, argument value must be a vector of size value array.
Supplied argument has value dimensions.
errorid=10601
On entry, argument value must be a vector of size value array.
Supplied argument was a vector of size value.
errorid=10601
On entry, argument value must be a vector of size value array.
The size for the supplied array could not be ascertained.
errorid=10602
On entry, the raw data component of value is null.
errorid=10603
On entry, unable to ascertain a value for value.
errorid=10605
On entry, the communication class value has not been initialized correctly.
errorid=-99
An unexpected error has been triggered by this routine.
errorid=-399
Your licence key may have expired or may not have been installed correctly.
errorid=-999
Dynamic memory allocation failed.

7 Accuracy

Not applicable.

8 Parallelism and Performance

Please see the description for the underlying computational routine in this section of the FL Interface documentation.

9 Further Comments

None.

10 Example

Examples of the use of this method may be found in the examples for: handle_​solve_​dfls_​rcomm.