数学建模社区-数学中国

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

作者: 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 =
/ Y3 w. \- ^0 C8 P-2


% X7 s' [, e# V0 O2 }! l. N; `) c; t-1

/ V+ _( z: y+ P% ]6 @: k
3

- T3 V7 i" h! u; _
-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 =& T6 M% j3 T# n: l- {: }' w6 h0 Q
1' B% O* p, Q: R
20 J; j7 ~8 ^$ ]! L2 Y3 h
4
, T) M- r  i1 j6 O-1

) w: H% W; c% d" ?( W  M7 r( ]
21 c% }0 j! T: @. p
3, E* T, L6 I' o9 [, W
-1: H: L% w) z7 E; B
1

/ T: H5 Y, }' l
1
- l' O% A. t1 l0 a0
8 S: `1 @, n8 ?9 P1; w; j" w3 R5 P
1


# Z: j8 x( e5 J1 J" n, d* Z-1" S4 z0 q! C- o* i; Z- a* @$ F
03 V2 [* p6 {( o: o8 a' x
0' O5 O9 O: r9 v+ F( {
0

/ U7 K* U) A9 g% ^
0; c* ^4 h% J' K+ _4 V
-1
% k# v, K4 d, F. k. \! Z1 y0
! Q: q2 y! [, u: G1 I2 t8 t* R* D0

& U& {3 k. e& L8 l
0
0 w" \1 n8 I2 H8 M" |2 W3 F$ }0
7 o; a* {5 d1 i-1
" m$ d! N7 x; G6 u* Z$ u0


* A5 m" @/ z- j; k2 y2 z: L) h0  `/ D1 p$ x  C% b* R: Y
0( R6 x, j, r  z
0/ {, H$ b7 j: `" N+ j
-1

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

b =
9 W2 t+ I& \% P3 j, F6


7 t7 s" a4 G  W6 q; U9 J& |* z5 L12

9 x0 Q3 q2 K- [8 E1 u; m; p
4


) G6 L% i- z7 ^+ {$ f2 M0

' a% o/ y- P' I" Y
0

( K! }  l2 n0 M0 q5 m; b4 H
0

6 S+ C' h( Q! q, M$ [* C
0

Optimization terminated successfully.

The optimization solution of the programming is:

x =
4 v7 w7 F4 Y2 q9 T  o0.0000

0 V% X) J( h0 T1 B! N" B
2.6667


5 {9 Z. g8 l! E% n0 w-0.0000

9 V0 F: {: G8 O# }, a$ Q
4.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

end7 [' H, a7 ~) _' |# l5 l' x2 B
!注释符号; 系统默认为自变量>0, 若不要求用free命令.

2 R6 Q( g, j9 @2 h) S# t
!在出来report windows之前可选择显示对此规划进行灵敏度分析等

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

LP OPTIMUM FOUND AT STEP! y- y' [5 R, ]% r7 x
2

( m  ~) Z/ Z; f& n0 z9 x: H/ b
OBJECTIVE FUNCTION VALUE


# C% n7 W2 t4 ?1)) r4 ~9 @+ T2 v1 V7 E4 V! j0 S4 q) |$ |
145.0000


5 k1 x! t/ r4 zVARIABLE
. N/ a$ H8 E( g" ?+ {0 zVALUE
( w1 F; j2 j9 W# q# O4 c4 bREDUCED COST


0 b$ G( l$ ]7 E5 X! c/ c9 ^8 F+ \X8 L" V+ Y. C! l8 h7 H' ]9 E
10.000000
( P( K) r  Q8 ?1 h# D0.000000

, }" I- ]0 w, K7 l: J
Y
' ^/ L! O* K4 X( X3.000000# @& L6 P: v/ Z* V1 J
0.000000


' x! T! I4 Z8 m  PROW; \- V3 b% C& G
SLACK OR SURPLUS
( ]1 v. M5 P; ]! y! t* q5 q. q5 ^DUAL PRICES


. b3 O% H' K8 ]! ^& c' Y2 O2)
: W# y$ p$ H; L8 u# B( ]8 `0.000000
% m0 s9 a5 M) \2.500000


8 G/ C. e4 f7 j- I+ l4 m3)
' b; t1 r, o& {9.000000* }1 c3 \5 h* L3 G8 `
0.000000


  e) Y1 v+ g! q( a4 z1 A4)* g4 p7 o% |& u; H
0.000000: f2 ?. P0 t' G
7.500000

  Y, H5 F0 X6 J/ r. F
NO. ITERATIONS=, a- e+ k- j! H  ^! z& u
2


# _; L) ?/ s( S/ z/ `RANGES IN WHICH THE BASIS IS UNCHANGED:

, q/ @. @3 c: {3 q% M
OBJ COEFFICIENT RANGES


& u# w3 e+ g+ ~VARIABLE
7 i. d+ [5 [( b% ^) @. gCURRENT
% X! u" m, z. _! {2 z" @9 XALLOWABLE
; M$ ~  t9 o. {! V( @ALLOWABLE


3 }2 T, O) V: k. oCOEF
0 Q7 {: u  Q  T% _INCREASE
, K* N* Q: r; M+ e  HDECREASE


! W) c. X' H/ {6 ^  X  p- A. f4 MX* E7 f* L: z3 |7 }; d( k) v
10.000000
8 E9 c# V+ J$ c5 o: i1 TINFINITY& a1 c! ~$ F$ }) p; e" N5 z) P
2.500000

2 f$ Q* A8 e& f* y9 G
Y
) I+ t" y( W( C! T. t( X15.0000001 [" Y* x& @- L7 i. H
5.0000003 O9 P3 _" n8 P/ S
15.000000


5 @) M0 S2 d; D$ n% ~# |RIGHTHAND SIDE RANGES


! X" _  O' p" \ROW( B7 j( l1 r) A. }, _  B: W
CURRENT
9 S8 y; t3 p8 C" {3 nALLOWABLE
5 w2 t/ l6 L! T! kALLOWABLE

7 g: L, c* z! _: |9 |) Y1 m$ Z
RHS
% c  F0 Y1 b+ ~: hINCREASE7 S" n& P- G! u
DECREASE


; h  L. I* m9 v: L3 [6 m& J4 d$ |
2, x% k7 i: U5 d6 w. @
10.000000/ z: i% E6 w3 \7 N# x$ z4 [4 \
6.000000; o2 Q0 ?8 i& ~' ]
10.000000

: \# f7 n( e# _9 q' [
3
6 a7 T2 U/ w1 a9 H! L12.000000( j4 f4 J& X, {& h0 D# G
INFINITY
. Z. F3 {; e- c. e, `! z0 q9 v9.000000

' A& |4 g" G' H, m. z
4# g  {5 }" c/ p$ b
16.000000
" g% D0 h& g* i: E3 b+ G18.0000000 z1 m2 O) p5 x2 c* g
6.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
. {9 c+ J+ M8 e: b- Z0 ]! Ireport
窗口得到以下结果:

2 r; s! d/ x* o, A2 o7 Q/ ^4 ^0 M( v. N
Global optimal solution found at iteration:! ~) C# ^. @/ z  U
2


4 ^( ^9 L' E% B1 S: i5 pObjective value:
) ~' j: i9 f  _2 d1 H, D6 H; u7.750000

/ g  q, @$ f* ?2 W% d7 q# S
Variable
" _" Z8 P; Z: c. z5 HValue* ~; |1 Y, C) x
Reduced Cost


) R" m( M$ G5 o" a) Q" G* \# OX1& M& P9 m' H9 O3 B3 j% y
0.5000000
7 L/ R1 r' Z# J$ P0.000000


  m: y% e. v$ FX3
" x$ m8 }4 L* S# P% m. p0.2500000' P5 X) u. e+ H& w/ H
0.000000

$ O; M9 l6 d6 _4 J( |

, j% |! m! \' A- n5 Y7 v$ I/ I0 \X2
8 R2 W: Z) ]4 {! x7 [2 `0.000000
' ?" V* g2 ?* N4 E0.5000000

: b# U& P, a7 D
X46 [* ]  z; x  l& f. w: K
0.0000004 x6 t+ h7 Y, T( o/ A* y; q
2.750000


& N) q, w4 b$ b& M1 ]6 m8 JX5
3 d. h% G, q* ?" Q- P2 P3 @0.000000; D8 v% m9 m/ C- a
2.250000


* F+ s. W; |9 ^* ~% D9 VRow
; d5 W( ]& s. ?6 S7 DSlack or Surplus! ]- M) `+ \& F1 `
Dual Price


% Y6 c+ n; K. S8 ~1
; _- A* b' r# R# g0 Q7.750000  P, `: L( L. t5 _& \3 ?
-1.000000

7 T! o7 s- O0 ?& M4 J! @0 {$ N
2
$ h! T% W( _% c7 v0.000000: ^, W( P: Z9 g- [+ t
-2.750000

0 e# C2 k: E5 c. s9 f
35 j9 I9 s7 G. d* O7 x3 |; L4 [
0.0000007 ^& D4 e+ |$ [0 k9 |
-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;8 z# l0 m0 X2 }
! this is a commnent;

x<=100;

y<=120;

x+2*y<=160;

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

  Global optimal solution found at iteration:
3 _8 U2 `1 I/ c! C, r2 {2

8 [5 P( ~; _% X: P
Objective value:; N! ?' c1 g; t) o- ~9 T3 }1 d
6 d" F2 v8 S: _- B, X$ U3 j. M
14500.00


& D( C" O* }, k  `4 d: Y; xVariable
1 x2 l' z. e" P, Y% K: X% k2 r# kValue
+ t; _+ k. ?8 s3 R- a/ GReduced Cost

8 e+ x# g; r$ \+ ]
X
& Y) ]; b* ~- b& z7 @0 k% `, \100.0000" \9 Z8 O4 S8 K- U$ G  b" _1 \
0.000000

; t* }& A0 L# w
Y) G- Z* w; C% ]8 X3 Z# F  g
30.000008 k6 ]' U' R9 i
0.000000


- a" J/ Z7 j% m& P& \Row
' J. D' Y' }% H6 X8 [Slack or Surplus# s0 V( }1 X$ N0 J; S4 [, [' F
Dual Price


3 ]. |! `# K, g  E% b5 x4 T1
" Q- y  G5 T+ @2 ~, x3 [14500.00. ]- E* W; T, g" B
1.000000

% \3 p: W! _8 X3 W2 ]5 ^
2* u( ^1 v! ^0 y% B% e% Y
0.000000
: n1 P' [/ l1 r# i) u' p1 d25.00000


- _8 ^6 O  i( ^7 T/ _3
- h# H& f8 a. O& i  \& [) Q90.00000
0 r0 V; i8 }  p6 M0.000000

4
2 H& \9 |8 e; Q0.000000
4 j, Q: H1 H! y4 N4 c/ z: ~6 Z* {9 m& S9 D1 W8 R
75.00000

第二章 线性规划.doc

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


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




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