Challenge with Ramsey Policy

Dear Prof. Pfeifer,

I am attempting to solve the Ramsey policy of a rent-seeking policymaker in a DSGE model with heterogenous households and firms. Upon solving with Dynare 4.5.7, I get the warning and error messages saying:

warning: division by zero

error: Ramsey: The steady state file computation for the Ramsey problem resulted in NaNs at the initial values of the instruments.

II have attached the codes. Please could you help go through it to point out the source(s) of this error?
csae3.mod (2.7 KB)

Your steady state uses W before you ever set it.

Thank you, Prof.,

I have adjusted W in the steady_state as you suggested but it still gives the error message:

Ramsey: The steady state file computation for the Ramsey problem resulted in NaNs at the initial values of the instruments

csae3.mod (2.7 KB)

Now you are using Y_r/N_r and both have not been set. Essentially do the following:

Thank you Prof. Pfeifer.