简体   繁体   English

Mosek求解器中决策变量值的初始化(通过Cvxpy框架)

[英]Initialization of decision variable's value in Mosek solver (via Cvxpy framework)

We have a optimization problem and want to initialize its decision variable's value for fast convergence.我们有一个优化问题,想要初始化其决策变量的值以实现快速收敛。

We are using Mosek solver (via its Cvxpy interface).我们正在使用 Mosek 求解器(通过其 Cvxpy 接口)。

Any help appreciated, Thank you very much!任何帮助表示赞赏,非常感谢!

Regarding your question about Pyomo in the comments: Yes, Pyomo's MOSEK interface will let you initialize the variables.关于您在评论中关于 Pyomo 的问题:是的,Pyomo 的 MOSEK 接口将让您初始化变量。 The following code provides you an example of what you can do in Pyomo-MOSEK:以下代码为您提供了在 Pyomo-MOSEK 中可以执行的操作的示例:

import mosek
import pyomo.kernel as pmo

solver = pmo.SolverFactory('mosek')

model = pmo.block()

# Integer variables with initial solution
init_sol = [1, 1, 0]
model.x = pmo.variable_list(pmo.variable(
    domain=pmo.NonNegativeIntegers, value=init_sol[i]) for i in range(3))
# Continuous variable
model.x.append(pmo.variable(domain=pmo.NonNegativeReals))

model.con_1 = pmo.constraint(sum(model.x) <= 2.5)

model.obj = pmo.objective(
    7*model.x[0] + 10*model.x[1] + model.x[2] + 5*model.x[3], sense=pmo.maximize)

# Solve "model" with warmstart set to True.
solver.solve(model, tee=True, warmstart=True)

print("Initial solution utilization = {}".format(
    solver._solver_model.getintinf(mosek.iinfitem.mio_construct_solution)))
print("Initial solution objective value = {}".format(
    solver._solver_model.getdouinf(mosek.dinfitem.mio_construct_solution_obj)))

PS: I did not have enough reputation to respond to the comment directly, hence the answer. PS:我没有足够的声誉直接回复评论,因此答案。 Sorry about that.对于那个很抱歉。

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

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