-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error on BigFloat inequalities #64
Comments
First of all: thanks for using Tulip (or at least trying) :) The occurs because JuMP (always) builds problems in Here are a few hacks to make it work nonetheless:
# Build your model here
lp = JuMP.Model()
@variable(lpl, x)
@variable(lp, y)
@constraints(lp, x - y >= 0)
# Export the model to an MPS file
JuMP.write_to_file(lp, "lp.mps")
# Import into Tulip, with BigFloat precision
lp_ex = Tulip.Model{BigFloat}()
Tulip.load_problem!(lp_ex, "lp.mps")
Tulip.optimize!(lp_ex) The call to |
Using Convex worked with Double64! The trick is to add the keyword argument
I am very excited to now have useable high-precision linear programming. |
I have some plans to improve the performance of high-precision solving, but it's not very high on my priority list right now.
The docs are due for a section on higher-precision arithmetic. I'll ping you when I add it. |
Running the first example of the tutorial with other types also yields conversion errors. I'm posting the example here since the issue is related, I can move it to a separate one if required: using Tulip
import MathOptInterface
const MOI = MathOptInterface
const T = Float32
lp = Tulip.Optimizer{T}()
# Create variables
x = MOI.add_variable(lp)
y = MOI.add_variable(lp)
# Set variable bounds
MOI.add_constraint(lp, MOI.SingleVariable(x), MOI.GreaterThan(T(0))) # x >= 0
MOI.add_constraint(lp, MOI.SingleVariable(y), MOI.GreaterThan(T(0))) # y >= 0
# Add constraints
row1 = MOI.add_constraint(lp,
MOI.ScalarAffineFunction(MOI.ScalarAffineTerm.(T[1.0, -1.0], [x, y]), T(0)),
MOI.GreaterThan(T(-2))
)
row2 = MOI.add_constraint(lp,
MOI.ScalarAffineFunction(MOI.ScalarAffineTerm.(T[2.0, -1.0], [x, y]), T(0)),
MOI.LessThan(T(4))
)
row3 = MOI.add_constraint(lp,
MOI.ScalarAffineFunction(MOI.ScalarAffineTerm.(T[1.0, 2.0], [x, y]), T(0)),
MOI.LessThan(T(7))
)
# Set the objective
MOI.set(lp,
MOI.ObjectiveFunction{MOI.ScalarAffineFunction{Float32}}(),
MOI.ScalarAffineFunction(MOI.ScalarAffineTerm.(T[-2.0, -1.0], [x, y]), T(0))
)
MOI.set(lp, MOI.ObjectiveSense(), MOI.MIN_SENSE)
MOI.optimize!(lp) Results in the following error: julia> MOI.optimize!(lp)
ERROR: MethodError: Cannot `convert` an object of type
LDLFactorizations.LDLFactorization{Float64,Int64,Int64,Int64} to an object of type
LDLFactorizations.LDLFactorization{Float32,Ti,Tn,Tp} where Tp<:Integer where Tn<:Integer where Ti<:Integer
Closest candidates are:
convert(::Type{T}, ::T) where T at essentials.jl:171
Stacktrace:
[1] Tulip.KKT.LDLFactSQD(::SparseArrays.SparseMatrixCSC{Float32,Int64}) at /home/mbesancon/.julia/packages/Tulip/3EWmj/src/KKT/ldlfact.jl:52
[2] setup(::Type{Tulip.KKT.LDLFactSQD}, ::SparseArrays.SparseMatrixCSC{Float32,Int64}) at /home/mbesancon/.julia/packages/Tulip/3EWmj/src/KKT/ldlfact.jl:57
[3] Tulip.HSD(::Tulip.IPMData{Float32,Array{Float32,1},BitArray{1},SparseArrays.SparseMatrixCSC{Float32,Int64}}, ::Tulip.KKT.KKTOptions{Float32}) at /home/mbesancon/.julia/packages/Tulip/3EWmj/src/IPM/HSD/HSD.jl:54 Following the stacktrace, the issue seems to occur in the constructor of
I believe S is converted to Float64 here because of the |
When I use JuMP to create two variables and try to place a constraint on them, I get an error.
Here is an minimal example and a prefix of the error message:
I am using Julia 1.5.2 on a Mac running OS version 10.15.6, JuMP version v0.21.4, Tulip version v0.6.2.
Tips on how to make this work would be very appreciated!
The text was updated successfully, but these errors were encountered: