2 %> Algorithm 20.1: local SQP algorithm. Implementation of algorithm 20.1 of \cite Bier15-book
4 %> @note Tested with \ref run2002.m
5 %> @note Tested with \ref run2003.m
6 %> @note Tested with \ref run2004.m
8 %> @author Michel Bierlaire
9 %> @date Thu Mar 26 13:33:44 2015
10 %> @ingroup Algorithms
13 %> Applies the local SQP method to solve \f[\min_x f(x) \f] subject to \f[h(x)=0,\f] where \f$f:\mathbb{R}^n \to \mathbb{R}\f$ and \f$h:\mathbb{R}^n \to \mathbb{R}^m \f$.
14 %> @param problem the name of the Octave
function defining f(x), h(x) and their derivatives. The funtion has two arguments: x and index. If index=0, the objective function \f$f\f$ and its derivatives are evaluated. If index=\f$i\f$, the constraint \f$h_i\f$ and its derivtives are evaluated.
15 %> @param x0 starting primal point (nx1)
16 %> @param lambda0 starting dual point (mx1)
17 %> @param eps algorithm stops if \f$\|\nabla L(x_k,\lambda_k\| \leq \varepsilon \f$ and \f$\|h(x_k)\|^2\f$.
18 %> @param maxiter maximum number of iterations (
default: 100)
19 %> @
return [solution,lambda]
20 %> @
return x: primal solution
21 %> @
return lambda: dual solution
22 function [solution,lambda] =
localSqp(problem,x0,lambda0,eps,maxiter=100)
28 # printf("x(1)\tx(2)\tlambda\tdx1\tdx2\tnorm\n") ; 31 printf(
"%d\t\%12.5e\t%12.5e\t%12.5e\t",k,xk(1),xk(2),lambdak) ;
32 # printf("%f,%f\n",xk(1),xk(2)) ; 33 [f,g,H] = feval(problem,xk,0) ;
38 [fi,gi,Hi] = feval(problem,xk,i) ;
39 contr = [contr ; fi] ;
40 gradcontr = [gradcontr ; gi] ;
41 hesslagrangien += lambdak(i) * Hi ;
43 [dx,qobj,info,dl] = qp(xk,hesslagrangien,g,-gradcontr
',contr); 45 gradlagrangien = [g + gradcontr * lambdak ; contr] ; 46 printf("%12.5e\n", norm(gradlagrangien)) ; 50 until (norm(gradlagrangien) <= eps || k >= maxiter) function localSqp(in problem, in x0, in lambda0, in eps, in maxiter)
Applies the local SQP method to solve subject to where and .