N = 8;
gpvar w(N) h(N) v(N+1) y(N+1);
wmin = .1; wmax = 100;
hmin = .1; hmax = 6;
Smin = 1/5; Smax = 5;
sigma_max = 1;
ymax = 10;
E = 1; F = 1;
obj = w'*h;
d = 6*F*ones(N,1)./(E*ones(N,1).*w.*h.^3);
constr_v = [];
constr_y = [];
for i = 1:N
constr_v = [constr_v; (2*i-1)*d(i) + v(i+1) <= v(i)];
constr_y = [constr_y; (i-1/3)*d(i) + v(i+1) + y(i+1) <= y(i)];
end
constr = [ ...
wmin*ones(N,1) <= w; w <= wmax*ones(N,1);
hmin*ones(N,1) <= h; h <= hmax*ones(N,1);
Smin*ones(N,1) <= h./w; h./w <= Smax*ones(N,1);
6*F*[1:N]'./(w.*(h.^2)) <= sigma_max*ones(N,1);
constr_v; constr_y;
y(1) <= ymax;
];
[obj_value, solution, status] = gpsolve(obj, constr);
assign(solution);
disp('The optimal widths and heights are: ');
w, h
fprintf(1,'The optimal minimum volume of the beam is %3.4f\n', sum(w.*h))
close all;
plot_cbeam([h; w])
Iteration primal obj. gap dual residual previous step.
1 5.51086e+00 1.41000e+02 4.78e+02 Inf
2 7.51982e+00 6.05762e+01 7.43e+00 8.68550e-01
3 8.54854e+00 2.94849e+01 1.20e-01 8.74857e-01
4 6.68816e+00 2.00658e+01 1.62e-02 6.21831e-01
5 5.12341e+00 1.50260e+01 4.49e-03 5.00000e-01
6 3.73928e+00 9.98356e+00 8.17e-05 1.00000e+00
7 1.26815e+00 4.99359e+00 1.33e-06 1.00000e+00
8 2.74551e-01 2.49745e+00 5.75e-05 1.00000e+00
9 1.13439e-01 1.87348e+00 1.48e-05 5.00000e-01
10 -3.31042e-03 1.24953e+00 4.57e-07 1.00000e+00
Iteration primal obj. gap dual residual previous step.
1 6.01601e+00 1.41000e+02 5.80e-01 Inf
2 5.99011e+00 7.04860e+01 6.02e-04 1.00000e+00
3 5.93268e+00 3.52434e+01 7.50e-04 1.00000e+00
4 5.80743e+00 1.76225e+01 6.64e-04 1.00000e+00
5 5.51852e+00 8.81364e+00 3.09e-04 1.00000e+00
6 4.89586e+00 4.42267e+00 2.99e-05 1.00000e+00
7 4.29210e+00 2.21572e+00 5.85e-06 1.00000e+00
8 3.99034e+00 1.11031e+00 1.18e-06 1.00000e+00
9 3.86425e+00 5.56771e-01 5.11e-07 1.00000e+00
10 3.80503e+00 2.79235e-01 1.69e-07 1.00000e+00
11 3.77556e+00 1.40061e-01 4.32e-08 1.00000e+00
12 3.76101e+00 7.02076e-02 1.69e-08 1.00000e+00
13 3.75402e+00 3.51772e-02 5.82e-09 1.00000e+00
14 3.75057e+00 1.76216e-02 1.11e-09 1.00000e+00
15 3.74882e+00 8.82381e-03 1.88e-10 1.00000e+00
16 3.74794e+00 4.41635e-03 2.72e-11 1.00000e+00
17 3.74751e+00 2.20954e-03 2.94e-12 1.00000e+00
18 3.74729e+00 1.10515e-03 2.40e-13 1.00000e+00
19 3.74718e+00 5.52672e-04 1.64e-14 1.00000e+00
20 3.74712e+00 2.76361e-04 1.05e-15 1.00000e+00
21 3.74709e+00 1.38187e-04 6.95e-17 1.00000e+00
22 3.74708e+00 6.90950e-05 5.41e-18 1.00000e+00
23 3.74707e+00 3.45479e-05 6.43e-19 1.00000e+00
24 3.74707e+00 1.72741e-05 1.24e-19 1.00000e+00
25 3.74707e+00 8.63707e-06 3.06e-20 1.00000e+00
26 3.74707e+00 4.31855e-06 8.08e-21 1.00000e+00
27 3.74707e+00 2.15928e-06 2.16e-21 1.00000e+00
28 3.74707e+00 1.07964e-06 5.78e-22 1.00000e+00
29 3.74707e+00 5.39821e-07 1.54e-22 1.00000e+00
30 3.74707e+00 2.69911e-07 4.11e-23 1.00000e+00
31 3.74707e+00 1.34956e-07 1.09e-23 1.00000e+00
32 3.74707e+00 6.74779e-08 2.90e-24 1.00000e+00
33 3.74707e+00 3.37390e-08 7.68e-25 1.00000e+00
34 3.74707e+00 1.68695e-08 2.03e-25 1.00000e+00
35 3.74707e+00 8.43477e-09 5.38e-26 1.00000e+00
Solved
Problem succesfully solved.
The optimal widths and heights are:
w =
0.6214
0.7830
0.9060
1.0124
1.1004
1.1762
1.2000
1.3333
h =
3.1072
3.9149
4.5298
5.0620
5.5019
5.8812
6.0000
6.0000
The optimal minimum volume of the beam is 42.3965