0

我正在用纸浆写一个离散的问题。我的代码如下:

from pulp import *

ind = [1,2,3,4,5,6,7,8,9]

opt_model = LpProblem("Model", LpMinimize)

x_vars  = {(i): LpVariable(cat = LpInteger, lowBound = 0, name="x_{0}".format(i)) for i in ind}

x_vars  = {1: x_1, 2: x_2, 3: x_3, 4: x_4, 5: x_5, 6: x_6, 7: x_7, 8: x_8, 9: x_9}

如何使 x_i 取列表 [0,4,5,6,10] 的一个值?

x_i : [0,4,5,6,10] for i in ind
4

0 回答 0