NAG CL Interface
e04rsc (handle_​set_​qconstr)

Settings help

CL Name Style:


1 Purpose

e04rsc is a part of the NAG optimization modelling suite and defines a new, or edits an existing, quadratic objective function or constraint of the problem.

2 Specification

#include <nag.h>
void  e04rsc (void *handle, double s, Integer nnzr, const Integer idxr[], const double r[], Integer nnzq, const Integer irowq[], const Integer icolq[], const double q[], Integer *idqc, NagError *fail)
The function may be called by the names: e04rsc or nag_opt_handle_set_qconstr.

3 Description

After the handle has been initialized (e.g., e04rac has been called), e04rsc may be used to edit a model by adding or replacing a quadratic objective function or constraint of the form
12 xTQx + rTx (1)
and
12 xTQx + rTx + s0 , (2)
respectively. If a factor F of Q such that Q=FTF is available, e04rtc should be called instead.
The matrix Q is a sparse symmetric n×n matrix. Typically e04rsc would be used together with Second-order Cone Programming (SOCP) solver e04ptc if Q is positive semidefinite which implies the problem is convex. Otherwise, if the problem is nonconvex, a general nonlinear optimization solver (such as e04stc) may be used. It is also acceptable if Q is a zero matrix, in which case the corresponding objective function or constraint becomes linear. Note that it is possible to temporarily disable and enable individual constraints in the model by e04tcc and e04tbc, respectively. 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: s double Input
On entry: the constant term in quadratic constraint.
If idqc=-1, s will not be referenced.
3: nnzr Integer Input
On entry: the number of nonzero elements in the sparse vector r.
If nnzr=0, r is considered to be zero and the arrays idxr and r will not be referenced and may be NULL.
Constraint: nnzr0.
4: idxr[nnzr] const Integer Input
5: r[nnzr] const double Input
On entry: the nonzero elements of the sparse vector r. idxr[i-1] must contain the index of r[i-1] in the vector, for i=1,2,,nnzr. No particular order is expected, but elements should not repeat. Note that n is the current number of variables in the problem.
Constraint: 1idxr[i-1]n, for i=1,2,,nnzr.
6: nnzq Integer Input
On entry: the number of nonzero elements in the upper triangle of the matrix Q.
If nnzq=0, the matrix Q is considered to be zero, the objective function or constraint is linear and irowq, icolq and q will not be referenced and may be NULL.
Constraint: nnzq0.
7: irowq[nnzq] const Integer Input
8: icolq[nnzq] const Integer Input
9: q[nnzq] const double Input
On entry: arrays irowq, icolq and q store the nonzeros of the upper triangle of the matrix Q in coordinate storage (CS) format (see Section 2.1.1 in the F11 Chapter Introduction). irowq specifies one-based row indices, icolq specifies one-based column indices and q specifies the values of the nonzero elements in such a way that Qij=q[l-1] where i=irowq[l-1], j=icolq[l-1], for l=1,2,,nnzq. No particular order is expected, but elements should not repeat.
Constraint: 1irowq[l-1]icolq[l-1]n, for l=1,2,,nnzq.
10: idqc Integer * Input/Output
On entry:
idqc=0
A new quadratic constraint is created.
idqc>0
Specifies the index of an existing constraint to be replaced. i.e., replaces the idqcth constraint.
idqc=-1
A new quadratic objective is created and will replace any previously defined objective function.
Constraint: idqc-1.
On exit: if idqc=0 on entry, then idqc is overwritten with the index of the new quadratic constraint. By definition, this is the number of quadratic constraints already defined plus one. Otherwise, idqc stays unchanged.
11: 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
nnzr and nnzq cannot be zero at the same time.
On entry, idqc=value.
Constraint: idqc-1.
On entry, nnzq=value.
Constraint: nnzq0.
On entry, nnzr=value.
Constraint: nnzr0.
NE_INTARR
On entry, i=value, idxr[i-1]=value and n=value.
Constraint: 1idxr[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, icolq[i-1]=value and n=value.
Constraint: 1icolq[i-1]n.
On entry, i=value, irowq[i-1]=value and icolq[i-1]=value.
Constraint: irowq[i-1]icolq[i-1] (elements within the upper triangle).
On entry, i=value, irowq[i-1]=value and n=value.
Constraint: 1irowq[i-1]n.
On entry, more than one element of q has row index value and column index value.
Constraint: each element of q 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, more than one element of idxr has index value.
Constraint: each element of idxr must have a unique index.
NE_PHASE
The problem cannot be modified right now, the solver is running.
NE_REF_MATCH
On entry, idqc=value.
The given idqc does not match with any quadratic constraint already defined.

7 Accuracy

Not applicable.

8 Parallelism and Performance

e04rsc is not threaded in any implementation.

9 Further Comments

None.

10 Example

This example demonstrates how to define and solve a convex quadratically constrained quadratic programming problem via SOCP. See also e04rtc where the quadratic term is defined by its factor.
This example solves a quadratically constrained quadratic programming problem
minimize x3 12 xT Q0 x + r0T x subject to 12 xT Q1 x + r1T x + s1 0 ,  
where
Q0= ( 0.4930.3820.270 0.3820.4750.448 0.2700.4480.515 ) Q1= ( 0.7370.4531.002 0.4530.3160.635 1.0020.6351.590 ) , r0= ( 0.847 0.08 0.505 ) r1= ( 0.065 0.428 0.097 )  
and s1=1.276.
The optimal solution (to five significant figures) is
x*=(1.1742,-4.2569,0.98144)T,  
and the objective function value is 2.5714.

10.1 Program Text

Program Text (e04rsce.c)

10.2 Program Data

Program Data (e04rsce.d)

10.3 Program Results

Program Results (e04rsce.r)