This model is a simple introductory example in Gurobi, that seems unsolvable with JuMP + Gurobi
The model itself is typical found in a Gurobi installation at /opt/gurobi702/linux64/examples/data/coins.lp
. Running gurobi_cl
on this file yields a feasible solution. Yet when called from JuMP
, it returns :InfeasibleOrUnbounded
.
using JuMP, Gurobi
m=Model(solver=GurobiSolver())
@variables m begin
Pennies, Int
Nickels, Int
Dimes, Int
Quarters, Int
Dollars, Int
Cu <= 1000
Ni <= 50
Zi <= 50
Mn <= 50
end
@constraints m begin
Copper, .06Pennies + 3.8Nickels + 2.1Dimes + 5.2Quarters +7.2Dollars - Cu == 0
Nickel, 1.2Nickels + .2Dimes + .5Quarters + .2Dollars - Ni == 0
Zinc, 2.4Pennies +.5Dollars - Zi == 0
Manganese, .3Dollars - Mn == 0
end
@objective(m, Max, .01Pennies + .05Nickels + .1Dimes + .25Quarters + 1Dollars )
status=solve(m)
I would have expected this simple model to work. Not sure where I might have gone wrong here.
When I print the model it appears pretty sound and should be solvable
julia> print(m)
Max 0.01 Pennies + 0.05 Nickels + 0.1 Dimes + 0.25 Quarters + Dollars
Subject to
0.06 Pennies + 3.8 Nickels + 2.1 Dimes + 5.2 Quarters + 7.2 Dollars - Cu = 0
1.2 Nickels + 0.2 Dimes + 0.5 Quarters + 0.2 Dollars - Ni = 0
2.4 Pennies + 0.5 Dollars - Zi = 0
0.3 Dollars - Mn = 0
Pennies, integer
Nickels, integer
Dimes, integer
Quarters, integer
Dollars, integer
Cu ≤ 1000
Ni ≤ 50
Zi ≤ 50
Mn ≤ 50
The optimal solution from gurobi_cl
is
# Objective value = 113.45
Pennies 0
Nickels 0
Dimes 2
Quarters 53
Dollars 100
Cu 999.8
Ni 46.9
Zi 50
Mn 30