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.0001
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.6363
0.3637
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.0000
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
|
74 Solvers
19 Solvers
54 Solvers
Fletcher-Reeves Conjugate Gradient Method
19 Solvers
309 Solvers
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!