了解 Python/PuLP 代码片段
Understanding fragments of a Python/PuLP code
我必须采用他们使用 PuLP 包的现有脚本。我需要知道下一行的结果是怎样的:
unit = ["one", "two", "three"]
time = range(10)
status=LpVariable.dicts("status",[(f,g) for f in unit for g in time],0,1,LpBinary)
keys/values 长什么样?
status["one"] = [0,1,1,1...]?
非常感谢您的帮助!
from pulp import *
unit = ["one", "two"]
time = range(2)
status=LpVariable.dicts("status",[(f,g) for f in unit for g in time],0,1,LpBinary)
通往
>>> status
{('two', 1): status_('two',_1),
('two', 2): status_('two',_2),
('one', 2): status_('one',_2),
('one', 0): status_('one',_0),
('one', 1): status_('one',_1),
('two', 0): status_('two',_0)}
因此,没有包含关键字 "one" 的条目。
我必须采用他们使用 PuLP 包的现有脚本。我需要知道下一行的结果是怎样的:
unit = ["one", "two", "three"]
time = range(10)
status=LpVariable.dicts("status",[(f,g) for f in unit for g in time],0,1,LpBinary)
keys/values 长什么样?
status["one"] = [0,1,1,1...]?
非常感谢您的帮助!
from pulp import *
unit = ["one", "two"]
time = range(2)
status=LpVariable.dicts("status",[(f,g) for f in unit for g in time],0,1,LpBinary)
通往
>>> status
{('two', 1): status_('two',_1),
('two', 2): status_('two',_2),
('one', 2): status_('one',_2),
('one', 0): status_('one',_0),
('one', 1): status_('one',_1),
('two', 0): status_('two',_0)}
因此,没有包含关键字 "one" 的条目。