线性规划— Matlab 多目标规划优化问题 fgoalattain 工程应用中 fgoalattain函数调用格式如下 fval=fgoalattain(fun, x0, goal, weight, A, b, Aeq, beq, Ib, ub, nonlcon) help fgoalattain FGOALATTAIN Solves the multi-objective goal attainment optimization proble Solve minimize value problem X-FGOALATTAINFUN, XO, GOAL, WEIGHT, A, B)solves the goal attainment problem subject to the linear inequalities A*X<=B X=FGOALATTAIN(FUN, XO, GOAL, WEIGHT, A, B, Aeq, Beg) solves the goal attainment subject to the linear equalities Aeq X= Beq as well X=FGOALATTAIN(FUN, XO, GOAL, WEIGHT, A, B, Aeq, Beq, LB, UB)defines a set of lower and upper bounds on the design variables, X, so that the solution is in the range LB <X<=UB. Use empty matrices for LB and U if no bounds exist. Set LB(i=-Inf if X(i)is unbounded below, set UB(i)=Inf if X(i) is unbounded above X=FGOALATTAIN(FUN, XO, GOAL, WEIGHT, A, B, Aeq, Beq, LB, UB, NONLCON) subje goal attainment problem to the constraints defined in nonlcon (usually an M-file: NONLCON. m). The function NONLCON should return the vectors C and Ceq, representing the nonlinear inequalities and equalities respectively, when called with feval: [C, Ceq]=feval(NONLCON, X). FGOALATTAIN optimizes such that C(XK=0 and Ceq X0 For more details, type the M-file FGOALATTAIN. M See also optimset optimget 例1.程序(利用 fgoalattain函数求解) min(x1-1)2+(x2-2)2+(x3-3) min x+2x+3x st.x1+x2+x3=6 x1,x2,x3≥0 ①建立M文件 functiony= fun(sol, options) 6sol,evl提示未定义 l(1), x 2= sol(2)
线性规划——Matlab 多目 化 标规划优 问题 fgoalattain 工程应用中 fgoalattain 函数调用格式如下: [x,fval]=fgoalattain (fun,x0,goal,weight,A,b,Aeq,beq,lb,ub,nonlcon) help fgoalattain FGOALATTAIN Solves the multi-objective goal attainment optimization problem. Solve minimize value problem. X=FGOALATTAIN(FUN,X0,GOAL,WEIGHT,A,B) solves the goal attainment problem subject to the linear inequalities A*X <= B. X=FGOALATTAIN(FUN,X0,GOAL,WEIGHT,A,B,Aeq,Beq) solves the goal attainment problem subject to the linear equalities Aeq*X = Beq as well. X=FGOALATTAIN(FUN,X0,GOAL,WEIGHT,A,B,Aeq,Beq,LB,UB) defines a set of lower and upper bounds on the design variables, X, so that the solution is in the range LB <= X <= UB. Use empty matrices for LB and U if no bounds exist. Set LB(i) = -Inf if X(i) is unbounded below; set UB(i) = Inf if X(i) is unbounded above. X=FGOALATTAIN(FUN,X0,GOAL,WEIGHT,A,B,Aeq,Beq,LB,UB,NONLCON) subjects the goal attainment problem to the constraints defined in NONLCON (usually an M-file: NONLCON.m). The function NONLCON should return the vectors C and Ceq, representing the nonlinear inequalities and equalities respectively, when called with feval: [C, Ceq] = feval(NONLCON,X). FGOALATTAIN optimizes such that C(X)<=0 and Ceq(X)=0. For more details, type the M-file FGOALATTAIN.M. See also OPTIMSET, OPTIMGET. 例 1. 程序(利用 fgoalattain 函数求解) 2 3 2 2 2 1 2 3 2 2 2 1 32min )3()2()1(min xxx xxx ++ −+−+− 0,, .. 6 321 321 ≥ + + = xxx xxxts ①建立 M 文件. function y = fun(sol, options) %([sol, eval]提示未定义) x1 = sol(1); x2 = sol(2); 1
线性规划— Matlab x3=sol(3) %y1=y(1) %y2=y(2) y(1)=(x1-1)^2+(x2-2)2+(x3-3)y2 y(2)=x1^2+2*x2^2+3*x3^2; ②在命令窗口中输入 x, feval]=fgoalattain('fun, [111][11],0,0,[11 1],[6],[0001D) ③得到结果 lower 3.2727163641.0909 feval= 8.9422196364 例2某钢铁公司因生产需要欲采购一批钢材,市面上的钢材有两种规格,第1种规格的单价 为3500元/t,第2种规格的单价为4000元几要求购买钢材的总费用不超过1000万元,够得 钢材总量不少于2000t问如何确定最好的采购方案,使购买钢材的总费用最小且购买的总量 最多 解:设采购第1、2种规格的钢材数量分别为x1和x2.根据题意建立如下多目标优化问题的 数学模型 minf(x)=3500x+4000x2 max3500x1+4000x2≤100000 x1+x2≥2000 x1x2≥0 ①建立M文件.在 Matlab编辑窗口中输入: function y fun(sol) y=3500*x1+4000*x2 ②在命令窗口中输入
线性规划——Matlab x3 = sol(3); %y1=y(1); %y2=y(2); y(1) = (x1-1)^2+(x2-2)^2+(x3-3)^2; y(2) = x1^2+2*x2^2+3*x3^2; ②在命令窗口中输入. [x, feval] = fgoalattain('fun', [1 1 1], [1 1], [1 1], [], [], [1 1 1], [6], [0 0 0], []) ③得到结果. lower upper ineqlin ineqnonlin 2 x = 3.2727 1.6364 1.0909 feval = 8.9422 19.6364 例 2.某钢铁公司因生产需要欲采购一批钢材,市面上的钢材有两种规格,第 1 种规格的单价 为 3500 元/t,第 2 种规格的单价为 4000 元/t.要求购买钢材的总费用不超过 1000 万元,够得 钢材总量不少于 2000t.问如何确定最好的采购方案,使购买钢材的总费用最小且购买的总量 最多. 解:设采购第 1、2 种规格的钢材数量分别为 和 .根据题意建立如下多目标优化问题的 数学模型. 1 x 2 x 0, 2000 3500max 4000 100000 3500)(min 4000 21 21 1 2 1 1 2 ≥ ≥+ ≤+ += xx xx xx xxxf ①建立 M 文件. 在 Matlab 编辑窗口中输入: function y = fun(sol) x1 = sol(1); x2 = sol(2); y = 3500*x1 + 4000*x2; ②在命令窗口中输入. 2
线性规划— Matlab x,fevl]l= fgoalattain(fun,[lJ1J.[100000035004000;-1-1],[10000002000,0., 00]郾)%初始值的要求可以不严,但目标值关键,设置要贴近 Magnitude of directional derivative in search direction less than 2*options. TolFun and maximum constraint violation is less than options. TolCon Active inequalities(to within options. TolCon=1e-006) 1.0e+003* 1.0000 10000 feval= 75000e+006
线性规划——Matlab 3 [x, feval] = fgoalattain('fun', [1 1],[1], [10000000], [3500 4000; -1 -1], [10000000; -2000], [], [], [0 0], []) %初始值的要求可以不严,但目标值关键,设置要贴近 Optimization terminated successfully: Magnitude of directional derivative in search direction less than 2*options.TolFun and maximum constraint violation is less than options.TolCon Active inequalities (to within options.TolCon = 1e-006): lower upper ineqlin ineqnonlin 2 1 x = 1.0e+003 * 1.0000 1.0000 feval = 7.5000e+006