Professional Documents
Culture Documents
424
* x(1) *x(2) - 0.09167*x(1)*x(3) + 0.133*x(2)*x(3))
Nugget_Diameter = (- 4.30682 + 1.4* x(1) -2.589* x(2) + 0.685* x(3)+0.114* x(4)0.0139 x(3)*x(3) - 0.077 *x(1) * x(3) + 0.176*x(2)*x(3))
x(1)= 7-11
x(2)=0.2-0.4
x(3)= 5-17
x(4)=5-7
[7;0.2;5;5]
[11;0.4;17;7]
Function
function y = strength(x)
y = (-(5.88835 + 0.375*x(1) - 6.20833*x(2) + 0.6888*x(3)+ 0.2*x(4) + 0.424 *
x(1) *x(2) - 0.09167*x(1)*x(3) + 0.133*x(2)*x(3)));
Bounds
[7;0.2;5;5]
[11;0.4;17;7]
Simulated Annealing
lb=[7;0.2;5;5];
ub=[11;0.4;17;7];
[x,fval,exitFlag,output] = simulannealbnd(ObjectiveFunction,X0,lb,ub);
fprintf('The number of iterations was : %d\n', output.iterations);
fprintf('The number of function evaluations was : %d\n', output.funccount);
fprintf('The best function value found was : %g\n', fval);
[x,fval,exitFlag] = simulannealbnd(ObjectiveFunction,X0,lb,ub)
Answer
1.0
2.0
3.0
4.0
7.000863171061406
0.20282731582566732
16.895950596159267
6.994413212913133
1.0
2.0
3.0
4.0
7.077282117937123
0.21630146244485385
16.257024099091417
6.8469101288832155
1.0
2.0
3.0
4.0
7.000366745740669
0.20001687430478454
16.83019532778666
6.999763159192615
----------------------------Optimization running.
GA
[x fval] = ga(@fitnessfun, nvars, options)
Optimization running.
Objective function value: -10.518108792056639
Optimization terminated: average change in the fitness value less than
options.TolFun.
7.0001127566664945
0.20012373439100895
16.999997871300458 6.999999966039531
fun = @strength;
nvars = 4;
lb=[7;0.2;5;5];
ub=[11;0.4;17;7];
[x,fval,exitflag] = particleswarm(fun,nvars,lb,ub)
Output
Optimization ended: relative change in the objective value
over the last OPTIONS.StallIterLimit iterations is less than OPTIONS.TolFun.
x=
7.0000
0.2000 17.0000
7.0000
fval =
-10.5184
exitflag =
options = optimoptions('particleswarm','SwarmSize',100);
[x,fval,exitflag] = particleswarm(fun,nvars,lb,ub,options)
fun = @strength;
nvars = 4;
lb=[7;0.2;5;5];
ub=[11;0.4;17;7];
options = optimoptions(@particleswarm,'OutputFcns',@pswplotranges);
rng default % For reproducibility
[x,fval,eflag] = particleswarm(fun,nvars,lb,ub,options)
x=
7.0000
fval =
-10.5184
eflag =
0.2000 17.0000
7.0000