I'm trying to do a fairly simple optimization, but I keep getting the error 'Singular matrix C in LSQ subproblem'. I've tried to search the internet, however I couldn't find anything about why this occurs or how I could solve it.
The following code for some reason always returns the same error regardless of the fact that (as far as I understand) the constraint is always satisfied:
cons = ({'type': 'eq', 'fun': lambda x: 0})
res = scipy.optimize.minimize(
cost_func,
v_init,
bounds=bounds,
constraints=cons,
options={'maxiter': 10, 'disp': True},
)
where the bounds are set such that every off-diagonal element must fall between 0 and 1 and every on-diagonal element must be 0 and v_init is a flattened matrix. When I remove the constraint, the optimization converges without any errors.
The cost function is quite sophisticated. It returns the total intraclass distance - interclass distance given a dissimilarity matrix calculated using the parameters v_init.
Can anyone enlighten me?