Hi,

I am solving a life-cycle model. For every point in the state-space, I need to solve a bellman equation. The maximization routine takes a njit objective function and returns the maximum point. The routine is written in njit mode. The problem is, inside for loops, I need to define the objective function and do the maximization.

Here is a sudo-code

@njit

def solve_period():

for x in x_grid:

@njit

def obj()

GoldenSearch(obj, args)

Numba returns an error saying that it does not recognize the obj function. GoldenSearch() is njit compiled and works outside the loop. I need to use it inside the for loops since I am optimizing at every point in the state-space. I also want to make it fast since I have muli-level for loops in the solve_period() function.

Is there a way to make it work?