Cody

# Problem 527. Augmented Lagrange Multiplier (ALM) Method

Solution 1737043

Submitted on 26 Feb 2019 by Alfonso Nieto-Castanon
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
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)

xmin = 2.0000 fmin = 1 u = 0.5000

2   Pass
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)

[Warning: Rank deficient, rank = 0, tol = 0.000000e+00.] [> In alm (line 8) In ScoringEngineTestPoint2 (line 4) In solutionTest (line 5)] xmin = 3.6363 0.3637 fmin = 14.5455 v = -7.2729

3   Pass
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)

[Warning: Rank deficient, rank = 0, tol = 0.000000e+00.] [> In alm (line 7) In ScoringEngineTestPoint3 (line 5) In solutionTest (line 7)] xmin = 2.0000 0.0001 fmin = 2 u = 0.2000 0.6000