NAG CL Interface
e04rfc (handle_​set_​quadobj)

Settings help

CL Name Style:


1 Purpose

e04rfc is a part of the NAG optimization modelling suite and defines or redefines the objective function of the problem to be linear or quadratic.

2 Specification

#include <nag.h>
void  e04rfc (void *handle, Integer nnzc, const Integer idxc[], const double c[], Integer nnzh, const Integer irowh[], const Integer icolh[], const double h[], NagError *fail)
The function may be called by the names: e04rfc or nag_opt_handle_set_quadobj.

3 Description

After the handle has been initialized (e.g., e04rac has been called), e04rfc may be used to define the objective function of the problem as a quadratic function cTx+12xTHx or a sparse linear function cTx. If the objective function has already been defined, it will be overwritten. If e04rfc is called with no nonzeroes in either c or H, any existing objective function is removed, no new one is added and the problem will be solved as a feasible point problem. e04tec may be used to set individual elements ci of the linear objective.
This objective function will typically be used for
Linear Programming (LP)
minimize xn cTx   (a) subject to   lBBxuB,   (b) lxxux ,   (c) (1)
Quadratic Programming problems (QP)
minimize xn 12 xTHx + cTx   (a) subject to lBBxuB,   (b) lxxux,   (c) (2)
or for Semidefinite Programming problems with bilinear matrix inequalities (BMI-SDP)
minimize xn 12 xTHx + cTx   (a) subject to   i,j=1 n xi xj Qijk + i=1 n xi Aik - A0k 0 ,  k=1,,mA ,   (b) lBBxuB,   (c) lxxux.   (d) (3)
The matrix H is a sparse symmetric n×n matrix. It does not need to be positive definite. See Section 4.1 in the E04 Chapter Introduction for more details about the NAG optimization modelling suite.

4 References

None.

5 Arguments

1: handle void * Input
On entry: the handle to the problem. It needs to be initialized (e.g., by e04rac) and must not be changed between calls to the NAG optimization modelling suite.
2: nnzc Integer Input
On entry: the number of nonzero elements in the sparse vector c.
If nnzc=0, c is considered to be zero and the arrays idxc and c will not be referenced and may be NULL.
Constraint: nnzc0.
3: idxc[nnzc] const Integer Input
4: c[nnzc] const double Input
On entry: the nonzero elements of the sparse vector c. idxc[i-1] must contain the index of c[i-1] in the vector, for i=1,2,,nnzc. The elements must be stored in ascending order. Note that n is the current number of variables in the model.
Constraints:
  • 1idxc[i-1]n, for i=1,2,,nnzc;
  • idxc[i-1]<idxc[i], for i=1,2,,nnzc-1.
5: nnzh Integer Input
On entry: the number of nonzero elements in the upper triangle of the matrix H.
If nnzh=0, the matrix H is considered to be zero, the objective function is linear and irowh, icolh and h will not be referenced and may be NULL.
Constraint: nnzh0.
6: irowh[nnzh] const Integer Input
7: icolh[nnzh] const Integer Input
8: h[nnzh] const double Input
On entry: arrays irowh, icolh and h store the nonzeros of the upper triangle of the matrix H in coordinate storage (CS) format (see Section 2.1.1 in the F11 Chapter Introduction). irowh specifies one-based row indices, icolh specifies one-based column indices and h specifies the values of the nonzero elements in such a way that hij=h[l-1] where i=irowh[l-1], j=icolh[l-1], for l=1,2,,nnzh. No particular order is expected, but elements should not repeat.
Constraint: 1irowh[l-1]icolh[l-1]n, for l=1,2,,nnzh.
9: fail NagError * Input/Output
The NAG error argument (see Section 7 in the Introduction to the NAG Library CL Interface).

6 Error Indicators and Warnings

NE_ALLOC_FAIL
Dynamic memory allocation failed.
See Section 3.1.2 in the Introduction to the NAG Library CL Interface for further information.
NE_BAD_PARAM
On entry, argument value had an illegal value.
NE_HANDLE
The supplied handle does not define a valid handle to the data structure for the NAG optimization modelling suite. It has not been properly initialized or it has been corrupted.
NE_INT
On entry, nnzc=value.
Constraint: nnzc0.
On entry, nnzh=value.
Constraint: nnzh0.
NE_INTARR
On entry, i=value, idxc[i-1]=value and n=value.
Constraint: 1idxc[i-1]n.
NE_INTERNAL_ERROR
An internal error has occurred in this function. Check the function call and any array sizes. If the call is correct then please contact NAG for assistance.
See Section 7.5 in the Introduction to the NAG Library CL Interface for further information.
NE_INVALID_CS
On entry, i=value, icolh[i-1]=value and n=value.
Constraint: 1icolh[i-1]n.
On entry, i=value, irowh[i-1]=value and icolh[i-1]=value.
Constraint: irowh[i-1]icolh[i-1] (elements within the upper triangle).
On entry, i=value, irowh[i-1]=value and n=value.
Constraint: 1irowh[i-1]n.
On entry, more than one element of h has row index value and column index value.
Constraint: each element of h must have a unique row and column index.
NE_NO_LICENCE
Your licence key may have expired or may not have been installed correctly.
See Section 8 in the Introduction to the NAG Library CL Interface for further information.
NE_NOT_INCREASING
On entry, i=value, idxc[i-1]=value and idxc[i]=value.
Constraint: idxc[i-1]<idxc[i] (ascending order).
NE_PHASE
The problem cannot be modified right now, the solver is running.

7 Accuracy

Not applicable.

8 Parallelism and Performance

Background information to multithreading can be found in the Multithreading documentation.
e04rfc is not threaded in any implementation.

9 Further Comments

9.1 Internal Changes

Internal changes have been made to this function as follows:
For details of all known issues which have been reported for the NAG Library please refer to the Known Issues.

10 Example

This example demonstrates how to use nonlinear semidefinite programming to find a nearest correlation matrix satisfying additional requirements. This is a viable alternative to functions g02aac, g02abc, g02ajc or g02anc as it easily allows you to add further constraints on the correlation matrix. In this case a problem with a linear matrix inequality and a quadratic objective function is formulated to find the nearest correlation matrix in the Frobenius norm preserving the nonzero pattern of the original input matrix. However, additional box bounds (e04rhc) or linear constraints (e04rjc) can be readily added to further bind individual elements of the new correlation matrix or new matrix inequalities (e04rnc) to restrict its eigenvalues.
The problem is as follows (to simplify the notation only the upper triangular parts are shown). To a given m×m symmetric input matrix G
G = ( g11 g1m gmm )  
find correction terms x1,,xn which form symmetric matrix G¯
G¯ = ( g¯11 g¯12 g¯1m g¯22 g¯2m g¯mm ) = ( 1 g12+x1 g13+x2 g1m+xi 1 g23+x3 1 1 gm-1m+xn 1 )  
so that the following requirements are met:
  1. (a)It is a correlation matrix, i.e., symmetric positive semidefinite matrix with a unit diagonal. This is achieved by the way G¯ is assembled and by a linear matrix inequality
    G¯ = x1 ( 0 1 0 0 0 0 0 0 0 0 ) + x2 ( 0 0 1 0 0 0 0 0 0 0 ) + x3 ( 0 0 0 0 0 1 0 0 0 0 ) + + xn ( 0 0 0 0 0 0 0 0 1 0 ) - ( −1 -g12 -g13 -g1m −1 -g23 -g2m −1 -g3m −1 ) 0 .  
  2. (b)G¯ is nearest to G in the Frobenius norm, i.e., it minimizes the Frobenius norm of the difference which is equivalent to:
    minimize ​12 ij ( g¯ ij -gij) 2 = i=1 n xi2 .  
  3. (c)G¯ preserves the nonzero structure of G. This is met by defining xi only for nonzero elements gij.
For the input matrix
G = ( 2 −1 0 0 −1 2 −1 0 0 −1 2 −1 0 0 −1 2 )  
the result is
G¯ = ( 1.0000 -0.6823 0.0000 0.0000 -0.6823 1.0000 -0.5344 0.0000 0.0000 -0.5344 1.0000 -0.6823 0.0000 0.0000 -0.6823 1.0000 ) .  
See also e04rac for links to further examples in the suite.

10.1 Program Text

Program Text (e04rfce.c)

10.2 Program Data

Program Data (e04rfce.d)

10.3 Program Results

Program Results (e04rfce.r)