Advertisement
Guest User

Untitled

a guest
Dec 6th, 2019
283
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Julia 0.57 KB | None | 0 0
  1. using JuMP, Gurobi
  2.  
  3. const GRB_ENV = Gurobi.Env();
  4.  
  5. nCan = 250 #Number of Candidates
  6. nVotes = 5000 #Number of Votes
  7.  
  8. m = JuMP.Model(with_optimizer(Gurobi.Optimizer, GRB_ENV, OutputFlag=0))
  9.  
  10. @variables(m, begin
  11.     0 ≤ y[1:(nVotes+1)] ≤ nCan, Int #Number of candidates at a vote count
  12.     z̄ ≥ 0 #Max number of Candidates
  13. end)
  14.  
  15. @constraints(m, begin
  16.     totCanCount, sum(y) == nCan
  17.     totVoteCount, y'*collect(0:nVotes) == nVotes
  18.    maxZ, z̄ .≥ y
  19. end)
  20.  
  21. @objective(m, Min, z̄)
  22. JuMP.optimize!(m)
  23. println(JuMP.termination_status(m))
  24. println(JuMP.value(z̄))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement