我必須採用他們使用PuLP程序包的現有腳本。我需要知道下列行的結果如何:瞭解Python/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)
鍵/值的外觀如何?
status["one"] = [0,1,1,1...]?
非常感謝您的幫助!
以下是['LpVariable.dicts']的文檔(http://www.coin-or.org/PuLP/pulp.html#pulp.LpVariable.dicts)。該代碼的哪一部分是你特別困惑的,列表理解? – CoryKramer
嘿!謝謝您的回覆。我查看了文檔 - 但不幸的是,我不確定「狀態」是什麼樣子的(文檔中也沒有結果的例子) – Matias
你的意思是狀態,而不是「狀態」,因爲後者只是一個字符串,右鍵? – Dschoni