Jump.jl: Generic numeric type in JuMP

Created on 14 Aug 2019  Â·  5Comments  Â·  Source: jump-dev/JuMP.jl

MOI parameterizes function and set types with the number type used to store the data, example:

julia> using JuMP
julia> MOI.LessThan(big"3.5")
MathOptInterface.LessThan{BigFloat}(3.5)

For the moment, JuMP uses and assumes Float64:

julia> @variable(m, x[1:3])
julia> @constraint(m, sum(x) <= 1//7)
x[1] + x[2] + x[3] ≤ 0.14285714285714285

Julia-native solvers should support more numeric types (see https://github.com/JuliaOpt/Convex.jl/issues/262#issuecomment-515522868), using them through JuMP would in the current state block this genericity.

From the user perspective, generic number types could allow chosen precision, Unitful.jl and others

Most helpful comment

One way to go for this is to parametrize the JuMP model with the coefficient type. Model() would give a JuMP.Model{Float64} and Model{T}() would give a JuMP.Model{T}(). JuMP.VariableRef will also be parametrized by T as one of its field is the JuMP.Model.
This means that in operators, we know which type to use for, e.g. +(::VariableRef, ::VariableRef).

All 5 comments

One way to go for this is to parametrize the JuMP model with the coefficient type. Model() would give a JuMP.Model{Float64} and Model{T}() would give a JuMP.Model{T}(). JuMP.VariableRef will also be parametrized by T as one of its field is the JuMP.Model.
This means that in operators, we know which type to use for, e.g. +(::VariableRef, ::VariableRef).

I think this will be fairly easier to implement and test once we have solvers working on multiple number types, from the conversations of last week Hypatia (Float64 / Complex) and SCIP (Float64, Rational)

CDDLib.Optimizer{Rational{BigInt}} and Polyhedra.VRepOptimizer{Rational{BigInt}} should work with Rational{BigInt}.

@jiazhengzhu and I are working on wrapping SDPA-GMP for high precision SDP solving, which would benefit from being able to use BigFloats. We’re currently using an branch of Convex with MOI support hacked on and parametrizing Convex’s Problem type with the numeric type, as was suggested above to do for JuMP. It would be great to be able to use JuMP to formulate problems as well.

edit: I would no longer call the MOI support in that Convex.jl branch as hacked-on, since we no longer re-use the MPB standard form and instead formulate the problem more directly for MOI

Hypatia and Tulip allow generic reals.
I just tried to use the JuMP.Model{T}() syntax expecting it to work but I forgot that it doesn't. My vote is for that syntax as it is quite natural.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

remi-garcia picture remi-garcia  Â·  4Comments

joaquimg picture joaquimg  Â·  8Comments

mlubin picture mlubin  Â·  5Comments

jrevels picture jrevels  Â·  4Comments

loylobo picture loylobo  Â·  5Comments