Open GGooeytoe opened 1 month ago
I think the issue here is related to the formatting of python sparse matrices, which are not guaranteed to be in "canonical" format (i.e. no duplicates, data within each column appearing in row order).
If I add this
sq_distance_cost.sort_indices()
sq_distance_cost.sum_duplicates()
then all the problems solve. Note that I'm not sure that the solutions are actually correct, because I didn't check whether the A matrices are also in non-standard format.
I will have a look and see where the most appropriate place is for a fix, since it's probably asking for trouble to expect users of the python interface to realise that they need to manually force a reshuffle of the matrix internals.
When using the rust interface directly, we have a public check_format
utility that can be run on the CscMatrix type before passing to the solver, but we don't use it internally. We should at least provide user facing sorting and deduplication tools as above in rust if that isn't available already.
I have fixed this issue permanently (I hope!) in #140, but a temporary fix is to manually sort indices and deduplicate as suggested above.
I pulled https://github.com/oxfordcontrol/Clarabel.rs/pull/140 and built and now Clarabel solves all the problems in the example script I posted. I confirm that this fixed the issue!
Clarabel v0.9.0 reports InsufficientProgress when asked to find the distance between two (very nearly touching, long and thin) polyhedra, expressed as intersections of halfspaces, provided I use a quadratic cost to do so. If instead I use a SOC constraint to constrain a variable to be larger than the distance between the two points, it works fine. SCS v3.2.7 solves the quadratic cost version of the problem without apparent issues, so it seems like my problem formulation isn't totally ridiculous.
I've attached an image of the sets in question:
Code block to demonstrate the behavior: