多目标非线性规划程序(Matlab)
- 格式:doc
- 大小:65.50 KB
- 文档页数:8
function [errmsg,Z,X,t,c,fail] =
BNB18(fun,x0,xstat,xl,xu,A,B,Aeq,Beq,nonlcon,setts,options1,options2,ma xSQPit,varargin);
%·ÇÏßÐÔÕûÊý¹æ»®Ä£ÐÍÇó½â·ÖÖ§¶¨½çµü´úËã·¨¡£ÔÚMATLAB5.3ÖÐʹÓã¬ÐèOptimizat ion toolbox 2.0Ö§³Ö?
% Minimize F(x)
%subject to: xlb <= x <=xub
% A*x <= B
% Aeq*x=Beq
% C(x)<=0
% Ceq(x)=0
%
% x(i)¿ÉΪÁ¬Ðø±äÁ¿£¬ÕûÊý£¬»ò¹Ì¶¨Öµ
% ʹÓøñʽ
%[errmsg,Z,X]=BNB18('fun',x0,xstat,xl,xu,A,B,Aeq,Beq,'nonlcon',setts)
%fun£º MÎļþÃû£¬±íʾ×îС»¯Ä¿±êº¯Êýf=fun(x)
%x0: ÁÐÏòÁ¿£¬±íʾ±äÁ¿³õÖµ
%xstat£º ÁÐÏòÁ¿£¬xstat(i)=0±íʾx(i)ΪÁ¬Ðø±äÁ¿£¬1±íʾÕûÊý£¬2±íʾ¹Ì¶¨Öµ
%xl£º ÁÐÏòÁ¿£¬±íʾ±äÁ¿Ï½ç
%xu: ÁÐÏòÁ¿£¬±íʾ±äÁ¿ÉϽç
%A: ¾ØÕó, ±íʾÏßÐÔ²»µÈʽԼÊøϵÊý
%B: ÁÐÏòÁ¿, ±íʾÏßÐÔ²»µÈʽԼÊøÉϽç
%Aeq: ¾ØÕó, ±íʾÏßÐÔµÈʽԼÊøϵÊý
%Beg: ÁÐÏòÁ¿, ±íʾÏßÐÔ²»µÈʽԼÊøÓÒ¶ËÖµ
%nonlcon:
MÎļþÃû£¬±íʾ·ÇÏßÐÔÔ¼Êøº¯Êý[C,Ceq]=nonlin(x),ÆäÖÐC(x)Ϊ²»µÈʽԼÊø,
% Ceq(x)ΪµÈʽԼÊø
%setts: Ëã·¨ÉèÖÃ
%errmsq: ·µ»Ø´íÎóÌáʾ
%Z: ·µ»ØÄ¿±êº¯Êý×îСֵ
%X: ·µ»Ø×îÓŽâ
%
%ÀýÌâ
% max x1*x2*x3
% -x1+2*x2+2*x3>=0
% x1+2*x2+2*x3<=72
% 10<=x2<=20
% x1-x2=10
% ÏÈд Mº¯Êýdiscfun.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,opti ons2,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 for 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.
% xstatus 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.
% [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 erro r 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 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 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 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 by 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 for 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.