To start with, Mosek's initialization API works great. We were able to speedup our optimization by 25X, merely by decision variable initialization on a sample problem (all variables integral constrained).
Now, we are solving a new large-scale MIQCQP problem (with some variable integral constrained and some contiguous) and we want to initialize all those variables.
When using the task.putxxslice
API [1], we are facing issues in deciding the value of whichsol
parameter.
Doubts:
Since our problem has both integral and continuous, would it be correct to substitute whichsol = mosek.soltype.itg
for all variables (integral and contiguous)?
Our final objective is adding this generic support custom Cvxpy. We have almost achieved that, just that - Is there any a programmatic way to decide whichsol
in Cvxpy? Or better asked - Is this the correct way?
if num_bool + num_int > 0: # if problem is Mixed-integer (some integral, some contiguous)
whichsol = mosek.soltype.itg
elif inverse_data['is_LP']: # if problem is LP
whichsol = mosek.soltype.bas
else: # all other cases
whichsol = mosek.soltype.itr
for idx, initial_guess in zip(idx_list, initial_guess_list):
task.putxxslice(whichsol, idx, idx+1, [initial_guess])
[1] - https://docs.mosek.com/latest/pythonapi/optimizer-task.html#mosek.task.putxxslice
The reasons to set an initial point in Mosek are:
Starting feasible point for the mixed-integer solver when the problem has integer variables, in that case set itg
Warm-starting the simplex solver, in that case set bas
.
Warm-starting the conic/interior-point solver, in that case set itr
, although this option is only theoretical because currently Mosek will not warm-start and just ignores that solution.
Normally if there are any integer variables in the problem, then only the itg
solution is relevant. If the problem is linear and the simplex solver is explicitly chosen via a Mosek parameter then only the bas
solution is relevant.
However imagine that the problem has integer variables but the user sets the Mosek parameter iparam.mio_mode=ignore
because then now want to solve only the LP relaxation. That is extremely unlikely that someone seriously needs such a combination but at least in principle it is possible. What then? There are lots of corner cases like this, and you would have to explicitly check lots of Mosek parameters (which can change over time) to make a decision.
One way out of this is to set all three primal solutions, and also set the parameter iparam.remove_unused_solutions
. Then, once Mosek internally decides which optimizer will be used, it will purge those solutions which are not relevant at this point.
Another option is that you only set the itg
solution. It is very unlikely that any cvxpy users would use this feature for anything else than 1. above.