Setting tolerances in JuMP - is there an Optimizer-independent way?

Is there a simple Optimizer-independent way to set tolerances in JuMP? I searched the documentation and couldn’t find anything on setting tolerances [I’m tired of multiplying my objective functions by large numbers :wink: ]

This is probably trivial if you know how to do it, and probably easy to find if you know where to look :wink:

Thanks for any help!

I’m tired of multiplying my objective functions by large numbers

Why are you doing this?

Is there a simple Optimizer-independent way to set tolerances in JuMP?

Nothing that is widely supported. Gurobi and CPLEX support setting MOI.AbsoluteGapTolerance() and MOI.RelativeGapTolerance().

See Models · JuMP

Because if my objective is 1000 times larger, this is equivalent but will automatically make my answer more precise. It is admittedly a clumsy way, but I don’t know another convenient way to achieve this.

Note that this will only affect absolute tolerances. Some solvers use relative tolerances (e.g., the relative gap when solving a MIP).

The bigger question to think about is why this is necessary. Solvers don’t use exact arithmetic, so you should always anticipate some tolerance. Instead of changing the tolerance, you’re usually better off reformulating the model to use different units. So if your objective value comes out to be much less than 1, you should probably use variables with units of millimeters instead of meters, for example.

Thanks. That is effectively what I am doing. I just wondered whether there were some other way.