comparison scripts/optimization/sqp.m @ 7371:fe9a44d753d6

[project @ 2008-01-14 19:34:22 by jwe]
author jwe
date Mon, 14 Jan 2008 19:34:22 +0000
parents a2870fd8ac58
children 90b931a40617
comparison
equal deleted inserted replaced
7370:74d64ead0cd7 7371:fe9a44d753d6
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 715
716 %! function r = g (x) 716 %!function r = g (x)
717 %! r = [sumsq(x)-10;
718 %! x(2)*x(3)-5*x(4)*x(5);
719 %! x(1)^3+x(2)^3+1 ];
717 %! 720 %!
718 %! r = [ sumsq(x)-10; 721 %!function obj = phi (x)
719 %! x(2)*x(3)-5*x(4)*x(5); 722 %! obj = exp(prod(x)) - 0.5*(x(1)^3+x(2)^3+1)^2;
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 %! 723 %!
727 %!test 724 %!test
728 %! x0 = [-1.8; 1.7; 1.9; -0.8; -0.8]; 725 %! x0 = [-1.8; 1.7; 1.9; -0.8; -0.8];
729 %! 726 %!
730 %! [x, obj, info, iter, nf, lambda] = sqp (x0, @phi, @g, []) 727 %! [x, obj, info, iter, nf, lambda] = sqp (x0, @phi, @g, [])
733 %! 1.595709610928535; 730 %! 1.595709610928535;
734 %! 1.827245880097156; 731 %! 1.827245880097156;
735 %! -0.763643103133572; 732 %! -0.763643103133572;
736 %! -0.763643068453300]; 733 %! -0.763643068453300];
737 %! 734 %!
738 %! obj_opt = 0.0539498477702739 735 %! obj_opt = 0.0539498477702739;
739 %! 736 %!
740 %! assert (all (abs (x-x_opt) < sqrt (eps)) && abs (obj-obj_opt) < sqrt (eps)); 737 %! assert (all (abs (x-x_opt) < sqrt (eps)) && abs (obj-obj_opt) < sqrt (eps));