Spot Weld Optimization Technique

10
strength = (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)) 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]

description

optimisation of nugget size of spot welding using simulated annealing and particle swarm optimization.

Transcript of Spot Weld Optimization Technique

strength = (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)) 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-11x(2)=0.2-0.4x(3)= 5-17x(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 AnnealingStart point [7;0.2;5;5]ObjectiveFunction = @strength;X0 = [7;0.2;5;5];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)

Optimization terminated: change in best function value less than options.TolFun.The number of iterations was : 2885The number of function evaluations was : 2962The best function value found was : -10.5112

Answer 1.07.000863171061406

2.00.20282731582566732

3.016.895950596159267

4.06.994413212913133

Objective function value: -10.336292294008466Optimization terminated: change in best function value less than options.TolFun.1.07.077282117937123

2.00.21630146244485385

3.016.257024099091417

4.06.8469101288832155

1.07.000366745740669

2.00.20001687430478454

3.016.83019532778666

4.06.999763159192615

-----------------------------Optimization running.Objective function value: -10.505376231029937Optimization terminated: change in best function value less than options.TolFun.

GA[x fval] = ga(@fitnessfun, nvars, options)

Optimization running.Objective function value: -10.518108792056639Optimization terminated: average change in the fitness value less than options.TolFun.

7.00011275666649450.2001237343910089516.9999978713004586.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)

OutputOptimization 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 =

1

options = optimoptions('particleswarm','SwarmSize',100);[x,fval,exitflag] = particleswarm(fun,nvars,lb,ub,options)

Copy to make new .m filefunction stop = pswplotranges(optimValues,state)

stop = false; % This function does not stop the solverswitch state case 'init' nplot = size(optimValues.swarm,2); % Number of dimensions for i = 1:nplot % Set up axes for plot subplot(nplot,1,i); tag = sprintf('psoplotrange_var_%g',i); % Set a tag for the subplot semilogy(optimValues.iteration,0,'-k','Tag',tag); % Log-scaled plot ylabel(num2str(i)) end xlabel('Iteration','interp','none'); % Iteration number at the bottom subplot(nplot,1,1) % Title at the top title('Log range of particles by component') setappdata(gcf,'t0',tic); % Set up a timer to plot only when needed case 'iter' nplot = size(optimValues.swarm,2); % Number of dimensions for i = 1:nplot subplot(nplot,1,i); % Calculate the range of the particles at dimension i irange = max(optimValues.swarm(:,i)) - min(optimValues.swarm(:,i)); tag = sprintf('psoplotrange_var_%g',i); plotHandle = findobj(get(gca,'Children'),'Tag',tag); % Get the subplot xdata = plotHandle.XData; % Get the X data from the plot newX = [xdata optimValues.iteration]; % Add the new iteration plotHandle.XData = newX; % Put the X data into the plot ydata = plotHandle.YData; % Get the Y data from the plot newY = [ydata irange]; % Add the new value plotHandle.YData = newY; % Put the Y data into the plot end if toc(getappdata(gcf,'t0')) > 1/30 % If 1/30 s has passed drawnow % Show the plot setappdata(gcf,'t0',tic); % Reset the timer end case 'done' % No cleanup necessaryend

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 0.2000 17.0000 7.0000

fval =

-10.5184

eflag =

1