【发布时间】:2022-11-27 21:17:27
【问题描述】:
嘿,目前我正在尝试使用 Python 编写二次规划算法。 但是我正在努力创建一个指示问题维度的向量。
我的问题:我正在尝试创建一个包含 N 个元素的向量 x = [x_1, x_2, x_3, ..., x_N] 。 N 变化。元素“x_N”应该是变量/我的优化问题的解决方案。
到目前为止我的代码:('NoE'... 等于 N+1,这就是我在 while 语句中减去 1 的原因)
#filling the x-vector according to the dimension of the given problem
temp_2 = 0
while temp_2 <= (NoE-1):
x[temp_2]= 'x_' + temp_2
print(x)
感谢您的帮助! :)
【问题讨论】: