簡體   English   中英

有沒有辦法在 PuLP 中實現 IRR 算法?

[英]Is there a way to implement the IRR algorithm in PuLP?

Numpy 有一個 function 允許我計算浮點數組的 IRR。 我的問題是我試圖在紙漿問題中使用它,而我想傳遞給 function 的數組由問題的變量組成。 我在這

    problem = pulp.LpProblem("TIR_MINIMIZE", pulp.LpMaximize)
    price_ppa = pulp.LpVariable("price_ppa")
    price_production = []

    for i in range(10):
        price_production.append(price_ppa * annual_production[i])
        # anual_production is an array of values calculated outside the function

    irr = numpy.irr(price_production)

    # CONSTRAINTS #####################################################################################
    problem += irr>= 0.075

    objective_function = -irr
    problem += objective_function

    #####################################################################################################
    problem.solve()

這段代碼不起作用,因為 numpy.irr 需要一個浮點數組,而我將一個 LpAffineExpressions 數組傳遞給它。 我的問題是,有沒有辦法以某種簡單的方式實現這一點? 我曾嘗試手動實現該算法,但我無法在 PuLP 約束定義中執行此操作。

理論

IRR 計算本質上是非線性的,因此無法在 PuLP model 中處理。 PuLP 只處理線性模型。

實踐

您正在調用numpy.irr但這必須在 LP 求解器運行時調用。 這是不允許的。 LP 求解器不能調用外部函數。

暫無
暫無

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

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