运筹学(高教版)
- 格式:doc
- 大小:449.50 KB
- 文档页数:49
《运筹学》教案授课专业:信息管理、工程管理任课教师:黄健南通大学商学院2007.2教案用纸第 1 次课 3 学时上次课复习:无一、本次课题(或教材章节题目):绪论1、运筹学的性质和特点2、运筹学的模型与工作步骤3、运筹学的应用与展望教学要求: 1、了解运筹学的性质和特点、运筹学的应用与展望2、运筹学的模型与工作步骤重点:运筹学工作步骤难点:无教学手段及教具:讲授讲授内容:1、运筹学的性质和特点2、运筹学的模型与工作步骤3、运筹学的应用与展望课后作业无同济大学出版社:运筹学教程参考资料高等教育出版社:管理运筹学注:本页为每次课教案首页教案用纸第 2 次课 3 学时上次课复习:运筹学的学科性质和发展概况运筹学的模型与工作步骤本次课题(或教材章节题目):二、线性规划与目标规划第一章线性规划及单纯形法1、线性规划问题及其数学模型教学要求:1、通过实际问题引入线性规划模型,初步掌握建立线性规划模型的方法;2、通过图解法直观地理解线性规划解的状态和线性规划的基本性质;3、熟练掌握线性规划问题的标准化方法;4、理解基、基解,基可行解的概念。
重点:线性规划问题及其数学模型、标准形式难点:线性规划问题及其数学模型、线性规划问题解的概念教学手段及教具:讲授讲授内容:1、线性规划模型的建立2、线性规划问题的图解法3、线性规划问题的标准形式4、线性规划问题解的概念课后作业P44: 1.1、1.2、1.3、1.10同济大学出版社:运筹学教程参考资料高等教育出版社:管理运筹学注:本页为每次课教案首页教案用纸第 3 次课 3 学时上次课复习:1、线性规划模型的建立2、线性规划问题的图解法3、线性规划问题的标准形式4、线性规划问题解的概念本次课题(或教材章节题目):2、线性规划问题的几何意义3、单纯形法4、单纯形法的计算步骤教学要求:1、了解线性规划问题的几何意义和基本性质2、理解单纯形法的理论基础,熟练掌握可行条件和优化条件;3、熟练掌握单纯形法的计算步骤重点:可行条件与优化条件。
《运筹学》教案(2014 年2 月)授课班级:2010级农林经济管理教材:《运筹学》,熊伟,机械工业出版社学分:4学分学时:64学时教学过程1.运筹学与线性规划基本概念(10分钟)2.应用模型举例(60分钟)生产计划问题、人员安排问题、合理用料问题、配料问题、投资问题教学过程3•线性规划的一般模型(10分钟)4.课堂练习(10分钟)5.课堂小结(5分钟)6.布置作业教学过程教学过程 1. 引例:(P41)两个模型的对应关系:(20分钟) 2. 线性规划的规范形式(10分钟) 3. 对偶模型(5分钟)4. 对称型对偶关系的一般形式(5分钟)5. 对称型对偶关系的一般形式(三个特点)(10分钟)非对称型对偶关系 对于非对称型且具有对偶关系的两个PL 问题,总结得出:定理:互为对偶的两个PL 问题,如果原问题中第k 个约束条件 是等式,则它的对偶规划中的第k 个变量无非负限制,反之亦然.线性规划的原始问题和对偶问题的对应关系可归纳为下表5. 6. 课堂小结,布置作业教学过程【性质1】(对称性)对偶问题的对偶是原问题。
(5分钟)【性质2】(弱对偶性)设F、r分别为LP(max)与DP (min)的可行解,则CX°<Y°b(10分钟)由性质2可得到下面几个推论:推论1:的任一可行解的目标值是(龙)的最优值下界;(龙)任一可行解的目标是(2乃的最优值的上界;推论2:在互为对偶的两个问题中,若一个问题具有无界解,则另一个问题无可行解;推论3:若原问题可行且另一个问题不可行,则原问题具有无界解。
【性质3](最优性)设F与尸分别是(2P)与(莎)的可行解,则F、尸是JLP)与(矿)的最优解当且仅当C X0 =卩呢(10分钟)【性质4】(对偶性)若互为对偶的两个问题其中一个有优解,则另一个也有最优解,且最优值相同。
(20分钟)教学过程由性质4还可推出另一结论:若(2P)与(矿)都有可行解,则两者都有最优解;若一个问题无最优解,则另一问题也无最优解。
第2 章线性规划的图解法1、解:x26A1O01BC36x1a.可行域为 OABC。
b.等值线为图中虚线所示。
c.由图可知,最优解为 B 点,最优解:x1 =1215x2 =,最优目标函数值:7769。
72、解:a x210.60.1O0.10.6x1有唯一解x1 = 0.2x 2 = 0.6函数值为3.6b c d e 无可行解无界解无可行解无穷多解20x1 =923f 有唯一解函数值为83x2 =33、解:a 标准形式:max f = 3x1 + 2 x 2 + 0s1 + 0 s 2 + 0s 39 x1 + 2 x 2 + s1 = 303x1 + 2 x 2 + s 2 = 132 x1 + 2 x 2 + s3 = 9x1 , x 2 , s1 , s 2 , s3 ≥ 0b 标准形式:max f = −4 x1 − 6 x3 − 0s1 − 0s23x1 − x 2 − s1 = 6x1 + 2 x 2 + s 2 = 107 x1 − 6 x 2 = 4x1 , x 2 , s1 , s 2 ≥ 0c 标准形式:max f = − x1' + 2 x2 − 2 x2 − 0s1 − 0s2'''− 3x1 + 5 x 2 − 5 x 2' + s1 = 70''2 x1' − 5 x 2 + 5 x 2' = 50''3x1' + 2 x 2 − 2 x 2' − s 2 = 30''x1' , x 2 , x 2' , s1 , s 2 ≥ 0''4 、解:标准形式:max z = 10 x1 + 5 x 2 + 0 s1 + 0 s 23x1 + 4 x 2 + s1 = 95 x1 + 2 x 2 + s 2 = 8x1 , x 2 , s1 , s 2 ≥ 0s1 = 2, s2 = 0标准形式:min f = 11x1 + 8 x 2 + 0s1 + 0s 2 + 0s310 x1 + 2 x 2 − s1 = 203x1 + 3x 2 − s 2 = 184 x1 + 9 x 2 − s3 = 36x1 , x 2 , s1 , s 2 , s3 ≥ 0 s1 = 0, s2 = 0, s3 = 136 、解:b 1 ≤ c1 ≤ 3c 2 ≤ c2 ≤ 6d x1 = 6x2 = 4x 2 = 16 − 2 x1e x1 ∈[4,8]f 变化。
第二章 线性规划本章, 我们介绍三种解决线性规划问题的软件:第一种: MATLAB 软件中的optimization toolbox 中的若干程序; 第二种: LINDO 软件; 第三种: LINGO 软件.1. MATLAB 程序说明程序名: lprogram 执行实例:1234123412341241234min -2-3-5s.t.24-623-124,,,0x x x x x x x x x x x x x x x x x x x +++≤++≤++≤≥ 在命令窗口的程序执行过程和结果如下:the program is with the linear programmingPlease input the constraints number of the linear programming m=7 m =7Please input the variant number of the linear programming n=4 n =4 Please input cost array of the objective function c(n)_T=[-2,-1,3,-5]' c = -2 -1 3 -5Please input the coefficient matrix of the constraints A(m,n)=[1,2,4,-1;2,3,-1,1;1,0,1,1;-1,0,0,0;0,-1,0,0;0,0,-1,0;0,0,0,-1] A = 1 2 4 -1 2 3 -1 1 1 0 1 1 -1 0 0 0 0 -1 0 0 0 0 -1 0 0 0 0 -1 Please input the resource array of the program b(m)_T=[6,12,4,0,0,0,0]' b = 6 124Optimization terminated successfully.The optimization solution of the programming is:x = 0.00002.6667-0.00004.0000The optimization value of the programming is:opt_value = -22.6667注: 红色字表示计算机的输出结果.程序的相关知识:Solve a linear programming problemwhere f, x, b, beq, lb, and ub are vectors and A and Aeq are matrices.相关的语法:x = linprog(f,A,b,Aeq,beq)x = linprog(f,A,b,Aeq,beq,lb,ub)x = linprog(f,A,b,Aeq,beq,lb,ub,x0)x = linprog(f,A,b,Aeq,beq,lb,ub,x0,options)[x,fval] = linprog(...)[x,fval,exitflag] = linprog(...)[x,fval,exitflag,output] = linprog(...)[x,fval,exitflag,output,lambda] = linprog(...)解释:linprog solves linear programming problems.x = linprog(f,A,b) solves min f'*x such that A*x <= b.x = linprog(f,A,b,Aeq,beq) solves the problem above while additionally satisfying the equality constraints Aeq*x = beq. Set A=[] and b=[] if no inequalities exist.x = linprog(f,A,b,Aeq,beq,lb,ub) defines a set of lower and upper bounds on the design variables, x, so that the solution is always in the range lb <= x <= ub. Set Aeq=[] and beq=[] if no equalities exist.x = linprog(f,A,b,Aeq,beq,lb,ub,x0) sets the starting point to x0. This option is only available with the medium-scale algorithm (the LargeScale option is set to 'off' using optimset). The default large-scale algorithm and the simplex algorithm ignore any starting point.x = linprog(f,A,b,Aeq,beq,lb,ub,x0,options) minimizes with the optimization options specified in the structure options. Use optimset to set these options.[x,fval] = linprog(...) returns the value of the objective function fun at the solution x: fval = f'*x.[x,lambda,exitflag] = linprog(...) returns a value exitflag that describes the exit condition.[x,lambda,exitflag,output] = linprog(...) returns a structure output that contains information about the optimization.[x,fval,exitflag,output,lambda] = linprog(...) returns a structure lambda whose fields contain the Lagrange multipliers at the solution x.2.LINDO 程序说明程序名:linear 执行实例:max 1015s.t.1012216,0x y x y x y x y +<<+<> 在命令窗口键入以下内容:max 10x+15y !也可以直接解决min 问题 subject to x<10 y<12 x+2y<16end !注释符号; 系统默认为自变量>0, 若不要求用free 命令.!在出来report windows 之前可选择显示对此规划进行灵敏度分析等按solve 键, 在reports window 中出现以下内容:LP OPTIMUM FOUND AT STEP 2OBJECTIVE FUNCTION VALUE 1) 145.0000VARIABLE VALUE REDUCED COST X 10.000000 0.000000 Y 3.000000 0.000000ROW SLACK OR SURPLUS DUAL PRICES 2) 0.000000 2.500000 3) 9.000000 0.000000 4) 0.000000 7.500000NO. ITERATIONS= 2RANGES IN WHICH THE BASIS IS UNCHANGED:OBJ COEFFICIENT RANGESVARIABLE CURRENT ALLOWABLE ALLOWABLE COEF INCREASE DECREASE X 10.000000 INFINITY 2.500000 Y 15.000000 5.000000 15.000000RIGHTHAND SIDE RANGESROW CURRENT ALLOWABLE ALLOWABLE RHS INCREASE DECREASE 2 10.000000 6.000000 10.000000 3 12.000000 INFINITY 9.000000 4 16.000000 18.000000 6.0000003.LINGO 程序说明3.1 程序名: linearp1(求极小问题) linearp1运行实例:5,,1 ,0 12 26 .t .s 215min 5321432121 =≥=-++=-+-+=j x x x x x x x x x x x z j在model window 中输入以下语句: min=5*x1+21*x3; x1-x2+6*x3-x4=2; x1+x2+2*x3-x5=1;按运行按钮在solution report 窗口得到以下结果:Global optimal solution found at iteration: 2 Objective value: 7.750000Variable Value Reduced Cost X1 0.5000000 0.000000 X3 0.2500000 0.000000 X2 0.000000 0.5000000 X4 0.000000 2.750000 X5 0.000000 2.250000Row Slack or Surplus Dual Price 1 7.750000 -1.000000 2 0.000000 -2.750000 3 0.000000 -2.2500003.2 程序名: linearp2(求极大问题) linearp2运行实例:max 100150..2160100120,0x y s t x y x y x y ++≤≤≤≥ 在model window 中输入以下语句:max=100*x+150*y; ! this is a commnent; x<=100; y<=120;x+2*y<=160;按运行按钮在solution report 窗口得到以下结果:Global optimal solution found at iteration: 2 Objective value: 14500.00Variable Value Reduced CostX 100.0000 0.000000 Y 30.00000 0.000000Row Slack or Surplus Dual Price 1 14500.00 1.000000 2 0.000000 25.00000 3 90.00000 0.0000004 0.000000 75.00000第三章 整数线性规划本章, 我们介绍三种解决整数线性规划问题的软件:第一种: MATLAB 中的optimization toolbox 中的若干程序; 第二种: LINDO 软件; 第二种: LINGO 软件.1. MATLAB 程序说明程序名: intprogram, L01p_e, L01p_ie, transdetobi, biprogramintprogram 是利用分支定界法解决整数规划问题, 是全部的整数规划问题; L01p_e 是利用枚举法解决0-1规划问题, 变量要求全部为0或者1; L01p_ie 是利用隐枚举法解决0-1规划问题, 变量要求全部为0或者1;Transdetobi 是枚举法和隐枚举法中利用到的将十进制数转化为二进制数的函数; Biprogram 是MATLAB6.5以上版本中有的求解0-1规划的函数的程序.intprogram 执行实例1:12121212max 2010s.t.54242513,0, f x x x x x x x x =++≤+≤≥ 且为整数在命令窗口的程序执行过程和结果如下: >> c=[-20,-10]; %将最大转化为最小;>> a=[5,4;2,5]; >> b=[24;13];>> [x,f]=intprogram(c,a,b,[0;0],[inf;inf],[],0,0.0001) % c,a,b 之后[0;0] is the value of low bound;[inf;inf] is the value of up bound;[] is the initialization;0 is the number of the equation constraints; 0.0001 is the concise rate. x =4.0000 1.0000 f = -90intprogram 执行实例2: 书中例题3.3.1在命令窗口的程序执行过程和结果如下:>> c=[-1,-1];>> a=[-4,2;4,2;0,-2]; >> b=[-1;11;-1];>> [x,f]=intprogram(c,a,b,[0;0],[inf;inf],[],0,0.0001) x =2 2 1 1 f = -3L01p_e 和L01p_ie 执行实例:1231231231223123max 325s.t.22 443 46,,01f x x x x x x x x x x x x x x x x =-++-≤++≤+≤+≤= - 或在命令窗口的程序执行过程和结果如下: >> c=[3,-2,5]; %将最大转化为最小; >> a=[1,2,-1;1,4,1;1,1,0;0,4,1]; >> b=[2;4;3;6];>> x1=L01p_e(c,a,b);x2=L01p_ie(c,a,b); %x1表示利用枚举法解决0-1规划问题,x2表示用隐% 枚举法解决问题, 结果是一样的 >> x1 x1 =1 0 >> x2x2 = 0 1 0biprogram 执行实例:12341234341324min ()9564s.t.63529 10 0f x x x x x x x x x x x x x x x =---+++≤+≤+≤-+≤ - -在命令窗口的程序执行过程和结果如下:the program is with the binary linear programmingPlease input the constraints number of the programming m=4 m = 4Please input the variant number of the programming n=4 n = 4Please input cost array of the objective function c(n)_T=[-9,-5,-6,-4]' c = -9 -5 -6 -4Please input the coefficient matrix of the constraints A(m,n)=[6,3,5,2;0,0,1,1; -1,0,1,0;0,-1,0,1]6 3 5 20 0 1 1-1 0 1 00 -1 0 1Please input the resource array of the program b(m)_T=[9,1,0,0]'b =91Optimization terminated successfully.x =11程序的相关知识:Solve binary integer programming problems of the formwhere f, b, and beq are vectors, A and Aeq are matrices, and the solution x is required to be a binary integer vector -- that is, its entries can only take on the values 0 or 1.语法如下:x = bintprog(f)x = bintprog(f, A, b)x = bintprog(f, A, b, Aeq, beq)x = bintprog(f, A, b, Aeq, beq, x0)x = bintprog(f, A, b, Aeq, beq, x0, options)[x, fval] = bintprog(...)[x,fval, exitflag] = bintprog(...)[x, fval, exitflag, output] = bintprog(...)解释:x = bintprog(f) solves the binary integer programming problemx = bintprog(f, A, b) solves the binary integer programming problemx = bintprog(f, A, b, Aeq, beq) solves the preceding problem with theadditional equality constraint.x = bintprog(f, A, b, Aeq, beq, x0) sets the starting point for the algorithm to x0. If x0 is not in the feasible region, bintprog uses the default initial point. x = bintprog(f, A, b, Aeq, Beq, x0, options) minimizes with the default optimization options replaced by values in the structure options, which you can create using the function optimset.[x, fval] = bintprog(...) returns fval, the value of the objective function at x.[x,fval, exitflag] = bintprog(...) returns exitflag that describes the exit condition of bintprog. See Output Arguments. [x, fval, exitflag, output] = bintprog(...) returns a structure output that contains information about the optimization. See Output Arguments.2.LINDO 程序说明LINDO 也提供了解决全整数规划、混合整数规划以及0-1规划的方法.2.1 解决全整数规划问题 程序名: intlpall intlpall 执行实例:min 1110s.t.212 31 ,0, x y x y x y x y ++<->> 且为整数在命令窗口键入以下内容:max 11x+10yst2x+y<12x-3y>1endgin x ! the general integer statement – GIN 将变量约束为整数gin y ! the general integer statement – GIN 将变量约束为整数按solve键在reports window出现:LP OPTIMUM FOUND AT STEP 7OBJECTIVE VALUE = 72.4285736NEW INTEGER SOLUTION OF 66.0000000 AT BRANCH 0 PIVOT 12BOUND ON OPTIMUM: 66.00000ENUMERATION COMPLETE. BRANCHES= 0 PIVOTS= 12LAST INTEGER SOLUTION IS THE BEST FOUNDRE-INSTALLING BEST SOLUTION...OBJECTIVE FUNCTION VALUE1) 66.00000VARIABLE VALUE REDUCED COSTX 6.000000 -11.000000Y 0.000000 -10.000000ROW SLACK OR SURPLUS DUAL PRICES2) 0.000000 0.0000003) 5.000000 0.000000NO. ITERATIONS= 12BRANCHES= 0 DETERM.= 1.000E 0]2.2 解决混合整数规划问题: 程序名:intlpsec intlpsec 执行实例:min 1110s.t.212 31 ,0, x y x y x y x y x ++<->> 且为整数在命令窗口键入以下内容: max 11x+10yst2x+y<12 x-3y>1 endgin x !only the general integer statement – GIN 只将变量x 约束为整数按solve 键在reports windows 中出现以下内容:LP OPTIMUM FOUND AT STEP 2 OBJECTIVE VALUE = 72.4285736SET X TO >= 6 AT 1, BND= 66.00 TWIN= 68.33 16NEW INTEGER SOLUTION OF 66.0000000 AT BRANCH 1 PIVOT 16BOUND ON OPTIMUM: 68.33334FLIP X TO <= 5 AT 1 WITH BND= 68.333336NEW INTEGER SOLUTION OF 68.3333359 AT BRANCH 1 PIVOT 16BOUND ON OPTIMUM: 68.33334 DELETE X AT LEVEL 1ENUMERATION COMPLETE. BRANCHES= 1 PIVOTS= 16LAST INTEGER SOLUTION IS THE BEST FOUND RE-INSTALLING BEST SOLUTION...OBJECTIVE FUNCTION VALUE1) 68.33334VARIABLE VALUE REDUCED COST X 5.000000 -14.333333 Y 1.333333 0.000000ROW SLACK OR SURPLUS DUAL PRICES 2) 0.666667 0.000000 3) 0.000000 -3.333333NO. ITERATIONS= 17BRANCHES= 1 DETERM.= 1.000E 02.3 解决0-1整数规划问题: 程序名:intlp01 intlp01执行实例:max 1002012s.t.100 117,0 01x y z y x y z z y z x -++-<+<<>= 或 在命令窗口键入以下内容: max -100x+20y+12zsty-10x<0 y+z<11 z<7 endint x !约束x 为0-1变量按solve 键在reports windows 中出现以下内容:LP OPTIMUM FOUND AT STEP 3 OBJECTIVE VALUE = 124.000000SET X TO >= 1 AT 1, BND= 112.0 TWIN= 84.00 9NEW INTEGER SOLUTION OF 112.000000 AT BRANCH 1 PIVOT 9BOUND ON OPTIMUM: 112.0000DELETE X AT LEVEL 1ENUMERATION COMPLETE. BRANCHES= 1 PIVOTS= 9LAST INTEGER SOLUTION IS THE BEST FOUND RE-INSTALLING BEST SOLUTION...OBJECTIVE FUNCTION VALUE1) 112.0000VARIABLE VALUE REDUCED COST X 1.000000 20.000000 Y 10.000000 0.000000 Z 1.000000 0.000000ROW SLACK OR SURPLUS DUAL PRICES 2) 0.000000 8.000000 3) 0.000000 12.000000 4) 6.000000 0.000000NO. ITERATIONS= 10BRANCHES= 1 DETERM.= 1.000E 03. LINGO 程序说明除了特别说明, LINGO 默认变量是非负的以及连续的, 但是可用以下命令使得变量满足要求:@GIN restricts a variable to being an integer value, @BIN makes a variable binary (i.e., 0 or 1),@FREE allows a variable to assume any real value, positive or negative @BND limits a variable to fall within a finite range 等.程序名: intlp (该程序主要是解决整数线性规划问题的, 用上述命令赋予变量属性.) intlp 执行实例:max 100150s.t.2160 100 120,0, x y x y x y x y ++<≤≤> 且为整数在模型命令窗口键入以下内容: max =100*x+150*y;x<=100; y<=120;x+2*y<=160;@gin (x);@gin (y);!若要只限制x,只要限制x 即可.按运行按钮在solution report 窗口得到以下结果:Global optimal solution found at iteration: 2 Objective value: 14500.00Variable Value Reduced Cost X 100.0000 -100.0000 Y 30.00000 -150.0000Row Slack or Surplus Dual Price 1 14500.00 1.000000 2 0.000000 0.000000 3 90.00000 0.000000 4 0.000000 0.000000程序名: bilp bilp 的执行实例:1231231231223123max 325..2244346,,01f x x x s t x x x x x x x x x x x x x or =-+-+-≤++≤+≤+≤= 在模型命令窗口键入以下内容: max =-3*x1+2*x2+5*x3;x1+2*x2-x3<=2; x1+4*x2+x3<=4; x1+x2<=3; 4*x2+x3<=6;@bin (x1);@bin (x2);@bin (x3);按运行按钮在solution report 窗口得到以下结果:Global optimal solution found at iteration: 0 Objective value: 5.000000Variable Value Reduced CostX1 0.000000 3.000000 X2 0.000000 -2.000000 X3 1.000000 -5.000000Row Slack or Surplus Dual Price 1 5.000000 1.000000 2 3.000000 0.000000 3 3.000000 0.000000 4 3.000000 0.000000 5 5.000000 0.000000第四章 非线性规划本章, 我们介绍两种解决非线性规划问题的软件:第一种: MATLAB 中的optimization toolbox 中的若干程序; 第二种: LINGO 软件.1.MATLAB 程序说明1.1 无约束问题程序名: unpfun1函数, unpfun2函数 unpfun1 实例:Minimize the function 221122()32f x x x x x =++在命令窗口输入以下信息:>> x0=[1,1]; % Then call fminunc to find a minimum of unpfun1 near [1,1]>> [x,fval]=fminunc(@unpfun1,x0)输出以下信息:Optimization terminated successfully:Search direction less than 2*options.TolX x =1.0e-008 *-0.7591 0.2665fval =1.3953e-016unpfun2实例:将上述的实例用梯度法做在命令窗口输入以下信息:>> options = optimset('GradObj','on'); % To minimize this function with the gradient provided>> x0 = [1,1];>> [x,fval] = fminunc(@unpfun2,x0,options)输出以下信息:Optimization terminated successfully:First-order optimality less than OPTIONS.TolFun, and no negative/zero curvature detectedx =1.0e-015 *0.1110 -0.8882fval =6.2862e-031程序的相关知识:第一种: fminsearchFind a minimum of an unconstrained multivariable functionwhere x is a vector and f(x) is a function that returns a scalar.语法如下:x = fminsearch(fun,x0)x = fminsearch(fun,x0,options)[x,fval] = fminsearch(...)[x,fval,exitflag] = fminsearch(...)[x,fval,exitflag,output] = fminsearch(...)解释:fminsearch attempts to find a minimum of a scalar function of several variables, starting at an initial estimate. This is generally referred to as unconstrained nonlinear optimization.x = fminsearch(fun,x0) starts at the point x0 and attempts to find a local minimum x of the function described in fun. fun is a functionhandle for either an M-file function or an anonymous function. x0 can be a scalar, vector, or matrix.x = fminsearch(fun,x0,options) minimizes with the optimization options specified in the structure options. Use optimset to set these options.[x,fval] = fminsearch(...) returns in fval the value of the objective function fun at the solution x.[x,fval,exitflag] = fminsearch(...) returns a value exitflag that describes the exit condition of fminsearch.[x,fval,exitflag,output] = fminsearch(...) returns a structure output that contains information about the optimization.Avoiding Global Variables via Anonymous and Nested Functions explains how to parameterize the objective function fun, if necessary.第二种: fminuncFind a minimum of an unconstrained multivariable functionwhere x is a vector and f(x) is a function that returns a scalar.语法如下:x = fminunc(fun,x0)x = fminunc(fun,x0,options)[x,fval] = fminunc(...)[x,fval,exitflag] = fminunc(...)[x,fval,exitflag,output] = fminunc(...)[x,fval,exitflag,output,grad] = fminunc(...)[x,fval,exitflag,output,grad,hessian] = fminunc(...)解释:fminunc attempts to find a minimum of a scalar function of several variables, starting at an initial estimate. This is generally referred to as unconstrained nonlinear optimization.x = fminunc(fun,x0) starts at the point x0 and attempts to find a local minimum x of the function described in fun. x0 can be a scalar, vector, or matrix.x = fminunc(fun,x0,options) minimizes with the optimization options specified in the structure options. Use optimset to set these options.[x,fval] = fminunc(...) returns in fval the value of the objective function fun at the solution x.[x,fval,exitflag] = fminunc(...) returns a value exitflag that describes the exit condition.[x,fval,exitflag,output] = fminunc(...) returns a structure output that contains information about the optimization.[x,fval,exitflag,output,grad] = fminunc(...) returns in grad the value of the gradient of fun at the solution x.[x,fval,exitflag,output,grad,hessian] = fminunc(...) returns in hessian the value of the Hessian of the objective function fun at the solution x. See Hessian.Avoiding Global Variables via Anonymous and Nested Functions explains how to parameterize the objective function fun, if necessary.1.2 有约束的非线性规划 程序名: cnpfun 函数 cnfun 实例:123123min s.t.02272f x x x x x x =-≤++≤ 在命令窗口输入以下信息:>> A=[-1,-2,-2;1,2,2]; >> b=[0;72];>> x0 = [10; 10; 10]; % Starting guess at the solution >> [x,fval] = fmincon(@cnpfun,x0,A,b)输出以下信息:Optimization terminated successfully:Magnitude of directional derivative in search directionless than 2*options.TolFun and maximum constraint violation is less than options.TolCon Active Constraints: 2 x =24.000012.000012.0000fval =-3456程序的相关知识:Find a minimum of a constrained nonlinear multivariable function∙subject to∙where x, b, beq, lb,and ub are vectors, A and Aeq are matrices, c(x) and ceq(x)are functions that return vectors, and f(x)is a function that returns a scalar. f(x), c(x), and ceq(x) can be nonlinear functions.语法如下:x = fmincon(fun,x0,A,b)x = fmincon(fun,x0,A,b,Aeq,beq)x = fmincon(fun,x0,A,b,Aeq,beq,lb,ub)x = fmincon(fun,x0,A,b,Aeq,beq,lb,ub,nonlcon)x = fmincon(fun,x0,A,b,Aeq,beq,lb,ub,nonlcon,options)[x,fval] = fmincon(...)[x,fval,exitflag] = fmincon(...)[x,fval,exitflag,output] = fmincon(...)[x,fval,exitflag,output,lambda] = fmincon(...)[x,fval,exitflag,output,lambda,grad] = fmincon(...)[x,fval,exitflag,output,lambda,grad,hessian] = fmincon(...)解释:fmincon attempts to find a constrained minimum of a scalar function of several variables starting at an initial estimate. This is generally referred to as constrained nonlinear optimization or nonlinear programming.x = fmincon(fun,x0,A,b) starts at x0 and attempts to find a minimum x to the function described in fun subject to the linear inequalities A*x <= b. x0 can be a scalar, vector, or matrix.x = fmincon(fun,x0,A,b,Aeq,beq) minimizes fun subject to the linear equalities Aeq*x = beq as well as A*x <= b. Set A=[] and b=[] if no inequalities exist.x = fmincon(fun,x0,A,b,Aeq,beq,lb,ub) defines a set of lower and upper bounds on the design variables in x, so that the solution is always in the range lb <= x <= ub. Set Aeq=[] and beq=[] if no equalities exist.x = fmincon(fun,x0,A,b,Aeq,beq,lb,ub,nonlcon) subjects the minimization to the nonlinear inequalities c(x) or equalities ceq(x) defined in nonlcon. fmincon optimizes such that c(x) <= 0 andceq(x) = 0. Set lb=[] and/or ub=[] if no bounds exist.x = fmincon(fun,x0,A,b,Aeq,beq,lb,ub,nonlcon,options) minimizes with the optimization options specified in the structure options. Use optimset to set these options. Set nonlcon = [] if there are no nonlinear inequality or equality constraints.[x,fval] = fmincon(...) returns the value of the objective function fun at the solution x.[x,fval,exitflag] = fmincon(...) returns a value exitflag that describes the exit condition of fmincon.[x,fval,exitflag,output] = fmincon(...) returns a structure output with information about the optimization.[x,fval,exitflag,output,lambda] = fmincon(...) returns a structure lambda whose fields contain the Lagrange multipliers at the solution x.[x,fval,exitflag,output,lambda,grad] = fmincon(...) returns the value of the gradient of fun at the solution x.[x,fval,exitflag,output,lambda,grad,hessian] = fmincon(...) returns the value of the Hessian at the solution x. See Hessian.Avoiding Global Variables via Anonymous and Nested Functions explains how to parameterize the objective function fun, if necessary.1.3 二次规划 程序名: qprogram qprogram 实例:221211212min ()6s.t.420,0f x x x x x x x x =++--≤≥ 在命令窗口输入以下信息::the program is with the quadratic programmingPlease input the constraints number of the programming m=4 m = 4Please input the variant number of the programming n=4 n = 4Please input cost matrix of the objective function H(n,n)=[2,0;0,2] H =2 0 0 2Please input cost array of the objective function c(n)_T=[6;0] c = 6 0Please input the coefficient matrix of the constraints A(m,n)=[-2,-1;-1,0;0,-1] A =-2 -1 -1 0 0 -1Please input the resource array of the program b(m)_T=[-4,0,0]'b =-4命令窗口输出信息:Optimization terminated successfully.The solution of the quadratic is:x =1.00002.0000程序的相关知识:Solve the quadratic programming problemwhere H, A, and Aeq are matrices, and f, b, beq, lb, ub, and x are vectors.语法如下:x = quadprog(H,f,A,b)x = quadprog(H,f,A,b,Aeq,beq)x = quadprog(H,f,A,b,Aeq,beq,lb,ub)x = quadprog(H,f,A,b,Aeq,beq,lb,ub,x0)x = quadprog(H,f,A,b,Aeq,beq,lb,ub,x0,options)[x,fval] = quadprog(...)[x,fval,exitflag] = quadprog(...)[x,fval,exitflag,output] = quadprog(...)[x,fval,exitflag,output,lambda] = quadprog(...)解释:x = quadprog(H,f,A,b) returns a vector x that minimizes1/2*x'*H*x + f'*x subject to A*x <= b.x = quadprog(H,f,A,b,Aeq,beq) solves the preceding problem while additionally satisfying the equality constraints Aeq*x = beq.x = quadprog(H,f,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.x = quadprog(H,f,A,b,Aeq,beq,lb,ub,x0) sets the starting point to x0.x = quadprog(H,f,A,b,Aeq,beq,lb,ub,x0,options) minimizes with the optimization options specified in the structure options. Use optimset to set these options.[x,fval] = quadprog(...) returns the value of the objective function at x:∙fval = 0.5*x'*H*x + f'*x.[x,fval,exitflag] = quadprog(...) returns a value exitflag that describes the exit condition of quadprog.[x,fval,exitflag,output] = quadprog(...) returns a structure output that contains information about the optimization.[x,fval,exitflag,output,lambda] = quadprog(...) returns a structure lambda whose fields contain the Lagrange multipliers at the solution x.2. LINGO 程序说明LINGO 也是解决非线性规划问题的有力工具之一。