# naginterfaces.library.opt.handle_​init¶

naginterfaces.library.opt.handle_init(nvar)[source]

handle_init initializes a data structure for the NAG optimization modelling suite for problems such as, Linear Programming (LP), Quadratic Programming (QP), Nonlinear Programming (NLP), Least Squares (LSQ) problems, Second-order Cone Programming (SOCP), linear Semidefinite Programming (SDP) and Semidefinite Programming with Bilinear Matrix Inequalities (BMI-SDP).

For full information please refer to the NAG Library document for e04ra

https://www.nag.com/numeric/nl/nagdoc_29/flhtml/e04/e04raf.html

Parameters
nvarint

, the initial number of decision variables defining the problem.

Returns
handleHandle

Holds a handle to the internal data structure where an empty problem with variables is defined.

Raises
NagValueError
(errno )

On entry, .

Constraint: .

Notes

handle_init initializes an empty problem, adds decision variables, , and returns a handle to the data structure. Note that further variables may be added to the problem later by handle_add_vars() and it is also possible to temporarily disable and enable individual variables in the model by handle_disable() and handle_enable(), respectively. This handle may then be passed to some of the functions of the suite to formulate the problem (define or edit the variables, the objective function and constraints). Once the problem is fully defined, the handle may be passed to a suitable solver from the suite (handle_solve_dfls(), handle_solve_dfls_rcomm(), handle_solve_bxnl(), handle_solve_dfno(), handle_solve_dfno_rcomm(), handle_solve_bounds_foas(), handle_solve_lp_ipm(), handle_solve_socp_ipm(), handle_solve_ipopt() or handle_solve_pennon()). Afterwards, the problem may be further modified or passed to another solver of the suite. The handle must not be changed between calls to the functions of the suite. When the handle is no longer needed, handle_free() must be called to destroy it and deallocate all the allocated memory and data within. See the E04 Introduction for more details about the NAG optimization modelling suite.