Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2018
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Julia 0.56 KB | None | 0 0
  1. using JuMP
  2. using GLPKMathProgInterface
  3.  
  4. m = Model(solver = GLPKSolverMIP())
  5.  
  6. @variable(m, x[1:8] >= 0)
  7. d = [0,2,4,4,3,2,3,0]
  8.  
  9. #@objective(m, Min, sum(x[i]*d[i] for i = 1:8))
  10. @objective(m, Min, x[8])
  11.  
  12. @constraint(m, x[4] - x[2] >= d[2])
  13. @constraint(m, x[5] - x[2] >= d[2])
  14. @constraint(m, x[5] - x[3] >= d[3])
  15. @constraint(m, x[6] - x[4] >= d[4])
  16. @constraint(m, x[7] - x[5] >= d[5])
  17. @constraint(m, x[8] - x[6] >= d[6])
  18. @constraint(m, x[8] - x[7] >= d[7])
  19.  
  20. status = solve(m)
  21.  
  22. println("Objective = ", getobjectivevalue(m))
  23. println("X = ", getvalue(x))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement