資源描述:
《整數(shù)規(guī)劃_分支定界法_matlab程序》由會員上傳分享,免費在線閱讀,更多相關(guān)內(nèi)容在行業(yè)資料-天天文庫。
1、整數(shù)規(guī)劃分支定界法MATLAB程序1.這種方法絕對能都解出答案,而且答案正確function[x,val]=fzdj(n,f,a,b,aeq,beq,lb,ub)x=zeros(n,1);x1=zeros(n,1);m1=2;m2=1;[x1,val1]=linprog(f,a,b,aeq,beq,lb,ub);if(x1==0)x=x1;val=val1;elseif(round(x1)==x1)x=x1;val=val1;elsee1={0,a,b,aeq,beq,lb,ub,x1,val1};e(1,1)={e1};zl=0;zu=-val1;while(zu~=zl)forc=1:1
2、:m2if(m1~=2)if(cell2mat(e{m1-1,c}(1))==1)e1={1,[],[],[],[],[],[],[],0};e(m1,c*2-1)={e1};e(m1,c*2)={e1};continue;end;end;x1=cell2mat(e{m1-1,c}(8));x2=zeros(n,1);s=0;s1=1;s2=1;lb1=cell2mat(e{m1-1,c}(6));ub1=cell2mat(e{m1-1,c}(7));lb2=cell2mat(e{m1-1,c}(6));ub2=cell2mat(e{m1-1,c}(7));ford=1:1:nif(abs(
3、(round(x1(d))-x1(d)))>0.0001)&(s==0)s=1;lb1(d)=fix(x1(d))+1;if(a*lb1<=b)s1=0;end;ub2(d)=fix(x1(d));if(a*lb2<=b)s2=0;end;end;end;e1={s1,a,b,aeq,beq,lb1,ub1,[],0};e2={s2,a,b,aeq,beq,lb2,ub2,[],0};e(m1,c*2-1)={e1};e(m1,c*2)={e2};end;m1=m1+1;m2=m2*2;forc=1:1:m2if(cell2mat(e{m1-1,c}(1))==0)[x1,val1]=lin
4、prog(f,cell2mat(e{m1-1,c}(2)),cell2mat(e{m1-1,c}(3)),cell2mat(e{m1-1,c}(4)),cell2mat(e{m1-1,c}(5)),cell2mat(e{m1-1,c}(6)),cell2mat(e{m1-1,c}(7)));e1={cell2mat(e{m1-1,c}(1)),cell2mat(e{m1-1,c}(2)),cell2mat(e{m1-1,c}(3)),cell2mat(e{m1-1,c}(4)),cell2mat(e{m1-1,c}(5)),cell2mat(e{m1-1,c}(6)),cell2mat(e{
5、m1-1,c}(7)),x1,val1};e(m1-1,c)={e1};end;z=val1;if((-z)<(-zl))e1={1,[],[],[],[],[],[],[],0};e(m1-1,c)={e1};elseif(abs(round(x1)-x1)<=0.0001)zl=z;end;end;forc=1:1:m2if(cell2mat(e{m1-1,c}(1))==0)zu=cell2mat(e{m1-1,c}(9));end;end;forc=1:1:m2if(-cell2mat(e{m1-1,c}(9))>(-zu))zu=cell2mat(e{m1-1,c}(9));end
6、;end;end;forc=1:1:m2if(cell2mat(e{m1-1,c}(1))==0)&(cell2mat(e{m1-1,c}(9))==zu)x=cell2mat(e{m1-1,c}(8));end;end;val=zu;end;2.這種方法是課本上的程序,但是不能解題,希望高手能將它改進function[x,y]=IntLp(f,G,h,Geq,heq,lb,ub,x,id,options)%整數(shù)線性規(guī)劃分支定界法,可求解全整數(shù)線性或混合整數(shù)線性規(guī)劃%y=minf'*xsubjectto:G*x<=hGeq*x=heqx為全整數(shù)%數(shù)或混合整數(shù)列向量%用法%[x,y]=IntL
7、p(f,G,h)%[x,y]=IntLp(f,G,h,Geq,heq)%[x,y]=IntLp(f,G,h,Geq,heq,lb,ub)%[x,y]=IntLp(f,G,h,Geq,heq,lb,ub,x)%[x,y]=IntLp(f,G,h,Geq,heq,lb,ub,x,id)%[x,y]=IntLp(f,G,h,Geq,heq,lb,ub,x,id,options)%參數(shù)說明%x:最優(yōu)解列向量;y:目標