小编Stu*_*run的帖子

类型错误:不支持的操作数类型 -:“生成器”和“NoneType”

当尝试进行简单的减法时,Python 给出了一个 typererror : TypeError: unsupported operand type(s) for -: 'generator' and 'NoneType'。在我看来,两侧只是数字,所以我并不真正理解这个问题。这是我的代码

m.addConstr(sum(x[i,j,t] for i in sub_nodes[z] for j in sub_nodes[z] if j>i) <=
            sum(y[i,t] for i in sub_nodes[z]) - max([y[k,t] for k in sub_nodes[z]]) 
                                                            for z in range(len(sub_nodes))
                                                            for t in periods)
Run Code Online (Sandbox Code Playgroud)

这是关于第二行的减号。我正在使用 Gurobi 求解器。有谁知道如何使这段代码工作吗?

python gurobi

6
推荐指数
1
解决办法
6974
查看次数

标签 统计

gurobi ×1

python ×1