Merge branch 'remove-globals-from-blocks'
commit
1349b448b0
|
@ -342,7 +342,7 @@ DynamicModel::writeModelEquationsOrdered_M(const string &dynamic_basename) const
|
|||
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, steady_state, it_, jacobian_eval)\n";
|
||||
else
|
||||
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";
|
||||
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, Periods)\n";
|
||||
BlockType block_type;
|
||||
if (simulation_type == SOLVE_TWO_BOUNDARIES_COMPLETE || simulation_type == SOLVE_TWO_BOUNDARIES_SIMPLE)
|
||||
block_type = SIMULTAN;
|
||||
|
@ -364,7 +364,6 @@ DynamicModel::writeModelEquationsOrdered_M(const string &dynamic_basename) const
|
|||
<< " % // Simulation type "
|
||||
<< BlockSim(simulation_type) << " //" << endl
|
||||
<< " % ////////////////////////////////////////////////////////////////////////" << endl;
|
||||
output << " global options_ oo_;" << endl;
|
||||
//The Temporary terms
|
||||
if (simulation_type == EVALUATE_BACKWARD || simulation_type == EVALUATE_FORWARD)
|
||||
{
|
||||
|
@ -385,9 +384,9 @@ DynamicModel::writeModelEquationsOrdered_M(const string &dynamic_basename) const
|
|||
output << " else\n";
|
||||
if (simulation_type == SOLVE_TWO_BOUNDARIES_COMPLETE || simulation_type == SOLVE_TWO_BOUNDARIES_SIMPLE)
|
||||
{
|
||||
output << " g1 = spalloc(" << block_mfs << "*options_.periods, "
|
||||
<< block_mfs << "*(options_.periods+" << max_leadlag_block[block].first+max_leadlag_block[block].second+1 << ")"
|
||||
<< ", " << nze << "*options_.periods);\n";
|
||||
output << " g1 = spalloc(" << block_mfs << "*Periods, "
|
||||
<< block_mfs << "*(Periods+" << max_leadlag_block[block].first+max_leadlag_block[block].second+1 << ")"
|
||||
<< ", " << nze << "*Periods);\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1789,8 +1788,7 @@ DynamicModel::writeSparseDynamicMFile(const string &dynamic_basename, const stri
|
|||
int Nb_SGE = 0;
|
||||
bool open_par = false;
|
||||
|
||||
mDynamicModelFile << "function [varargout] = " << dynamic_basename << "(varargin)\n";
|
||||
mDynamicModelFile << " global oo_ options_ M_ ;\n";
|
||||
mDynamicModelFile << "function [varargout] = " << dynamic_basename << "(options_, M_, oo_, varargin)\n";
|
||||
mDynamicModelFile << " g2=[];g3=[];\n";
|
||||
//Temporary variables declaration
|
||||
OK = true;
|
||||
|
@ -1805,7 +1803,7 @@ DynamicModel::writeSparseDynamicMFile(const string &dynamic_basename, const stri
|
|||
(*it)->writeOutput(tmp_output, oMatlabStaticModelSparse, temporary_terms);
|
||||
}
|
||||
if (tmp_output.str().length() > 0)
|
||||
mDynamicModelFile << " global " << tmp_output.str() << " M_ ;\n";
|
||||
mDynamicModelFile << " global " << tmp_output.str() << ";\n";
|
||||
|
||||
mDynamicModelFile << " T_init=zeros(1,options_.periods+M_.maximum_lag+M_.maximum_lead);\n";
|
||||
tmp_output.str("");
|
||||
|
@ -1882,7 +1880,7 @@ DynamicModel::writeSparseDynamicMFile(const string &dynamic_basename, const stri
|
|||
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, steady_state, 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 << "," << "options_.periods" << ");\n";
|
||||
mDynamicModelFile << " residual(y_index_eq)=r(:,M_.maximum_lag+1);\n";
|
||||
break;
|
||||
default:
|
||||
|
@ -2065,7 +2063,7 @@ DynamicModel::writeSparseDynamicMFile(const string &dynamic_basename, const stri
|
|||
<<", options_.periods, " << max_leadlag_block[block].first
|
||||
<<", " << max_leadlag_block[block].second
|
||||
<<", " << blocks_linear[block]
|
||||
<<", blck_num, y_kmin, options_.simul.maxit, options_.solve_tolf, options_.slowc, " << cutoff << ", options_.stack_solve_algo, M_, oo_);\n";
|
||||
<<", blck_num, y_kmin, options_.simul.maxit, options_.solve_tolf, options_.slowc, " << cutoff << ", options_.stack_solve_algo, options_, M_, oo_);\n";
|
||||
mDynamicModelFile << " tmp = y(:,M_.block_structure.block(" << block + 1 << ").variable);\n";
|
||||
mDynamicModelFile << " if any(isnan(tmp) | isinf(tmp))\n";
|
||||
mDynamicModelFile << " disp(['Inf or Nan value during the resolution of block " << block <<"']);\n";
|
||||
|
@ -2077,6 +2075,7 @@ DynamicModel::writeSparseDynamicMFile(const string &dynamic_basename, const stri
|
|||
mDynamicModelFile << " end;\n";
|
||||
open_par = false;
|
||||
mDynamicModelFile << " oo_.endo_simul = y';\n";
|
||||
mDynamicModelFile << " varargout{1} = oo_;\n";
|
||||
mDynamicModelFile << "return;\n";
|
||||
mDynamicModelFile << "end" << endl;
|
||||
|
||||
|
|
Loading…
Reference in New Issue