Optimal policy parameters in a non-linear model with csminwel

Hi.
I am trying to find the parameters in a Taylore rule that maximize the unconditional welfare in the same way as in the topic:

I ran the same code as in the topic but it did not work. I think there is some incompatibility between the code and the dynare version/csminwel function. I changed some things like (codes in annex):

info = stoch_simul(var_list_);

to

info = stoch_simul(M_, options_, oo_,var_list_);

The code now runs, but the check that Professor Pfeifer proposed in the topic above is suggesting that something is wrong: The mean of v in the approximated theoretical moments is not minus the value of fhat.
I believe csminwel is not searching in the range of x_opt_name, so fhat is stucked in the initial point.

Would you please check what should be the changes that I have to do? The changes in CMAES also would help.

Thank you.

housing.mod (9.1 KB)
welfare_objective.m (943 Bytes)
csminwel.m (11.7 KB)

You did not ask for the output of stoch_simul:

[info, oo_] = stoch_simul(M_, options_, oo_, var_list_);

Use
welfare_objective2.m (824 Bytes)