Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from cvxopt import solvers, matrix
- # Elements of a matrix are columns
- # All the elements must be FLOAT, so I add a '.', so 2 = 2. = 2.0
- A = matrix([[-1., -1., 0., 1.], [1., -1., -1., -2.]])
- print(A)
- b = matrix([1., -2., 0., 4.])
- print(b)
- c = matrix([2., 1.])
- print(c)
- # Minimization problem is the following:
- # min(c^T * x) subject to: Ax <= b
- sol = solvers.lp(c, A, b)
- sol2 = solvers.lp(c, A, b, options = {'maxiters': 3})
- optimal = sol['x']
- print("Optimal Solution")
- print(optimal)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement