MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

# Solution 65390

Submitted on 24 Mar 2012 by Robert Canfield

Correct

475Size
`This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.`

### Test Suite

Test
Code Input and Output
1
Pass

```%% 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)
```
```xmin =
2.0020
fmin =
1.0010
```
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.0000
fmin =
2.0000
```
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
Pass

```%%
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)
```
```xmin =
1.9998
0.0009
fmin =
2.0007
```