NAG FL Interface
e04rtf (handle_​set_​qconstr_​fac)

Settings help

FL Name Style:


FL Specification Language:


1 Purpose

e04rtf 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 using a factor of the quadratic coefficient matrix.

2 Specification

Fortran Interface
Subroutine e04rtf ( handle, s, nnzr, idxr, r, mf, nnzf, irowf, icolf, f, idqc, ifail)
Integer, Intent (In) :: nnzr, idxr(nnzr), mf, nnzf, irowf(nnzf), icolf(nnzf)
Integer, Intent (Inout) :: idqc, ifail
Real (Kind=nag_wp), Intent (In) :: s, r(nnzr), f(nnzf)
Type (c_ptr), Intent (In) :: handle
C Header Interface
#include <nag.h>
void  e04rtf_ (void **handle, const double *s, const Integer *nnzr, const Integer idxr[], const double r[], const Integer *mf, const Integer *nnzf, const Integer irowf[], const Integer icolf[], const double f[], Integer *idqc, Integer *ifail)
The routine may be called by the names e04rtf or nagf_opt_handle_set_qconstr_fac.

3 Description

After the handle has been initialized (e.g., e04raf has been called), e04rtf may be used to edit a model by adding or replacing a quadratic objective function or constraint of the form
12 xTFTFx + rTx (1)
and
12 xTFTFx + rTx + s0 , (2)
respectively.
The matrix F is a sparse m×n matrix. It can be viewed as the factor of the symmetric matrix Q=FTF in a general quadratic function
12 xTQx + rTx + s . (3)
It is also acceptable if F is a zero matrix, in which case the corresponding objective function or constraint becomes linear. If you have the full matrix Q as input data, please call routine e04rsf instead. Note that it is possible to temporarily disable and enable individual constraints in the model by e04tcf and e04tbf, respectively. See Section 3.1 in the E04 Chapter Introduction for more details about the NAG optimization modelling suite.

4 References

None.

5 Arguments

1: handle Type (c_ptr) Input
On entry: the handle to the problem. It needs to be initialized (e.g., by e04raf) and must not be changed between calls to the NAG optimization modelling suite.
2: s Real (Kind=nag_wp) 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.
Constraint: nnzr0.
4: idxr(nnzr) Integer array Input
5: r(nnzr) Real (Kind=nag_wp) array Input
On entry: the nonzero elements of the sparse vector r. idxr(i) must contain the index of r(i) 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)n, for i=1,2,,nnzr.
6: mf Integer Input
On entry: m, row dimension of matrix F.
Constraint: mf>0.
7: nnzf Integer Input
On entry: the number of nonzero elements in the matrix F.
If nnzf=0, the matrix F is considered to be zero, the objective function or constraint is linear and mf, irowf, icolf and f will not be referenced.
Constraint: nnzf0.
8: irowf(nnzf) Integer array Input
9: icolf(nnzf) Integer array Input
10: f(nnzf) Real (Kind=nag_wp) array Input
On entry: arrays irowf, icolf and f store the nonzeros of the matrix F in coordinate storage (CS) format (see Section 2.1.1 in the F11 Chapter Introduction). irowf specifies one-based row indices, icolf specifies one-based column indices and f specifies the values of the nonzero elements in such a way that Fij=f(l) where i=irowf(l), j=icolf(l), for l=1,2,,nnzf. No particular order is expected, but elements should not repeat.
Constraint: 1irowf(l)mf, ​1icolf(l)n, for l=1,2,,nnzf.
11: 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.
12: ifail Integer Input/Output
On entry: ifail must be set to 0, −1 or 1 to set behaviour on detection of an error; these values have no effect when no error is detected.
A value of 0 causes the printing of an error message and program execution will be halted; otherwise program execution continues. A value of −1 means that an error message is printed while a value of 1 means that it is not.
If halting is not appropriate, the value −1 or 1 is recommended. If message printing is undesirable, then the value 1 is recommended. Otherwise, the value −1 is recommended. 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 properly initialized or it has been corrupted.
ifail=2
The problem cannot be modified right now, the solver is running.
ifail=4
On entry, idqc=value.
The given idqc does not match with any quadratic constraint already defined.
ifail=5
On entry, idqc=value.
Constraint: idqc−1.
ifail=6
nnzr and nnzf cannot be zero at the same time.
On entry, mf=value.
Constraint: mf>0.
On entry, nnzf=value.
Constraint: nnzf0.
On entry, nnzr=value.
Constraint: nnzr0.
ifail=7
On entry, i=value, idxr(i)=value and n=value.
Constraint: 1idxr(i)n.
On entry, more than one element of idxr has index value.
Constraint: each element of idxr must have a unique index.
ifail=8
On entry, i=value, icolf(i)=value and n=value.
Constraint: 1icolf(i)n.
On entry, i=value, irowf(i)=value and mf=value.
Constraint: 1irowf(i)mf.
On entry, more than one element of f has row index value and column index value.
Constraint: each element of f must have a unique row and column index.
ifail=-99
An unexpected error has been triggered by this routine. Please contact NAG.
See Section 7 in the Introduction to the NAG Library FL Interface for further information.
ifail=-399
Your licence key may have expired or may not have been installed correctly.
See Section 8 in the Introduction to the NAG Library FL Interface for further information.
ifail=-999
Dynamic memory allocation failed.
See Section 9 in the Introduction to the NAG Library FL Interface for further information.

7 Accuracy

Not applicable.

8 Parallelism and Performance

e04rtf is not threaded in any implementation.

9 Further Comments

None.

10 Example

This example demonstrates how to define and solve a convex quadratic programming problem where the quadratic term is defined by its factors.
We solve the following norm minimization problem:
minimize xR3 Ax-b22 subject to eTx=1, lx x ux,  
where
A= ( 0.493 0.382 0.0 0.0 0.270 0.475 ) ,  b= ( 0.2 0.4 ),  
lx= ( -1.0 -1.0 -1.0 ) ,  ux= ( 1.0 1.0 1.0 ),  
and eR3 is vector of all ones. Note that
Ax-b22 = xTATAx - 2bTAx + bTb  
which is a convex quadratic function.
The optimal solution (to five significant figures) is
x*=(1.0000,-0.97221,0.97221)T,  
and the objective function value without the constant term bTb is 0.13130.

10.1 Program Text

Program Text (e04rtfe.f90)

10.2 Program Data

Program Data (e04rtfe.d)

10.3 Program Results

Program Results (e04rtfe.r)