Use values of variables as initial guess (in mixed integer proplems)
Is your feature request related to a problem? Please describe. An important feature when solving mixed integer problems is to be able to suggest a good feasible solution. Some solvers support this feature, e.g. MOSEK (see https://docs.mosek.com/9.0/pythonapi/tutorial-mio-shared.html#specifying-an-initial-solution).
Describe the solution you'd like
I suggest using the value property of variables for that purpose. That is, if a value exists, it should be used as initial guess provided the warm_start argument is set to True. This would require a minor adjustment when the stacked problem is created: the original variable values must be handed over to the newly created problem. Handing over these values to the respective solvers must be done according to the respective solver interfaces.
Describe alternatives you've considered According to my knownledge this feature does not exist in CVXPY, and the only alternative would be to use a different software instead. This would be unfortunate, as the required change is small.
Implementation
I have implemented my suggested solution for MOSEK and tested it on a problem of interest to me. Affected files are matrix_stuffing.py (I have added a helper function to stack the values), cone_matrix_stuffing.py (the stacked value is handed over to the new variable), and mosek_conif.py (the value is saved in the data dictionary and then handed over to the solver).
The files are attached (as .txt, since upload of .py files was not supported). Changes are highlighted with a CHANGE key word.
I would be happy to create a pull request, but I am not sure that my solution is in line with the envisioned development path of CVXPY. The implemented solution affects MOSEK only, all other solvers will behave as usual. If this inconsistency is unwanted, I would like to encourage this feature to be implemented on a wider scale. Nonetheless, some people may be helped by my solution already.
Please let me know if I can be of any further help.
cone_matrix_stuffing.txt matrix_stuffing.txt mosek_conif.txt
Thanks for the implementation! The proposed change is in line with future development plans for cvxpy. It's implemented in some of the cvxpy extensions for nonconvex problems, such as dccp.
I am aware that this has been implemented in extensions (though I am not sure whether also for integer programs - I should have looked into that). Maybe it would make then more sense to copy their implementation rather than reimplementing the feature from scratch.
So how do we proceed now? Should I then create a pull request with the proposed changes? I may not be able to do that very soon, and I am not sure that I ave currently time to implement extensive tests. If anyone more experienced with contributing helped me with that, I would certainly not mind.
The reason I haven't added it yet is because I wanted to generate guesses for the slack variables introduced during the canonicalization process. This is actually not that hard theoretically, but the implementation will be a lot of work. I would recommend using your custom cvxpy, and at some point we'll have it in the main cvxpy.
Sounds good. Note, though, that some solvers (e.g. Mosek) can work with partial initial guesses. Consequently, potentially existent slack variables would be computed (by the solver) based on the given variables. I agree that it would be nice to compute everything beforehand that can be computed directly, but it may not make a huge difference. Therefore, users might already appreciate a partial solution.
I do not know whether my solution as implemented works well in the presence of slack variables. That would be an easy fix, though.
That's good to know!
This missed 1.3, but it would be great to get into 1.4. Help would be much appreciated!
This did make it into 1.3 for Gurobi.
This feat. request is very interesting. Any plans to make use of the warm_start for other solvers? HIGHS can be a good candidate: https://ergo-code.github.io/HiGHS/dev/guide/further/ (they support it through setSolution)