I am trying to optimize a function to get it as close to zero as possible.
The function is:
def goal_seek_func(x: float) -> float:
lcos_list_temp = [energy_output[i] * x for i in range(life)]
npv_lcos_temp = npv(cost_capital, lcos_list_temp)
total = sum([cost_energy_capacity,
cost_power_conversion,
balance_of_plant,
cost_construction_commissioning,
npv_o_m,
npv_eol,
npv_cost_charging,
npv_lcos_temp,
])
return total
All the variables calculated previously in the code.
It is a linear equation, where as x
gets smaller, so does total
.
I am trying to find the value of x
where total
is as close to 0
as possible.
I have tried to use:
scipy.optimize.minimize_scalar(goal_seek_func)
but this clearly minimizes the equation to -inf
. I have read the docs, but cannot see where to define a target output of the function. Where can I define this, or is there a better method?