【贪婪算法来解决供应链分销网络问题】使用混合整数规划(MIP)优化供应链分销网络研究(Matlab代码实现)

  💥💥💞💞欢迎来到本博客❤️❤️💥💥

🏆博主优势:🌞🌞🌞博客内容尽量做到思维缜密,逻辑清晰,为了方便读者。

⛳️座右铭:行百里者,半于九十。

📋📋📋本文目录如下:🎁🎁🎁

目录

 ⛳️赠与读者

💥1 概述

📚2 运行结果

🎉3 参考文献

🌈4 Matlab代码、文章下载


 ⛳️赠与读者

👨‍💻做科研,涉及到一个深在的思想系统,需要科研者逻辑缜密,踏实认真,但是不能只是努力,很多时候借力比努力更重要,然后还要有仰望星空的创新点和启发点。当哲学课上老师问你什么是科学,什么是电的时候,不要觉得这些问题搞笑。哲学是科学之母,哲学就是追究终极问题,寻找那些不言自明只有小孩子会问的但是你却回答不出来的问题。建议读者按目录次序逐一浏览,免得骤然跌入幽暗的迷宫找不到来时的路,它不足为你揭示全部问题的答案,但若能让人胸中升起一朵朵疑云,也未尝不会酿成晚霞斑斓的别一番景致,万一它居然给你带来了一场精神世界的苦雨,那就借机洗刷一下原来存放在那儿的“躺平”上的尘埃吧。

     或许,雨过云收,神驰的天地更清朗.......🔎🔎🔎

💥1 概述

参考文献:

近年来,质量和物流问题一直是现代企业面临的严峻挑战,关乎其竞争力乃至生存,这使得人们重新聚焦于生产系统的规划与管理。尽管生产相关问题,比如生产排程与采购,基本在过去几年中得到有效解决,当今的挑战主要集中在商品流动(或物流)方面,即如何以最快的方式将适量的产品送达正确的客户。本工作的目的是研究、理解和建模供应链分销网络,并制定一个恰当的问题陈述,以揭示真实系统的所有特征。采用逐步深入的方法,从一个基本的理想情况描述问题,逐渐过渡到更加现实的情形,通过减少假设并扩大建模能力。运用多种方法评估形式化的问题,并最终对比、评估这些方法,得出结论。需要特别强调的是,本工作包含了物流相关特性(例如,运输成本、库存、运输车辆等),而在生产问题方面采用了较为简化的表示,因此不涉及典型生产调度问题(如生产能力的扩展、周转与班次、外包人力等)。通过这种方式,我们集中探讨了物流领域的核心议题。

这是一个将贪婪算法与局部搜索应用到供应链配送网络问题求解中的实例。我们处理的是一个包含工厂集合和销售点集合的单一层级供应链。每个销售点在特定时间有其需求量,而每个工厂则有其生产限制。此外,我们还假设了未满足需求会带来损失(即缺货惩罚)。目标是确定从任意工厂运往任意销售点的产品数量矩阵,以期达到总成本最小化。更多详细信息见第4部分。

文章目录:

📚2 运行结果

主函数代码:

clc
clear all
tic
%***********************User inserted input for the problem***************

nosp = 5;             %reads the number of sales points considered
noft = 4;                %reads the number of factories
nopd = 3;         %number of planning period
trkcap = 70;                    %Capacity of the truck

%***********************inputs from excel file for the formulation ***************

demand = [35 35    60    80    100; 25    100    125    55    20; 150    120    100    60    110; 50    70    40    140    40 ; 90    110    90    50    30;0    110    90    40    50; 60    70    0    110    10; 140    70    90    100    30 ;10    130    130    40    140; 30    90    70    40    0; 70    100    100    50    90; 110    50    50    110    100 ]; %stores the demand in the time horizons for each sales point 
lostdemandcost = [30    35    25    40    55] ;  %lost demand per unit for each sales point
transcost = [ 100    400    800    1100    1700 ; 1500    1800    1200    2200    1500 ; 1400    1000    400    1000    700 ; 800    700    900    700    1200] ; %xlsread('greedyinput','Sheet1','O3:S6');        %transportation cost matrix
setupcost = [ 4500    2000    2500    3000 ] ;  %setup costs for individual factories
factorycap = [300    500    250    150]; % xlsread('greedyinput','Sheet2','B4:E4');       %capacity of the factories
factholdcost = [5    2    4    3]; %xlsread('greedyinput','Sheet2','B5:E5');     %holding cost per unit in a factory
for i = 1:nopd
quantityshipped{i} = zeros(noft,nosp);
factoryresiduals{i} = zeros(1,noft);
factoryactivation{i} = zeros(1,noft);
salespointresiduals{i} = zeros(1,nosp);
end

%*****************************counter-check if the inputs are well read*********

disp(demand);
disp(lostdemandcost);
disp(transcost);
disp(setupcost);
disp(factorycap);
disp(factholdcost);
for i = 1:nopd
disp(quantityshipped{i});
end


%****************************starts the calculation of the greedy alg********

initlostsales = calclostsales(demand,lostdemandcost,nopd,nosp); %Calculates the lost demand with the initial assumption that all the demand is lost
disp(initlostsales);
cumsetupcost = 0;
cumtransportcost = 0;
cumholdingcost = 0;
saveddemand = 0;
salespoint{nosp}= [0,0]; 
for ft = 1:noft                                          %Initialize the factory activation status and residual for each time preiod (zero for the first one)
           factory{ft}(1,1) = 0;
           factory{ft}(1,2) = 0;
end
for time = 1:nopd                                               %iterates for each planning period beginning from the 1st
    
                                                                
       
       for sp = 1:nosp
           salespoint{sp}(1,1) = 0;                             %the array stores the activation status and the demand of a sales point 
            salespoint{sp}(1,2) =  demand(time,sp);             %this populates the sales point for a time horizon with demand and filling status
       end
       
       
       
       
       for ft = 1:noft                                          %Initialize the factory activation status and residual for each time preiod (zero for the first one)
           factory{ft}(1,1) = 0;
           
       end
       
   % loadfactory(capacity,prevresidual);
   
    for points = 1:nosp
        [selectedsp,maxlostsales] = choosesalespt(lostdemandcost,salespoint,nosp);             %Chooses the salespoint with the highest possible lost sales
        disp('----------------------------');
        fprintf('Selected Sales Point: %d\n', selectedsp);
        fprintf('Potential Lost Sales cost: %.2f\n', maxlostsales);
        
        salespoint{selectedsp}(1,1)=1;
        
            [costunit,selectedf] = choosefactory(factorycap,factholdcost,transcost,setupcost,factory,trkcap,salespoint,selectedsp); %chooses the preferable factory to deliver to the selected salespoint
            fprintf('selected factory: %d\n',selectedf);
            fprintf('Cost of the selected factory: %.2f\n', costunit);
            quantityshipped{time}(selectedf,selectedsp) = salespoint{selectedsp}(1,2);
            if (factory{selectedf}(1,2)>= salespoint{selectedsp}(1,2))
            factory{selectedf}(1,2) = factory{selectedf}(1,2) - salespoint{selectedsp}(1,2);
            
            % saveddemand = saveddemand + salespoint{selectedsp}(1,2)*lostdemandcost(selectedsp);                             % accumulates the reduction of the lost demand for each sent item to a destination sales point
            end
            if(factory{selectedf}(1,1)==0 && factory{selectedf}(1,2)<= salespoint{selectedsp}(1,2))
                factory{selectedf}(1,2) = factory{selectedf}(1,2)+factorycap(selectedf)-salespoint{selectedsp}(1,2);
                cumsetupcost = cumsetupcost + setupcost(selectedf);                                                         %accumulates the activation cost for each factory when there is an accompanying activation
               % cumtransportcost = cumtransportcost + ceil(salespoint{selectedsp}(1,2)/trkcap)*transcost(selectedf,selectedsp);
                factory{selectedf}(1,1)=1;                
            end
            saveddemand = saveddemand + salespoint{selectedsp}(1,2)*lostdemandcost(selectedsp);
            cumtransportcost = cumtransportcost + ceil(salespoint{selectedsp}(1,2)/trkcap)*transcost(selectedf,selectedsp); %accumulates the transportaton cost for each iteration
            
            
            fprintf('Cumulative setupcost: %.2f\n',cumsetupcost);
            fprintf('Cumulative trasportation cost: %.2f\n',cumtransportcost);
    end
    currentholdingcost = 0;
    for i = 1:noft
        currentholdingcost= currentholdingcost + factory{i}(1,2)*factholdcost(i);                                         %the holding costs are accumulatedat each factory at the end of each planning period
        factoryresiduals{time}(i) = factory{i}(1,2);
        factoryactivation{time}(i) = factory{i}(1,1);
        factory{i}(1,1)= 0;
    end
    cumholdingcost = cumholdingcost + currentholdingcost;                                                                  % holding cost of the whole factory at the end of a planning period                                                                
    objectivesolution = initlostsales -saveddemand+ cumholdingcost+cumsetupcost+cumtransportcost
    end
%objectivesolution = initlostsales-saveddemand+cumsetupcost+cumtransportcost
%objectivesolution = initlostsales -saveddemand+ cumholdingcost+cumsetupcost+cumtransportcost
disp('====================shipped quantity matrix==================')
for i = 1:nopd
disp(quantityshipped{i});
end  
disp('=====================factory residual matrix=================')
for i = 1:nopd
disp(factoryresiduals{i});
end
disp('=====================factory activation status===============')
for i = 1:nopd
disp(factoryactivation{i});
end
objectivesolution
% New_transportation_costs=0;
% F_holding_cost=0;
% Act_cost= 0;
% for t=1:nopd
%     for i=1:noft
%         F_holding_cost = F_holding_cost + factholdcost(i) *factoryresiduals{t}(1,i); 
%         Act_cost = Act_cost + factoryactivation{t}(1,i)* setupcost(i);
%         
%         
%         for j =1:nosp
%     New_transportation_costs= ceil(quantityshipped{t}(i,j)/trkcap) * transcost(i,j)+ New_transportation_costs;
%         end
%     end
% end
% New_transportation_costs
% F_holding_cost
% Act_cost
% tot_cost = New_transportation_costs + F_holding_cost +Act_cost
% saveddemand
% initlostsales
% cumtransportcost
toc

🎉3 参考文献

文章中一些内容引自网络,会注明出处或引用为参考文献,难免有未尽之处,如有不妥,请随时联系删除。

🌈4 Matlab代码、文章下载

资料获取,更多粉丝福利,MATLAB|Simulink|Python资源获取

                                                           在这里插入图片描述

  • 16
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值