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

📄 trans.m

📁 物流分析工具包。Facility location: Continuous minisum facility location, alternate location-allocation (ALA)
💻 M
字号:
function [F,TC] = trans(C,s,d)
%TRANS Transportation and assignment problems.
%[F,TC] = trans(C,s,d), transportation problem
%       = trans(C),     assignment problem
%     C = m x n matrix of costs
%     s = m-element vector of supplies
%       = [1], default
%     d = n-element vector of demands
%       = [1], default
%     F = m x n matrix of flows
%    TC = total cost
%
% Wrapper for: C(C == 0) = NaN; MCNF(LEV2LIST(C),[s; -d])

% 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));

[m,n] = size(C);

if nargin < 2 | isempty(s), s = ones(m,1); else s = s(:); end
if nargin < 3 | isempty(d), d = ones(n,1); else d = d(:); end

if sum(s) < sum(d)
   error('Total supply cannot be less than total demand.')
elseif length(s) > m | any(s < 0)
   error('"s" must be an m-element non-negative vector.')
elseif length(d) > n | any(d < 0)
   error('"d" must be an n-element non-negative vector.')
end
% End (Input Error Checking) **********************************************

C(C == 0) = NaN;       % Can have zero costs on arcs
s(isinf(s)) = sum(d);  % MCNF requires finite supplies

if all(isint(s)) & all(isint(d))
   TolInt = 1e-3;
else
   TolInt = [];
end

[F,TC] = mcnf(lev2list(C),[s; -d],...
   'LP',[],'LrgProb',[],'TolInt',TolInt);

F = reshape(F,m,n);

⌨️ 快捷键说明

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