The objective function is
def obj(w):
a = f(w)
return g(a)
The constraint function is
def cons(w):
a = f(w)
return a - 1
The function f(w) in both obj(w) and cons(w) is calculation heavy. How to calculate f(w) just once for every guess of w please?
Thanks.