数学建模社区-数学中国

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

作者: 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 =
- w7 ^! ^8 v. \  X' I-2

" G/ M6 X: |' ?: w
-1


9 y* O* a8 P1 p7 w0 y) z! k3


* v, P. W* ?  r* M$ `6 P4 S, A-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 =
9 H$ V9 @$ v* H0 a- }  C1; P) V6 d) q0 Q4 R) {- ?& C) a4 J8 L
2% o$ m  M8 x& i: C  b, k; R8 G/ [" h
4% N# d- O  q7 Q4 E  l. T
-1


) n  T& W, e% c3 ?9 B3 c2* Q6 a& C* |1 Y! ?: M
39 k) |$ [4 Z7 Z7 `. L- m
-14 J9 L  A+ Z+ G
1

+ _) Q  |' a  n
1' I. [. e* M! M; g$ {' ~
0  D' I% {6 w8 l9 E
1
( L% K+ ^. j- q, Y/ Q1

8 r; I( I- q$ f+ v# C
-1
% L* B/ y4 T" q0+ F# y* A/ `' W; [, f# h! g
0' w# T* K/ o2 P: ^. w5 T2 H! O; b
0


% R& c) V, }4 y0 U/ C07 z6 U2 J" u& ]* D- ~
-19 n: M5 j) p; b+ X3 b
0
" d6 f! x) J) j1 L6 Z6 j7 s$ t0


# d: V7 F' O; I. t; }, ?0
' @" ]5 m6 A2 h" p+ z0 t0
6 O; f, S# G0 G( o( d. C" L7 V-1
* M* H( n8 K8 Z" b' i0

! W( Z( d$ k! j/ J* s
0% l, {7 Q7 ?1 A1 ~7 I
0% n/ z$ |: B: b, P( {3 ]- O& l
0+ {3 r0 N6 o; v  N5 R; b
-1

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

b =. F/ }: ~& V2 [, l4 x
6

+ v# @9 i6 k% }4 V1 K! e) c5 Z
12


# M3 @2 L; W$ e  ~# ~+ C* a4

; j0 d6 X; z: s% N  J# {, `# Z
0

) `0 o% e1 V8 f
0


# q/ X! G1 t! q+ M$ k" F) B0

2 s5 ]# m4 O' M3 g0 r
0

Optimization terminated successfully.

The optimization solution of the programming is:

x =& I5 n/ ?- ^5 b4 G& k3 j, s
0.0000

- i8 f  n% x' G) R0 Z/ f6 k9 ]4 }
2.6667

; i9 J+ _* k- `; p/ G  ?5 s( H
-0.0000


6 c( Z$ P8 B5 M6 F# w  [9 g4.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) F0 k, ]# m) \- p+ V5 A( E1 |
!注释符号; 系统默认为自变量>0, 若不要求用free命令.


) W3 Z+ ]: G  p: z!在出来report windows之前可选择显示对此规划进行灵敏度分析等

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

LP OPTIMUM FOUND AT STEP% z; v3 T2 ?8 r
2


% P6 e8 k/ r# I' E! q& @OBJECTIVE FUNCTION VALUE


6 {4 s5 Z2 d( P( M1)8 _! R1 [" ^6 b: r  w4 C
145.0000


7 G# [0 r% N, p" _* O& o0 L& j% uVARIABLE0 a$ l  t! Q6 @+ g, _8 m) t$ b
VALUE
5 U% }4 O. b4 ]( ~5 pREDUCED COST

& c& W0 T) [0 @
X
) |# T( q/ k/ z% p4 n- G! h- T10.000000
  n+ t3 X. V0 A2 p2 {1 r: H- ^+ ]0.000000


- w2 u: n/ U( i0 rY. r3 `- r2 `. T3 c' P" a/ s' j
3.000000
/ A' ]. ^% o1 M% J3 z$ {0.000000

$ A# L8 `# n* v2 I* ^5 h$ ^
ROW
$ k: K1 B3 r4 s% X: l* `, vSLACK OR SURPLUS9 v3 |# n+ v# O! m; P
DUAL PRICES

( c: c( [2 s, J$ Q( W$ s7 R# \
2)
5 ~  E0 z4 A+ z. }8 L# ?0.0000000 k; |2 O) Z: @$ q0 R) d+ ]& u2 [
2.500000


! H$ j* {* _' a5 ~3)
$ F" q  u2 t" b0 G/ R4 v9 w7 ]& P# y9.0000001 i( K! Z) G3 m# s
0.000000

  l0 Z5 R) F; q6 F
4)8 c! v" d/ U4 y, `
0.000000* ~( u. y) }: s
7.500000


9 n! z+ f* N( G; h- ^) vNO. ITERATIONS=6 m" U2 s7 @. h# C; Z
2

" p7 \+ s' G2 D- D0 }- a# U- n3 J! t- s
RANGES IN WHICH THE BASIS IS UNCHANGED:


. ]$ v! p& t: b8 mOBJ COEFFICIENT RANGES


7 d$ R: k7 n9 K% s2 m9 \VARIABLE3 e  ?8 ], _6 Z
CURRENT& x% h1 v9 o6 Y" F3 W+ \
ALLOWABLE
1 I3 N- Y" v0 p9 M0 q+ \% JALLOWABLE


5 @6 T3 X# T% }( hCOEF
( ?2 j3 E4 i7 z$ AINCREASE2 R6 [8 V: u, w+ n! ~! k- j
DECREASE

! B" o; f3 z& B. p8 A8 U) s9 J' N
X
2 q3 \: R7 x  P: G7 z9 I) U6 _6 k10.0000000 Q3 e" K, j6 j) N
INFINITY
* f% s+ w* z0 T" U2.500000

/ t: x& \/ H9 N
Y+ L: z  ~( W% [. ^
15.000000  M7 o" w/ O# I8 o$ q
5.000000
. I$ a, J% J; f15.000000

, T& B/ g4 t3 }4 {% G, Z+ b) B
RIGHTHAND SIDE RANGES

# Y! l' N. l: {. W! u
ROW
+ _& l% x3 S2 b" T) yCURRENT5 G8 [9 j# O! m( @" P+ M% k% l. s4 i
ALLOWABLE
4 S4 J9 k! s+ Q9 s& y& [2 CALLOWABLE

  n/ J7 u! X7 Y7 k) h
RHS5 o4 U) {: r3 A; n. ~# N! ~8 y% M
INCREASE9 v2 }9 j3 `: G8 s
DECREASE

/ I( z; ?" p  U! L% ?4 Q

/ [5 X5 P1 ^/ v  `3 Q2
0 L" I# Y7 P$ N8 F( c% U10.0000008 o) I& _4 G& T0 ^# e7 Q4 [
6.0000006 O, t) j9 y, x7 }0 A, o* ^
10.000000


/ A, N+ I6 y7 L  O3
& P- I1 z$ A, \. C; R9 A) ^12.0000002 N8 k1 T6 e0 y# E6 ^7 K
INFINITY
  B% w( Z0 k1 t; a) T3 r. r* Y9.000000


6 X2 n* _/ E; {4
. ~! C5 S& a0 l1 i$ [/ K16.000000
5 H( X. e* i) X! q5 c18.000000
$ H. m; D9 R$ E. \* a6.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  r2 A$ A* R: T5 `0 b
report
窗口得到以下结果:

( T* b* u0 {2 e& a8 k, M7 F
Global optimal solution found at iteration:1 g4 T. Z! h# q+ }) E
2


# }$ z  K' l' U; l" \6 }Objective value:5 D( D, ^" m! j) G& [
7.750000

$ {* A$ Q5 x( g6 p. M3 S: H  [
Variable5 X) H4 ^( b! R, \) T3 g
Value  d* [0 n' ?2 }; t/ O- w) s
Reduced Cost

4 Z( T; P" M: K$ z: ?( C
X1
6 R7 `3 W, J2 E. B1 T7 `0.5000000
" v" l4 b" W# D0.000000


" n' U: t2 {  t6 s( [% F4 ~& rX3" _" q" y0 }, p5 g4 `* }8 E
0.2500000
5 N) y% v" \& o3 J) s  @( \0.000000


- N& G$ u8 z1 u+ S# l9 B
$ Z) P; }7 |# x2 A2 ]! p4 rX2
' |5 V$ J( G6 M. N0.000000
0 h6 r: d+ T9 k0.5000000

8 V  a* a9 J& x& g  Y1 W1 r* }& {$ p
X4# Y3 a' E3 s( n  M8 v
0.000000
7 u* S- V& r1 Z6 a+ S9 n: }2 N2.750000


- p/ ~. C9 B+ S9 M) r# @X5
* Z+ |0 ?8 I) k0.000000; ?" P! s8 d% ^
2.250000


9 U8 R- K9 k# m* y1 VRow) n: j( y5 {, j+ {3 w! _5 W8 S
Slack or Surplus
! ?; J( v8 K. e9 FDual Price

& p, N/ r( Z- C+ W9 h8 R
1; a6 V% A, ^. ]' I5 z  X: N- ]  H# q
7.750000
( I+ e2 l: y  `+ n3 `" p0 G7 \-1.000000


/ @" @+ T6 V6 |' Y. s( P5 j2
. C8 l5 f, |; [" x3 s  k0.0000006 C! I. O/ m# E' j1 v2 o
-2.750000

+ Q) Q8 B) E. H: Y
3
, r) o- m  D/ w0.0000008 c/ F$ b( M/ u, d7 n/ e
-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;
$ E% h: ?4 L; }! this is a commnent;

x<=100;

y<=120;

x+2*y<=160;

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

  Global optimal solution found at iteration:& ?2 a$ p; n3 Y+ {* S% _
2


" p/ T0 a% @: t. m( U0 cObjective value:
1 _, U6 z7 a' p* G) x
# ~' m/ q1 M: H9 N14500.00


; |2 W  x- O1 Y5 A6 I  V$ kVariable
: e0 j1 x/ f5 B1 TValue
' g8 c' O5 Y0 L* n% n; vReduced Cost

, D5 n! U8 K, k1 ]2 R( V- g$ y! U
X
7 N( O4 N, f! n( E' z, N100.0000# ^  F" r( w$ {
0.000000


9 J0 }! c) K- x3 k6 ?0 C6 m; xY
' q+ ?! I0 V7 W1 l7 }6 Y+ D* R30.00000. J4 ?' i3 p. o' x
0.000000


5 b$ h, Q( j) T8 A+ q9 |Row) C7 S( [1 B* D) X# Y( g) x
Slack or Surplus1 F4 R" _8 O/ i1 C6 s
Dual Price

/ y0 L3 h, W. C. h3 I
1
4 m( A- _! J) `9 N, g5 h14500.008 ^3 j7 a0 \8 q
1.000000

, @! N2 x& O, q! g% f
2( m, [+ G+ X8 A" n
0.000000# N9 b  ]' _3 m0 I$ \
25.00000

* O& z0 \7 X- O  k, b* e
3
) T: R; A0 k* ~) t8 `2 p; y6 e90.000001 T6 z: M$ m1 s. M" E
0.000000

4
+ H/ g' N* H+ N; b9 M3 x0.000000- C! Y* F: U/ S

" ]; X; i& I( w75.00000

第二章 线性规划.doc

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


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




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