⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rte2w.m

📁 物流分析工具包。Facility location: Continuous minisum facility location, alternate location-allocation (ALA)
💻 M
字号:
function W = rte2W(rte,f,h)
%RTE2W Converts routings to weight matrix.
%   W = rte2W(rte,f,h)
% rte = routings; e.g., rte = {[1 2 3];[4 1]}, for routing 1-2-3 and 4-1
%   f = flow
%   h = handling cost (or equivalence factor)
%
% Example:
% rte = {[1 2 3 4],[2 4 1 2 3],[3 4 1 2 4]};
% f = [8 5 12];
% h = [3 2 1];
% W = rte2W(rte,f,h)

% Copyright (c) 1994-2006 by Michael G. Kay
% Matlog Version 9 13-Jan-2006 (http://www.ie.ncsu.edu/kay/matlog)

% Input Error Checking ****************************************************
error(nargchk(1,3,nargin));

if ~iscell(rte), rte = {rte}; end
if nargin < 2, f = ones(1,length(rte)); end
if nargin < 3, h = ones(1,length(rte)); end

if length(rte) ~= length(f(:))
   error('Length of "f" must equal the number of routings.')
elseif length(rte) ~= length(h(:))
   error('Length of "h" must equal the number of routings.')
end
% End (Input Error Checking) **********************************************

n = max([rte{:}]);
W = zeros(n);

for i = 1:length(rte)
   for j = 1:length(rte{i})-1
      W(rte{i}(j),rte{i}(j+1)) = W(rte{i}(j),rte{i}(j+1)) + f(i)*h(i);
   end
end

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -