Advertisement
Guest User

Untitled

a guest
Dec 11th, 2019
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1.  
  2. import numpy as np
  3. import scipy.optimize as scipy
  4.  
  5. np.set_printoptions(precision = 4)
  6. np.set_printoptions(suppress = True)
  7.  
  8. #zad1
  9. A =[[4, 3],
  10. [1, 1],
  11. [-1, 0],
  12. [0, -1]]
  13.  
  14.  
  15. b = [190, 55, 0, 0]
  16. c = [-23, -17]
  17.  
  18. res = scipy.linprog(c, A, b).x
  19. result = 23 * res[0] + 17 * res[1]
  20.  
  21.  
  22. print("Task 1")
  23. print("x vector:", res)
  24. print("Result for F(x) function:", result)
  25. print("###################################\n")
  26.  
  27.  
  28. #zad2
  29. A =[[4, 3],
  30. [1, 1],
  31. [-1, 0],
  32. [0, -1],
  33. [1, 0]]
  34.  
  35.  
  36. b = [190, 55, 0, 0, 47]
  37. c = [-23, -17]
  38.  
  39. res = scipy.linprog(c, A, b).x
  40. result = 23 * res[0] + 17 * res[1]
  41.  
  42.  
  43. print("Task 2")
  44. print("x vector:", res)
  45. print("Result for F(x) function:", result)
  46. print("###################################\n")
  47.  
  48. #zad3
  49. A =[[4, 3],
  50. [1, 1],
  51. [-1, 0],
  52. [0, -1]]
  53.  
  54.  
  55. b = [190, 55, -48, 0]
  56. c = [-23, -17]
  57.  
  58. res = scipy.linprog(c, A, b).x
  59. result = 23 * res[0] + 17 * res[1]
  60.  
  61. print("Task 3")
  62. print("x vector:", res)
  63. print("Result for F(x) function:", result)
  64. print("###################################\n")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement