Cody

Solution 67533

Submitted on 29 Mar 2012 by Charles Eger
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

Test Suite

Test Status Code Input and Output
1   Pass
%% Haftka & Gurdal, Figure 5.7.1 example f = @(x) 0.5*x; g = @(x) 2-x; x0 = 0; [xmin,fmin]=sumt_exterior(f,g,[],x0) %#ok<*NOPTS> xcorrect=2; assert(norm(xmin-xcorrect)<1e-3) assert(abs(fmin-f(xcorrect))<1e-3)
xmin = 2.0000 fmin = 1.0000
2   Pass
%% f = @(x) 0.5*x; g = @(x) 2-x; x0 = 0; [xmin,fmin]=sumt_exterior(f,g,[],x0,1) % 1 iteration for unit penalty value xr1=1.75; assert(norm(xmin-xr1)<1e-4) assert(abs(fmin-f(xr1))<1e-4)
xmin = 1.7500 fmin = 0.8750
3   Pass
%% Haftka & Gurdal, Example 5.7.1 f = @(x) x(1).^2 + 10*x(2).^2; h = @(x) sum(x)-4; x0 = [0; 0]; [xmin,fmin]=sumt_exterior(f,[],h,x0) xcorrect=[40; 4]/11; assert(norm(xmin-xcorrect)<1e-3) assert(abs(fmin-f(xcorrect))<1e-4)
xmin = 3.6364 0.3636 fmin = 14.5455
4   Pass
%% f = @(x) x(1).^2 + 10*x(2).^2; h = @(x) sum(x)-4; x0 = [0; 0]; r = [1, 5]; [xmin,fmin]=sumt_exterior(f,[],h,x0,r) % 2 iterations xr2=[3.0769 0.3077]; assert(norm(xmin-xr2,inf)<1e-4) assert(abs(fmin-f(xr2))<1e-4)
xmin = 3.0769 0.3077 fmin = 10.4141
5   Pass
%% Vanderplaats, Figure 5-4 example f = @(x) sum(x); g = @(x) [x(1) - 2*x(2) - 2 8 - 6*x(1) + x(1).^2 - x(2)]; x0 = [0; 0]; [xmin,fmin]=sumt_exterior(f,g,[],x0) xcorrect=[2; 0]; assert(norm(xmin-xcorrect)<1e-4) assert(abs(fmin-f(xcorrect))<1e-4)
xmin = 2.0000 0.0001 fmin = 2.0000
6   Pass
%% f = @(x) sum(x); g = @(x) [x(1) - 2*x(2) - 2 8 - 6*x(1) + x(1).^2 - x(2)]; x0 = [5; 5]; r = [1, 2]; [xmin,fmin]=sumt_exterior(f,g,[],x0,r) % 2 iterations xr2=[1.9536 -0.0496]; assert(norm(xmin-xr2)<1e-4) assert(abs(fmin-f(xr2))<1e-4)
xmin = 1.9536 -0.0496 fmin = 1.9040