问题描述
在这段代码中:
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)
我正在寻找一种选择暖身值 我自己的方式 (例如:x = 1/2和y = 1/2),而不是先前的求解器结果。
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.
有什么办法可以给求解器输入?如果不是,是否还有cvxpy的非商业替代方案?
Is there any way to give the solver this input? And if not, is there a non-commercial alternative to cvxpy?
推荐答案
您可以使用<$ c $手动分配值c> x.value = 1/2 ,然后在可用的求解器中传递 warm_start = True
参数。请记住,并非所有求解器都允许这样做,例如SCS。
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
这篇关于CVXPY中的初始猜测/热启动:给出解决方案的提示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!