naginterfaces.library.opt.handle_set_linconstr¶
- naginterfaces.library.opt.handle_set_linconstr(handle, bl=None, bu=None, irowb=None, icolb=None, b=None, idlc=0)[source]¶
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.For full information please refer to the NAG Library document for e04rj
https://support.nag.com/numeric/nl/nagdoc_30.2/flhtml/e04/e04rjf.html
- Parameters
- handleHandle
The handle to the problem. It needs to be initialized (e.g., by
handle_init()
) and must not be changed between calls to the NAG optimization modelling suite.- blNone or float, array-like, shape , optional
defines the lower bounds of the linear constraints,
- buNone or float, array-like, shape , optional
defines the upper bounds of the linear constraints,
- irowbNone or int, array-like, shape , optional
specifies one-based row indices of the nonzeros of the sparse matrix in coordinate storage (CS) format.
- icolbNone or int, array-like, shape , optional
specifies one-based column indices of the nonzeros of the sparse matrix in coordinate storage (CS) format.
- bNone or float, array-like, shape , optional
stores the nonzeros of the sparse matrix in coordinate storage (CS) format.
- idlcint, optional
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 must be set to one.
- Returns
- idlcint
If , the number of the last linear constraint added. By definition, it is the number of linear constraints already defined plus . Otherwise, stays unchanged.
- Raises
- NagValueError
- (errno )
has not been initialized.
- (errno )
does not belong to the NAG optimization modelling suite, has not been initialized properly or is corrupted.
- (errno )
has not been initialized properly or is corrupted.
- (errno )
The problem cannot be modified right now, the solver is running.
- (errno )
On entry, .
Constraint: .
- (errno )
On entry, .
The given does not match with any existing linear constraint.
The maximum is .
- (errno )
On entry, .
Constraint: .
- (errno )
On entry, .
Constraint: .
- (errno )
On entry, and .
Constraint: If , .
- (errno )
On entry, , and .
Constraint: .
- (errno )
On entry, , and .
Constraint: .
- (errno )
On entry, more than one element of has row index and column index .
Constraint: each element of must have a unique row and column index.
- (errno )
On entry, , and .
Constraint: .
- (errno )
On entry, , , .
Constraint: .
- (errno )
On entry, , , .
Constraint: .
- Notes
After the 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 constraintswhere 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 option ‘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 . A single constraint (i.e., a single row of the matrix ) can be modified (replaced) by
handle_set_linconstr
by referring to its . An individual coefficient of the matrix can be set or modified byhandle_set_linconstr_coeff()
and bounds of a single constraint can be set or modified byhandle_set_bound()
. Note that it is also possible to temporarily disable and enable individual constraints in the model byhandle_disable()
andhandle_enable()
, 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 the E04 Introduction for more details about the NAG optimization modelling suite.
See also
naginterfaces.library.examples.mip.handle_solve_milp_ex.main()
naginterfaces.library.examples.opt.handle_add_vars_ex.main()
naginterfaces.library.examples.opt.handle_solve_ipopt_ex.main()
naginterfaces.library.examples.opt.handle_solve_lp_ipm_ex.main()
naginterfaces.library.examples.opt.handle_solve_lp_simplex_ex.main()
naginterfaces.library.examples.opt.handle_solve_nldf_ex.main()
naginterfaces.library.examples.opt.handle_solve_socp_ipm_ex.main()
naginterfaces.library.examples.opt.handle_solve_ssqp_ex.main()