Mercurial > octave
comparison scripts/optimization/sqp.m @ 7361:a2870fd8ac58
[project @ 2008-01-12 07:50:54 by jwe]
author | jwe |
---|---|
date | Sat, 12 Jan 2008 07:50:55 +0000 |
parents | 120f3135952f |
children | fe9a44d753d6 |
comparison
equal
deleted
inserted
replaced
7360:1e716cb4b2a3 | 7361:a2870fd8ac58 |
---|---|
710 if (! isempty (cigradfcn)) | 710 if (! isempty (cigradfcn)) |
711 res = [feval(cigradfcn,x); eye(numel(x)); -eye(numel(x))]; | 711 res = [feval(cigradfcn,x); eye(numel(x)); -eye(numel(x))]; |
712 endif | 712 endif |
713 | 713 |
714 ### endfunction | 714 ### endfunction |
715 | |
716 %! function r = g (x) | |
717 %! | |
718 %! r = [ sumsq(x)-10; | |
719 %! x(2)*x(3)-5*x(4)*x(5); | |
720 %! x(1)^3+x(2)^3+1 ]; | |
721 %! endfunction | |
722 %! | |
723 %! function obj = phi (x) | |
724 %! obj = exp(prod(x)) - 0.5*(x(1)^3+x(2)^3+1)^2; | |
725 %! endfunction | |
726 %! | |
727 %!test | |
728 %! x0 = [-1.8; 1.7; 1.9; -0.8; -0.8]; | |
729 %! | |
730 %! [x, obj, info, iter, nf, lambda] = sqp (x0, @phi, @g, []) | |
731 %! | |
732 %! x_opt = [-1.717143501952599; | |
733 %! 1.595709610928535; | |
734 %! 1.827245880097156; | |
735 %! -0.763643103133572; | |
736 %! -0.763643068453300]; | |
737 %! | |
738 %! obj_opt = 0.0539498477702739 | |
739 %! | |
740 %! assert (all (abs (x-x_opt) < sqrt (eps)) && abs (obj-obj_opt) < sqrt (eps)); |