I'm trying to use OSQP to solve some least-squares problems . I've adapted your example and it works great with one of my problems, but with the second one, I've got a segmentation fault.
It crashes during the setup. If I remove the last two lines of A2, and the last two values of vmax, it works. If I add any of the two lines or any line with multiple 1 ot -1, it crashes.
Here is a similar problem that works:
import osqp
import numpy as np
from scipy import sparse
# a b c d e f g h i
A1 = sparse.csc_matrix([[0, 0, 0, 0, 0, 1, 0, 1, 0], #c12
[1, 1, 1, 1, 0, 0, 1, 0, 1], #c13
[-1, -1, -1, -1, 0, -1, -1, -1, -1], #c23
[1, 1, 1, 0, 0, 0, 1, 0, 0], #maths
[0, 0, 0, 0, 0, 1, 0, 1, 0], #spc
[0, 0, 1, 1, -1, 0, 0, 0, 1] #svt
])
m, n = A1.shape
constantes = np.array([40, 5, 64, 16, 1, 9])
effectifs_attendus = np.array([54.5, 27.25, 27.25, 31, 20, 13.5])
objectifs = effectifs_attendus - constantes
vmin = np.array([0] * len(vmax))
# a b c d e f g h i
A2 = sparse.csc_matrix([[1, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 1, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 1, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 1, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 1, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 1, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 1, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 1, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 1],
[0, 0, 0, 0, 0, 1, 1, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 1, 1]
])
l = np.concatenate((objectifs, vmin), axis=None)
u = np.concatenate((objectifs, vmax), axis=None)
P = sparse.block_diag([sparse.csc_matrix((n, n)), sparse.eye(m)], format='csc')
q = np.zeros(n+m)
A = sparse.bmat([
[A1, -sparse.eye(m)],
[A2, None],
], format='csc')
prob = osqp.OSQP()
prob.setup(P, q, A, l, u, verbose=0)
res = prob.solve()
I've installed osqp-python with pip.
I've used solve_ls from qpsolvers with the OSQP solver with the same problem, and it worked. Here is the program I used:
Hi,
I'm trying to use OSQP to solve some least-squares problems . I've adapted your example and it works great with one of my problems, but with the second one, I've got a segmentation fault.
Here is my file:
It crashes during the setup. If I remove the last two lines of A2, and the last two values of vmax, it works. If I add any of the two lines or any line with multiple 1 ot -1, it crashes.
Here is a similar problem that works:
I've installed osqp-python with pip.
I've used
solve_ls
fromqpsolvers
with the OSQP solver with the same problem, and it worked. Here is the program I used:I hope it can help finding the bug.
Thanks.