路径规划基于matlab汽车零部件循环取货路径优化(三维装载约束)含Matlab源码 1100期
Posted 紫极神光(Q1564658423)
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了路径规划基于matlab汽车零部件循环取货路径优化(三维装载约束)含Matlab源码 1100期相关的知识,希望对你有一定的参考价值。
一、简介
1 问题描述:
在考虑汽车零部件包装箱长、宽、高等三维尺寸的约束下,以配送中心为原点,分派多辆同一规格的货车到n个供应商处取货,最后回到配送中心。本章所构建的三维装载约束下的汽车零部件循环取货路径优化模型要解决的问题是确定循环取货路径,要求充分考虑汽车零部件在货车车厢中的三维装载位置,确保每个供应商处的零部件均能成功装载,尽可能使车辆装载率最大,且所有车辆的总行驶路径最短。
基于上述分析,本文所研究的循环取货优化问题可做如下假设:
假设条件:
(1)一个配送中心与多个供应商,且车辆从配送中心出发,最后均回到配送中心;
(2)每辆货车车厢规格(即车厢长、宽、高,载重质量等)均相同;
(3)每辆货车匀速行驶,且行驶速度已知;不存在交通堵塞情况;
(4)配送中心与各零部件供应商以及各供应商之间的距离已知;
(5)各供应商处提供的零部件均由长方体箱包装,且各长方体箱的尺寸、数量、重量等参数已知;
(6)每个供应商提供的零部件总体积、总重量均小于每辆车的容积与载重质量;每个供应商只由一辆车完成服务,且只服务一次;
(7)每条线路上的货物总重量、总体积不得超过货车载重质量及容积;
(8)考虑汽车零部件供应的准时性,每辆货车必须在规定时间以内返回配送中心;
(9)零部件(指长方体包装箱,下同)必须在车厢内部,不得超出车厢车门;
(10)零部件的边总是与车厢的边平行或者垂直、高度方向与车厢高度方向平行,且不得倒置;
(11)货物的重心即为几何中心。
二、源代码
close all;
clear;
clc;
format long;
%load data of mat file trans from excel
load_data;
%set data of known infomation
set_data;
%get the distance among the nodes
get_distance;
%preparation for true task
preparation;
%GA
%GA_for_route;
%GA for tabu
GA_tabu_for_route;
%plot
plot_final;
%start the GA
%struct of GA
GA=struct('num_of_individual',[],'num_of_generation',[],...
'probability_of_mate',[],...
'pairs_of_mate',[],...
'probability_of_mutation',[],...
'probability_of_reverse',[],...
'individual',...
struct(...
'route_code',[],'distance',[],'time_cost',[],...
'volume_rate',[],'weight_rate',[],'adaptability',[],...
'satisfy',[],'van_instance',...
struct('supplier_num_list',[],'distance',[],'time_cost',[],...
'satisfy',[],'topology',[],...
'length_width',[],'height',[])...
),...
'sum_of_adaptability',[],'accumulate_of_adaptability',[]);
%set the numbers individual in the group
GA.num_of_individual=8000;
%set the generations
GA.num_of_generation=200;
%set the probability of mate
GA.probability_of_mate=0.4;
%set the pairs to mate
GA.pairs_of_mate=...
floor(GA.probability_of_mate*GA.num_of_individual/2);
%set the probability of mutation
GA.probability_of_mutation=0.15;
%set the probability of reverse
GA.probability_of_reverse=0.1;
%set the property of individual in the group
GA.individual(1:GA.num_of_individual)=...
struct('route_code',[],'distance',[],'time_cost',[],...
'volume_rate',[],'weight_rate',[],'adaptability',[],...
'satisfy',[],'van_instance',...
struct('supplier_num_list',[],'distance',[],'time_cost',[],...
'satisfy',[],'topology',[],...
'length_width',[],'height',[]));
%result show
group_trend(1:GA.num_of_generation)=...
struct('route_code',[],'distance',[],'time_cost',[],...
'volume_rate',[],'weight_rate',[],'adaptability',[],...
'satisfy',[],'van_instance',...
struct('supplier_num_list',[],'distance',[],'time_cost',[],...
'satisfy',[],'topology',[],...
'length_width',[],'height',[]));
%%
%for the number of van,start from min_van_num
van_parameter.van_num=van_parameter.min_van_num;
%start
van_parameter.van_num=num_of_node;
%the problem is not solved in the beginning
problem_solved=0;
%a list save new generation
temp.index_in_accumulate_list=zeros(GA.num_of_individual,1);
while 1
%initialize all the individual in the group
%for each individual
for index_of_individual=1:GA.num_of_individual
%route code and whom to service
GA.individual(index_of_individual).route_code=...
van_parameter.van_num*rand(num_of_node,1);
%initialize the van information
GA.individual(index_of_individual)...
.van_instance(1:van_parameter.van_num)=struct(...
'supplier_num_list',[],'distance',[],'time_cost',[],...
'satisfy',[],'topology',[],...
'length_width',[],'height',[]);
end
for index_of_generation=1:GA.num_of_generation
%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%step 1
%compute the adaptability for each individual
%and the summation of all the individual
%the summation of all the individual in the group is 0
GA.sum_of_adaptability=0;
%set the accumulation of the adaptability
GA.accumulate_of_adaptability=...
zeros(GA.num_of_individual,1);
%for each individual compute the adaptability
for index_of_individual=1:GA.num_of_individual
%reset distance for each individual
GA.individual(index_of_individual).distance=0;
%van instance
%depend on the number of the van
%for each van
for index_of_van=1:van_parameter.van_num
%get the supplier number list
temp.belong_list=...
find(ceil(GA.individual(index_of_individual)...
.route_code)==index_of_van);
[~,temp.sorted_belong_list]=...
sort(GA.individual(index_of_individual)...
.route_code(temp.belong_list));
GA.individual(index_of_individual)...
.van_instance(index_of_van).supplier_num_list=...
temp.belong_list(temp.sorted_belong_list);
%get the distance and the time cost
[~,GA.individual(index_of_individual)...
.van_instance(index_of_van).distance,...
GA.individual(index_of_individual)...
.van_instance(index_of_van).time_cost]=...
get_distance_and_time_cost(...
GA.individual(index_of_individual)...
.van_instance(index_of_van).supplier_num_list,...
distance_data_struct,van_parameter,time);
%get distance of each individual
%add to time cost
GA.individual(index_of_individual).distance=...
GA.individual(index_of_individual).distance+...
GA.individual(index_of_individual)...
.van_instance(index_of_van).distance;
end
%for index_of_van=1:van_parameter.van_num
%get time cost of each individual
GA.individual(index_of_individual).time_cost=...
GA.individual(index_of_individual).distance/...
van_parameter.speed+num_of_node*time.load_and_unload;
%get adaptability of each individual
GA.individual(index_of_individual).adaptability=...
(GA.individual(index_of_individual).time_cost)^(-9);
%adaptability post process
GA.individual(index_of_individual)=...
post_process(GA.individual(index_of_individual),...
supplier_struct,time,van_parameter,total);
%give the accumulated adaptability
if index_of_individual==1
GA.accumulate_of_adaptability(index_of_individual)=...
GA.individual(index_of_individual).adaptability;
else
GA.accumulate_of_adaptability(index_of_individual)=...
GA.accumulate_of_adaptability(index_of_individual-1)+...
GA.individual(index_of_individual).adaptability;
end
end
%for index_of_individual=1:GA.num_of_individual
%get the summation of adaptability
GA.sum_of_adaptability=...
GA.accumulate_of_adaptability(index_of_individual);
%save index
[~,max_index]=max(cat(1,GA.individual.adaptability));
%save result
group_trend(index_of_generation)=GA.individual(max_index);
%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%step 2
%individual copy by itself
%eliminate the weaked
%for each individual judge whether copy
for index_of_individual=1:GA.num_of_individual
%generate a random number
temp.rand=rand*GA.sum_of_adaptability;
%get the index in the accumulate of adaptability list
temp.index_in_accumulate_list(index_of_individual)=...
find((temp.rand<GA.accumulate_of_adaptability),1);
end
%copy
GA.individual=GA.individual(temp.index_in_accumulate_list);
%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%step 3
%mate
for index_of_pair=1:GA.pairs_of_mate
%choose two mate individual
temp.mate_num1=ceil(rand*GA.num_of_individual);
temp.mate_num2=ceil(rand*GA.num_of_individual);
%choose the mate exchange joint
temp.mate_joint=ceil(rand*(num_of_node-1));
%make two new individual's route code
temp.new_route_code1=...
[GA.individual(temp.mate_num1)...
.route_code(1:temp.mate_joint);...
GA.individual(temp.mate_num2)...
.route_code(temp.mate_joint+1:end)];
temp.new_route_code2=...
[GA.individual(temp.mate_num2)...
.route_code(1:temp.mate_joint);...
GA.individual(temp.mate_num1)...
.route_code(temp.mate_joint+1:end)];
%cover the old
GA.individual(temp.mate_num1).route_code=temp.new_route_code1;
GA.individual(temp.mate_num2).route_code=temp.new_route_code2;
end
%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%step 4
%mutation
for index_of_individual=1:GA.num_of_individual
%generate a random number
temp.rand=rand;
%judge whether can mutate
if temp.rand<GA.probability_of_mutation
%mutation_joint
temp.mutation_joint=ceil(rand*num_of_node);
%mutate
GA.individual(index_of_individual)...
.route_code(temp.mutation_joint)=...
GA.individual(index_of_individual).以上是关于路径规划基于matlab汽车零部件循环取货路径优化(三维装载约束)含Matlab源码 1100期的主要内容,如果未能解决你的问题,请参考以下文章