簡體   English   中英

Pyomo Set和Python set之間有什么區別嗎?

[英]Is there any differences between Pyomo Set and Python set?

第一次使用pyomo用戶。

在優化模型中聲明集合之間有什么區別嗎

model.A = Set(initialize = list_values) 

並使用像這樣的內置python集?

A = set(list_values)

一個相對於另一個有什么優勢嗎?

首先,您可以通過以下方式在約束規則中調用模型變量,集合,參數:

def some_constraint_rule(model):
    return model.some_set

因此,您無法通過python集執行此類操作,因為在約束規則中輸入的模型沒有python集。

其次,您無法索引python集(到目前為止,我知道,因此您需要一個字典?),但是使用pyomo集,您可以做更多的事情,例如:

m.t = pyomo.Set(
    within=m.index,
    initialize=something,
    ordered=True,
    doc='some documentation for your set?')

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM