Numpy has a function which allows me to calculate the IRR of an array of floats. My problem is that I am trying to use it within a PuLP problem, and the array that I want to pass to the function is compossed of the variables of the problem. Here i
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()
And this code doesn't work because numpy.irr is expecting an array of floats, while I pass it an array of LpAffineExpressions. My question is, is there a way to implement this in a somewhat easy way? I have tried to implement the algorithm manually, but I can't do it inside the PuLP constraint definition.