File Exchange

image thumbnail

slp_trust, sqp

version 1.2.2 (808 KB) by

Sequential Linear Programming (SLP) with trust region and Sequential Quadratic Programming (SQP)



View License

Solve constrained, nonlinear parameter optimization problems using sequential linear programming with a trust region strategy (slp_trust) or sequential quadratic programming (sqp), similarly to fmincon in the Optimization Toolbox. SQP is a second-order method, implementing Schittkowski's NLPQL Fortran algorithm. SLP is a first-order method, but may be more efficient for large numbers of design variables. Both are implemented using the original calling sequence of the obsolete MATLAB constr.m function from Version 1 of the optim toolbox, but may alternatively accept a problem data structure used by fmincon as an input argument. The original calling sequence had the advantage that one user function computed the objective and constraint values together, with a separate function for their gradients when finite differences were not used. Both slp_trust and sqp offer the feature of complex step derivatives, which can be accurate to machine precision, in place of finite difference derivatives, when the user does not supply a function that computes the derivatives.

Comments and Ratings (23)

Ali, thanks. Initialization of vold will be fixed in next version I upload.

in 'sqp.m' in line No. 698 where:
status=('Lagrange Multipliers not finite'); v=vold; break
the variable 'vold' is not defined before and can result in an error

Ali Aghaeifar

The function 'trust_adapt' in trust_region.m is undefined and causes an error

Hieu Nguyen

Can any one help me on this?
I don't know how to use this.

Thanks in advanced


Flavio (view profile)

It would be great if line search could recover from nan or inf values

In trying to run "runfHaftka4p2p1.m", I was unable to do so because 'trust_adapt' was not available for use in "slp_trust". Could you please include it? Thanks,


Flavio (view profile)

Sorry.. I've seen the example with the dummy constraint, nice job


Flavio (view profile)

very good for bounded constrained optimizations, but is it possible to perform bounded unconstrained optimization?

Payal Thukral

Hi Robert. Really great job !
Can you tell me if The SLP_Trust can be used for nonlinear equality constraints? I am trying to use it. Thanks!!

Inequality constraints are supported. Equality constraints are supported in sqp, but not in sip_trust. The user returns both in the same vector for sqp. See documentation on how to specify them.


Óscar (view profile)

Hi Robert, Thank you for sharing such an interesting code. One quick question. Do you maybe have an updated version that supports inequality constraints? Thank you very much.

By default slp_trust and sqp request gradients of all constraints from the user, which should handle hundreds of constraints, but may falter for more than that (depending partly on number of design variables). A user may code gradient functions to take advantage of an active set strategy, which is implemented differently in the two codes. For slp_trust the user may code his gradient function to compute only active constraint gradients based on an optional input argument. Only the first iteration requires all gradients. For sqp the user may code her gradient function to compute only active constraint gradients based on a global variable, ACTIVE_CONSTRAINTS. The documentation in the help folder provides the details.


lala (view profile)

Hi Robert ,Thanks for your share. Does the toolbox can solve the large-scale NLP problem,which means it has hundreds of constrains?

Marco, the basic trust region strategy is classical (e.g., Moré, J.J. and D.C. Sorensen, "Computing a Trust Region Step," SIAM Journal on Scientific and Statistical Computing, Vol. 3, pp 553–572, 1983); however, the detailed implementation, including how to treat constraints, is original.


Marco (view profile)

Hi Robert, I am also tryng to find a reference for the slp_trust algorithm you implemented. I am particulary interested in the trust region update phase, can you help me out? I have serched extensively on scholar but I do not found anything.

Marco, thank you. Yes, you did catch a typo: gradg should be gradf on that line. I will correct with next upload.


Marco (view profile)

Hi Robert,
at line 290 of slp_trust is really

or it should be
gradf=gradf(:)' ?

Thank you for sharing this good piece of code!

slp_trust requires lp and sqp requires qp from optimization toolbox to solve respective search direction sub-problems.

Marc Matten

Okay, then I mixed up some downloads.
I had a look on your scipts, aswell. Is it possible to use them without the optimization toolbox?

Marc, not sure what you mean about modQPM.m (not one of my m-files). This implementation handles nonlinear and equality constraints.

Marc Matten

Hi Robert,
I really like your SQP program. I found that the current version of 'modSQP.m' handles only inequality and bound constraints. Is there an updated version or a simple way to respect equality and nonlinear constraints?



Trust region filter is new default for sip_trust. sqp handles quadprog error return better.


Trust region filter is new default for sip_trust. sqp handles quadprog error return better.


Compatible with R2016b Optimization Toolbox version 7.5 optimoptions function.


Adds trust region filter. [Nocedal and Wright, Numerical Optimization, 2006] Algorithms 4.1, 15.1. See also [Fletcher and Leafier, Mathematical Programming Vol. 91, No. 2, 2002] doi: 10.1007/s101070100244


Set options.TrustRegion='TRAM' instead of 'on' or 'off' in sip_trust to exercise variable move limit reduction and expansion. Loosely implements trust region approximation method: Wujek, B. A., and Renaud, J. E., AIAA J., 1988.


Removed .git folder


Removed .git folder

MATLAB Release
MATLAB 9.1 (R2016b)

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video