NAG Library Routine Document

e04rff  (handle_set_quadobj)

 Contents

    1  Purpose
    7  Accuracy

1
Purpose

e04rff is a part of the NAG optimization modelling suite and defines the linear or the quadratic objective function of the problem.

2
Specification

Fortran Interface
Subroutine e04rff ( handle, nnzc, idxc, c, nnzh, irowh, icolh, h, ifail)
Integer, Intent (In):: nnzc, idxc(nnzc), nnzh, irowh(nnzh), icolh(nnzh)
Integer, Intent (Inout):: ifail
Real (Kind=nag_wp), Intent (In):: c(nnzc), h(nnzh)
Type (c_ptr), Intent (In):: handle
C Header Interface
#include nagmk26.h
void  e04rff_ ( void **handle, const Integer *nnzc, const Integer idxc[], const double c[], const Integer *nnzh, const Integer irowh[], const Integer icolh[], const double h[], Integer *ifail)

3
Description

After the initialization routine e04raf has been called, e04rff may be used to define the objective function of the problem as a quadratic function cTx+12xTHx or a sparse linear function cTx unless the objective function has already been defined by another routine in the suite. 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 by n matrix. It does not need to be positive definite. See e04raf for more details.

4
References

None.

5
Arguments

1:     handle – Type (c_ptr)Input
On entry: the handle to the problem. It needs to be initialized by e04raf and must not be changed.
2:     nnzc – IntegerInput
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.
Constraint: nnzc0.
3:     idxcnnzc – Integer arrayInput
4:     cnnzc – Real (Kind=nag_wp) arrayInput
On entry: the nonzero elements of the sparse vector c. idxci must contain the index of ci in the vector, for i=1,2,,nnzc. The elements are stored in ascending order. Note that n, the number of variables in the problem, was set in nvar during the initialization of the handle by e04raf.
Constraints:
  • 1idxcin, for i=1,2,,nnzc;
  • idxci<idxci+1, for i=1,2,,nnzc-1.
5:     nnzh – IntegerInput
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.
Constraint: nnzh0.
6:     irowhnnzh – Integer arrayInput
7:     icolhnnzh – Integer arrayInput
8:     hnnzh – Real (Kind=nag_wp) arrayInput
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=hl where i=irowhl, j=icolhl, for l=1,2,,nnzh. No particular order is expected, but elements should not repeat.
Constraint: 1irowhlicolhln, for l=1,2,,nnzh.
9:     ifail – IntegerInput/Output
On entry: ifail must be set to 0, -1​ or ​1. If you are unfamiliar with this argument you should refer to Section 3.4 in How to Use the NAG Library and its Documentation for details.
For environments where it might be inappropriate to halt program execution when an error is detected, the value -1​ or ​1 is recommended. If the output of error messages is undesirable, then the value 1 is recommended. Otherwise, the recommended value is -1. When the value -1​ or ​1 is used it is essential to test the value of ifail on exit.
On exit: ifail=0 unless the routine detects an error or a warning has been flagged (see Section 6).

6
Error Indicators and Warnings

If on entry ifail=0 or -1, explanatory error messages are output on the current error message unit (as defined by x04aaf).
Errors or warnings detected by the routine:
ifail=1
The supplied handle does not define a valid handle to the data structure for the NAG optimization modelling suite. It has not been initialized by e04raf or it has been corrupted.
ifail=2
The problem cannot be modified in this phase any more, the solver has already been called.
ifail=3
The objective function has already been defined.
ifail=6
On entry, nnzc=value.
Constraint: nnzc0.
On entry, nnzh=value.
Constraint: nnzh0.
ifail=7
On entry, i=value, idxci=value and idxci+1=value.
Constraint: idxci<idxci+1 (ascending order).
On entry, i=value, idxci=value and n=value.
Constraint: 1idxcin.
ifail=8
On entry, i=value, icolhi=value and n=value.
Constraint: 1icolhin.
On entry, i=value, irowhi=value and icolhi=value.
Constraint: irowhiicolhi (elements within the upper triangle).
On entry, i=value, irowhi=value and n=value.
Constraint: 1irowhin.
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.
ifail=-99
An unexpected error has been triggered by this routine. Please contact NAG.
See Section 3.9 in How to Use the NAG Library and its Documentation for further information.
ifail=-399
Your licence key may have expired or may not have been installed correctly.
See Section 3.8 in How to Use the NAG Library and its Documentation for further information.
ifail=-999
Dynamic memory allocation failed.
See Section 3.7 in How to Use the NAG Library and its Documentation for further information.

7
Accuracy

Not applicable.

8
Parallelism and Performance

e04rff is not threaded in any implementation.

9
Further Comments

None.

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 routines g02aaf, g02abf, g02ajf or g02anf 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 (e04rhf) or linear constraints (e04rjf) can be readily added to further bind individual elements of the new correlation matrix or new matrix inequalities (e04rnf) to restrict its eigenvalues.
The problem is as follows (to simplify the notation only the upper triangular parts are shown). To a given m by 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:
(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 .  
(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 .  
(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 Section 10 in e04raf for links to further examples in the suite.

10.1
Program Text

Program Text (e04rffe.f90)

10.2
Program Data

Program Data (e04rffe.d)

10.3
Program Results

Program Results (e04rffe.r)

© The Numerical Algorithms Group Ltd, Oxford, UK. 2017