




已閱讀5頁,還剩3頁未讀, 繼續(xù)免費(fèi)閱讀
版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
function errmsg,Z,X,t,c,fail = BNB18(fun,x0,xstat,xl,xu,A,B,Aeq,Beq,nonlcon,setts,options1,options2,maxSQPit,varargin);%MATLAB5.3Optimization toolbox 2.0?% Minimize F(x) %subject to: xlb = x =xub% A*x = B% Aeq*x=Beq% C(x)=0% x1+2*x2+2*x3=72% 10=x2=20% x1-x2=10% Mdiscfun.m% function f=discfun(x)% f=-x(1)*x(2)*x(3);% clear;x0=25,15,10;xstat=1 1 1;% xl=20 10 -10;xu=30 20 20;% A=1 -2 -2;1 2 2;B=0 72;Aeq=1 -1 0;Beq=10;% err,Z,X=BNB18(discfun,x0,xstat,xl,xu,A,B,Aeq,Beq);% XMAX=X,ZMAX=-Z% BNB18 Finds the constrained minimum of a function of several possibly integer variables.% Usage: errmsg,Z,X,t,c,fail = % BNB18(fun,x0,xstatus,xlb,xub,A,B,Aeq,Beq,nonlcon,settings,options1,options2,maxSQPiter,P1,P2,.) % BNB solves problems of the form:% Minimize F(x) subject to: xlb = x0 =xub% A*x = B Aeq*x=Beq% C(x) 0), EXITFLAG = -1; end;% In optim/private/qpsub.m ($Revision: 1.21 $ $Date: 1998/09/01 21:37:56 $):% Stop qpsub from hanging.% After the line: % Andy Grace 7-9-90. Mary Ann Branch 9-30-96.% add the line: global maxSQPiter; % and changed the line: maxSQPiters = Inf;% to the line: if exist(maxSQPiter,var), maxSQPiters = maxSQPiter; else maxSQPiters=inf; end; % I guess there was a reason to put maxSQPiters at infinity, but this works fine for me.global maxSQPiter; % STEP 0 CHECKING INPUTZ=; X=; t=0; c=0; fail=0;if nargin1, errmsg=x0 must be a column vector.; return; end;xstatus=zeros(size(x0);if nargin2 & isempty(xstat) if all(size(xstat)=size(x0) xstatus(1:size(xstat)=xstat; else errmsg=xstatus must be a column vector the same size as x0.; return; end; if any(xstatus=round(xstatus) | xstatus0 | 23 & isempty(xl) if all(size(xl)=size(x0) xlb(1:size(xl,1)=xl; else errmsg=xlb must be a column vector the same size as x0.; return; end;end;if any(x0xlb) errmsg=x0 must be in the range xlb 4 & isempty(xu) if all(size(xu)xub) errmsg=x0 must be in the range x0 5 if isempty(A) & size(A,2)=size(x0,1), errmsg=Matrix A not correct.; return; end;else A=; end;if nargin6 if isempty(B) & any(size(B)=size(A,1) 1), errmsg=Column vector B not correct.; return; end;else B=; end;if isempty(A) & isempty(B), errmsg=A and B should only be nonempty together.; return; end;if isempty(B) & isempty(A), B=zeros(size(A,1),1); end;if nargin7 & isempty(Aeq) if size(Aeq,2)=size(x0,1), errmsg=Matrix Aeq not correct.; return; end;else Aeq=; end;if nargin8 if isempty(Beq) & any(size(Beq)=size(Aeq,1) 1), errmsg=Column vector Beq not correct.; return; end;else Beq=; end;if isempty(Aeq) & isempty(Beq), errmsg=Aeq and Beq should only be nonempty together; return; end;if isempty(Beq) & isempty(Aeq), Beq=zeros(size(Aeq,1),1); end;if nargin10 & isempty(setts) if all(size(setts)=size(settings) settings(setts=0)=setts(setts=0); else errmsg=settings should be a row vector of length 3.; return; end;end;if nargin12, options1=; end;options1=optimset(optimset(fmincon),options1);if nargin13, options2=; end;options2=optimset(optimset(fmincon),options2);if nargin0 & round(maxSQPit)=maxSQPit maxSQPiter=maxSQPit;else errmsg=maxSQPiter must be an integer 0; return; end;eval(z=,fun,(x0,varargin:);,errmsg=fun caused error.; return;);if isempty(nonlcon) eval(C, Ceq=,nonlcon,(x0,varargin:);,errmsg=nonlcon caused error.; return;); if size(C,2)1 | size(Ceq,2)1, errmsg=C en Ceq must be column vectors.; return; end;end; % STEP 1 INITIALISATIONcurrentwarningstate=warning;warning off;tic;lx = size(x0,1);z_incumbent=inf;x_incumbent=inf*ones(size(x0);I = ceil(sum(log2(xub(find(xstatus=1)-xlb(find(xstatus=1)+1)+size(find(xstatus=1),1)+1);stackx0=zeros(lx,I);stackx0(:,1)=x0;stackxlb=zeros(lx,I);stackxlb(:,1)=xlb;stackxub=zeros(lx,I);stackxub(:,1)=xub;stacksize=1;xchoice=zeros(size(x0);if isempty(Aeq) j=0; for i=1:size(Aeq,1) if Beq(i)=1 & all(Aeq(i,:)=0 | Aeq(i,:)=1) J=find(Aeq(i,:)=1); if all(xstatus(J)=0 & xchoice(J)=0 & xlb(J)=0 & xub(J)=1) if all(xstatus(J)=2) | all(x0(J(find(xstatus(J)=2)=0) j=j+1; xchoice(J)=j; if sum(x0(J)=0, errmsg=x0 not correct.; return; end; end; end; end; end;end;errx=optimget(options2,TolX);errcon=optimget(options2,TolCon);fail=0;c=0; % STEP 2 TERMINIATIONwhile stacksize0 c=c+1; % STEP 3 LOADING OF CSP x0=stackx0(:,stacksize); xlb=stackxlb(:,stacksize); xub=stackxub(:,stacksize); x0(find(x0xlb)=xlb(find(x0xub)=xub(find(x0xub); stacksize=stacksize-1; % STEP 4 RELAXATION % PHASE 1 con=BNBCON(x0,A,B,Aeq,Beq,xlb,xub,nonlcon,varargin:); if abs(con)errcon & settings(1)=0 x1 dummy feasflag=fmincon(0,x0,A,B,Aeq,Beq,xlb,xub,nonlcon,options1,varargin:); if settings(3) & feasflag=0 con=BNBCON(x1,A,B,Aeq,Beq,xlb,xub,nonlcon,varargin:); if con0 x z convflag=fmincon(fun,x1,A,B,Aeq,Beq,xlb,xub,nonlcon,options2,varargin:); if settings(3) & convflag=0 con=BNBCON(x,A,B,Aeq,Beq,xlb,xub,nonlcon,varargin:); if conerrcon, convflag=1; end; end; else convflag=feasflag; end; % STEP 5 FATHOMING K = find(xstatus=1 & xlb=xub); separation=1; if convflag=z_incumbent & convflag0 % FC 2 separation=0; elseif all(abs(round(x(K)-x(K)0 % FC 3 z_incumbent = z; x_incumbent = x; separation = 0; end; % STEP 6 SELECTION if separation = 1 & isempty(K) dzsep=-1; for i=1:size(K,1) dxsepc = abs(round(x(K(i)-x(K(i); if dxsepc=errx | convflag=0 xsepc = x; xsepc(K(i)=round(x(K(i); dzsepc = abs(feval(fun,xsepc,varargin:)-z); if dzsepcdzsep dzsep=dzsepc; ixsep=K(i); end; end; end; % STEP 7 SEPARATION if xchoice(ixsep)=0 % XCHOICE=0 branch=1; domain=xlb(ixsep) xub(ixsep); while branch=1 xboundary=(domain(1)+domain(2)/2; if x(ixsep)xboundary domainA=domain(1) floor(xboundary); domainB=floor(xboundary+1) domain(2); else domainA=floor(xboundary+1) domain(2); domainB=domain(1) floor(xboundary); end; stacksize=stacksize+1; stackx0(:,stacksize)=x; stackxlb(:,stacksize)=xlb; stackxlb(ixsep,stacksize)=domainB(1); stackxub(:,stacksize)=xub; stackxub(ixsep,stacksize)=domainB(2); if domainA(1)=domainA(2) stacksize=stacksize+1; stackx0(:,stacksize)=x; stackxlb(:,stacksize)=xlb; stackxlb(ixsep,stacksize)=domainA(1); stackxub(:,stacksize)=xub; stackxub(ixsep,stacksize)=domainA(2); branch=0; else domain=domainA; branch=1; end; end; else % XCHOICE=0 L=find(xchoice=xchoice(ixsep); M=intersect(K,L); dummy,N=sort(x(M); part1=M(N(1:floor(size(N)/2); part2=M(N(floor(size(N)/2)+1:size(N); stacksize=stacksize+1; stackx0(:,stacksize)=x; O = (1-sum(stackx0(part1,stacksize)/size(part1,1); stackx0(part1,stacksize)=stackx0(part1,stacksize)+O; stackxlb(:,stacksize)=xlb; stackxub(:,stacksize)=xub; stackxub(part2,stacksize)=0; stacksize=stacksize+1; stackx0(:,stacksize)=x; O = (1-sum(stackx0(part2,stacksize)/size(part
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 2025年Samos測(cè)流風(fēng)機(jī)項(xiàng)目投資可行性研究分析報(bào)告
- 演出托管運(yùn)營(yíng)管理制度
- 危險(xiǎn)化學(xué)品包裝(金屬罐)產(chǎn)品質(zhì)量監(jiān)督抽查實(shí)施細(xì)則
- 2025年膏藥市場(chǎng)分析報(bào)告
- 2025年別墅毛毯行業(yè)深度研究分析報(bào)告
- 2024-2025學(xué)年高中數(shù)學(xué)第一章集合與函數(shù)概念1.1.1集合的含義與表示第一課時(shí)集合的含義課時(shí)作業(yè)新人教A版必修1
- 2024-2025學(xué)年高中歷史第三單元從人文精神之源到科學(xué)理性時(shí)代第13課挑戰(zhàn)教皇的權(quán)威課后篇鞏固探究岳麓版必修3
- 2024-2025學(xué)年高中化學(xué)第3章第4節(jié)離子晶體教案新人教版選修3
- 手機(jī)游戲市場(chǎng)全景評(píng)估及發(fā)展趨勢(shì)研究預(yù)測(cè)報(bào)告
- 基于微信小程序的健康小屋信息系統(tǒng)設(shè)計(jì)與實(shí)現(xiàn)
- 河南省鄭州市外國(guó)語高中2025屆高考仿真卷英語試卷含解析
- 超市投標(biāo)書范文
- 《工程合同管理與招投標(biāo)實(shí)訓(xùn)》課程電子教案
- 腫瘤科疼痛一病一品
- 2024-2030年中國(guó)礦用錨桿行業(yè)發(fā)展現(xiàn)狀需求分析報(bào)告
- 2024年1月浙江省高考英語真題試卷含答案
- 人民醫(yī)院樣本外送檢測(cè)管理制度
- DG-TJ 08-2451-2024 電動(dòng)自行車集中充電和停放場(chǎng)所設(shè)計(jì)標(biāo)準(zhǔn)
- DB3301-T 65.28-2024 反恐怖防范系統(tǒng)管理規(guī)范 第28部分:硬質(zhì)隔離設(shè)施
- 心電監(jiān)護(hù)儀的操作及注意事項(xiàng) 課件
- 11BS4排水工程華北標(biāo)圖集
評(píng)論
0/150
提交評(píng)論