数学建模社区-数学中国

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

作者: 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 =( p) P0 Z- z  u3 P" z  @
-2

3 p5 b' i  J! `  ~$ R- ~9 b
-1

5 G7 V6 U; ^7 x3 |
3


1 O3 k9 ~- F( c4 b# X) u" c' B-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 [/ r/ A2 z5 Y( M" E% f, C0 n
1; d6 @/ y7 C6 t1 c$ ~- S/ r
22 X: K& E$ F9 m0 f& Z$ H
4
" f# U  G; N! H# L2 p-1

# W& X# C0 K: N0 \  Y+ X
2
6 |6 J9 f# l' c3' j( u, ~  @3 i$ h  h6 _: |7 |
-1  @& ~' E/ L' H1 B: x% [2 G9 B+ p
1

8 ^! Z3 N7 g! e* c5 H/ p" Z8 M& P
1
- V3 A) i0 S$ D% X% M7 k08 _$ g: V+ }% K% p
1
& _/ I* h2 X  Q1 ^1

/ q4 D) g) H- G2 K; b$ @$ {
-1
+ f2 z# d- [$ d  h' c0
& T7 X$ l' w* k8 Z7 m' B0
2 w$ I7 h- i1 A0


2 S; `$ ^% {7 @) a; c0
4 l" O, e4 e$ {. {9 z-1- b4 u0 S; a/ B) p* t0 s2 }+ |
0
4 ^2 g9 b8 U- N+ \: V0


  p7 l; g" P  p1 O2 ?0
7 f) }( F+ R" i: @0
0 z% ~& P: O4 q# G-1
5 T+ c7 }0 K, Q( H, W! G0

# }: N' T' I" W/ I
0; k, O3 r" b' u3 M% L3 e2 e2 \
0& A" e4 G9 r& P
0
5 Q0 |8 f) r& O  v-1

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

b =+ ]; N. V9 x6 K7 r
6


9 Z6 y4 [5 w+ n6 \7 {12

3 m% _4 `5 I% D: A; x1 L
4

! N7 g; m& P; q, p& R7 A2 A
0

% g5 k$ w% o: ?) o. E3 y. R
0

- b4 |! I7 M! c  h! ~- y$ Q
0

! d- A: ~, g: T3 G
0

Optimization terminated successfully.

The optimization solution of the programming is:

x =
  S( H) I& i  E0.0000

2 K: |+ g* Q+ {- p
2.6667

6 r! @; e- s6 }, S) T9 d1 H3 f* k: X
-0.0000

- t# k. U6 e% b2 V( S' ^+ d
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

end
% h/ m0 T! n: ]. i& L. v% W) c' \!注释符号; 系统默认为自变量>0, 若不要求用free命令.


1 o2 P6 K# \/ Q) A; P9 E+ d!在出来report windows之前可选择显示对此规划进行灵敏度分析等

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

LP OPTIMUM FOUND AT STEP
' r) i4 t5 R8 o) b  [2


6 m. h# [" {$ p2 p2 L" v& `: hOBJECTIVE FUNCTION VALUE

9 @. q% n% i* m" d( _
1)# y* h) O. \6 h* u& D2 G; y
145.0000


  C7 l+ ?- o, _" W& UVARIABLE: |5 @: w4 n. [+ w- o8 |- L2 a2 M
VALUE4 Z4 J- Q* q6 x# [1 V% O
REDUCED COST

& h3 z' b& a! o1 P! K
X5 V% ]  `% D& N' O3 Z: z
10.000000
# l& H' b# m" q( l; c0.000000


- a: s  z) z  g2 @# ?1 m! f' k- k! PY0 j3 c+ Q, j! |5 X2 }
3.000000; m4 X- Q# f! l, [- L
0.000000


! C9 w2 |* ^7 w6 x9 t5 T& UROW
+ p& j% ]4 u: @1 D& u# wSLACK OR SURPLUS
( ]5 i$ R4 }7 d  RDUAL PRICES


' D) T! ~4 g# l) a  a  O2)
+ D% K# r5 A  y0.000000  L* f* r3 V2 `" j$ ]
2.500000


& C- T8 j+ {3 K3). t- A6 K* `5 k) o! D
9.000000
3 H  h# B" S: ]0.000000

3 L3 O; G- }- i
4)
0 ~# M9 e1 ^, i1 ~4 ^0.0000007 g# C$ a2 z# K
7.500000


9 m4 k4 s9 {" ?8 r7 d! z0 YNO. ITERATIONS=
; a9 t% ^: y) V& \, T9 j, S2


8 R1 L$ p3 Y& m: BRANGES IN WHICH THE BASIS IS UNCHANGED:


9 N! f& F; M5 @* m" |OBJ COEFFICIENT RANGES

/ i7 n) [; @: ]8 N8 C/ J
VARIABLE
) h( z% v8 @8 S0 C1 n1 cCURRENT
1 A: H4 ^* o$ F$ ~ALLOWABLE, H# K: p% j: ]9 i) o7 B, d
ALLOWABLE

4 q3 B: ~. C3 w$ E$ ~& A/ ?
COEF
# s+ @+ s9 H; w1 mINCREASE  U( i6 ~9 x% a' e& p* I1 m6 ~. Q
DECREASE


9 `, @1 T& x7 u3 ]2 e4 q3 O" fX- ?, m* P3 [4 l( q2 n8 q5 V
10.000000
2 v3 {7 s+ w7 [! l+ o- Z2 IINFINITY  y# A) F; ^1 a6 B9 j
2.500000


# r0 A, r+ r$ ?) @Y
0 S  a3 H$ @( u8 C6 T  C/ d* c' f4 W15.000000
3 y8 ^; u1 u; s0 h3 \5.000000* ^1 W$ L5 p/ t! V" R
15.000000

( C1 d3 j' ~& ~2 Z5 W- `6 I, o/ `
RIGHTHAND SIDE RANGES


  [' n9 @# x0 \' ]. _9 IROW2 C  o3 a5 F  y4 S
CURRENT
  d& w% }% y0 v3 {) T! BALLOWABLE$ D% n- E, [8 x" T' o( g
ALLOWABLE


5 B; L8 f; n+ V+ \; \" q2 LRHS
- a7 V5 h8 [9 o+ C5 CINCREASE- x/ W% {6 M  A$ X  i
DECREASE


4 R. i# c8 L5 d
- h: h+ R1 E0 l- k; Q, S+ P8 t6 d26 O; d# r" F7 L2 [# F
10.0000006 e: i0 W: L% W" T
6.000000
% j6 [: k! y2 L( J& p* Q  M) m10.000000


, x. L3 S% s8 T& r! a& K! G3
8 I% x- ]8 I- s12.000000" o# G5 [- X$ D% u% |7 Z
INFINITY, _/ d  f9 ~  k3 N: B% p
9.000000


0 s0 q, z9 q! g6 O4) K8 t2 I/ W: W6 [+ F% o8 ^7 V" \6 y
16.0000008 ~+ S$ y9 W' n) L3 J* E8 C
18.000000
6 @8 [/ [4 E4 x6.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' r0 M! u1 v' a
report
窗口得到以下结果:


4 ]1 L; ?7 a# t
Global optimal solution found at iteration:3 t, B6 O* P# @+ ]; v8 g- ~7 [
2

' V$ \7 L' }3 t5 f) a
Objective value:8 o0 |( C% `# q5 z
7.750000


% n. n" d, J+ u- H. Z" lVariable, V& M3 w' d) T- R/ C1 Q
Value% y7 G" O8 L( E' z
Reduced Cost

+ W6 B" `; E4 K6 _) U- p
X17 f! U/ f7 D7 \6 h4 g  b$ J
0.5000000' t5 n$ e2 ]/ J1 P
0.000000

+ z+ O( q( m! e3 A: H% _3 h
X35 b) Q1 i! S5 a( @
0.2500000& L* r5 j- f+ e, j: Q7 [
0.000000


) `8 A: J6 y8 d
/ N  k5 s$ k+ o  G- n  c( \X2( I$ a( {0 n  u  c( J0 a/ F, e
0.000000. F3 [* h! o# N: y
0.5000000

* x5 E0 Q; D. T( ]8 O* Q( B
X4* j: A2 U3 R6 y; a4 c/ F
0.0000002 R9 A" @6 h7 f4 A( B! L) h
2.750000


7 W3 i# b3 t( i6 }  ]  q2 y/ rX5
; N' q2 F4 `2 p  z0.0000002 H# h2 n# T: B/ @$ q; o3 ^
2.250000


( @% `5 B; g- o$ T0 F5 kRow
( @& A8 x/ e5 e4 U! }  d5 RSlack or Surplus, M. L1 i+ _  d& F# q
Dual Price


" t# a6 g" e5 M) F1) U" A! E  j7 t, q5 M0 k# P
7.750000
& x# ^3 g4 ~3 h, |; d$ R-1.000000


; C- A8 ]% r8 |# Q% B& \8 u2
) F: U% @$ R6 u2 f0 ?0.000000
+ [/ V2 G( ?0 f-2.750000

1 t/ d( A" B1 F. }! k- c
39 q, H+ s8 k9 l! i1 G- j4 S
0.000000
6 I. G' H$ T. \4 z9 g' k-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;
1 `# e2 v' o/ V( o/ x  v0 p# E, W! this is a commnent;

x<=100;

y<=120;

x+2*y<=160;

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

  Global optimal solution found at iteration:& o  n, w7 z* B  _# z; G( x
2


8 t. O+ h  K5 a+ G7 P9 @# UObjective value:
2 R/ Z" @9 D; ~1 X/ Q1 }
2 R# M/ y. m1 Y/ Z14500.00

0 V# X. i: ^* [4 t4 s
Variable) Y1 T" b, ]' H2 `$ i' I. _6 z
Value
/ N, ~9 l$ y2 k5 gReduced Cost

4 H8 Y* T' E! b  v$ \6 ?: T& x" @% _4 U
X
7 ^. }: V/ W0 B* A- {100.0000
4 ?) r( G2 y: f2 M: K) R0.000000


& Y1 y: G3 [# DY5 a) A- t) Q: `8 I3 ^" F: Z
30.00000
; o; D9 ~; P4 [: T, P; _0.000000

! e% m" D% n2 M
Row
1 f  I. a; x0 Q( ~( c# `! LSlack or Surplus
% I" `6 m% h' ~" Y' h& M7 j5 k) QDual Price

/ R# s4 k  W, A5 O: @
1+ I) ~0 m) ~+ _# B1 V% {6 g; H
14500.00
7 R5 R9 a9 k) q4 e% q1 T, X1.000000


; O5 R! O/ _. O1 i5 k6 J2 k) n2
, M6 A" |( h; S. Z: b& [4 T0.000000# Y# a3 n0 J" w% B3 n0 G
25.00000


& j- q$ {  v9 w! A; {4 d3
3 O9 V. k; Z$ A2 \1 e6 P90.00000
* [& b: @/ I; C: p) M/ ~  S& t0.000000

4" K# [4 F0 b4 v) }% h
0.000000/ Q( K: i# Y( e! v# v0 R* B) g
4 r9 O. |7 S/ c' c: e8 x; ^
75.00000

第二章 线性规划.doc

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


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




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