Unrecognized function or variable 'perfect_foresight_problem'

Hi, I try to solve this model by the perfect foresight path for deterministic shocks. But keep getting this error:

Unrecognized function or variable ‘perfect_foresight_problem’.

I even reinstall Dynare 6.2 in my Matlab but still doesn’t work.

Here I also attached my code. Could you please tell me where I am wrong?

Really thank you!
PS2.mod (1.3 KB)

I can run your code without issues. There must be something wrong with your installation. Can you provide the full output of the error message.

Sure! Here it is!


Unrecognized function or variable 'perfect_foresight_problem'.

Error in sim1 (line 70)
    [res, A] = perfect_foresight_problem(y, y0, yT, exogenousvariables, M_.params, steadystate, periods, M_, options_);

Error in perfect_foresight_solver_core (line 103)
                    [y, success, maxerror, iter] = sim1(y, exo_simul, steady_state, M_, options_);

Error in perfect_foresight_solver>homotopy_loop (line 357)
        [endo_simul, success, maxerror, solver_iter, per_block_status] = perfect_foresight_solver_core(endo_simul, exo_simul, steady_state, exo_steady_state, M_, options_);

Error in perfect_foresight_solver (line 153)
[completed_share, endo_simul, exo_simul, steady_state, exo_steady_state, iteration, maxerror, solver_iter, per_block_status] = homotopy_loop(M_,options_,oo_,options_.simul.homotopy_max_completion_share, shareorig, endoorig, exoorig, endobase, exobase, initperiods, simperiods, lastperiods, recompute_final_steady_state, oo_.steady_state, oo_.exo_steady_state);

Error in PS2.driver (line 363)
[oo_, Simulated_time_series] = perfect_foresight_solver(M_, options_, oo_);

Error in dynare (line 308)
    evalin('base',[fname '.driver']);

That looks like the mex-files are missing. What is your OS? What is the content of the dynare/mex/matlab subfolder?

I am using macOS 13.4.1, Matlab R2023a + Dynare 6.2, both in Arm64. Here is the content I find at dynare/mex/matlab:

@wmutschl Do you maybe know what is going on?

Hi, I just tried Dynare in x86 and suddenly it works. I guess I must remember the wrong version of my Matlab and since everything runs well in stochastic situation I didn’t find this problem before. Sorry for the disturbance and thank you so much for your help!

Hi, @jpfeifer
I’m experiencing the same issue as Hegema regarding the “Unrecognized function or variable ‘perfect_foresight_problem’” error.

Whenever I try to solve a perfect foresight problem for a deterministic model, I encounter the exact same error message. Additionally, the full error output is identical to the one Hegema shared earlier.

I attempted to use the same file (PS2.mod) and followed the suggested solution of re-downloading Dynare for the x86. However, the issue persists for me.

I’m using macOS 15 + Matlab R2024a + Dynare 6.2.

Despite following the suggested steps, the problem remains unresolved. Could anyone suggest alternative methods to address this issue?

Thank you in advance for your help!

Hi, my old problem is I did not match the version of Matlab and Dynare at the same time. Once I use them both in X86 version, everything is fine. That’s what I found. Maybe you can try it.

Thank you!

1 Like