A question about write_to_file in JuMP

My model is a MISOCP model with Gurobi, if i want to solve it directly with Gurobi, how to code it?

julia> write_to_file(model, "model.lp")
ERROR: MathOptInterface.UnsupportedConstraint{MathOptInterface.VectorAffineFunction{Float64}, MathOptInterface.SecondOrderCone}: `MathOptInterface.VectorAffineFunction{Float64}`-in-`MathOptInterface.SecondOrderCone` constraint is not supported by the model.   
1 Like

JuMP doesn’t have a way to write MISOCP to a file format that Gurobi understands. But you can write out an MPS file using Gurobi’s extension to the MPS format:

using JuMP, Gurobi
model = direct_model(Gurobi.Optimizer())
# ... build model
GRBwrite(backend(model), "model.mps")

You could then pass that MPS file to gurobi_cl.

Edit: the error message occurred because the LP file format doesn’t support SOCP. But we should improve the error message: Improve error message for write_to_file when unsupported · Issue #2974 · jump-dev/JuMP.jl · GitHub