Cody

Solution 68873

Submitted on 1 Apr 2012
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   Fail
%% Haftka & Gurdal, Figure 5.7.1 example f = @(x) 0.5*x; g = @(x) 2-x; x0 = 5; [xmin,fmin]=sumt_interior(f,g,x0) %#ok<*NOPTS> xcorrect=2; assert(norm(xmin-xcorrect)<2e-3) assert(abs(fmin-f(xcorrect))<1e-3)
Error: Assertion failed.
2   Pass
%% f = @(x) 0.5*x; g = @(x) 2-x; x0 = 5; [xmin,fmin]=sumt_interior(f,g,x0,1) % 1 iteration for unit penalty value xr1=4; assert(norm(xmin-xr1)<1e-4) assert(abs(fmin-f(xr1))<1e-4)
xmin = 4 fmin = 2
3   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 = [3; 3]; [xmin,fmin]=sumt_interior(f,g,x0,1) % 1 iteration xr2=[1.8686 2.1221]; assert(norm(xmin-xr2)<1e-2) assert(abs(fmin-f(xr2))<1e-2)
xmin = 1.8686 2.1221 fmin = 3.9906
4   Fail
%% f = @(x) sum(x); g = @(x) [x(1) - 2*x(2) - 2 8 - 6*x(1) + x(1).^2 - x(2)]; x0 = [2.1; 0.1]; r = 2^12; [xmin,fmin]=sumt_interior(f,g,x0,r) % Final iteration xcorrect=[2; 0]; assert(norm(xmin-xcorrect)<5e-3) assert(abs(fmin-f(xcorrect))<2e-3)
Error: Assertion failed.