运筹学(高教版)
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
第二章 线性规划
本章, 我们介绍三种解决线性规划问题的软件:
第一种: MATLAB 软件中的optimization toolbox 中的若干程序; 第二种: LINDO 软件; 第三种: LINGO 软件.
1. MATLAB 程序说明
程序名: lprogram 执行实例:
1234123412341241234min -2-3-5s.t.24-623-124,,,0
x x x x x x x x x x x x x x x x x x x +++≤++≤++≤≥
在命令窗口的程序执行过程和结果如下:
the program is with the linear programming
Please input the constraints number of the linear programming m=7 m =7
Please 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 -5
Please 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 12
4
Optimization terminated successfully.
The optimization solution of the programming is:
x = 0.0000
2.6667
-0.0000
4.0000
The optimization value of the programming is:
opt_value = -22.6667
注: 红色字表示计算机的输出结果.
程序的相关知识:
Solve a linear programming problem
where 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,0
x y x y x y x y +<<+<>
在命令窗口键入以下内容:
max 10x+15y !也可以直接解决min 问题 subject to x<10 y<12 x+2y<16