Cody

Solution 1908584

Submitted on 22 Aug 2019
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
f = @(x) 0.5*x; g = @(x) 2-x; x0 = 0; [xmin,fmin,u]=alm(f,g,[],x0) %#ok<*NOPTS> xcorrect=2; ucorrect=0.5; assert(norm(xmin-xcorrect)<1e-3) assert(abs(fmin-f(xcorrect))<1e-3) assert(abs(u-ucorrect)<1e-3)

Output argument "x" (and maybe others) not assigned during call to "alm". Error in Test1 (line 4) [xmin,fmin,u]=alm(f,g,[],x0) %#ok<*NOPTS>

2   Fail
f = @(x) x(1).^2 + 10*x(2).^2; h = @(x) sum(x)-4; x0 = [0; 0]; [xmin,fmin,~,v]=alm(f,[],h,x0) xcorrect=[40; 4]/11; vcorrect=-7.2727; assert(norm(xmin-xcorrect)<1e-3) assert(abs(fmin-f(xcorrect))<1e-4) assert(abs(v-vcorrect)<1e-2)

Output argument "x" (and maybe others) not assigned during call to "alm". Error in Test2 (line 4) [xmin,fmin,~,v]=alm(f,[],h,x0)

3   Fail
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,u]=alm(f,g,[],x0) xcorrect=[2; 0]; ucorrect=[0.2; 0.6]; assert(norm(xmin-xcorrect)<1e-4) assert(abs(fmin-f(xcorrect))<1e-4) assert(norm(u-ucorrect)<1e-2)

Output argument "x" (and maybe others) not assigned during call to "alm". Error in Test3 (line 5) [xmin,fmin,u]=alm(f,g,[],x0)