NAG CPP Interface
nagcpp::opt::handle_set_quadobj (e04rf)

Settings help

CPP Name Style:



1 Purpose

handle_set_quadobj 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 "e04/nagcpp_e04rf.hpp"
#include "e04/nagcpp_class_CommE04RA.hpp"
template <typename COMM, typename IDXC, typename C, typename IROWH, typename ICOLH, typename H>

void function handle_set_quadobj(COMM &comm, const IDXC &idxc, const C &c, const IROWH &irowh, const ICOLH &icolh, const H &h, OptionalE04RF opt)
template <typename COMM, typename IDXC, typename C, typename IROWH, typename ICOLH, typename H>

void function handle_set_quadobj(COMM &comm, const IDXC &idxc, const C &c, const IROWH &irowh, const ICOLH &icolh, const H &h)

3 Description

After the handle has been initialized (e.g., handle_​init has been called), handle_set_quadobj 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 handle_set_quadobj 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. e04tef (no CPP interface) 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 3.1 in the E04 Chapter Introduction for more details about the NAG optimization modelling suite.

4 References

None.

5 Arguments

1: comm CommE04RA Input/Output
Communication structure. An object of either the derived class CommE04RA or its base class NoneCopyableComm can be supplied. It is recommended that the derived class is used. If the base class is supplied it must first be initialized via a call to opt::handle_init (e04ra).
2: idxc(nnzc) types::f77_integer array 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.
3: c(nnzc) double array 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.
4: irowh(nnzh) types::f77_integer array 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.
5: icolh(nnzh) types::f77_integer array 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.
6: h(nnzh) double array 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.
7: opt OptionalE04RF Input/Output
Optional parameter container, derived from Optional.

5.1Additional Quantities

1: nnzc
The number of nonzero elements in the sparse vector c
2: nnzh
The number of nonzero elements in the upper triangle of the matrix H

6 Exceptions and Warnings

Errors or warnings detected by the function:
All errors and warnings have an associated numeric error code field, errorid, stored either as a member of the thrown exception object (see errorid), or as a member of opt.ifail, depending on how errors and warnings are being handled (see Error Handling for more details).
Raises: ErrorException
errorid=1
comm::handle has not been initialized.
errorid=1
comm::handle does not belong to the NAG optimization modelling suite,
has not been initialized properly or is corrupted.
errorid=1
comm::handle has not been initialized properly or is corrupted.
errorid=2
The problem cannot be modified right now, the solver is running.
errorid=6
On entry, nnzh = value.
Constraint: nnzh0.
errorid=6
On entry, nnzc = value.
Constraint: nnzc0.
errorid=7
On entry, i=value, idxc[i-1]=value and
idxc[i+0]=value.
Constraint: idxc[i-1]<idxc[i+0] (ascending order).
errorid=7
On entry, i=value, idxc[i-1]=value and
n=value.
Constraint: 1idxc[i-1]n.
errorid=8
On entry, i=value, irowh[i-1]=value and
n=value.
Constraint: 1irowh[i-1]n.
errorid=8
On entry, i=value, icolh[i-1]=value and
n=value.
Constraint: 1icolh[i-1]n.
errorid=8
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).
errorid=8
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.
errorid=10601
On entry, argument value must be a vector of size value array.
Supplied argument has value dimensions.
errorid=10601
On entry, argument value must be a vector of size value array.
Supplied argument was a vector of size value.
errorid=10601
On entry, argument value must be a vector of size value array.
The size for the supplied array could not be ascertained.
errorid=10602
On entry, the raw data component of value is null.
errorid=10603
On entry, unable to ascertain a value for value.
errorid=10605
On entry, the communication class value has not been initialized correctly.
errorid=−99
An unexpected error has been triggered by this routine.
errorid=−399
Your licence key may have expired or may not have been installed correctly.
errorid=−999
Dynamic memory allocation failed.

7 Accuracy

Not applicable.

8 Parallelism and Performance

Please see the description for the underlying computational routine in this section of the FL Interface documentation.

9 Further Comments

10 Example

Examples of the use of this method may be found in the examples for: handle_​solve_​lp_​ipm.