-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MosekMathProgModel numvar field is broken #16
Comments
Yes, it is a hack, and there probably is a bug. I will see if I can fix it. The reason it is that SOCP a constraint can have the form xz-y'y>0, while MOSEK accepts the form 1/2 xz-y'y>0. I have to add an extra variable x=2w and add the constraint as 1/2wz-y'y>0. The numvar should keep track of the number of variable the user has added, since I don't want to report the internal variable values. Of course this breaks if the user adds variables after a cone. |
One fix would be to change the MathProgBase interface, as I don't think that this will be the last time that auxiliary variables will bite us. One simple solution would be to have |
If/when solvers need to add auxiliary variables is a solver-specific detail that I don't think users of the interface should have to deal with, and it will add unneeded complexity to JuMP if we have to pad variables for this. The second option, building up the model in a Julia struct and then committing it to MOSEK, seems better in my opinion. |
I agree that it'd be nice to keep this complexity out of JuMP, but it seems like a lot of work at the solver level. I think it's also possible to "quarantine" the auxiliary variables until after all user variables are added, and then we only need to carry around an integer equal to the number of auxiliary variables added so far. E.g. in the norm stuff I did, I need to know the solver-level indices for aux variables I'm introducing, but if I just add these constraints after all user variables are added, I just need to know the offset. |
I don't think the interface should expose non-user-generated variables. Should I propose one change in the interface, I would say that addconstr! and addvar! might handles that give access to their solution values. I think this was discussed before somewhere. |
I think I have fixed this now. I have added a mapping from user indexes to native indexes for both variables and constraints. MosekMathProgModel now contains varmap and conmap. Auxiliary vars/cons do not appear in varmap and conmap. |
Hmm this seems to break my code using the interface. The only bit I dropped down to the Mosek level was in a |
Mapping between user indices and native indices seems like a reasonable approach to me. |
Yeah, it's probably the way to go, especially when the number of variables isn't extremely large. |
Minimal working example: adding two SOCP constraints and two new variables is enough to break it. JuMP model:
Corresponding MathProgBase interface calls:
|
Oops. I forgot to map the variable indexes in addconstr!. A fix has been committed. |
Fixes that example, but I'm still having problems with a maximum ellipse, which is giving incorrect answers now. It's a bit more complicated, but I'll try to narrow down the MPB calls. |
I have implemented the conic interface for MOSEK and fixed at least one addquadconstr!() bug. This may have fixed the bug - but I have not been able to verify this (the maximum ellipse examples does not run with the public version of JuMP). |
I am testing this on the sdp2 branch of JuMP, and I'm having issues with adding a constraint of the form
It looks like |
Ah. I see the problem: Z is an SDP variable, and I have completely forgotten to add support for SDP in addquadconstr!(). |
This seems like an awkward way to combine SOC and SDP constraints. |
|
Miles: Yes, it is a bit awkward, but it just requires me to split the A matrix into SDP and non-SDP parts. I think a more natural way would be to extend the conic interface with something like
|
I have fixed a bunch of problems, including handling linear and quadratic constraints separetely. Also:
|
@ulfworsoe I'm still seeing the same Mosek error as before, for both the maxellipse.jl and robust_uncertainty.jl examples. |
@joehuchette, what do you think about folding the SDP interface into |
Yes, that seems reasonable to me. |
I think I'm seeing an error related to this: on the
gives the error
(If this problem is unrelated I'll open a separate issue.) |
I think this is a separate issue. It appears that MOSEK has changed behaviour so putmaxnumvar cannot remove variables. |
I have replace the putmax... with resizetask. Could you check if it fixes the problem? |
Great! That fixes it. |
Closing |
The field is not updated when variables are added internally (for instance, when auxiliary variables are created in
addquadconstr!
); this bit me for pretty much the whole weekend when I couldn't find out why multiple quadratic constraints were breaking :(It seems that there is no reason to carry around this state when it's liable to break like this and a call to
getnumvar(m.task)
is so easy. I'm not sure if there was a reason to do it this way that I'm missing @ulfworsoe @wflu, but if not I'll go through the MathProgBase interface and change it.The text was updated successfully, but these errors were encountered: