《多目标非线性规划程序(Matlab).doc》由会员分享,可在线阅读,更多相关《多目标非线性规划程序(Matlab).doc(8页珍藏版)》请在金锄头文库上搜索。
1、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=-
2、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,f
3、ail = % 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 Ceq(x)=0% x(i) is continuous for xstatus(i)=0 % x(i) integer for xstatus(i)= 1% x(i) fixed fo
4、r xstatus(i)=2% BNB uses:% Optimization Toolbox Version 2.0 (R11) 09-Oct-1998% From this toolbox fmincon.m is called. For more info type help fmincon.% fun is the function to be minimized and should return a scalar. F(x)=feval(fun,x).% x0 is the starting point for x. x0 should be a column vector.% x
5、status is a column vector describing the status of every variable x(i).% xlb and xub are column vectors with lower and upper bounds for x.% A and Aeq are matrices for the linear constrains.% B and Beq are column vectors for the linear constrains.% nonlcon is the function for the nonlinear constrains
6、.% C(x);Ceq(x)=feval(nonlcon,x). Both C(x) and Ceq(x) should be column vectors.% errmsg is a string containing an error message if BNB found an error in the input.% Z is the scalar result of the minimization, X the values of the accompanying variables. % t is the time elapsed while the algorithm BNB
7、 has run, c is the number of BNB cycles and% fail is the number of unsolved leaf sub-problems. % settings is a row vector with settings for BNB:% settings(1) (standard 0) if 1: use phase 1 by relaxation. This sometimes makes the algorithm% faster, because phase 1 means the algorithm first checks if
8、there is a feasible solution% for a sub-problem before trying to find a best solution. If there is no feasible solution BNB% will not try to find a best solution.% settings(2) (standard 0) if 1: if the sub-problem did not converge do not branch. If a sub-% problem did not converge this means BNB did
9、 not find a solution for it. Normally BNB will % branch the problem so it can try again to find a solution.% A sub-problem that is a leaf of the branch-and-bound-three can not be branched. If such% a problem does not converge it will be considered unfeasible and the parameter fail will be % raised b
10、y one.% settings(3) (standard 0) if 1: if 1 a sub-problem that did not converge but did return a feasible% point will be considered convergent. This might be useful if fmincon is having a hard time with% a certain problem but you do want some results.% options1 and options2 are options structures fo
11、r phase 1 and phase 2.% For details about the options structure type help optimset.% maxSQPiter is a global variable used by fmincon (if modified as described in bnb18.m).% maxSQPiter is 1000 by default.% P1,P2,. are parameters to be passed to fun and nonlcon.% F(x)=feval(fun,x,P1,P2,.). C(x);Ceq(x)
12、=feval(nonlcon,x,P1,P2,.).% Type edit BNB18 for more info. % E.C. Kuipers% e-mail E.C.Kuiperscpedu.rug.nl % FI-Lab% Applied Physics% Rijksuniversiteit Groningen % To get rid of bugs and to stop fmincon from hanging make the following chances:% In optim/private/nlconst.m ($Revision: 1.20 $ $Date: 1998/08/24 13:46:15 $):% Get EXITFLAG independent of verbosity.% After the line