数学建模社区-数学中国

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

作者: 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 =
$ [4 r1 W0 Y* I( _1 g, J-2


7 S. E! G7 ^9 Q# N-1

; |- {+ s+ m/ f  d8 B" s5 j/ E% Y$ f
3


# L* g4 M: A6 d+ p. Q" ^-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 =
: P2 T* T) p- a8 H$ R) s1
4 i% K0 w/ q7 I$ l0 E1 }2- N: x5 [  M* u! J: `
4
+ f$ U! W1 y5 m-1


  ?* U$ d6 P* N  z/ l2
5 d5 x& I# s( T33 w: u' g$ c3 X1 t% M4 A! K
-19 f3 W) D2 j) C+ B; N
1

3 a" h* e8 h" W1 ?9 x) J( w7 n
1
- D; X. `; J1 j. ^- P6 l02 T9 C) R6 a% a6 i$ Q
1
! w/ V; h& D0 T1

4 f# M( R1 ]+ D- U3 A! Z
-1
# q  e& r% y1 W  V, w00 I( R/ i, I, Z( O2 L. h' N
0$ S( T+ x- b2 b) [& U; F8 q( X
0

! G5 b# b! V1 Z3 Q. p
09 H) d0 B0 p1 z5 m; F9 L" _
-15 |# u! O4 n) U* H6 h
04 }) [& {! B. c  ?
0


9 i6 i8 }1 ~& |& j0
/ ~- s7 ?8 p' K8 Q; m$ f8 M. V0
6 Z* _; g$ D$ U' ^, O-1
7 {' f: Q2 p1 \7 _7 e0

  J/ o0 j- q- x+ z
0, J! }" ^6 F( C( ~% F7 f
06 }# T5 F$ O% C$ _8 L" w
0
  s& i/ }9 R, }8 E& F" w# z-1

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

b =
' C! k. x" X9 s6 x6 s6


, C( Z% j* y0 \& R4 i6 E12


4 g9 h0 @+ V  P# k: e9 `/ V4

% ~, E  p, M8 q8 e/ i( w$ z- I
0

4 b% O7 E2 y' n) c) U  Q# G
0


& r1 ^: c7 A( E) I# j0

8 r2 K6 x3 v5 s# c8 N
0

Optimization terminated successfully.

The optimization solution of the programming is:

x =
* U. z' N! Q, ]. G- b* E( e0.0000


9 I. w: u9 i: r7 B" P5 o9 H( v- ^" ^& x2.6667

5 U% F) r. h  Q& b" U) h. X
-0.0000

% X+ U! y. B4 X0 E8 Q& }( ?' q: r
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% E9 O' w! n. `* a5 M$ f1 r% j
!注释符号; 系统默认为自变量>0, 若不要求用free命令.

& h3 t0 w9 e. b
!在出来report windows之前可选择显示对此规划进行灵敏度分析等

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

LP OPTIMUM FOUND AT STEP! Z- V$ u, R; w
2


# q3 ?* e* `7 w' L& C  t. o4 T6 {OBJECTIVE FUNCTION VALUE


: r- E7 n+ _8 g7 I3 D% |3 Y0 E1)
2 Z, e: q' \6 m+ ~9 V145.0000


7 `  _6 H. ~' p) z9 Y4 ]VARIABLE
  ~  S  Y$ n0 o) VVALUE- E1 l3 N) m6 t& r; B" V0 N1 w
REDUCED COST


' i# J) D) D+ L: Q$ ^6 ~. E2 rX* |% f( H% C5 `9 p: H0 O- _
10.000000
# Q$ l: J: G( w8 J, o% l5 E0.000000

6 L4 ^7 P  d. t2 h9 s% X. ]' x: \
Y
/ x4 n% w+ X! A- j: d3.000000
: z2 \- h8 Y& p- ]4 Q+ ^1 a0.000000

' _) l9 q; _# [" q5 n) Y' }
ROW' r+ O/ O/ |. t# J6 U
SLACK OR SURPLUS
3 U8 \# J0 V8 lDUAL PRICES

& D: v/ J  n! H
2)
. P9 y/ S7 b0 n0 @+ R% ]4 e" B0.000000( w' |+ ^: Q  {
2.500000

3 L: i1 T' _8 z# K
3)6 W) d) T7 e5 \' C* Q8 o0 }2 A) v
9.000000
/ j; E! d2 J- R( m/ c% z0.000000

* {) l" X( i3 o: D+ C- `
4)/ r9 N$ _3 c3 H" _( z5 ~
0.000000
/ z" v* y8 N$ ^3 q7.500000

8 p5 Y  I  Y: q
NO. ITERATIONS=7 h) A1 q$ d" N/ O( C
2


/ v% E3 \7 S2 ^* Q* URANGES IN WHICH THE BASIS IS UNCHANGED:


9 b( o2 A* E2 f- z+ a2 wOBJ COEFFICIENT RANGES

0 N& z- n6 G& s0 Z) j6 B
VARIABLE+ I* f0 u5 b( t6 i1 ?' m2 G
CURRENT
" v1 s$ n2 T' T* T! e* |ALLOWABLE+ w! x  H$ Y+ g' V( @; c  p
ALLOWABLE


9 g2 J, K0 u+ O0 ~2 N2 d$ F' JCOEF5 \8 N, e1 X8 p1 I! y' x1 J+ u
INCREASE5 w/ M" r/ d9 k$ ^; ~; O" K
DECREASE


( c- m( h0 j5 mX
5 L' \+ x" [$ ?! W) j' l; l; Y10.000000) A5 @& }9 |' L8 C
INFINITY/ @4 b( B$ A7 L2 |, t# e* ]# |
2.500000

- X: w4 i5 P7 a1 `  N2 v' o. X
Y( n; o6 e$ t. A; m4 J. v' O# j$ ]# h7 m
15.000000
0 B9 j8 [6 F' P; E& r' [, ~0 R5.000000
0 b! `& l2 v1 x+ L% h15.000000


4 z3 I- ?; |8 JRIGHTHAND SIDE RANGES

, K, O, j, Z2 i* e! @2 r
ROW
+ A% d/ y( a3 m' V2 c+ JCURRENT
, ]2 [+ p( m8 H0 c0 oALLOWABLE
- g9 M& t, U% |ALLOWABLE


2 Y* H) y. P  ~% X/ gRHS' r1 ^# Q3 ^6 z: H6 j" f6 e3 I5 e
INCREASE2 z/ ^" Z# I8 l% X
DECREASE

9 o( l- z  h8 G

; r# u: t/ h- K' ~$ m6 V2. S" L, d' w' k& j1 ~9 ]
10.000000
' M1 M0 m. T9 X0 S7 Y6.000000& H* v& l% ^, s2 X, y9 _) Y
10.000000

! ?* O$ j& x7 W! T5 X% b
3
5 X( `" e5 X5 G12.000000
7 N* Q# a# Y8 WINFINITY$ z: h, y! k, B3 I- M6 H  S
9.000000


9 \5 C- E9 V* q$ P+ z4 e+ d4
' d! k5 b6 q7 m7 t* X16.000000
# N8 i9 i: f: O18.000000
7 T  R( f( ?* y4 f( e6.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
6 Q. L$ o; z) d% t- N/ Sreport
窗口得到以下结果:


: W/ l: v3 v0 G7 W, Q' U0 }! U: X4 P
Global optimal solution found at iteration:
, Z1 l/ Q' |! H2


# t) E6 |0 _' C% q7 y5 m! ~Objective value:( S/ ?4 j- X7 i5 b, X; p
7.750000

* v/ @) g# A& ], j% A
Variable
: Q" P9 d! \* [7 b7 vValue8 z( \3 q; W! F5 T7 w6 l" V
Reduced Cost

/ ]3 ]3 I3 u6 g5 s" j/ J* X
X1  b5 y0 ?& m: s, e5 [1 p5 q3 a
0.50000001 W0 k8 _: n6 J4 u, X9 b5 p! E  P' U
0.000000

8 s1 S% ^, f8 c! K. n* j9 l; I! |
X3
. B( J; ]/ M& A9 }; h0.2500000
, J# `4 p$ j- h8 Z0.000000


& y3 v1 }3 @4 c' n, Y5 t/ k) n' H# O8 b/ u* F  o' L; M
X2
0 R% N4 [% j1 s) Z3 h% m& @0.000000
1 w" f4 q  f( v3 U0.5000000

+ T: p5 p% Q$ n7 E. e
X4% C7 }( l) n; `4 @" V6 g: n4 S2 I& i
0.000000
& q0 R6 _8 V- G  a! E8 P2.750000

; ?- D5 E0 q1 g
X5
! F; ^* X( @: Z! J( F* m; u0.000000
6 ]! c" E- ?) L2.250000

7 C0 W" |2 u+ c) k4 K( f- p
Row6 \7 I4 ^* ^' f: ~, f* m
Slack or Surplus
' ^- v' G8 o6 Y# \Dual Price


4 S/ F( X, H2 _: J; a1 ~! R1 _1
; i3 T8 ]5 b! r! ~4 g4 Z7.750000* X6 @) ~& N( B; ]
-1.000000


* r* [( T/ Y5 P: [2# k# C# Y+ |$ R$ w. R1 U
0.0000009 Z. P4 \9 G. F5 [2 g# V: g8 E
-2.750000


. P8 [; ~, e! c2 ?( B0 X9 h3) O+ |8 I+ L" O+ ?7 x3 B
0.000000
2 ]* ^! i( E: ]2 H0 G# h-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;
  o4 E+ d4 _4 P% ?  v6 J/ J* X  p! this is a commnent;

x<=100;

y<=120;

x+2*y<=160;

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

  Global optimal solution found at iteration:+ y) g  R- P3 l$ d; Y
2

$ L  K1 D9 m: E/ S2 `
Objective value:
3 b) R  T$ ]9 J' N# ?% B9 _2 a. |" @0 D  ?: |/ ~
14500.00


, M4 Z# o1 s) v- zVariable  a8 ^+ O- O4 M
Value5 s6 I) L; g! l0 g( m1 L5 h
Reduced Cost

: p8 T; \& l) K% [
X
( [  q* m- M& X( j% N100.0000
( q! b+ w. k/ U7 M( n  b' ~' g0.000000


. n4 U( v# t+ G; FY
' W9 }5 l7 G7 Y# t/ E/ h5 B. e0 B30.00000* ~: u4 h# o( j* P; o
0.000000


& Q' J( q2 J0 f+ }4 u  yRow0 w! e! C9 Z% O$ [1 u
Slack or Surplus; [7 n, [. [# F6 H0 N& {4 F
Dual Price


$ l) h% k. h- e1
1 g* g0 X% m6 ]0 z14500.00
7 ~8 r' C( C- W: p: y; E: {  U7 c1.000000

6 J0 [$ I8 O" T9 O' v: ?+ Z
2
% e& i0 P0 ^+ w8 o; W2 j0.0000003 }/ ?/ _) l0 z6 l
25.00000


- G9 b+ u# [0 p3 i+ Y3
0 M/ b6 ~0 K! Z90.00000# g7 E5 m; \4 _0 H0 t
0.000000

4
! _2 T+ Q% {( C/ Y' R  B. u( G0.0000001 E- X" U" ]$ `8 G7 e
3 b3 E- l' w, R% u
75.00000

第二章 线性规划.doc

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


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




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