3 回答

TA贡献1830条经验 获得超3个赞
如果你看看你的变量:
{('Detroit', 'Boston', 'Pencils'): <gurobi.Var C0>,
('Detroit', 'Boston', 'Pens'): <gurobi.Var C1>,
('Detroit', 'New York', 'Pencils'): <gurobi.Var C2>,
('Detroit', 'New York', 'Pens'): <gurobi.Var C3>,
('Detroit', 'Seattle', 'Pencils'): <gurobi.Var C4>,
('Detroit', 'Seattle', 'Pens'): <gurobi.Var C5>,
('Denver', 'Boston', 'Pencils'): <gurobi.Var C6>,
('Denver', 'Boston', 'Pens'): <gurobi.Var C7>,
('Denver', 'New York', 'Pencils'): <gurobi.Var C8>,
('Denver', 'New York', 'Pens'): <gurobi.Var C9>,
('Denver', 'Seattle', 'Pencils'): <gurobi.Var C10>,
('Denver', 'Seattle', 'Pens'): <gurobi.Var C11>}
你会看到你需要解开每个元组arcs:
m.addConstrs( flow[e1, e2, c] == 1 for e1, e2 in arcs for c in commodities)
添加回答
举报