```
P = spzeros(4, 4)
P[1, 1] = 20
q = zeros(4)
A = spzeros(5, 4)
A[2, 1] = -100
A[1, 2] = 10
A[2, 2] = 1
A[3, 2] = -100
A[3, 3] = 1
A[1, 4] = -0.01
A[4, 4] = 1
A[5, 4] = 1
l = [0., -100, 0, -100, -Inf]
u = [0., -100, 0, Inf, 100]
m = OSQP.Model()
OSQP.setup!(m; P=P, A=A, l=l, u=u)
results = OSQP.solve!(m)
results.x
```
The expected solution is [0.999, -0.1, -10.0, -100.0], which is exactly what I get using Gurobi. OSQP, on the other hand, returns [0.999999, -7.93976e-5, -0.00793976, -0.0793976], which is far from the optimal solution.
The complete solver output is:
```
-----------------------------------------------------------------
OSQP v0.4.0 - Operator Splitting QP Solver
(c) Bartolomeo Stellato, Goran Banjac
University of Oxford - Stanford University 2018
-----------------------------------------------------------------
problem: variables n = 4, constraints m = 5
nnz(P) + nnz(A) = 9
settings: linear system solver = qdldl,
eps_abs = 1.0e-03, eps_rel = 1.0e-03,
eps_prim_inf = 1.0e-04, eps_dual_inf = 1.0e-04,
rho = 1.00e-01 (adaptive),
sigma = 1.00e-06, alpha = 1.60, max_iter = 4000
check_termination: on (interval 25),
scaling: on, scaled_termination: off
warm start: on, polish: off
iter objective pri res dua res rho time
1 0.0000e+00 1.00e+02 1.00e+04 1.00e-01 4.46e-05s
50 1.0000e+01 1.58e-07 2.00e-04 1.00e-01 7.30e-05s
status: solved
number of iterations: 50
optimal objective: 10.0000
run time: 7.80e-05s
optimal rho estimate: 3.98e-04
```
Gurobi, on the other hand, reports:
```
Academic license - for non-commercial use only
Optimize a model with 10 rows, 4 columns and 16 nonzeros
Model has 1 quadratic objective term
Coefficient statistics:
Matrix range [1e-02, 1e+02]
Objective range [0e+00, 0e+00]
QObjective range [2e+01, 2e+01]
Bounds range [0e+00, 0e+00]
RHS range [1e+02, 1e+02]
Presolve removed 10 rows and 4 columns
Presolve time: 0.00s
Presolve: All rows and columns removed
Barrier solved model in 0 iterations and 0.00 seconds
Optimal objective 9.98001000e+00
```
note that OSQP is reporting an optimal objective of 10.0000, while Gurobi was able to find an objective of 9.98001 (the true optimal value).
I have tried the exact same problem using the OSQP Python bindings and gotten the exact same result as I got in Julia, so I don't think this is a problem with the Julia interface.
These results were generated with OSQP v0.4.0, but I've had similar problems with 0.3.x versions.
Do you have any suggestions? Is this a bug in OSQP?
By the way, I tried removing the infinities and adjusting the scaling of the problem a little bit:
```
P = spzeros(4, 4)
P[1, 1] = 20
q = zeros(4)
A = spzeros(5, 4)
A[1, 2] = 10
A[1, 4] = -0.1
A[2, 1] = -10
A[2, 2] = 1
A[3, 2] = -10
A[3, 3] = 1
A[4, 4] = 1
A[5, 4] = 1
l = [0., -10, 0, -100, -100]
u = [0., -10, 0, 100, 100]
```
This still results in a wrong answer from OSQP: [0.995844, -0.0392951, -0.392951, -3.93114] with an objective value of 9.9171, vs. Gurobi's [0.9, -1.0, -10.0, -100.0] with an objective value of 8.1000.
--
You received this message because you are subscribed to the Google Groups "OSQP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to osqp+uns...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/osqp/c3efb18e-b732-4c7e-8327-525c01e5e230%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
To unsubscribe from this group and stop receiving emails from it, send an email to osqp+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/osqp/c3efb18e-b732-4c7e-8327-525c01e5e230%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
To unsubscribe from this group and stop receiving emails from it, send an email to osqp+uns...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/osqp/CACV469GaM6_Ja_8KO_PqW5bEOY%2BeoTTXAx%3D2%3DO%3DYZuTe_mUD%2BA%40mail.gmail.com.
Yeah, understood. This isn't the actual MPC problem I'm trying to solve, merely a minimal example that showed the solver behavior. In practice, for the problem specified above, I have to put a very large penalty (1e-1) on control action to get OSQP and Gurobi to agree with the default tolerances, at which point I've penalized control so much that the controller itself is ineffective.
--
You received this message because you are subscribed to the Google Groups "OSQP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to osqp+uns...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/osqp/5e15464a-4db8-4d69-8845-ce485415e7df%40googlegroups.com.