如何使用NPAARRAY PURP PYTHON创建lpvariables
我正在使用纸浆求解器来处理数千个变量的优化问题。 变量以阵列(约200个数组)保存,每个Arry均为50 * 50维度。
_t111 = ['xx1', 'xa1', 'xb1', 'xc1', 'xd1', 'xe1', 'xf1', 'xg1', 'xh1', 'xi1', 'xj1', 'xxa1', 'xxb1','xxc1', 'xxd1', 'xxe1', 'xxf1', 'xxg1', 'xxh1', 'xxi1', 'xxj1', 'xxxa1', 'xxxb1', 'xxxc1', 'xxxd1','xxxe1', 'xxxf1', 'xxxg1', 'xxxh1', 'xxxi1', 'xxxj1', 'xxxxa1', 'xxxxb1', 'xxxxc1', 'xxxxd1', 'xxxxe1', 'xxxxf1', 'xxxxg1', 'xxxxh1', 'xxxxi1', 'xxxxj1', 'xxxxxa1', 'xxxxxb1', 'xxxxxc1','xxxxxd1', 'xxxxxe1', 'xxxxxf1', 'xxxxxg1', 'xxxxxh1', 'xxxxxi1', 'xxxxxj1']
t111 = np.array([[LpVariable(f"{i}{j}", cat=LpBinary) for i in _t111] for j in _t111])
我在论坛中找到了这种方法。我声明了所有_t111,_t112 ...在变量T111 T112之前。 更好的方法吗?
我确定有人可以帮助我的
I'm using pulp solver to handle an optimization probleme with thousands of variables.
The variables are held in arrays ( around 200 arrays) and each arry is a 50 * 50 dimensions.
_t111 = ['xx1', 'xa1', 'xb1', 'xc1', 'xd1', 'xe1', 'xf1', 'xg1', 'xh1', 'xi1', 'xj1', 'xxa1', 'xxb1','xxc1', 'xxd1', 'xxe1', 'xxf1', 'xxg1', 'xxh1', 'xxi1', 'xxj1', 'xxxa1', 'xxxb1', 'xxxc1', 'xxxd1','xxxe1', 'xxxf1', 'xxxg1', 'xxxh1', 'xxxi1', 'xxxj1', 'xxxxa1', 'xxxxb1', 'xxxxc1', 'xxxxd1', 'xxxxe1', 'xxxxf1', 'xxxxg1', 'xxxxh1', 'xxxxi1', 'xxxxj1', 'xxxxxa1', 'xxxxxb1', 'xxxxxc1','xxxxxd1', 'xxxxxe1', 'xxxxxf1', 'xxxxxg1', 'xxxxxh1', 'xxxxxi1', 'xxxxxj1']
t111 = np.array([[LpVariable(f"{i}{j}", cat=LpBinary) for i in _t111] for j in _t111])
I have found this method in a forum. I declare all my _t111, _t112... before the variables t111 t112.. the prob is that it takes me a lot to comple it. I'm sure there is a better way
Some one can help me ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论