连接两个约束时遇到的问题

2024-09-26 22:54:52 发布

您现在位置:Python中文网/ 问答频道 /正文

我试图在这个优化问题中加入这些约束,但无论我做什么,我都会得到错误“'generator'对象没有属性'variables'”

objective2 = cp.Minimize(cp.norm(s_new - ss))
constraints2 = [s_newi <=1 and s_newi >= 0 for s_newi in s_new)]
prob2 = cp.Problem(objective2, constraints2)
print("Second problem:", prob2.solve())
print("s_new:", s_new.value)

Tags: 对象normnew属性错误variablesgeneratorcp

热门问题