Advertisement
Guest User

Untitled

a guest
May 23rd, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.07 KB | None | 0 0
  1. #Zadatak 3
  2.  
  3. from cvxopt.glpk import ilp
  4. from cvxopt import solvers
  5. from cvxopt.base import matrix
  6. import numpy as np
  7. RealNumber=float
  8. Integer=int
  9. c1=matrix([3. , 8. , 5. , 3. , 6. , 2. , 5. , 6. , 2. , 9. , 7. , 4.])
  10. c2=matrix([7. , 6. , 4. , 1. , 4. , 4. , 3. , 7. , 5. , 3. , 6. , 5.])
  11. A=matrix([[-1. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0.,] ,
  12. [0. , -1. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0.,] ,
  13. [0. , 0. , -1. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0.,] ,
  14. [0. , 0. , 0. , -1. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0.,] ,
  15. [0. , 0. , 0. , 0. , -1. , 0. , 0. , 0. , 0. , 0. , 0. , 0.,] ,
  16. [0. , 0. , 0. , 0. , 0. , -1. , 0. , 0. , 0. , 0. , 0. , 0.,] ,
  17. [0. , 0. , 0. , 0. , 0. , 0. , -1. , 0. , 0. , 0. , 0. , 0.,] ,
  18. [0. , 0. , 0. , 0. , 0. , 0. , 0. , -1. , 0. , 0. , 0. , 0.,] ,
  19. [0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , -1. , 0. , 0. , 0.,] ,
  20. [0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , -1. , 0. , 0.,] ,
  21. [0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , -1. , 0.,] ,
  22. [0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , -1.,]])
  23. h=matrix ([0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , - 0. , 0. , 0. , 0.,])
  24. beq=matrix([1. , 0. , 0. , 0. , 0. , 0. , 1.])
  25. Aeq=matrix([[1. , 1. , 0. , 0. , 0. , 0. , 0.] ,
  26. [1. , 0. , 0. , 1. , 0. , 0. , 0. ] ,
  27. [1. , 0. , 1. , 0. , 0. , 0. , 0. ] ,
  28. [0. , -1. , 0. , 0. , 1. , 0. , 0.] ,
  29. [0. , -1. , 0. , 1. , 0. , 0. , 0.] ,
  30. [0. , 0. , -1. , 1. , 0. , 0. , 0.] ,
  31. [0. , 0. , -1. , 0. , 0. , 1. , 0.] ,
  32. [0. , 0. , 0. , -1. , 1. , 0. , 0.] ,
  33. [0. , 0. , 0. , -1. , 0. , 1. , 0.] ,
  34. [0. , 0. , 0. , 0. , -1. , 0. , 1.] ,
  35. [0. , 0. , 0. , -1. , 0. , 0. , 1.] ,
  36. [0. , 0. , 0. , 0. , 0. , -1. , 1.]])
  37. (status , x1)=ilp(c1, A, h, Aeq, beq)
  38. (status , x2)=ilp(c2, A, h, Aeq, beq)
  39. #Najkraci put
  40. print("Najkraci put: ")
  41. print x1
  42. #Najekonomicniji put
  43. print("Najekonomicniji put: ")
  44. print x2
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement