Initial Guess/Warm start in CVXPY: give a hint of the solution

血红的双手。 提交于 2020-06-22 12:54:53

问题


In this bit of code:

import cvxpy as cvx

# Examples: linear programming
# Create two scalar optimization variables.
x = cvx.Variable()
y = cvx.Variable()

# Create 4 constraints.
constraints = [x >= 0,
               y >= 0,
               x + y >= 1,
              2*x + y >= 1]

# Form objective.
obj = cvx.Minimize(x+y)

# Form and solve problem.
prob = cvx.Problem(obj, constraints)
prob.solve(warm_start= True)  # Returns the optimal value.
print ("status:", prob.status)
print ("optimal value", prob.value)
print ("optimal var", x.value, y.value)

I'm looking for a way to choose the warm start value myself (for example: x = 1/2 and y = 1/2), not the previous solver result.

Is there any way to give the solver this input? And if not, is there a non-commercial alternative to cvxpy?


回答1:


You can manually assign the values using x.value = 1/2, and then passing the warm_start=True parameter in the available solvers. Keep in mind not all solvers allow this, one that does is for example SCS.

More info available on: https://www.cvxpy.org/tutorial/advanced/index.html



来源:https://stackoverflow.com/questions/52314581/initial-guess-warm-start-in-cvxpy-give-a-hint-of-the-solution

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!