QP_OASES – Quadratic programming using active set method

Block SymbolLicensing group: ADVANCED
PIC

Function Description
The QP_OASES block solves a quadratic programming problem using active set method [11]

minxnV 1 2xT Hx + xT G, s. t. lbA Ax ubA, lb x ub,

where nV is number of variables, nC is number of constraints, the Hessian matrix H nV×nV is symmetric and positive (semi-)definite, the gradient vector G nV, the constraint matrix A nC×nV, bound vectors lb,ub nV and constraint vectors lbA,ubA RnC.

The block wraps the qpOASES library (qpOASES is distributed under the GNU Lesser General Public License, see Appendix A of [12].), the use of which is described in the manual [12].

The output references yH, yG, yA, yLB, yUB, yLBA, yUBA, yXopt and yYopt are always set to the corresponding input uH, uG, uA, uLB, uUB, uLBA, uUBA, uXopt and uYopt. If the input uQP is not connected, the particular quadratic problem (QP) is allocated in the first execution of the function block (see below) and the output yQP is set to the reference of the allocated QP. If uQP is connected (to the yQP output of the previous QP_OASES block), the yQP output is set to uQP and the block works with an already allocated QP.

The block uses internal variables nV and nC. The value of nV is set to the number of rows of the vector G referenced by uG, the value of nV is set to the number of rows of the matrix A referenced by uA. If the reference uA is not defined (the matrix A is not connected), the value nC = 0.

To solve the QP problem, a QProblem object is created in the generic case (see Chapter 3 of [12]). However, the block can also solve the following special cases depending on the input references and the hessianType parameter:

uH not connected.
In this case, it is assumed that Hessian matrix has a trivial value of the identity or zero matrix. The hessianType parameter must be equal to HST_ZERO or HST_IDENTITY, see Section 4.5 of the manual [12].
uA not connected.
In this case, the constraint matrix A is not used (nC = 0, the QProblemB object is created, see Section 4.3 of the manual [12]. The hessianType parameter can be any allowed value.
VAR = on.
If the input VAR = on during the first time the block is executed, an object of class SQProblem is created, see Section 4.2 of the manual [12]. In this case, all input matrices and vectors can change in each execution step in which VAR = on.

To obtain the solution of the QP problem, at least one of the input references uXopt and uYopt must be defined (connected to a vector). If connected to uXopt, the yXopt output will refer to the primal solution Xopt nV, if connected to uYopt, the yYopt output will refer to the dual solution Yopt nV+nC of the QP problem. If both inputs are connected, both solutions will be obtained in each step. The optimal objective function value is indicated on the output objval.

The integer input unWSR specifies the maximum number of working set recalculations to be performed during the initial homotopy, see Section 3.2 of the manual [12]. Output ynWSR contains the number of working set recalculations actually performed. If the double input utime is connected and has a positive value, it contains the maximum allowed CPU time in seconds for the whole initialisation. The actually required CPU time for the initialization is indicated on the output ytime.

At least one vector must be connected from the uXopt and uYopt pair must be connected to obtain the solution of the QP problem. If uXopt is connected, the yXopt output will refer to the primary Xopt solution, if uYopt is connected, the yYopt output will refer to the dual Yopt solution of the QP task. If both inputs are connected, both solutions will be obtained in each step.

If the input INIT = on then the particular allocated QP problem is re-initialized. The INIT should be on for only a single period (edge) because no solution is computed during the QP initialisation. If HLD = on then nothing is computed.

The error flag E is set to on and the error code iE is set to zero if:

  • the reference uG or uLB or uUB is not defined (i.e. input uG or uLB or uUB is not connected),
  • the reference uA is defined and uLBA or uUBA is not defined (i.e. input uA is connected and uLBA or uUBA is not connected),
  • both references uXopt and uYopt are not defined (i.e. neither of the inputs uXopt and uYopt is connected),
  • the Hessian matrix H referenced by uH has a different number of rows and columns than nV,
  • the number of rows of vectors referenced by uLB and uUB is not equal to nV (or the number of their columns is not equal to 1),
  • the number of rows of vectors referenced by uLBA and uUBA is not equal to nC (or the number of their columns is not equal to 1) if the matrix A referenced by uA is connected,
  • the number of rows of the vector referenced by uXopt is not equal to nV or the number of rows of the vector referenced by yOpt is not equal to nV+nC (or the number of their columns is not equal to 1),
  • the internal space for transposed copies of matrices H or A is too small.

If the flag E is set to on and the error code iE is not zero then iE indicates the qpOASES error code, see the include file MessageHandling.hpp from qpOASES library.

Inputs

uQP

Input reference to quadratic programming problem

Reference

uH

Input reference to Hessian matrix H

Reference

uG

Input reference to gradient vector G

Reference

uA

Input reference to constraint matrix A

Reference

uLB

Input reference to lower bound vector LB

Reference

uUB

Input reference to upper bound vector LB

Reference

uLBA

Input reference to lower constraints’ bound vector LB

Reference

uUBA

Input reference to upper constraints’ bound vector LB

Reference

uXopt

Input reference to primal optimal solution

Reference

uYopt

Input reference to dual optimal solution

Reference

unWSR

Maximum number of initial working set recalculations

Long (I32)

utime

Maximum allowed CPU time in seconds for the whole initialisation

Double (F64)

VAR

Indiates that matrices H and A are time varying

Bool

INIT

Calls init() function instead of hotstart() in each block execution

Bool

HLD

If HLD = on then nothing is computed

Bool

Parameters

nVmax

Maximum number of optimization variables nV

Long (I32)

nCmax

Maximum number of optimization constraints nC

Long (I32)

hessianType

Hessian matrix type

Long (I32)

printLevel

Print level

Long (I32)

enableRamping

Enable ramping

Bool

enableFarBounds

Enable use of far bounds

Bool

enableFlippingBounds

Enable use of flipping bounds

Bool

enableRegularisation

Enable regularisation of semidefinite Hessian matrix

Bool

enableFullLITests

Enable use of condition-hardened linear independence tests

Bool

enableNZCTests

Enable nonzero curvature tests

Bool

enableDriftCorrection

Frequency of drift corrections (0 = off)

Long (I32)

enableCholeskyRefact

Frequency of full refactorisation of projected Hessian (0 = off)

Long (I32)

enableEqualities

Equalities shall be always treated as active constraints

Bool

terminationTolerance

Termination tolerance

Double (F64)

boundTolerance

If upper and lower limits differ less than this tolerance, they are regarded equal, i.e. as equality constraint

Double (F64)

boundRelaxation

Initial relaxation of bounds to start homotopy and initial value for far bounds.

Double (F64)

epsNum

Numerator tolerance for ratio tests

Double (F64)

epsDen

Denominator tolerance for ratio tests

Double (F64)

maxPrimalJump

Maximum allowed jump in primal variables in nonzero curvature tests

Double (F64)

maxDualJump

Maximum allowed jump in dual variables in linear independence tests

Double (F64)

initialRamping

Start value for ramping strategy

Double (F64)

finalRamping

Final value for ramping strategy

Double (F64)

initialFarBounds

Initial size of Far Bounds

Double (F64)

growFarBounds

Factor to grow Far Bounds

Double (F64)

initialStatusBounds

Initial status of bounds at first iteration

Long (I32)

epsFlipping

Tolerance of squared entry of Cholesky diagonal which triggers flipping bounds

Double (F64)

numRegularisationSteps

Maximum number of successive regularisation steps

Long (I32)

epsRegularisation

Scaling factor of identity matrix used for Hessian regularisation

Double (F64)

numRefinementSteps

Maximum number of iterative refinement steps

Long (I32)

epsIterRef

Early termination tolerance for iterative refinement

Double (F64)

epsLITests

Tolerance for linear independence tests

Double (F64)

epsNZCTests

Tolerance for nonzero curvature tests

Double (F64)

Outputs

yQP

Output reference to quadratic programming problem

Reference

yH

Output reference to Hessian matrix H

Reference

yG

Output reference to gradient vector G

Reference

yA

Output reference to constraint matrix A

Reference

yLB

Output reference to lower bound vector LB

Reference

yUB

Output reference to upper bound vector LB

Reference

yLBA

Output reference to lower constraints’bound vector LB

Reference

yUBA

Output reference to upper constraints’ bound vector LB

Reference

yXopt

Output reference to primal optimal solution

Reference

yYopt

Output reference to dual optimal solution

Reference

ynWSR

Number of performed initial working set recalculations

Long (I32)

ytime

Elapsed CPU time in seconds for the whole initialisation

Double (F64)

objval

Optimal objective function value

Double (F64)

E

Error indicator

Bool

iE

Error code

Long (I32)

2024 © REX Controls s.r.o., www.rexygen.com