Commit 31b6c083 authored by Ferhat Mihoubi's avatar Ferhat Mihoubi
Browse files

Correct a bug when the model contains deterministic exogenous variables and...

Correct a bug when the model contains deterministic exogenous variables and bytecode option is used.
Note that stochastic simulations do not work for the moment with block option.
parent 0359c280
......@@ -160,7 +160,7 @@ else
if (options_.bytecode)
[chck, junk, loc_dr] = bytecode('dynamic','evaluate', z,[oo_.exo_simul ...
oo_.exo_det_simul], M_.params, dr.ys, 1);
jacobia_ = [loc_dr.g1 loc_dr.g1_x];
jacobia_ = [loc_dr.g1 loc_dr.g1_x loc_dr.g1_xd];
else
[junk,jacobia_] = feval([M_.fname '_dynamic'],z,[oo_.exo_simul ...
oo_.exo_det_simul], M_.params, dr.ys, it_);
......
......@@ -250,8 +250,8 @@ main(int nrhs, const char *prhs[])
xd = mxGetPr(mxGetFieldByNumber(oo_, 0, mxGetFieldNumber(oo_, "exo_simul")));
row_x = mxGetM(mxGetFieldByNumber(oo_, 0, mxGetFieldNumber(oo_, "exo_simul")));
col_x = mxGetN(mxGetFieldByNumber(oo_, 0, mxGetFieldNumber(oo_, "exo_simul")));
nb_row_xd = row_x;
}
nb_row_xd = int (floor(*(mxGetPr(mxGetFieldByNumber(M_, 0, mxGetFieldNumber(M_, "exo_det_nbr"))))));
y_kmin = int (floor(*(mxGetPr(mxGetFieldByNumber(M_, 0, mxGetFieldNumber(M_, "maximum_lag"))))));
y_kmax = int (floor(*(mxGetPr(mxGetFieldByNumber(M_, 0, mxGetFieldNumber(M_, "maximum_lead"))))));
......@@ -267,7 +267,7 @@ main(int nrhs, const char *prhs[])
steady_xd = mxGetPr(mxGetFieldByNumber(oo_, 0, mxGetFieldNumber(oo_, "exo_steady_state")));
steady_row_x = mxGetM(mxGetFieldByNumber(oo_, 0, mxGetFieldNumber(oo_, "exo_steady_state")));
steady_col_x = mxGetN(mxGetFieldByNumber(oo_, 0, mxGetFieldNumber(oo_, "exo_steady_state")));
steady_nb_row_xd = int (floor(*(mxGetPr(mxGetFieldByNumber(M_, 0, mxGetFieldNumber(M_, "exo_det_nbr"))))));
steady_nb_row_xd = steady_row_x;
}
else
{
......@@ -280,8 +280,8 @@ main(int nrhs, const char *prhs[])
xd = mxGetPr(mxGetFieldByNumber(oo_, 0, mxGetFieldNumber(oo_, "exo_steady_state")));
row_x = mxGetM(mxGetFieldByNumber(oo_, 0, mxGetFieldNumber(oo_, "exo_steady_state")));
col_x = mxGetN(mxGetFieldByNumber(oo_, 0, mxGetFieldNumber(oo_, "exo_steady_state")));
nb_row_xd = row_x;
}
nb_row_xd = int (floor(*(mxGetPr(mxGetFieldByNumber(M_, 0, mxGetFieldNumber(M_, "exo_det_nbr"))))));
}
int maxit_ = int (floor(*(mxGetPr(mxGetFieldByNumber(options_, 0, mxGetFieldNumber(options_, "maxit_"))))));
double slowc = double (*(mxGetPr(mxGetFieldByNumber(options_, 0, mxGetFieldNumber(options_, "slowc")))));
......
......@@ -837,7 +837,8 @@ DynamicModel::writeModelEquationsCode(string &file_name, const string &bin_basen
for (int i = 0; i < symbol_table.exo_nbr(); i++)
exo.push_back(i);
map<pair< int, pair<int, int> >, expr_t> first_derivatives_reordered_endo, first_derivatives_reordered_exo;
map<pair< int, pair<int, int> >, expr_t> first_derivatives_reordered_endo;
map<pair< pair<int, int>, pair<int, int> >, expr_t> first_derivatives_reordered_exo;
for (first_derivatives_t::const_iterator it = first_derivatives.begin();
it != first_derivatives.end(); it++)
{
......@@ -849,7 +850,7 @@ DynamicModel::writeModelEquationsCode(string &file_name, const string &bin_basen
if (getTypeByDerivID(deriv_id) == eEndogenous)
first_derivatives_reordered_endo[make_pair(lag, make_pair(var, eq))] = it->second;
else if (getTypeByDerivID(deriv_id) == eExogenous || getTypeByDerivID(deriv_id) == eExogenousDet)
first_derivatives_reordered_exo[make_pair(lag, make_pair(var, eq))] = it->second;
first_derivatives_reordered_exo[make_pair(make_pair(lag, getTypeByDerivID(deriv_id)), make_pair(var, eq))] = it->second;
}
int prev_var = -1;
int prev_lag = -999999999;
......@@ -868,21 +869,24 @@ DynamicModel::writeModelEquationsCode(string &file_name, const string &bin_basen
}
prev_var = -1;
prev_lag = -999999999;
int prev_type = -1;
int count_col_exo = 0;
for (map<pair< int, pair<int, int> >, expr_t>::const_iterator it = first_derivatives_reordered_exo.begin();
for (map<pair< pair<int, int>, pair<int, int> >, expr_t>::const_iterator it = first_derivatives_reordered_exo.begin();
it != first_derivatives_reordered_exo.end(); it++)
{
int var = it->first.second.first;
int lag = it->first.first;
if (prev_var != var || prev_lag != lag)
int lag = it->first.first.first;
int type = it->first.first.second;
if (prev_var != var || prev_lag != lag || prev_type != type)
{
prev_var = var;
prev_lag = lag;
prev_type = type;
count_col_exo++;
}
}
FBEGINBLOCK_ fbeginblock(symbol_table.endo_nbr(),
simulation_type,
0,
......@@ -1010,12 +1014,12 @@ DynamicModel::writeModelEquationsCode(string &file_name, const string &bin_basen
prev_var = -1;
prev_lag = -999999999;
count_col_exo = 0;
for (map<pair< int, pair<int, int> >, expr_t>::const_iterator it = first_derivatives_reordered_exo.begin();
for (map<pair< pair<int, int>, pair<int, int> >, expr_t>::const_iterator it = first_derivatives_reordered_exo.begin();
it != first_derivatives_reordered_exo.end(); it++)
{
unsigned int eq = it->first.second.second;
int var = it->first.second.first;
int lag = it->first.first;
int lag = it->first.first.first;
expr_t d1 = it->second;
FNUMEXPR_ fnumexpr(FirstExoDerivative, eq, var, lag);
fnumexpr.write(code_file, instruction_number);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment