矩形排料问题,组合优化问题
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
《二维矩形条带装箱问题的底部左齐择优匹配算法_蒋兴波》matlab的实现,不包括遗传算法部分。fun cti on area =
Packi ngAlgorithm(le ngth,width,le ngth1,width1,le ngth2,width2,le ngth3,width3,restrict1,res
trict2)
area = 0;
frameCou nt = 1;
cou nt1 = 0;
cou nt2 = 0;
run LLABF;
fun ction run LLABF
rectBig.le ngth = len gth;
rectBig.width = width;
rectSmall(1).le ngth = len gth1;
rectSmall(1).width = width1;
rectSmall(1).color = 'r';
rectSmall(2).le ngth = len gth2;
rectSmall(2).width = width2;
rectSmall(2).color = 'b';
rectSmall(3).le ngth = len gth3;
rectSmall(3).width = width3;
rectSmall(3).color = 'g';
edges⑴.x = 0;
edges⑴.y = 0;
edges(1) .len gth = rectBig .len gth;
edges (2).x = -100;
edges (2).y = 10000;
edges(2 ).len gth = 0;
edges (3) .x = rectBig.le ngth+100;
edges (3).y = 10000;
edges(3 ).len gth = 0;
while (1)
flag = -1; if(flag < 0)
[sortedEdges,lowestEdge,id] = edgesSort(edges); [edges,flag] =
FullFitFirst(sortedEdges,lowestEdge,id,rectSmall);
if(flag<0)
[sortedEdges,lowestEdge,id] = edgesSort(edges);
[edges,flag] = WidthFitFirst(sortedEdges,lowestEdge,id,rectSmall); end
if(flag<0)
[sortedEdges,lowestEdge,id] = edgesSort(edges);
[edges,flag] = HeightFitFirst(sortedEdges,lowestEdge,id,rectSmall); end if(flag<0)
[sortedEdges,lowestEdge,id] = edgesSort(edges);
[edges,flag] = PlaceabelFirst(sortedEdges,lowestEdge,id,rectSmall); end if(flag<0)
[sortedEdges,lowestEdge,id] = edgesSort(edges);
[edges,flag] = cann otPalce(sortedEdges,lowestEdge,id,rectSmall,flag) end end
if cou nt1 >= restrict1
rectSmall(1).le ngth = 100000;
rectSmall(1).width = 100000;
end
if cou nt2 >= restrict2
rectSmall(2).le ngth = 100000;
rectSmall(2).width = 100000;
end
sortRect = sort([rectSmall(1).le ngth,rectSmall(1).width, ...
rectSmall(2).le ngth,rectSmal l(2) .width, ...
rectSmal l( 3).le ngth,rectSmal l(3) .width]);
min Rect = sortRect(1);
min Rect2 = sortRect(2);
[sortedEdges,lowestEdge,id] = edgesSort(edges);
[~,h] = size(sortedEdges);
for i = 1:h
if (sortedEdges(i).y+mi nRect <= width )
break ;
end
end
if i == h
break ;
end
if i == h-1 && lowestEdge.x + minRect2 > length break
end
if frameCou nt > 300
break ;
end
end
end
fun cti on in itial
rectBig.le ngth = 30;
rectBig.width = 20;
rectSmall(1).le ngth = 4;
rectSmall(1).width = 3;
rectSmall(2).le ngth = 3;
rectSmall(2).width = 3;
rectSmall(3).le ngth = 4;
rectSmall(3).width = 1;
edges(1).x = 0;
edges ⑴.y = 0;
edges(1) .len gth = rectBig .len gth;
edges(1).x = 12; edges(1).y = 10; edges(1) .len gth = 2;
edges(2).x = 3;
edges (2).y = 8; edges(2 ).len gth = 2;
%
edges (3).x = 6;
%
edges (3).y = 4; % edges(3).le ngth = 1; %
%
% %
%
%
%