我有一个LP问题,我试图用Python-3中的PuLP来解决它。我能想到的一个选择是显式地编写所有变量,但我想避免它。有没有一种方法可以在这个问题中使用列表/字典?(我确实提到了使用dicts的https://pythonhosted.org/PuLP/CaseStudies/a_sudoku_problem.html,但不太了解整个解决方案)
假设wt{i,j,type}表示人[i]和人[j]之间的交易商品数量。在
LP问题:
(这里,cost{i,j}是所有(i,j)配对的已知成本。在
受制于:
我将非常感谢任何帮助,因为我是优化和python/pull的初学者。在
“list/dicts”是一种在域(索引变量)上定义变量的方法。
LpVariable.dicts()
的indexs
参数定义所提供集的域笛卡尔积。另见纸浆的文档-LpVariable。在下面的代码示例并不包含您的所有约束,但我相信您可以轻松地填充其余的约束。约束1(带有
const1
和const2
)通过wt
变量的上下界来处理。在相关问题 更多 >
编程相关推荐