简体   繁体   English

以编程方式识别 Mosek 的解决方案类型参数

[英]Programmatically identify Mosek's solution type parameter

To start with, Mosek's initialization API works great.首先,Mosek 的初始化 API 效果很好。 We were able to speedup our optimization by 25X, merely by decision variable initialization on a sample problem (all variables integral constrained).我们能够将优化速度提高 25 倍,仅通过对样本问题进行决策变量初始化(所有变量都受积分约束)。

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.现在,我们正在解决一个新的大规模 MIQCQP 问题(一些变量积分约束和一些连续变量),我们想要初始化所有这些变量。

When using the task.putxxslice API [1], we are facing issues in deciding the value of whichsol parameter.使用task.putxxslice API [1] 时,我们在决定whichsol参数的值时遇到了问题。

Doubts:疑问:

  1. Since our problem has both integral and continuous, would it be correct to substitute whichsol = mosek.soltype.itg for all variables (integral and contiguous)?由于我们的问题既有积分又有连续,用whichsol = mosek.soltype.itg代替所有变量(积分和连续)是否正确?

  2. Our final objective is adding this generic support custom Cvxpy.我们的最终目标是添加此通用支持自定义 Cvxpy。 We have almost achieved that, just that - Is there any a programmatic way to decide whichsol in Cvxpy?我们几乎已经实现了这一点,只是 - 是否有任何编程方式来决定whichsol中的 whichsol? 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 [1] - https://docs.mosek.com/latest/pythonapi/optimizer-task.html#mosek.task.putxxslice

The reasons to set an initial point in Mosek are:在 Mosek 中设置初始点的原因是:

  1. Starting feasible point for the mixed-integer solver when the problem has integer variables, in that case set itg当问题有 integer 个变量时混合整数求解器的起始可行点,在这种情况下设置itg

  2. Warm-starting the simplex solver, in that case set bas .热启动单纯形求解器,在这种情况下设置bas

  3. 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.热启动圆锥/内点解算器,在这种情况下设置itr ,尽管此选项只是理论上的,因为目前 Mosek 不会热启动并且只是忽略该解决方案。

Normally if there are any integer variables in the problem, then only the itg solution is relevant.通常如果问题中有任何 integer 个变量,那么只有itg解是相关的。 If the problem is linear and the simplex solver is explicitly chosen via a Mosek parameter then only the bas solution is relevant.如果问题是线性的,并且通过 Mosek 参数明确选择了单纯形求解器,则只有bas解是相关的。

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.然而,假设问题有 integer 个变量,但用户设置了 Mosek 参数iparam.mio_mode=ignore因为现在只想解决 LP 松弛问题。 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.有很多这样的极端情况,您必须明确检查很多 Mosek 参数(这些参数会随时间变化)才能做出决定。

One way out of this is to set all three primal solutions, and also set the parameter iparam.remove_unused_solutions .解决此问题的一种方法是设置所有三个原始解决方案,并设置参数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.然后,一旦 Mosek 内部决定使用哪个优化器,它就会清除此时不相关的那些解决方案。

Another option is that you only set the itg solution.另一种选择是您只设置itg解决方案。 It is very unlikely that any cvxpy users would use this feature for anything else than 1. above.任何 cvxpy 用户都不太可能将此功能用于上述 1. 之外的任何其他用途。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM