资源简介
这是用Matlab实现Wagner Whitin算法的代码,里面附有相关算例,算例参考了经典库存控制教材Inventory Control(2rd)中的练习题(在代码中注释了每题运算的最终结果,具有可重复性),有助于理解算法的实现流程。
代码片段和文件信息
function [z x J arg_J C] = wargner_whitin0(d K c h);
% Wagner-Whitin Algorithm
%
% Build production plans versus time cycles k =1...N responding production queries dk
% and miniming the sum of following production costs
%
% i) Fix production cost K_k
% ii) Unitary production cost c_k
% iii) Stockage unitary cost h_k
%
% Assumption : initial and final stocks are null.
%
%
% Inputs
% ------
%
% d Queries of production througth time cycles (1 x N)
% K Fix production cost (1 x N)
% c Unitary production cost (1 x N)
% h Stockage unitary cost (1 x N)
%
%
% Outputs
% ------
%
%
% z Optimal cost at the end of the N cycles
% x Quantities to product (1 x N)
% J Partial politics (1 x N)
% arg_J Arguments of the partial politics (1 x N)
% C Cost transition matrix (N x N)
%
%
%
% Example1
% -------
%
% clearclose all hidden
% d = [8 10 7 9 6];
% K = [50 40 50 70 60];
% c = [5 5 6 4 5];
% h = [4 2 3 4 NaN];
% [z x J arg_J C] = wargner_whitin(d K c h);
%
%
% Example2
% --------
%
%
%clearclose all hidden
%N = 100;
% d = ceil(N*rand(1 N));
% K = ceil(N*rand(1 N));
% c = ceil(N*rand(1 N));
% h = ceil(N*rand(1 N));
%[z x J arg_J C] = wargner_whitin(d K c h);
%ind_x = find(x);
%figure(1)
%subplot(211)
%stem((1:N)J)
%xlabel(‘Period N‘‘fontname‘‘times‘‘fontsize‘12)
%ylabel(‘Production costs‘‘fontname‘‘times‘‘fontsize‘12)
%title([‘N = ‘ num2str(N) ]‘fontname‘‘times‘‘fontsize‘13)
%subplot(212)
%stem(ind_x x(ind_x) ‘ro‘)
%xlabel(‘P閞iod N‘‘fontname‘‘times‘‘fontsize‘12)
%ylabel(‘Quantities to product‘‘fontname‘‘times‘‘fontsize‘12)
%figure(2)
%imagesc(C)
%colorbar
%title(‘Transition cost production matrix ‘‘fontname‘‘times‘‘fontsize‘13)
%
%
% Author : S閎astien PARIS (sebastien.paris@lsis.org) 08/30/2001.
% ------
%
%
% 使用示例(Inventory Control第二版上的例题):
% x:订货策略
% oper_cost:运作成本(包括订货成本和库存成本)
%
% Example1:课本(P64 Example4.5)
% d
评论
共有 条评论