Function: handle_set_linconstr
NAG CPP Interface
nagcpp::opt::handle_set_linconstr (e04rj)
Function: handle_set_linconstr
1
Purpose
handle_set_linconstr is a part of the NAG optimization modelling suite and adds a new block of linear constraints to the problem or modifies an individual linear constraint.
2
Specification
#include "e04/nagcpp_e04rj.hpp"
#include "e04/nagcpp_class_CommE04RA.hpp"
template <typename COMM, typename BL, typename BU, typename IROWB, typename ICOLB, typename B>
void function handle_set_linconstr(COMM &comm, const BL &bl, const BU &bu, const IROWB &irowb, const ICOLB &icolb, const B &b, OptionalE04RJ opt)
template <typename COMM, typename BL, typename BU, typename IROWB, typename ICOLB, typename B>
void function handle_set_linconstr(COMM &comm, const BL &bl, const BU &bu, const IROWB &irowb, const ICOLB &icolb, const B &b)
3
Description
After the
handle has been initialized (e.g.,
handle_init has been called),
handle_set_linconstr may be used to add to the problem a new block of
linear constraints
where
is a general
rectangular matrix,
is the current number of decision variables in the model and
and
are
-dimensional vectors defining the lower and upper bounds, respectively. The call can be repeated to add multiple blocks to the model.
Note that the bounds are specified for all the constraints of this block. This form allows full generality in specifying various types of constraint. In particular, the
th constraint may be defined as an equality by setting
. If certain bounds are not present, the associated elements of
or
may be set to special values that are treated as
or
. See the description of the optional parameter
Infinite Bound Size which is common among all solvers in the suite. Its value is denoted as
further in this text. Note that the bounds are interpreted based on its value at the time of calling this function and any later alterations to
Infinite Bound Size will not affect these constraints.
The linear constraints can be edited. To identify the individual constraints, they are numbered starting with
, see
idlc. A single constraint (i.e., a single row of the matrix
) can be modified (replaced) by
handle_set_linconstr by referring to its
idlc. An individual coefficient
of the matrix
can be set or modified by
e04tjf (no CPP interface) and bounds of a single constraint can be set or modified by
e04tdf (no CPP interface). Note that it is also possible to temporarily disable and enable individual constraints in the model by
e04tcf (no CPP interface) and
e04tbf (no CPP interface), respectively.
Linear constraints may be present in many different types of problems, for simplicity of the notation, only one block of linear constraints is presented. For example,
Linear Programming (LP)
Quadratic Programming (QP)
Quadratically Constrained Quadratic Programming (QCQP)
Nonlinear Programming (NLP)
or linear Semidefinite Programming (SDP)
See
Section 3.1 in the
E04 Chapter Introduction for more details about the NAG optimization modelling suite.
4
References
None.
5
Arguments
-
1:
– 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:
– double array
Input
-
On entry:
bl and
bu define lower and upper bounds of the linear constraints,
and
, respectively. To define the
th constraint as equality, set
, where
. To specify a nonexistent lower bound (i.e.,
), set
; to specify a nonexistent upper bound, set
.
Constraints:
- , for ;
- , for ;
- , for ;
- if , , for .
-
3:
– double array
Input
-
On entry:
bl and
bu define lower and upper bounds of the linear constraints,
and
, respectively. To define the
th constraint as equality, set
, where
. To specify a nonexistent lower bound (i.e.,
), set
; to specify a nonexistent upper bound, set
.
Constraints:
- , for ;
- , for ;
- , for ;
- if , , for .
-
4:
– types::f77_integer array
Input
-
On entry: arrays
irowb,
icolb and
b store
nnzb nonzeros of the sparse matrix
in coordinate storage (CS) format (see
Section 2.1.1 in the
F11 Chapter Introduction). The matrix
has dimensions
, where
is the current number of decision variables in the model.
irowb specifies one-based row indices,
icolb specifies one-based column indices and
b specifies the values of the nonzero elements in such a way that
where
and
, for
. No particular order of elements is expected, but elements should not repeat.
Constraint:
, , for .
-
5:
– types::f77_integer array
Input
-
On entry: arrays
irowb,
icolb and
b store
nnzb nonzeros of the sparse matrix
in coordinate storage (CS) format (see
Section 2.1.1 in the
F11 Chapter Introduction). The matrix
has dimensions
, where
is the current number of decision variables in the model.
irowb specifies one-based row indices,
icolb specifies one-based column indices and
b specifies the values of the nonzero elements in such a way that
where
and
, for
. No particular order of elements is expected, but elements should not repeat.
Constraint:
, , for .
-
6:
– double array
Input
-
On entry: arrays
irowb,
icolb and
b store
nnzb nonzeros of the sparse matrix
in coordinate storage (CS) format (see
Section 2.1.1 in the
F11 Chapter Introduction). The matrix
has dimensions
, where
is the current number of decision variables in the model.
irowb specifies one-based row indices,
icolb specifies one-based column indices and
b specifies the values of the nonzero elements in such a way that
where
and
, for
. No particular order of elements is expected, but elements should not repeat.
Constraint:
, , for .
-
7:
– OptionalE04RJ
Input/Output
-
Optional parameter container, derived from
Optional.
Container for:
- idlc – types::f77_integer
This optional parameter
may be set using the method
OptionalE04RJ::idlc
and accessed via
OptionalE04RJ::get_idlc.
Default:
On entry: if
, a new block of linear constraints is added to the model; otherwise,
refers to the number of an existing linear constraint which will be replaced and
nclin must be set to one.
Constraint:
.
On exit: if
, the number of the last linear constraint added. By definition, it is the number of linear constraints already defined plus
nclin. Otherwise,
stays unchanged.
5.1Additional Quantities
- 1:
- , the number of linear constraints (number of rows of the matrix ) in this block.
- 2:
- nnzb gives the number of nonzeros in matrix
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
-
- comm::handle has not been initialized.
- comm::handle does not belong to the NAG optimization modelling suite,
has not been initialized properly or is corrupted.
- comm::handle has not been initialized properly or is corrupted.
- The problem cannot be modified right now, the solver is running.
- On entry, .
Constraint: .
- On entry, .
The given idlc does not match with any existing linear constraint.
The maximum idlc is .
- On entry, .
Constraint: .
- On entry, .
Constraint: .
- On entry, and .
Constraint: If , .
- On entry, , and
.
Constraint: .
- On entry, , and
.
Constraint: .
- On entry, more than one element of b has row index
and column index .
Constraint: each element of b must have a unique row and column index.
- On entry, , and
.
Constraint: .
- On entry, , ,
.
Constraint: .
- On entry, , ,
.
Constraint: .
- On entry, argument must be a vector of size array.
Supplied argument has dimensions.
- On entry, argument must be a vector of size array.
Supplied argument was a vector of size .
- On entry, argument must be a vector of size array.
The size for the supplied array could not be ascertained.
- On entry, the raw data component of is null.
- On entry, unable to ascertain a value for .
- On entry, the communication class has not been initialized correctly.
- An unexpected error has been triggered by this routine.
- Your licence key may have expired or may not have been installed correctly.
- 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.
10
Example
Examples of the use of this method may be found in the examples for:
handle_solve_lp_ipm,
handle_set_group and
handle_solve_ipopt.
Function: handle_set_linconstr