nag_opt_handle_set_quadobj (e04rfc) (PDF version)
e04 Chapter Contents
e04 Chapter Introduction
NAG Library Manual

NAG Library Function Document

nag_opt_handle_set_quadobj (e04rfc)


    1  Purpose
    7  Accuracy

1  Purpose

nag_opt_handle_set_quadobj (e04rfc) is a part of the NAG optimization modelling suite and defines the linear or the quadratic objective function of the problem.

2  Specification

#include <nag.h>
#include <nage04.h>
void  nag_opt_handle_set_quadobj (void *handle, Integer nnzc, const Integer idxc[], const double c[], Integer nnzh, const Integer irowh[], const Integer icolh[], const double h[], NagError *fail)

3  Description

After the initialization function nag_opt_handle_init (e04rac) has been called, nag_opt_handle_set_quadobj (e04rfc) 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 been defined previously by nag_opt_handle_set_linobj (e04rec), nag_opt_handle_set_quadobj (e04rfc) or by nag_opt_handle_set_nlnobj (e04rgc). This objective function will typically be used for quadratic programming problems (QP)
minimize xn 12 xTHx + cTx   (a) subject to lBBxuB   (b) lxxux   (c) (1)
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) (2)
The matrix H is a sparse symmetric n by n matrix. It does not need to be positive definite. See nag_opt_handle_init (e04rac) for more details.

4  References


5  Arguments

1:     handle void *Input
On entry: the handle to the problem. It needs to be initialized by nag_opt_handle_init (e04rac) 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 and may be NULL.
Constraint: nnzc0.
3:     idxc[nnzc] const IntegerInput
4:     c[nnzc] const doubleInput
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 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 nag_opt_handle_init (e04rac).
  • 1idxc[i-1]n, for i=1,2,,nnzc;
  • idxc[i-1]<idxc[i], 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 and may be NULL.
Constraint: nnzh0.
6:     irowh[nnzh] const IntegerInput
7:     icolh[nnzh] const IntegerInput
8:     h[nnzh] const doubleInput
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 2.7 in How to Use the NAG Library and its Documentation).

6  Error Indicators and Warnings

Dynamic memory allocation failed.
See Section in How to Use the NAG Library and its Documentation for further information.
The objective function has already been defined.
On entry, argument value had an illegal value.
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 nag_opt_handle_init (e04rac) or it has been corrupted.
On entry, nnzc=value.
Constraint: nnzc0.
On entry, nnzh=value.
Constraint: nnzh0.
On entry, i=value, idxc[i-1]=value and n=value.
Constraint: 1idxc[i-1]n.
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.
An unexpected error has been triggered by this function. Please contact NAG.
See Section 2.7.6 in How to Use the NAG Library and its Documentation for further information.
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.
Your licence key may have expired or may not have been installed correctly.
See Section 2.7.5 in How to Use the NAG Library and its Documentation for further information.
On entry, i=value, idxc[i-1]=value and idxc[i]=value.
Constraint: idxc[i-1]<idxc[i] (ascending order).
The problem cannot be modified in this phase any more, the solver has already been called.

7  Accuracy

Not applicable.

8  Parallelism and Performance

nag_opt_handle_set_quadobj (e04rfc) is not threaded in any implementation.

9  Further Comments


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 nag_nearest_correlation (g02aac), nag_nearest_correlation_bounded (g02abc), nag_nearest_correlation_h_weight (g02ajc) or nag_nearest_correlation_shrinking (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 (nag_opt_handle_set_simplebounds (e04rhc)) or linear constraints (nag_opt_handle_set_linconstr (e04rjc)) can be readily added to further bind individual elements of the new correlation matrix or new matrix inequalities (nag_opt_handle_set_linmatineq (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 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 nag_opt_handle_init (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)

nag_opt_handle_set_quadobj (e04rfc) (PDF version)
e04 Chapter Contents
e04 Chapter Introduction
NAG Library Manual

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