Commit 1d67940e authored by Sébastien Villemot's avatar Sébastien Villemot
Browse files

Merge commit 'remotes/ferhat/master~2'

parents 7e29a03f dfec70bc
......@@ -114,12 +114,18 @@ else
oo_.exo_det_steady_state], M_.params);
end;
else
% linear models
[fvec,jacob] = feval(fh,steady_state,[oo_.exo_steady_state;...
oo_.exo_det_steady_state], M_.params);
if max(abs(fvec)) > 1e-12
steady_state = steady_state-jacob\fvec;
end
if (options_.block == 0 && options_.bytecode == 0)
% linear models
[fvec,jacob] = feval(fh,steady_state,[oo_.exo_steady_state;...
oo_.exo_det_steady_state], M_.params);
if max(abs(fvec)) > 1e-12
steady_state = steady_state-jacob\fvec;
end
else
[steady_state,check1] = dynare_solve_block_or_bytecode(steady_state,...
[oo_.exo_steady_state; ...
oo_.exo_det_steady_state], M_.params);
end;
end
end
end
......
......@@ -63,30 +63,36 @@ ghx = dr.ghx;
ghu = dr.ghu;
npred = dr.npred;
nstatic = dr.nstatic;
kstate = dr.kstate;
order_var = dr.order_var;
inv_order_var = dr.inv_order_var;
nx = size(ghx,2);
ikx = [nstatic+1:nstatic+npred];
k0 = kstate(find(kstate(:,2) <= M_.maximum_lag+1),:);
i0 = find(k0(:,2) == M_.maximum_lag+1);
i00 = i0;
n0 = length(i0);
AS = ghx(:,i0);
ghu1 = zeros(nx,M_.exo_nbr);
ghu1(i0,:) = ghu(ikx,:);
for i=M_.maximum_lag:-1:2
i1 = find(k0(:,2) == i);
n1 = size(i1,1);
j1 = zeros(n1,1);
for k1 = 1:n1
j1(k1) = find(k0(i00,1)==k0(i1(k1),1));
nx = size(ghx,2);
if options_.block == 0
%order_var = dr.order_var;
inv_order_var = dr.inv_order_var;
kstate = dr.kstate;
ikx = [nstatic+1:nstatic+npred];
k0 = kstate(find(kstate(:,2) <= M_.maximum_lag+1),:);
i0 = find(k0(:,2) == M_.maximum_lag+1);
i00 = i0;
n0 = length(i0);
AS = ghx(:,i0);
ghu1 = zeros(nx,M_.exo_nbr);
ghu1(i0,:) = ghu(ikx,:);
for i=M_.maximum_lag:-1:2
i1 = find(k0(:,2) == i);
n1 = size(i1,1);
j1 = zeros(n1,1);
for k1 = 1:n1
j1(k1) = find(k0(i00,1)==k0(i1(k1),1));
end
AS(:,j1) = AS(:,j1)+ghx(:,i1);
i0 = i1;
end
AS(:,j1) = AS(:,j1)+ghx(:,i1);
i0 = i1;
end
else
ghu1 = zeros(nx,M_.exo_nbr);
trend = 1:M_.endo_nbr;
inv_order_var = trend(M_.block_structure.variable_reordered);
ghu1(1:length(dr.state_var),:) = ghu(dr.state_var,:);
end;
b = ghu1*M_.Sigma_e*ghu1';
......
......@@ -1891,7 +1891,7 @@ Interpreter::simulate_a_block(const int size, const int type, string file_name,
}
else
{
for (it_ = periods+y_kmin; it_ > y_kmin; it_--)
for (it_ = periods+y_kmin-1; it_ >= y_kmin; it_--)
{
cvg = false;
iter = 0;
......@@ -2239,7 +2239,7 @@ Interpreter::simulate_a_block(const int size, const int type, string file_name,
if (!is_linear)
{
max_res_idx = 0;
for (it_ = periods+y_kmin; it_ > y_kmin; it_--)
for (it_ = periods+y_kmin-1; it_ >= y_kmin; it_--)
{
cvg = false;
iter = 0;
......@@ -2297,7 +2297,7 @@ Interpreter::simulate_a_block(const int size, const int type, string file_name,
}
else
{
for (it_ = periods+y_kmin; it_ > y_kmin; it_--)
for (it_ = periods+y_kmin-1; it_ >= y_kmin; it_--)
{
it_code = begining;
Per_y_ = it_*y_size;
......
......@@ -2324,16 +2324,15 @@ DynamicModel::writeOutput(ostream &output, const string &basename, bool block_de
<< "M_.nboth = " << nboth << ";" << endl;
for (int endoID = 0; endoID < symbol_table.endo_nbr(); endoID++)
{
output << endl;
// Loop on periods
for (int lag = -max_endo_lag; lag <= max_endo_lead; lag++)
for (int lag = -max_endo_lag; lag < 0; lag++)
{
// Print variableID if exists with current period, otherwise print 0
try
{
int varID = getDerivID(variable_reordered[symbol_table.getID(eEndogenous, endoID)], lag);
if (lag < 0 && find(state_var.begin(), state_var.end(), variable_reordered[symbol_table.getID(eEndogenous, endoID)]+1) == state_var.end())
state_var.push_back(variable_reordered[symbol_table.getID(eEndogenous, endoID)]+1);
getDerivID(symbol_table.getID(eEndogenous, variable_reordered[endoID]), lag);
if (lag < 0 && find(state_var.begin(), state_var.end(), variable_reordered[endoID]+1) == state_var.end())
state_var.push_back(variable_reordered[endoID]+1);
}
catch (UnknownDerivIDException &e)
{
......
Markdown is supported
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