得到多種功能的值,讓我們假設目標函數是如何Pyomo
max z(x,y) = f1(x) - f2(y)
其中f1
是變量函數x
和f2
是變量y
功能。
這可能在Pyomo容易通過調用(因爲它是目標函數)可以寫成
def z(model):
return f1(model) - f2(model)
def f1(model):
return [some summation of x variables with some coefficients]
def f2(model):
return [some summation of y variables with some coefficients]
model.objective = Objective(rule=z)
我知道這是可能得到的z(x,y)
數值:
print(model.objective())
但有沒有辦法在優化之後分開獲取這些子函數的數值,即使它們沒有明確定義爲目標?