GAMS-dev / gams.jl

A MathOptInterface Optimizer to solve JuMP models using GAMS
MIT License
35 stars 3 forks source link

Input data rounded? #5

Closed ChrisFuelOR closed 3 years ago

ChrisFuelOR commented 3 years ago

Hello,

first of all, thank you for providing this package allowing to call GAMS and its solvers from Julia. This is really helpful in integrating different solvers into a project.

Currently, I face the issue that some problem data seems to be rounded before the problem is solved in GAMS. It is clear to me that there is a limit on input precision (https://support.gams.com/gams:precision_of_data_within_gams), but I wonder if the rounding in my case is intended or a bug. Especially, since creating the same problem in GAMS Studio does not show this issue.

Here is a minimal working example:

using GAMS
using JuMP
using Gurobi
using MathOptInterface

m1 = JuMP.Model(GAMS.Optimizer)
JuMP.set_optimizer_attribute(m1, "Solver", "Gurobi")
JuMP.@variable(m1, x>=0)
JuMP.@objective(m1, MOI.MIN_SENSE, x)
JuMP.@constraint(m1, x >= 2257.812325)
JuMP.optimize!(m1)

m2 = JuMP.Model(Gurobi.Optimizer)
JuMP.@variable(m2, y>=0)
JuMP.@objective(m2, MOI.MIN_SENSE, y)
JuMP.@constraint(m2, y >= 2257.812325)

JuMP.optimize!(m2)

println()
println("Optimal point calling Gurobi via GAMS:")
println(JuMP.value(x))
println("Optimal point calling Gurobi directly:")
println(JuMP.value(y))

The console output is

Optimal point calling Gurobi via GAMS:
2257.81
Optimal point calling Gurobi directly:
2257.812325

As you can see, calling Gurobi directly provides the correct solution, which also modeling and solving the problem in GAMS Studio does. Calling Gurobi via GAMS in Julia (which would be the preferred way within my project) gives a solution, though, which does not satisfy the constraint. This may be problematic if cutting planes are created iteratively within an algorithm.

This seems to be input and not output related, since the .gms-file created by gams.jl already contains the constraint in form

x >= 2257.81

only instead of the original form.

I use package version 0.1.4 for GAMS, 0.21.5 for JuMP and 0.9.19 for MathOptInterface.

Many thanks in advance.

renkekuhlmann commented 3 years ago

Thanks for providing this example! This is definitely not intended. I'll look into it next week. With the example it should be easy to fix the issue quickly.

renkekuhlmann commented 3 years ago

The issue has been resolved in the new GAMS.jl version 0.1.5. You can update GAMS.jl using the package manager (] + update). Thanks again very much for reporting this issue!

ChrisFuelOR commented 3 years ago

Thank you for solving this issue very quickly.