【文章內(nèi)容簡介】
s=1。% add the line: if (strncmp(howqp, 39。i39。,1) amp。 mg 0), EXITFLAG = 1。 end。%% In optim/private/ ($Revision: $ $Date: 1998/09/01 21:37:56 $):% Stop qpsub from hanging.% After the line: % Andy Grace 7990. Mary Ann Branch 93096.% add the line: global maxSQPiter。 % and changed the line: maxSQPiters = Inf。% to the line: if exist(39。maxSQPiter39。,39。var39。), 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 nargin2, errmsg=39。BNB needs at least 2 input arguments.39。 return。 end。if isempty(fun), errmsg=39。No fun found.39。 return。 end。if isempty(x0), errmsg=39。No x0 found.39。 return。elseif size(x0,2)1, errmsg=39。x0 must be a column vector.39。 return。 end。xstatus=zeros(size(x0))。if nargin2 amp。 ~isempty(xstat) if all(size(xstat)=size(x0)) xstatus(1:size(xstat))=xstat。 else errmsg=39。xstatus must be a column vector the same size as x0.39。 return。 end。 if any(xstatus~=round(xstatus) | xstatus0 | 2xstatus) errmsg=39。xstatus must consist of the integers 0,1 en 2.39。 return。 end。end。xlb=zeros(size(x0))。xlb(find(xstatus==0))=inf。if nargin3 amp。 ~isempty(xl) if all(size(xl)=size(x0)) xlb(1:size(xl,1))=xl。 else errmsg=39。xlb must be a column vector the same size as x0.39。 return。 end。end。if any(x0xlb) errmsg=39。x0 must be in the range xlb = x0.39。 return。elseif any(xstatus==1 amp。 (~isfinite(xlb) | xlb~=round(xlb))) errmsg=39。xlb(i) must be an integer if x(i) is an integer variabele.39。 return。end。xlb(find(xstatus==2))=x0(find(xstatus==2))。xub=ones(size(x0))。xub(find(xstatus==0))=inf。if nargin4 amp。 ~isempty(xu) if all(size(xu)=size(x0)) xub(1:size(xu,1))=xu。 else errmsg=39。xub must be a column vector the same size as x0.39。 return。 end。end。if any(x0xub) errmsg=39。x0 must be in the range x0 =xub.39。 return。elseif any(xstatus==1 amp。 (~isfinite(xub) | xub~=round(xub))) errmsg=39。xub(i) must be an integer if x(i) is an integer variabale.39。 return。end。xub(find(xstatus==2))=x0(find(xstatus==2))。if nargin5 if ~isempty(A) amp。 size(A,2)~=size(x0,1), errmsg=39。Matrix A not correct.39。 return。 end。else A=[]。 end。if nargin6 if ~isempty(B) amp。 any(size(B)~=[size(A,1) 1]), errmsg=39。Column vector B not correct.39。 return。 end。else B=[]。 end。if isempty(A) amp。 ~isempty(B), errmsg=39。A and B should only be nonempty together.39。 return。 end。if isempty(B) amp。 ~isempty(A), B=zeros(size(A,1),1)。 end。if nargin7 amp。 ~isempty(Aeq) if size(Aeq,2)~=size(x0,1), errmsg=39。Matrix Aeq not correct.39。 return。 end。else Aeq=[]。 end。if nargin8 if ~isempty(Beq) amp。 any(size(Beq)~=[size(Aeq,1) 1]), errmsg=39。Column vector Beq not correct.39。 return。 end。else Beq=[]。 end。if isempty(Aeq) amp。 ~isempty(Beq), errmsg=39。Aeq and Beq should only be nonempty together39。 return。 end。if isempty(Beq) amp。 ~isempty(Aeq), Beq=zeros(size(Aeq,1),1)。 end。if nargin10, nonlcon=39。39。 end。settings = [0 0 0]。if nargin10 amp。 ~isempty(setts) if all(size(setts