Commit 55bb27c5 authored by MichelJuillard's avatar MichelJuillard
Browse files

new correction for steady_state operator bug. Steady_state vector is passed as...

new correction for steady_state operator bug. Steady_state vector is passed as argument to *_dynamic model function. As a result, bytecode is currently broken.
parent dcfe3e57
......@@ -163,7 +163,7 @@ else
jacobia_ = [loc_dr.g1 loc_dr.g1_x];
else
[junk,jacobia_] = feval([M_.fname '_dynamic'],z,[oo_.exo_simul ...
oo_.exo_det_simul], M_.params, it_);
oo_.exo_det_simul], M_.params, dr.ys, it_);
end;
elseif options_.order == 2
if (options_.bytecode)
......@@ -173,7 +173,7 @@ else
else
[junk,jacobia_,hessian1] = feval([M_.fname '_dynamic'],z,...
[oo_.exo_simul ...
oo_.exo_det_simul], M_.params, it_);
oo_.exo_det_simul], M_.params, dr.ys, it_);
end;
if options_.use_dll
% In USE_DLL mode, the hessian is in the 3-column sparse representation
......
......@@ -62,9 +62,11 @@ else
Size = 1;
end;
if (options_.bytecode)
[chck, zz, data]= bytecode('dynamic','evaluate',z,[oo_.exo_simul oo_.exo_det_simul], M_.params, 1, data);
[chck, zz, data]= bytecode('dynamic','evaluate',z,[oo_.exo_simul ...
oo_.exo_det_simul], M_.params, dr.ys, 1, data);
else
[r, data] = feval([M_.fname '_dynamic'], z', [oo_.exo_simul oo_.exo_det_simul], M_.params, 2, data);
[r, data] = feval([M_.fname '_dynamic'], z', [oo_.exo_simul ...
oo_.exo_det_simul], M_.params, dr.ys, 2, data);
chck = 0;
end;
mexErrCheck('bytecode', chck);
......
......@@ -73,7 +73,8 @@ Uy = Uy';
Uyy = reshape(Uyy,endo_nbr,endo_nbr);
% retrieving derivatives of original model
[f,fJ,fH] = feval([fname '_dynamic'],y(k),zeros(2,exo_nbr), M_.params, it_);
[f,fJ,fH] = feval([fname '_dynamic'],y(k),zeros(2,exo_nbr), M_.params, ys, ...
it_);
instr_nbr = endo_nbr - size(f,1);
mult_nbr = endo_nbr-instr_nbr;
......
......@@ -87,7 +87,8 @@ y = repmat(x(i_endo),1,max_lag+max_lead+1);
k = find(i_lag');
it_ = 1;
% [f,fJ,fH] = feval([fname '_dynamic'],y(k),ex);
[f,fJ] = feval([fname '_dynamic'],y(k),[oo.exo_simul oo.exo_det_simul], M_.params, it_);
[f,fJ] = feval([fname '_dynamic'],y(k),[oo.exo_simul oo.exo_det_simul], ...
M_.params, x, it_);
% indices of Lagrange multipliers
inst_nbr = endo_nbr - size(f,1);
i_mult = [endo_nbr+1:2*endo_nbr-inst_nbr]';
......
function ra = lnsrch1_wrapper_two_boundaries(ya, fname, y, y_index, x, params, periods, y_kmin, y_size)
function ra = lnsrch1_wrapper_two_boundaries(ya, fname, y, y_index, x, ...
params, steady_state, periods, y_kmin, y_size)
% wrapper for solve_one_boundary m-file when it is used with a dynamic
% model
%
......@@ -44,5 +45,5 @@ function ra = lnsrch1_wrapper_two_boundaries(ya, fname, y, y_index, x, params, p
%reshape the input arguments of the dynamic function
y(y_kmin+1:y_kmin+periods, y_index) = reshape(ya',length(y_index),periods)';
[r, y, g1, g2, g3, b]=feval(fname, y, x, params, periods, 0, y_kmin, y_size);
[r, y, g1, g2, g3, b]=feval(fname, y, x, params, steady_state, periods, 0, y_kmin, y_size);
ra = reshape(r(:, y_kmin+1:periods+y_kmin),periods*y_size, 1);
......@@ -133,7 +133,7 @@ else
end
z = z(iyr0) ;
[junk,jacobia_] = feval([M_.fname '_dynamic'],z,[oo_.exo_simul ...
oo_.exo_det_simul], M_.params, it_);
oo_.exo_det_simul], M_.params, dr.ys, it_);
if options_.ACES_solver==1 && (length(sim_ruleids)>0 || length(tct_ruleids)>0 )
if length(sim_ruleids)>0
......
......@@ -68,14 +68,15 @@ for iter = 1:options_.maxit_
it_ = it_init ;
z = [oo_.endo_simul(iyp,it_-1) ; oo_.endo_simul(:,it_) ; oo_.endo_simul(iyf,it_+1)] ;
[d1,jacobian] = feval([M_.fname '_dynamic'],z,oo_.exo_simul, M_.params, it_);
[d1,jacobian] = feval([M_.fname '_dynamic'],z,oo_.exo_simul, M_.params, oo_.steady_state,it_);
jacobian = [jacobian(:,iz) -d1] ;
ic = [1:ny] ;
icp = iyp ;
c (ic,:) = jacobian(:,is)\jacobian(:,isf1) ;
for it_ = it_init+(1:options_.periods-1)
z = [oo_.endo_simul(iyp,it_-1) ; oo_.endo_simul(:,it_) ; oo_.endo_simul(iyf,it_+1)] ;
[d1,jacobian] = feval([M_.fname '_dynamic'],z,oo_.exo_simul, M_.params, it_);
[d1,jacobian] = feval([M_.fname '_dynamic'],z,oo_.exo_simul, ...
M_.params, oo_.steady_state, it_);
jacobian = [jacobian(:,iz) -d1] ;
jacobian(:,[isf nrs]) = jacobian(:,[isf nrs])-jacobian(:,isp)*c(icp,:) ;
ic = ic + ny ;
......
function [y, info] = solve_one_boundary(fname, y, x, params, y_index_eq, nze, periods, is_linear, Block_Num, y_kmin, maxit_, solve_tolf, lambda, cutoff, stack_solve_algo, forward_backward, is_dynamic, verbose)
function [y, info] = solve_one_boundary(fname, y, x, params, steady_state, ...
y_index_eq, nze, periods, is_linear, Block_Num, y_kmin, maxit_, solve_tolf, lambda, cutoff, stack_solve_algo, forward_backward, is_dynamic, verbose)
% Computes the deterministic simulation of a block of equation containing
% lead or lag variables
%
......@@ -8,6 +9,7 @@ function [y, info] = solve_one_boundary(fname, y, x, params, y_index_eq, nze, pe
% y [matrix] All the endogenous variables of the model
% x [matrix] All the exogenous variables of the model
% params [vector] All the parameters of the model
% steady_state [vector] steady state of the model
% y_index_eq [vector of int] The index of the endogenous variables of
% the block
% nze [integer] number of non-zero elements in the
......@@ -95,9 +97,10 @@ for it_=start:incr:finish
g1=spalloc( Blck_size, Blck_size, nze);
while ~(cvg==1 || iter>maxit_),
if(is_dynamic)
[r, y, g1, g2, g3] = feval(fname, y, x, params, it_, 0);
[r, y, g1, g2, g3] = feval(fname, y, x, params, steady_state, ...
it_, 0);
else
[r, y, g1] = feval(fname, y, x, params);
[r, y, g1] = feval(fname, y, x, params, steady_state);
end;
if(~isreal(r))
max_res=(-(max(max(abs(r))))^2)^0.5;
......@@ -233,7 +236,8 @@ for it_=start:incr:finish
options.TolFun=1e-8;
options.Display = 'iter';
options.Jacobian = 'on';
[yn,fval,exitval,output] = fsolve(@local_fname, y(y_index_eq), options, x, params, y, y_index_eq, fname, 0);
[yn,fval,exitval,output] = fsolve(@local_fname, y(y_index_eq), ...
options, x, params, steady_state, y, y_index_eq, fname, 0);
y(y_index_eq) = yn;
if exitval > 0
info = 0;
......@@ -256,10 +260,13 @@ for it_=start:incr:finish
f = 0.5*r'*r;
p = -g1\r ;
if (is_dynamic)
[ya,f,r,check]=lnsrch1(y(it_,:)',f,g,p,stpmax,'lnsrch1_wrapper_one_boundary',nn, y_index_eq, y_index_eq, fname, y, x, params, it_);
[ya,f,r,check]=lnsrch1(y(it_,:)',f,g,p,stpmax, ...
'lnsrch1_wrapper_one_boundary',nn, ...
y_index_eq, y_index_eq, fname, y, x, params, steady_state, it_);
dx = ya' - y(it_, :);
else
[ya,f,r,check]=lnsrch1(y,f,g,p,stpmax,fname,nn,y_index_eq,x, params, 0);
[ya,f,r,check]=lnsrch1(y,f,g,p,stpmax,fname,nn,y_index_eq,x, ...
params, steady_state,0);
dx = ya - y(y_index_eq);
end;
......@@ -272,7 +279,8 @@ for it_=start:incr:finish
if (verbose == 1)
disp('steady: csolve');
end
[yn,info] = csolve(@local_fname, y(y_index_eq),@local_fname,1e-6,500, x, params, y, y_index_eq, fname, 1);
[yn,info] = csolve(@local_fname, y(y_index_eq),@ ...
local_fname,1e-6,500, x, params, steady_state, y, y_index_eq, fname, 1);
dx = ya - yn;
y(y_index_eq) = yn;
elseif((stack_solve_algo==1 && is_dynamic) || (stack_solve_algo==0 && is_dynamic) || (~is_dynamic && (options_.solve_algo==1 || options_.solve_algo==6))),
......@@ -330,9 +338,10 @@ for it_=start:incr:finish
y(y_index_eq) = phat;
end;
if(is_dynamic)
[r, y, g1, g2, g3] = feval(fname, y, x, params, it_, 0);
[r, y, g1, g2, g3] = feval(fname, y, x, params, ...
steady_state, it_, 0);
else
[r, y, g1] = feval(fname, y, x, params);
[r, y, g1] = feval(fname, y, x, params, steady_state);
end;
if max(abs(r)) >= options_.solve_tolf
[dx,flag1] = bicgstab(g1,-r,1e-7,Blck_size,L1,U1);
......@@ -404,9 +413,9 @@ else
end;
return;
function [err, G]=local_fname(yl, x, params, y, y_index_eq, fname, is_csolve)
function [err, G]=local_fname(yl, x, params, steady_state, y, y_index_eq, fname, is_csolve)
y(y_index_eq) = yl;
[err, y, G] = feval(fname, y, x, params, 0);
[err, y, G] = feval(fname, y, x, params, steady_state, 0);
if(is_csolve)
G = full(G);
end;
function y = solve_two_boundaries(fname, y, x, params, y_index, nze, periods, y_kmin_l, y_kmax_l, is_linear, Block_Num, y_kmin, maxit_, solve_tolf, lambda, cutoff, stack_solve_algo)
function y = solve_two_boundaries(fname, y, x, params, steady_state, y_index, nze, periods, y_kmin_l, y_kmax_l, is_linear, Block_Num, y_kmin, maxit_, solve_tolf, lambda, cutoff, stack_solve_algo)
% Computes the deterministic simulation of a block of equation containing
% both lead and lag variables using relaxation methods
%
......@@ -8,6 +8,7 @@ function y = solve_two_boundaries(fname, y, x, params, y_index, nze, periods, y_
% y [matrix] All the endogenous variables of the model
% x [matrix] All the exogenous variables of the model
% params [vector] All the parameters of the model
% steady_state [vector] steady state of the model
% y_index [vector of int] The index of the endogenous variables of
% the block
% nze [integer] number of non-zero elements in the
......@@ -73,7 +74,7 @@ Jacobian_Size=Blck_size*(y_kmin+y_kmax_l +periods);
g1=spalloc( Blck_size*periods, Jacobian_Size, nze*periods);
reduced = 0;
while ~(cvg==1 || iter>maxit_),
[r, y, g1, g2, g3, b]=feval(fname, y, x, params, periods, 0, y_kmin, Blck_size);
[r, y, g1, g2, g3, b]=feval(fname, y, x, params, steady_state, periods, 0, y_kmin, Blck_size);
% fjac = zeros(Blck_size, Blck_size*(y_kmin_l+1+y_kmax_l));
% disp(['Blck_size=' int2str(Blck_size) ' size(y_index)=' int2str(size(y_index,2))]);
% dh = max(abs(y(y_kmin+1-y_kmin_l:y_kmin+1+y_kmax_l, y_index)),options_.gstep*ones(y_kmin_l+1+y_kmax_l, Blck_size))*eps^(1/3);
......@@ -302,7 +303,8 @@ while ~(cvg==1 || iter>maxit_),
g = (ra'*g1a)';
f = 0.5*ra'*ra;
p = -g1a\ra;
[yn,f,ra,check]=lnsrch1(ya,f,g,p,stpmax,'lnsrch1_wrapper_two_boundaries',nn,nn, fname, y, y_index, x, params, periods, y_kmin, Blck_size);
[yn,f,ra,check]=lnsrch1(ya,f,g,p,stpmax, ...
'lnsrch1_wrapper_two_boundaries',nn,nn, fname, y, y_index, x, params, steady_state, periods, y_kmin, Blck_size);
dx = ya - yn;
y(1+y_kmin:periods+y_kmin,y_index)=reshape(yn',length(y_index),periods)';
end
......
......@@ -37,11 +37,13 @@ DynamicModelMFile::eval(const Vector &y, const Vector &x, const Vector &modParam
prhs[0] = mxCreateDoubleMatrix(y.length(), 1, mxREAL);
prhs[1] = mxCreateDoubleMatrix(1, x.length(), mxREAL);
prhs[2] = mxCreateDoubleMatrix(modParams.length(), 1, mxREAL);
prhs[3] = mxCreateDoubleScalar(1.0);
prhs[3] = mxCreateDoubleMatrix(ySteady.length(), 1, mxREAL);
prhs[4] = mxCreateDoubleScalar(1.0);
memcpy((void *) (mxGetPr(prhs[0])), (void *) y.base(), y.length()*sizeof(double));
memcpy((void *) (mxGetPr(prhs[1])), (void *) x.base(), x.length()*sizeof(double));
memcpy((void *) (mxGetPr(prhs[2])), (void *) modParams.base(), modParams.length()*sizeof(double));
memcpy((void *) (mxGetPr(prhs[3])), (void *) ySteady.base(), modParams.length()*sizeof(double));
int retVal = mexCallMATLAB(nlhs_dynamic, plhs, nrhs_dynamic, prhs, DynamicMFilename.c_str());
if (retVal != 0)
......
......@@ -34,7 +34,7 @@ class DynamicModelMFile : public DynamicModelAC
private:
const string DynamicMFilename;
const static int nlhs_dynamic = 4;
const static int nrhs_dynamic = 4;
const static int nrhs_dynamic = 5;
public:
DynamicModelMFile(const string &modName) throw (DynareException);
virtual ~DynamicModelMFile();
......
......@@ -344,14 +344,14 @@ DynamicModel::writeModelEquationsOrdered_M(const string &dynamic_basename) const
output << "%/\n";
if (simulation_type == EVALUATE_BACKWARD || simulation_type == EVALUATE_FORWARD)
{
output << "function [y, g1, g2, g3, varargout] = " << dynamic_basename << "_" << block+1 << "(y, x, params, jacobian_eval, y_kmin, periods)\n";
output << "function [y, g1, g2, g3, varargout] = " << dynamic_basename << "_" << block+1 << "(y, x, params, steady_state, jacobian_eval, y_kmin, periods)\n";
}
else if (simulation_type == SOLVE_FORWARD_COMPLETE || simulation_type == SOLVE_BACKWARD_COMPLETE)
output << "function [residual, y, g1, g2, g3, varargout] = " << dynamic_basename << "_" << block+1 << "(y, x, params, it_, jacobian_eval)\n";
output << "function [residual, y, g1, g2, g3, varargout] = " << dynamic_basename << "_" << block+1 << "(y, x, params, steady_state, it_, jacobian_eval)\n";
else if (simulation_type == SOLVE_BACKWARD_SIMPLE || simulation_type == SOLVE_FORWARD_SIMPLE)
output << "function [residual, y, g1, g2, g3, varargout] = " << dynamic_basename << "_" << block+1 << "(y, x, params, it_, jacobian_eval)\n";
output << "function [residual, y, g1, g2, g3, varargout] = " << dynamic_basename << "_" << block+1 << "(y, x, params, steady_state, it_, jacobian_eval)\n";
else
output << "function [residual, y, g1, g2, g3, b, varargout] = " << dynamic_basename << "_" << block+1 << "(y, x, params, periods, jacobian_eval, y_kmin, y_size)\n";
output << "function [residual, y, g1, g2, g3, b, varargout] = " << dynamic_basename << "_" << block+1 << "(y, x, params, steady_state, periods, jacobian_eval, y_kmin, y_size)\n";
BlockType block_type;
if (simulation_type == SOLVE_TWO_BOUNDARIES_COMPLETE || simulation_type == SOLVE_TWO_BOUNDARIES_SIMPLE)
block_type = SIMULTAN;
......@@ -1509,16 +1509,13 @@ DynamicModel::writeDynamicMFile(const string &dynamic_basename) const
cerr << "Error: Can't open file " << filename << " for writing" << endl;
exit(EXIT_FAILURE);
}
mDynamicModelFile << "function [residual, g1, g2, g3] = " << dynamic_basename << "(y, x, params, it_)" << endl
mDynamicModelFile << "function [residual, g1, g2, g3] = " << dynamic_basename << "(y, x, params, steady_state, it_)" << endl
<< "%" << endl
<< "% Status : Computes dynamic model for Dynare" << endl
<< "%" << endl
<< "% Warning : this file is generated automatically by Dynare" << endl
<< "% from model file (.mod)" << endl << endl;
if (isUnaryOpUsed(oSteadyState))
mDynamicModelFile << "global oo_;" << endl << endl;
writeDynamicModel(mDynamicModelFile, false);
mDynamicModelFile << "end" << endl; // Close *_dynamic function
writePowerDeriv(mDynamicModelFile, false);
......@@ -1576,8 +1573,11 @@ DynamicModel::writeDynamicCFile(const string &dynamic_basename, const int order)
<< " /* Create a pointer to the input matrix params. */" << endl
<< " params = mxGetPr(prhs[2]);" << endl
<< endl
<< " /* Create a pointer to the input matrix steady_state. */" << endl
<< " steady_state = mxGetPr(prhs[3]);" << endl
<< endl
<< " /* Fetch time index */" << endl
<< " it_ = (int) mxGetScalar(prhs[3]) - 1;" << endl
<< " it_ = (int) mxGetScalar(prhs[4]) - 1;" << endl
<< endl
<< " /* Gets number of rows of matrix x. */" << endl
<< " nb_row_x = mxGetM(prhs[1]);" << endl
......@@ -1618,7 +1618,6 @@ DynamicModel::writeDynamicCFile(const string &dynamic_basename, const int order)
<< " v3 = mxGetPr(plhs[3]);" << endl
<< " }" << endl
<< endl
<< " steady_state = mxGetPr(mxGetField(mexGetVariable(\"global\", \"oo_\"), 0, \"steady_state\"));" << endl
<< " /* Call the C subroutines. */" << endl
<< " Dynamic(y, x, nb_row_x, params, steady_state, it_, residual, g1, v2, v3);" << endl
<< "}" << endl;
......@@ -1762,8 +1761,9 @@ DynamicModel::writeSparseDynamicMFile(const string &dynamic_basename, const stri
<< " y=varargin{1};" << endl
<< " x=varargin{2};" << endl
<< " params=varargin{3};" << endl
<< " it_=varargin{4};" << endl
<< " dr=varargin{5};" << endl
<< " steady_state=varargin{4};" << endl
<< " it_=varargin{5};" << endl
<< " dr=varargin{6};" << endl
<< " Per_u_=0;" << endl
<< " Per_y_=it_*y_size;" << endl
<< " ys=y(it_,:);" << endl;
......@@ -1802,22 +1802,22 @@ DynamicModel::writeSparseDynamicMFile(const string &dynamic_basename, const stri
{
case EVALUATE_FORWARD:
case EVALUATE_BACKWARD:
mDynamicModelFile << " [y, dr(" << count_call << ").g1, dr(" << count_call << ").g2, dr(" << count_call << ").g3, dr(" << count_call << ").g1_x, dr(" << count_call << ").g1_xd, dr(" << count_call << ").g1_o]=" << dynamic_basename << "_" << block + 1 << "(y, x, params, 1, it_-1, 1);\n";
mDynamicModelFile << " [y, dr(" << count_call << ").g1, dr(" << count_call << ").g2, dr(" << count_call << ").g3, dr(" << count_call << ").g1_x, dr(" << count_call << ").g1_xd, dr(" << count_call << ").g1_o]=" << dynamic_basename << "_" << block + 1 << "(y, x, params, steady_state, 1, it_-1, 1);\n";
mDynamicModelFile << " residual(y_index_eq)=ys(y_index)-y(it_, y_index);\n";
break;
case SOLVE_FORWARD_SIMPLE:
case SOLVE_BACKWARD_SIMPLE:
mDynamicModelFile << " [r, y, dr(" << count_call << ").g1, dr(" << count_call << ").g2, dr(" << count_call << ").g3, dr(" << count_call << ").g1_x, dr(" << count_call << ").g1_xd, dr(" << count_call << ").g1_o]=" << dynamic_basename << "_" << block + 1 << "(y, x, params, it_, 1);\n";
mDynamicModelFile << " [r, y, dr(" << count_call << ").g1, dr(" << count_call << ").g2, dr(" << count_call << ").g3, dr(" << count_call << ").g1_x, dr(" << count_call << ").g1_xd, dr(" << count_call << ").g1_o]=" << dynamic_basename << "_" << block + 1 << "(y, x, params, steady_state, it_, 1);\n";
mDynamicModelFile << " residual(y_index_eq)=r;\n";
break;
case SOLVE_FORWARD_COMPLETE:
case SOLVE_BACKWARD_COMPLETE:
mDynamicModelFile << " [r, y, dr(" << count_call << ").g1, dr(" << count_call << ").g2, dr(" << count_call << ").g3, dr(" << count_call << ").g1_x, dr(" << count_call << ").g1_xd, dr(" << count_call << ").g1_o]=" << dynamic_basename << "_" << block + 1 << "(y, x, params, it_, 1);\n";
mDynamicModelFile << " [r, y, dr(" << count_call << ").g1, dr(" << count_call << ").g2, dr(" << count_call << ").g3, dr(" << count_call << ").g1_x, dr(" << count_call << ").g1_xd, dr(" << count_call << ").g1_o]=" << dynamic_basename << "_" << block + 1 << "(y, x, params, steady_state, it_, 1);\n";
mDynamicModelFile << " residual(y_index_eq)=r;\n";
break;
case SOLVE_TWO_BOUNDARIES_COMPLETE:
case SOLVE_TWO_BOUNDARIES_SIMPLE:
mDynamicModelFile << " [r, y, dr(" << count_call << ").g1, dr(" << count_call << ").g2, dr(" << count_call << ").g3, b, dr(" << count_call << ").g1_x, dr(" << count_call << ").g1_xd, dr(" << count_call << ").g1_o]=" << dynamic_basename << "_" << block + 1 << "(y, x, params, it_-" << max_lag << ", 1, " << max_lag << ", " << block_recursive << ");\n";
mDynamicModelFile << " [r, y, dr(" << count_call << ").g1, dr(" << count_call << ").g2, dr(" << count_call << ").g3, b, dr(" << count_call << ").g1_x, dr(" << count_call << ").g1_xd, dr(" << count_call << ").g1_o]=" << dynamic_basename << "_" << block + 1 << "(y, x, params, steady_state, it_-" << max_lag << ", 1, " << max_lag << ", " << block_recursive << ");\n";
mDynamicModelFile << " residual(y_index_eq)=r(:,M_.maximum_lag+1);\n";
break;
default:
......@@ -1860,6 +1860,7 @@ DynamicModel::writeSparseDynamicMFile(const string &dynamic_basename, const stri
prev_Simulation_Type = -1;
mDynamicModelFile << " params=M_.params;\n";
mDynamicModelFile << " steady_state=oo_.steady_state;\n";
mDynamicModelFile << " oo_.deterministic_simulation.status = 0;\n";
for (block = 0; block < nb_blocks; block++)
{
......@@ -1893,7 +1894,7 @@ DynamicModel::writeSparseDynamicMFile(const string &dynamic_basename, const stri
mDynamicModelFile << " oo_.deterministic_simulation.block(blck_num).error = 0;\n";
mDynamicModelFile << " oo_.deterministic_simulation.block(blck_num).iterations = 0;\n";
mDynamicModelFile << " g1=[];g2=[];g3=[];\n";
mDynamicModelFile << " y=" << dynamic_basename << "_" << block + 1 << "(y, x, params, 0, y_kmin, periods);\n";
mDynamicModelFile << " y=" << dynamic_basename << "_" << block + 1 << "(y, x, params, steady_state, 0, y_kmin, periods);\n";
mDynamicModelFile << " tmp = y(:,M_.block_structure.block(" << block + 1 << ").variable);\n";
mDynamicModelFile << " if(isnan(tmp) | isinf(tmp))\n";
mDynamicModelFile << " disp(['Inf or Nan value during the evaluation of block " << block <<"']);\n";
......@@ -1921,7 +1922,7 @@ DynamicModel::writeSparseDynamicMFile(const string &dynamic_basename, const stri
mDynamicModelFile << " oo_.deterministic_simulation.block(blck_num).error = 0;\n";
mDynamicModelFile << " oo_.deterministic_simulation.block(blck_num).iterations = 0;\n";
mDynamicModelFile << " g1=[];g2=[];g3=[];\n";
mDynamicModelFile << " " << dynamic_basename << "_" << block + 1 << "(y, x, params, 0, y_kmin, periods);\n";
mDynamicModelFile << " " << dynamic_basename << "_" << block + 1 << "(y, x, params, steady_state, 0, y_kmin, periods);\n";
mDynamicModelFile << " tmp = y(:,M_.block_structure.block(" << block + 1 << ").variable);\n";
mDynamicModelFile << " if(isnan(tmp) | isinf(tmp))\n";
mDynamicModelFile << " disp(['Inf or Nan value during the evaluation of block " << block <<"']);\n";
......@@ -1949,7 +1950,7 @@ DynamicModel::writeSparseDynamicMFile(const string &dynamic_basename, const stri
mDynamicModelFile << " blck_num = 1;\n";
mDynamicModelFile << " end;\n";
mDynamicModelFile << " y = solve_one_boundary('" << dynamic_basename << "_" << block + 1 << "'"
<<", y, x, params, y_index, " << nze
<<", y, x, params, steady_state, y_index, " << nze
<<", options_.periods, " << blocks_linear[block]
<<", blck_num, y_kmin, options_.maxit_, options_.solve_tolf, options_.slowc, " << cutoff << ", options_.stack_solve_algo, 1, 1, 0);\n";
mDynamicModelFile << " tmp = y(:,M_.block_structure.block(" << block + 1 << ").variable);\n";
......@@ -1979,7 +1980,7 @@ DynamicModel::writeSparseDynamicMFile(const string &dynamic_basename, const stri
mDynamicModelFile << " blck_num = 1;\n";
mDynamicModelFile << " end;\n";
mDynamicModelFile << " y = solve_one_boundary('" << dynamic_basename << "_" << block + 1 << "'"
<<", y, x, params, y_index, " << nze
<<", y, x, params, steady_state, y_index, " << nze
<<", options_.periods, " << blocks_linear[block]
<<", blck_num, y_kmin, options_.maxit_, options_.solve_tolf, options_.slowc, " << cutoff << ", options_.stack_solve_algo, 1, 1, 0);\n";
mDynamicModelFile << " tmp = y(:,M_.block_structure.block(" << block + 1 << ").variable);\n";
......@@ -2007,7 +2008,7 @@ DynamicModel::writeSparseDynamicMFile(const string &dynamic_basename, const stri
mDynamicModelFile << " blck_num = 1;\n";
mDynamicModelFile << " end;\n";
mDynamicModelFile << " y = solve_two_boundaries('" << dynamic_basename << "_" << block + 1 << "'"
<<", y, x, params, y_index, " << nze
<<", y, x, params, steady_state, y_index, " << nze
<<", options_.periods, " << max_leadlag_block[block].first
<<", " << max_leadlag_block[block].second
<<", " << blocks_linear[block]
......
......@@ -632,7 +632,7 @@ VariableNode::writeOutput(ostream &output, ExprNodeOutputType output_type,
break;
case oMatlabDynamicSteadyStateOperator:
case oMatlabDynamicSparseSteadyStateOperator:
output << "oo_.steady_state(" << tsid + 1 << ")";
output << "steady_state(" << tsid + 1 << ")";
break;
case oCDynamicSteadyStateOperator:
output << "steady_state[" << tsid << "]";
......
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