I am using L-BFGS-B optimizer from Scipy package. Here is the documentation.
My code has the following structure. obj_func is the objective function that is used to minimize "a". In order to do so, obj_func should only return "a".
Question: Is there a way to obtain "b" and "c" from obj_func?
Currently I am using function attribute. But I am not sure this is the preferred way.
def obj_func(x, *args)
a, b, c = compute(x) # compute is where major computation happens
# I want to access b and c from outside the function
obj_func.result = [b,c] # use function attribute
return a
result = optimize.fmin_l_bfgs_b(obj_func, x0, bounds=bounds, args=args)
b, c = obj_func.result