Cody

# Problem 527. Augmented Lagrange Multiplier (ALM) Method

Solution 1737040

Submitted on 26 Feb 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)

Undefined function or variable 'x'. Error in alm (line 4) for k=logspace(0,10,11),x=fminsearch(@(x)f(x)+1e6*sum(h(x).^2)+k*sum(max(0,g(x))),x);end 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)

Undefined function or variable 'x'. Error in alm (line 4) for k=logspace(0,10,11),x=fminsearch(@(x)f(x)+1e6*sum(h(x).^2)+k*sum(max(0,g(x))),x);end 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)

Undefined function or variable 'x'. Error in alm (line 4) for k=logspace(0,10,11),x=fminsearch(@(x)f(x)+1e6*sum(h(x).^2)+k*sum(max(0,g(x))),x);end Error in Test3 (line 5) [xmin,fmin,u]=alm(f,g,[],x0)