Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Optimization help

ogro0ogro0 Posts: 1Member
Hi everyone!

Iam not so good at english, but ill try to expolain my problem to you.
A factory uses ingots to do some products, that have a fix volume, but the ingots dont. They have an error in their dimensions that affects on the end of the process, giving more or less material loss.
So thats it, I need to arrange the ingots in order to have minimum material loss and iam doing this with genetic algorithm as solver.
The fact is that iam getting the quantity of material lost, but I cant have a fix order to the ingots (probably many results).


Iam posting my function and the genetic algorithm code now:

function sobra = lingoten(x);
vol=[932.632661923009;896.096943763439;833.371277330512;843.809844382488;929.391342004761;904.160516477429;1025.99962821412;870.221930789316;944.865478885808;984.150429036178;833.990702471929;852.559052149479;834.376307939848;861.292659074916;863.365915901348;890.730603197672;963.504073232846;886.996713449424;793.389622161219;888.816391134596;949.696136725675;917.256662064900;852.207569275760;814.794835044433;847.553580285134;943.871877391880;955.143074172044;929.219111657251;];
[xord,ordem] = sort(x);


sobra(1) = vol(ordem(1))-900;
if sobra(1)<0
sobra(1)= 15*abs(sobra(1));
end
sobra(2) = sum(vol(ordem(2:3)))-1550;
if sobra(2)<0
sobra(2)=15*abs(sobra(2));
end
sobra(3) = sum(vol(ordem(4:6)))-2650;
if sobra(3)<0
sobra(3)=15*abs(sobra(3));
end
sobra(4) = vol(ordem(7))-900;
if sobra(4)<0
sobra(4)=15*abs(sobra(4));
end
sobra(5) = sum(vol(ordem(8:10)))-2650;
if sobra(5)<0
sobra(5)=15*abs(sobra(5));
end
sobra(6) = sum(vol(ordem(11:13)))-2650;
if sobra(6)<0
sobra(6)=15*abs(sobra(6));
end
sobra(7) = sum(vol(ordem(14:15)))-1550;
if sobra(7)<0
sobra(7)=15*abs(sobra(7));
end
sobra(8) = sum(vol(ordem(16:18)))-2650;
if sobra(8)<0
sobra(8)=15*abs(sobra(8));
end
sobra(9) = sum(vol(ordem(19:20)))-1550;
if sobra(9)<0
sobra(9)=15*abs(sobra(9));
end
sobra(10)= sum(vol(ordem(21:22)))-1550;
if sobra(10)<0
sobra(10)=15*abs(sobra(10));
end
sobra(11)= vol(ordem(23))-900;
if sobra(11)<0
sobra(11)=15*abs(sobra(11));
end
sobra(12)= vol(ordem(24))-900;
if sobra(12)<0
sobra(12)=15*abs(sobra(12));
end
sobra(13)= sum(vol(ordem(25:26)))-1550;
if sobra(13)<0
sobra(13)=15*abs(sobra(13));
end
sobra(14)= sum(vol(ordem(27:28)))-1550;
if sobra(14)<0
sobra(14)=15*abs(sobra(14));
end

sobra = sum(sobra);





now the GA:



clear all
clc

%funcao: minimizar a perda de material:
%% Dados de Entrada
f = @lingoten; % funcao objetivo
nvar = 28; % numero de variaveis
a = zeros(1,28); % valores inferiores das suas vari
Sign In or Register to comment.