Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using JuMP, Gurobi
- const GRB_ENV = Gurobi.Env();
- nCan = 250 #Number of Candidates
- nVotes = 5000 #Number of Votes
- m = JuMP.Model(with_optimizer(Gurobi.Optimizer, GRB_ENV, OutputFlag=0))
- @variables(m, begin
- 0 ≤ y[1:(nVotes+1)] ≤ nCan, Int #Number of candidates at a vote count
- z̄ ≥ 0 #Max number of Candidates
- end)
- @constraints(m, begin
- totCanCount, sum(y) == nCan
- totVoteCount, y'*collect(0:nVotes) == nVotes
- maxZ, z̄ .≥ y
- end)
- @objective(m, Min, z̄)
- JuMP.optimize!(m)
- println(JuMP.termination_status(m))
- println(JuMP.value(z̄))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement