Rで解く最適化問題 線型計画問題編

10,751 views

Published on

0 Comments
11 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
10,751
On SlideShare
0
From Embeds
0
Number of Embeds
3,277
Actions
Shares
0
Downloads
88
Comments
0
Likes
11
Embeds 0
No embeds

No notes for slide
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • Rで解く最適化問題 線型計画問題編

    1. 1. 1
    2. 2. 2
    3. 3. 3
    4. 4. ( / ) ( / ) 4
    5. 5. min. f (x) s. t. x∈Sf XS Xx∈S fx S=∅ S=∅ 5
    6. 6. inf{f (x)|x ∈ S} 6
    7. 7. •• • • •• • •••• 7
    8. 8. 8
    9. 9. X n Rn f S aij , bi , cj (i = 1, · · · , m; j = 1, · · · , n) xj (j = 1, · · · , n) min. c 1 x1 + · · · + c n xn s. t. ai1 x1 + · · · + ain xn ≤ bi (i = 1, · · · , l) ai1 x1 + · · · + ain xn = bi (i = l + 1, · · · , m) 9
    10. 10. aij , bi , cj (i = 1, · · · , m; j = 1, · · · , n)min. c 1 x1 + · · · + c n xns. t. ai1 x1 + · · · + ain xn ≥ bi (i = 1, · · · , m) xj ≥ 0(j = 1, · · · , n)min. cT xs. t. Ax ≥ b x≥0 10
    11. 11. n n n aj xj = b → aj xj ≤ b, aj xj ≥ bj=1 j=1 j=1 n nmax. cj xj → min. − c j xj j=1 j=1 n n a j xj ≤ b → − aj xj ≥ −bj=1 j=1x → x = x1 − x2 , x1 ≥ 0, x2 ≥ 0 11
    12. 12. min. c 1 x1 + · · · + c n xns. t. ai1 x1 + · · · + ain xn = bi (i = 1, · · · , m) xj ≥ 0(j = 1, · · · , n)min. cT xs. t. Ax = b x≥0 12
    13. 13. min. c 1 x1 + · · · + c n xns. t. ai1 x1 + · · · + ain xn ≥ bi (i = 1, · · · , m) xj ≥ 0(j = 1, · · · , n)i xn+iai1 x1 + · · · + ain xn ≥ bi → ai1 x1 + · · · + ain xn − xn+i = bi , xn+i ≥ 0 13
    14. 14. 14
    15. 15. 15
    16. 16. min. cT xs. t. Ax ≥ b x≥0 z = cT x x = (xx+1 , · · · , xn+m )min. zs. t. z = 0 + cT x x = −b + Ax x, x ≥ 0 z z 16
    17. 17. min. cT xs. t. Ax ≥ b x≥0 z = cT x x = (xx+1 , · · · , xn+m )min. zs. t. z = 0 + cT x {n + 1, · · · , n + m} x = −b + Ax x, x ≥ 0 z z 16
    18. 18. z = 0 + cT xx = −b + Ax 17
    19. 19. D B z xs xsDr0 /|Drs | = min{Di0 /|Dis ||Dis < 0, i ∈ B {z}}, Drs < 0 xr r (r, s) 18
    20. 20. D r s Drs = 0D B N D i Di (i = r) r Dr Dis /Drs xs xrDir Dr −1/Drs xs xr DsB ← B {r} ∪ {s} N ← N {r} ∪ {s} 19
    21. 21. z = 0 − 2x1 − x2 − x3x4 = 4 − 2x1 − 2x2 + x3x5 = 4 − 2x1 − 4x3x6 = 1 + 4x1 − 3x2 + x3 (4, 1) z = −4 + x4 + x2 − 2x3x1 = 2 − 1/2x4 − x2 + 1/2x3x5 = 0 + x4 + 2x2 − 5x3x6 = 0 − 2x4 − 7x2 + 3x3 20
    22. 22. min. −2x1 − x2 − x3s. t. −2x1 − 2x2 + x3 ≥ −4 −2x1 − 4x3 ≥ −4 4x1 − 3x2 + x3 ≥ −1 x1 ≥ 0, x2 ≥ 0, x3 ≥ 0 x4 , x5 , x6 z = 0 − 2x1 − x2 − x3x4 = 4 − 2x1 − 2x2 + x3x5 = 4 − 2x1 − 4x3x6 = 1 + 4x1 − 3x2 + x3(x1 , x2 , x3 , x4 , x5 , x6 , z) = (0, 0, 0, 4, 4, 1, 0) 21
    23. 23. x1 = 1 x4 = 2, x5 = 2, x6 = 5, z = −2x1 = 2 x4 = 0, x5 = 0, x6 = 9, z = −4x1 = 3 x4 = −2, x5 = −2, x6 = 13, z = −6 x1 2(x1 , x2 , x3 , x4 , x5 , x6 , z) = (2, 0, 0, 0, 0, 9, −4) x1 x1 x4 (4, 1) z = −4 + x4 + x2 − 2x3x1 = 2 − 1/2x4 − x2 + 1/2x3x5 = 0 + x4 + 2x2 − 5x3x6 = 0 − 2x4 − 7x2 + 3x3 22
    24. 24. x1 = 1 x4 = 2, x5 = 2, x6 = 5, z = −2x1 = 2 x4 = 0, x5 = 0, x6 = 9, z = −4x1 = 3 x4 = −2, x5 = −2, x6 = 13, z = −6 x1 2(x1 , x2 , x3 , x4 , x5 , x6 , z) = (2, 0, 0, 0, 0, 9, −4) x1 x1 x4 (4, 1) z = −4 + x4 + x2 − 2x3x1 = 2 − 1/2x4 − x2 + 1/2x3x5 = 0 + x4 + 2x2 − 5x3x6 = 0 − 2x4 − 7x2 + 3x3 23
    25. 25. x3 x5 z = −4 + 3/5x4 + 1/52 + 2/5x5x1 = 2 − 2/5x4 − 4/5x2 − 1/10x5x3 = 0 + 1/5x4 + 2/5x2 − 1/5x5x6 = 9 − 7/5x4 − 29/5x2 − 3/5x5 (x1 , x2 , x3 , x4 , x5 , x6 , z) = (2, 0, 0, 0, 0, 9, −4) 24
    26. 26. D B z xs xsDr0 /|Drs | = min{Di0 /|Dis ||Dis < 0, i ∈ B {z}}, Drs < 0 xr r (r, s) 25
    27. 27. b≤0 26
    28. 28. min. cT x s. t. Ax ≥ b x≥0 xa e = (1, · · · , 1) ∈ Rm min. xa s. t. Ax + exa ≥ b x ≥ 0, xa ≥ 0xaxa 27
    29. 29. za = x a za = 0 + 0T x + x a x = −b + Ax + exab≤0 xr(r, a) 28
    30. 30. min. −x1 − 2x2 s. t. −x1 − x2 ≥ −1 x1 + x2 ≥ 1 x1 ≥ 0, x2 ≥ 0 za = xa z = −x1 − 2x2 x3 = 1 − x1 − x2 + xa x4 = −1 + x1 + x2 + xa(4, a) za = 1 − x1 − x2 + x4 z = −x1 − 2x2 x3 = 2 − 2x1 − 2x2 + x4 xa = 1 − x1 − x2 + x4 29
    31. 31. (a, 1)za = x a z = −1 + xa − x2 − x4x3 = 2xa − x4x1 = 1 − xa − x2 + x4 30
    32. 32. xa xr(r, a) 31
    33. 33. 32
    34. 34. 33
    35. 35. solveLP(cvec, bvec, Amat, maximum = FALSE, const.dir = rep( "<=", length( bvec ) ))cvec bbvec c min. cT xAmat A s. t. Ax ≥ bmaximum x≥0const.dir 34
    36. 36. min. −2x1 − x2 − x3s. t. −2x1 − 2x2 + x3 ≥ −4 −2x1 − 4x3 ≥ −4 4x1 − 3x2 + x3 ≥ −1 x1 ≥ 0, x2 ≥ 0, x3 ≥ 0> cvec <- c(-2, -1, -1)> bvec <- c(-4, -4, -1)> Amat <- rbind(c(-2, -1, -1), c(-2, 0, -4), c(4, -3, 1))> result <-solveLP(cvec, bvec, Amat, const.dir=rep(">=",length(bvec))) 35
    37. 37. > result$opt #[1] -4> result$solution #1 2 32 0 0> result$iter1 # 1[1] 0> result$iter2 # 1[1] 1 36
    38. 38. 37
    39. 39. •• • ••• 38
    40. 40. 39

    ×
    Save this presentationTap To Close