%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 这是两个建模仿真的案例。一个是航空公司航线网络最短路问题,一个是航空公司
%航线网络中枢纽机场的选择问题。shortestpath.mat中的A矩阵是该网络的矩阵。
%citycover.mat中包括了航空公司航线网络中12个城市的距离矩阵。运行程序前需要
%先将这两个文件载入到工作空间中。
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 最短路问题
% B=sparse(A);
% [dist,path,pred] = graphshortestpath(B,1,10);
% h = view(biograph(B,[],'ShowWeights','on'))
% set(h.Nodes(path),'Color',[1 0.4 0.4])
% edges = getedgesbynodeid(h,get(h.Nodes(path),'ID'));
% set(edges,'LineColor',[1 0 0])
% set(edges,'LineWidth',1.5)
%% 集划分问题
CoverCity=(CityDist<=1000);
f=[1 1 1 1 1 1 1 1 1 1 1 1]';
intcon=[1 2 3 4 5 6 7 8 9 10 11 12];
Aeq=double(CoverCity);
Beq=[1 1 1 1 1 1 1 1 1 1 1 1]';
lb=zeros(12,1);
ub=[1 1 1 1 1 1 1 1 1 1 1 1]';
x = intlinprog(f,intcon,[],[],Aeq,Beq,lb,ub)
%% 集覆盖问题
% f=[1 1 1 1 1 1 1 1 1 1 1 1];
% intcon=[1 2 3 4 5 6 7 8 9 10 11 12];
% Aeq=double(CoverCity);
% A=-1*Aeq;
% b=-1*[1 1 1 1 1 1 1 1 1 1 1 1];
% lb=zeros(12,1);
% ub=[1 1 1 1 1 1 1 1 1 1 1 1];
% x = intlinprog(f,intcon,A,b,[],[],lb,ub)