Last active
April 12, 2017 20:57
-
-
Save odow/2dd99948fde8ae8bafc92f3f40d6aa2e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# First comment out lines https://github.com/JuliaOpt/Gurobi.jl/blob/master/src/GurobiSolverInterface.jl#L246-L254 | |
using Gurobi,JuMP | |
# Create the JuMP Model: | |
# min 0 | |
# s.t. | |
# x >= 1 | |
# x <= 3 | |
m=Model(solver=GurobiSolver()) | |
@variable(m, x) | |
@constraints(m, begin | |
x >= 1 | |
x <= 3 | |
end) | |
# initialise Gurobi Model | |
JuMP.build(m) | |
# Change Gurobi model to | |
# min -y | |
# s.t. | |
# x - y >= 1 | |
# x + y <= 3 | |
# y ∈ [0, 1] | |
# has optimal solution (x,y) = (2, 1), obj=-1 | |
MathProgBase.addvar!(internalmodel(m), [1, 2], [-1.0, 1.0], 0, 1, -1) | |
Gurobi.updatemodel!(internalmodel(m)) | |
@assert Gurobi.getobj(internalmodel(m)) == [0.0, -1.0] | |
@assert Gurobi.getsense(internalmodel(m)) == :Min | |
@assert Gurobi.num_vars(internalmodel(m).inner) == 2 | |
@assert solve(m) == :Optimal | |
@assert getobjectivesense(m) == :Min | |
@assert Gurobi.getobj(internalmodel(m)) == [0.0, -1.0] # fails: reports [0.0, 3.19e-308] | |
@assert getobjectivevalue(m) == -1 # fails: reports 0.0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment