OSQP does not detect the Objective Function while reading nl file model through MathOptInterface #706
Replies: 4 comments
-
Did you mean to include a sample |
Beta Was this translation helpful? Give feedback.
-
Never mind, I was able to reproduce it. The problem is that the .nl file format produces a model with a general nonlinear objective, and OSQP only knows what to do with quadratic or affine objectives. This should have resulted in an error, but was instead the model was accepted and the objective function not correctly populated. Fix is here: osqp/OSQP.jl#128 Note that that the "fix" is to just crash with a warning that a nonlinear model is not suitable for the solver. I think you would be better served with a different file format if you want to use this solver. |
Beta Was this translation helpful? Give feedback.
-
Hi @goulart-paul , thanks a lot for your reply! Can you please provide me with a simple example file which can be correctly read using the MOI and solved with OSQP then? I tried some instances from QPLIB but those are not working well. Please help me with this. |
Beta Was this translation helpful? Give feedback.
-
I would try just round tripping a test problem through the various support JuMP file formats. Here's an example showing that using JuMP, OSQP
format = MOI.FileFormats.FORMAT_MPS
# Define the model
model1 = Model(OSQP.Optimizer)
# Define variables
@variable(model1, x >= 1)
@variable(model1, y >= 1)
# Define the objective function: x^2 + y^2 + 2
@objective(model1, Min, x^2 + y^2 + 2)
# Solve the problem
optimize!(model1)
# save and reload
JuMP.write_to_file(model1,"example.txt", format = format)
model2 = JuMP.read_from_file("example.txt", format = format)
set_optimizer(model2, OSQP.Optimizer)
optimize!(model2)
@assert objective_value(model1) == objective_value(model2) |
Beta Was this translation helpful? Give feedback.
-
Description
OSQP does not detect the Objective Function while reading nl file through MathOptInterface.
We tried running a simple problem to demonstrate the issue:
Using the following approaches:
The 1st one works fine and gives the correct results while the 2nd one doesn't detect the Objective Function correctly.
Steps to Reproduce
Extract the zip file attached here:
circle.zip
julia circle_osqp.jl
. This runs OSQP directly using JuMP by defining the model in Julia.julia circle_osqp_nl.jl
. This runs OSQP using the MathOptInterface to read the model from .nl file.Expected Behavior
Both
circle_osqp.jl
andcircle_osqp_nl.jl
must give the same the same result. But, the objective is not getting detected in case ofcircle_osqp_nl.jl
due to which the objective value in the result is 0.Version and OS
Beta Was this translation helpful? Give feedback.
All reactions