數學建模程式與演算法之整數線性規劃
定義
在線性規劃模型中,規劃中的變數限制為整數時稱為整數線性規劃。
- 變數全部限制為整數,稱為(完全)整數線性規劃
- 變數部分限制為整數,稱為混合整數線性規劃
完全整數線性規劃問題:
%%%%%%%%%%%%%%%% min z=-x1-x2 %%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%% 約束條件 %%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%% -4x1+2x2<=-1 %%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%% 4x1+2x2<=11 %%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%% -2x2<=-1 %%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%% x1,x2>=0且為整數 %%%%%%%%%%%%%%%%%%%%%%%%%
%clc;
% f_13=[-1,-1];
% ic_13=[1,2];%第幾個決策變數為整數
% A_13=[-4,2;4,2;0,-2];
% b_13=[-1;11;-1];
% lb_13=zeros(2,1);%
% [x_13,fval_13,flag_13]=intlinprog(f_13,ic_13,A_13,b_13,[],[],lb_13,[])
%[x_13,fval_13,flag_13]=intlinprog(f_13,ic_13,A_13,b_13,[],[],lb_13,ub_13=ones[2,1])%0-1整數規劃混合整數線性規劃問題
matlab原始碼程式碼如下:
% clc;
% f=[4.8;5.6;4.8;5.6;-10;-8;-6;0;0;0];
% ic=[8,9,10];
% a=[1 1 0 0 1 1 1 0 0 0;0 0 1 1 0 0 0 0 0 0;-0.5 0 0.5 0 0 0 0 0 0 0;0 -0.4 0 0.6 0 0 0 0 0 0;
% 0 0 0 0 -1 0 0 0 500 0;0 0 0 0 1 0 0 -500 0 0;0 0 0 0 0 -1 0 0 0 500;
% 0 0 0 0 0 1 0 0 -500 0;0 0 0 0 0 0 1 0 0 -500];
% b=[500;1000;0;0;0;0;0;0;0];
% lb=zeros(10,1);
% ub=[500;500;1000;1000;500;500;500;1;1;1];
% [x,fval,flag_13]=intlinprog(-f,ic,a,b,[],[],lb,ub)