数学建模社区-数学中国

标题: 运筹学第三版(刁在钧)光盘中的内容 [打印本页]

作者: mnpfc    时间: 2009-12-31 14:14
标题: 运筹学第三版(刁在钧)光盘中的内容
第二章 线性规划

本章, 我们介绍三种解决线性规划问题的软件:

第一种: MATLAB软件中的optimization toolbox中的若干程序;

第二种: LINDO软件;

第三种: LINGO软件.

1. MATLAB程序说明程序名: lprogram执行实例:

file:///C:/DOCUME~1/ADMINI~1/LOCALS~1/Temp/msohtml1/01/clip_image002.gif

在命令窗口的程序执行过程和结果如下:

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 =8 T1 Q- n+ s: b3 Y7 n
-2


. m3 E) u6 N% l* I: D: B-1


* D8 k$ a! C/ z  Y9 ?1 z4 E3


- B+ v. f# c7 b+ q: e' ?9 d2 Y-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 =5 P. c& g4 O: @# r+ O
11 B$ p/ {0 V7 t( o
2
& T! z7 Y  t3 Q# |4
1 X/ @  T  [+ E-1

( i( |7 h- R  U" t7 W' s* o
2+ G( ]; z& W, i, v
3! _6 j* f% s5 u* y
-1
0 r1 G% J0 E( B% e. O. U1

) \% z1 r0 F' B; h/ h, Q
19 w& s9 c1 y- d) G& k0 G$ h
0
4 U: A8 U3 T6 c. Y# t8 m. q1: n& ]$ v# D1 \% [# M6 _7 _
1


2 [" q$ z5 d/ d, Z& u-1
/ c1 C4 x7 o. S4 L( I  K0
/ _, y3 ^' Y: U8 e6 R6 G5 V0' q) m  ^, y# s8 a2 J
0


( K- h) J: N2 h: w! P  Y; T  h0
6 O! v7 F  K$ g3 i( n0 _-1" r. e8 U7 \6 m/ d7 p/ M7 }
0
1 o/ |, r8 U$ p9 n2 n0


: l9 D; A2 y( H. l" ?+ e3 z0# e0 G( @- `' D" e: o9 A
0& {# p. J; H, U2 r6 r
-1
; X9 g# ~0 L5 l# F. N, z0


3 r# N" L: I7 Z% c+ z3 w  t0- W* j% G4 N, P8 F, n8 R& g
0
  V" q1 B- R: L- C8 W6 P; t0
0 S6 t, O: q6 V( a' x( E7 w( Q-1

Please input the resource array of the program b(m)_T=[6,12,4,0,0,0,0]'

b =
( v' K$ I+ @5 q6


: w: Q3 m' C) |: p8 a: E12

' w9 |0 L( {! S; j
4

! q3 N9 ]9 {1 g( e& j" k6 [
0


% N9 E- a1 b! c, P' s: ?0


2 r2 ~1 Y% Y0 D$ B! U0

9 u- @7 u( u1 ~, x. l7 S8 y3 \
0

Optimization terminated successfully.

The optimization solution of the programming is:

x =+ u: U2 ?0 B" F( o" H, ?$ i, l
0.0000


/ \  T. [0 O7 I" J: [2.6667

, R' T6 V7 u( s$ k$ R/ i0 k0 M9 C
-0.0000


1 C( ~& p/ D+ E7 N! _# `6 I4.0000

The optimization value of the programming is:

opt_value = -22.6667

: 红色字表示计算机的输出结果.

程序的相关知识:

Solve a linear programming problem

file:///C:/DOCUME~1/ADMINI~1/LOCALS~1/Temp/msohtml1/01/clip_image003.gif

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 **x 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.

2LINDO 程序说明程序名:linear执行实例:

file:///C:/DOCUME~1/ADMINI~1/LOCALS~1/Temp/msohtml1/01/clip_image005.gif

在命令窗口键入以下内容:

max 10x+15y !也可以直接解决min问题

subject to

x<10

y<12

x+2y<16

end* |3 I- j/ M; g$ r2 [
!注释符号; 系统默认为自变量>0, 若不要求用free命令.


9 g4 V, e* b/ q!在出来report windows之前可选择显示对此规划进行灵敏度分析等

solve, reports window中出现以下内容:

LP OPTIMUM FOUND AT STEP
" D  |1 K# ?7 V6 s2 H2


  _5 f" _9 M' l+ V0 ^; YOBJECTIVE FUNCTION VALUE


, c2 \* G3 j1 H6 U1)) l* p* R  {0 X9 I
145.0000

3 `# R6 ?. l+ o, w% k8 L
VARIABLE5 M" c4 X/ |% N- k& U* I
VALUE
9 U* ?7 S3 q* ^3 N: r5 RREDUCED COST

' S9 e4 G" Y' ?5 A. x+ a7 Q8 _3 f
X
- G: }, ]1 G. {% r, g0 d8 o10.0000006 Z3 r. H# v+ q, t0 m9 o
0.000000

* V0 p' s" `4 m* `4 U& a# J
Y$ x' ^  X- a2 u  y0 `" `. r
3.000000
: g/ g8 X/ L6 G0.000000


5 |, x/ u9 O, O. XROW, }  V4 G) e2 C( S) U# b  t5 d4 c7 u3 ^( B
SLACK OR SURPLUS, n( s) v6 j4 ^! N
DUAL PRICES

- k, o4 S, ~) [/ J
2)5 ~9 _( p6 G- h8 a/ f
0.000000
* R( w" F! O' z& r9 a0 {2.500000

! ~2 [7 N2 {* P* S* f- q
3)
  o' O$ r( ?; S6 ]4 t! b9.000000' h3 m. K5 l9 {! ]: i" F
0.000000


; C6 b. ^( |# ]( R8 L4)! s/ C) f" m. W) B% |) K
0.000000. J0 y6 n" n8 d( k& X
7.500000

6 P: h; L8 Y, E0 S$ I4 m
NO. ITERATIONS=
, X1 ?/ G2 u; K2

" Q" l* L4 Y1 O1 {2 Y& x" s2 d
RANGES IN WHICH THE BASIS IS UNCHANGED:


4 _& ^* f( w' @OBJ COEFFICIENT RANGES

+ [' h- S' k$ P7 B1 _
VARIABLE' l% T: M! n0 l0 |$ a: d# X
CURRENT" K4 P8 Q* @+ c9 n* H5 k
ALLOWABLE
/ j) Z$ m  F$ \( r1 DALLOWABLE


; ^2 L* o# r/ O4 r2 Q; zCOEF. A- h/ u$ J1 E
INCREASE
8 H  Z, S* A8 L; q3 t& ]  F6 f! W4 f3 ^DECREASE


, z! D/ M! y/ g2 i1 N* |/ ]X/ |: w0 [9 Q1 b, M/ A" E& U) V( x$ y
10.000000
, k4 \1 i0 L2 e9 FINFINITY) B+ w: Y4 i4 x( U3 `* I9 ]% a0 D
2.500000

* \+ R0 ^6 q9 O) \( g
Y
+ `; @0 k  n8 Q3 J15.000000' D. T6 J0 L7 b2 v" S
5.000000" n1 A/ X7 k  H' Y
15.000000


6 C2 P1 P7 V1 r0 \+ G4 tRIGHTHAND SIDE RANGES


# f* H  F+ g9 _# W# R+ Q8 `ROW) [4 ^  F% z, O. R
CURRENT/ ]! s# f/ r) j5 b4 s. }
ALLOWABLE
  X) s/ s" f; l2 NALLOWABLE


$ o. Y  @& F8 F/ _" d) URHS; g, W+ K/ X. {
INCREASE
0 w* Z* j5 Q% c# k1 b- v( XDECREASE

- w% @2 ~) w& [+ \% f( y
* Z3 q) T8 H# t# [4 X2 w. ^: c
2. x0 c6 O9 f- y4 u6 I. [
10.000000
2 ^* @% ^: Y# p! ^% b7 ]& _* N& V6.000000
* L( H5 \1 _8 X6 g1 F10.000000


$ B7 b/ O, e1 H2 C3
- m+ w( Z# q  g12.0000007 C! f4 j8 K. v6 k& `
INFINITY
, i8 Y# r" F# {0 ], s$ R5 s9.000000


- E/ O3 j8 C; t1 z7 r, L4* x  `% v/ V% G; u2 j. W0 ~$ |- [1 H6 S
16.000000
$ ^5 q! [& D2 h' h) X* f2 P18.000000
4 |; J6 {. w. e1 O6.000000

3LINGO 程序说明3.1 程序名: linearp1(求极小问题)linearp1运行实例:

file:///C:/DOCUME~1/ADMINI~1/LOCALS~1/Temp/msohtml1/01/clip_image007.gif

model window中输入以下语句:

min=5*x1+21*x3;

x1-x2+6*x3-x4=2;

x1+x2+2*x3-x5=1;

按运行按钮在solution
* ^# O! Y& h) v( S- G4 J6 t- z% X' B* }report
窗口得到以下结果:


; `( X  m0 ?, E! }3 G9 u% U
Global optimal solution found at iteration:9 J$ ~! S% \9 I6 I! u* f
2

% L) P" }" a7 z# r1 ^' s
Objective value:) p, S* H- `" ^" S) b
7.750000

+ W$ ]$ t+ f3 @& |
Variable! o' [' P( M6 x2 w& _: t5 J
Value) p9 k; w, f6 A1 k. E$ `: w4 ~5 N
Reduced Cost

+ p+ h: @% y$ [' _4 g' ~
X1
! @3 ^/ g( x7 {; u- }8 q0.5000000
$ g- X8 i3 ~" ?. r1 K& K0.000000


% v2 f* Y3 T% ^7 V4 UX3
/ m8 h$ I2 q5 _) N/ N0.25000009 @0 Y; I- ]) w' C' n! o8 M% ]9 y
0.000000

* }# L. a$ @  S6 w2 [6 Q

8 b; @+ X' k- S. R1 s! EX20 W! i+ F$ }6 `6 z) ^% v& H
0.000000
& {1 b4 h% E3 Q7 F5 T% A3 p0.5000000

  L1 c! u# [0 F
X4
& Q# d( }* N( d% H' A0.000000* _  |3 @) z# Z/ p
2.750000


1 ~; Q4 U- N/ _; b* u. zX5  Y+ x2 \) D& Z4 D
0.000000
- H$ A6 {5 _* a* }( W2.250000


& q9 ^; W; c( b8 ], R6 DRow
( C+ g4 ?9 o; ]+ m0 qSlack or Surplus+ K/ k7 f7 p. M  l
Dual Price

: y7 M- l4 N+ V0 M1 [$ @7 I
1
3 p6 W0 \0 n3 z- \# t9 l4 D' O7 ~7.750000& m- O6 Y& e+ q! p! [6 Z$ o& x
-1.000000


8 y4 _4 `$ a- c2% Y, c( q) K+ T) M: G/ V, j
0.000000
8 d  r. t) r/ D' Z( J-2.750000


: h' o: o$ D' R/ [& r3* Z$ a. O6 V7 d- p
0.000000
7 _% J' ?- f0 {, r-2.250000

3.2 程序名: linearp2(求极大问题)linearp2运行实例:

file:///C:/DOCUME~1/ADMINI~1/LOCALS~1/Temp/msohtml1/01/clip_image009.gif

model window中输入以下语句:

max=100*x+150*y;- h7 r& Z- W  @6 Y# \8 h' ^
! this is a commnent;

x<=100;

y<=120;

x+2*y<=160;

按运行按钮在solution report 窗口得到以下结果:

  Global optimal solution found at iteration:
8 Y4 s* G. z4 b1 E2


2 w; F! [* a9 i4 _( N5 D, vObjective value:
, R. y: F  a! g, s9 U- k3 ]  y; T  R( I
14500.00

* v( X. }: J9 H! s
Variable1 w0 }' f* k: K9 H' y* k7 `
Value- u+ S4 z! h) l2 B- S3 I+ e/ @
Reduced Cost


$ [/ Y( h5 U- e5 Y$ uX
0 C3 L7 N0 T: R, d# n3 g" j0 }100.00001 P0 u5 j3 O1 N# {/ D$ b
0.000000

+ n+ V- c7 ?0 {8 M) x3 U
Y
$ q# ~  k7 W, G7 K* b30.00000
3 ~% T5 ?7 d. V0.000000

1 T* U0 G7 ~6 g- y# P. O5 x( K+ w
Row1 R' c* s  i* [8 l2 D3 E; d
Slack or Surplus
5 k) e2 u0 Z* z3 m/ b& o: P) VDual Price

. Q2 C& l5 m* I' g; ^
1
( T* Z0 X- ?' O3 z0 ^( Y14500.00  C; g+ k  w7 Z" f
1.000000


7 j+ [2 g6 S7 Z0 @. N1 ]! q1 z2
  s/ C5 s, o/ J+ M$ }; K0.000000
* ^* `6 o  r" S+ \- M25.00000

% r, u" ?* p/ i7 {; n! n
3
0 B9 x, L6 t. ~; l) {90.000000 p6 j; T6 n# n4 \  s3 L9 v
0.000000

4
! z; n0 c9 P& J0.000000
8 G2 E- n( L2 l3 J& q$ z* k; o1 r5 D2 @
75.00000

第二章 线性规划.doc

62.5 KB, 下载次数: 14, 下载积分: 体力 -2 点


作者: loooog12    时间: 2010-7-28 14:27
先下下来看看




欢迎光临 数学建模社区-数学中国 (http://www.madio.net/) Powered by Discuz! X2.5