Commit f78fd342 authored by Stéphane Adjemian's avatar Stéphane Adjemian
Browse files

Removed options_ and oo_ globals from generated dynamic model

routines (with block option).
parent 904c93a7
...@@ -342,7 +342,7 @@ DynamicModel::writeModelEquationsOrdered_M(const string &dynamic_basename) const ...@@ -342,7 +342,7 @@ DynamicModel::writeModelEquationsOrdered_M(const string &dynamic_basename) const
else if (simulation_type == SOLVE_BACKWARD_SIMPLE || simulation_type == SOLVE_FORWARD_SIMPLE) 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"; output << "function [residual, y, g1, g2, g3, varargout] = " << dynamic_basename << "_" << block+1 << "(y, x, params, steady_state, it_, jacobian_eval)\n";
else 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; BlockType block_type;
if (simulation_type == SOLVE_TWO_BOUNDARIES_COMPLETE || simulation_type == SOLVE_TWO_BOUNDARIES_SIMPLE) if (simulation_type == SOLVE_TWO_BOUNDARIES_COMPLETE || simulation_type == SOLVE_TWO_BOUNDARIES_SIMPLE)
block_type = SIMULTAN; block_type = SIMULTAN;
...@@ -364,7 +364,6 @@ DynamicModel::writeModelEquationsOrdered_M(const string &dynamic_basename) const ...@@ -364,7 +364,6 @@ DynamicModel::writeModelEquationsOrdered_M(const string &dynamic_basename) const
<< " % // Simulation type " << " % // Simulation type "
<< BlockSim(simulation_type) << " //" << endl << BlockSim(simulation_type) << " //" << endl
<< " % ////////////////////////////////////////////////////////////////////////" << endl; << " % ////////////////////////////////////////////////////////////////////////" << endl;
output << " global options_ oo_;" << endl;
//The Temporary terms //The Temporary terms
if (simulation_type == EVALUATE_BACKWARD || simulation_type == EVALUATE_FORWARD) if (simulation_type == EVALUATE_BACKWARD || simulation_type == EVALUATE_FORWARD)
{ {
...@@ -385,9 +384,9 @@ DynamicModel::writeModelEquationsOrdered_M(const string &dynamic_basename) const ...@@ -385,9 +384,9 @@ DynamicModel::writeModelEquationsOrdered_M(const string &dynamic_basename) const
output << " else\n"; output << " else\n";
if (simulation_type == SOLVE_TWO_BOUNDARIES_COMPLETE || simulation_type == SOLVE_TWO_BOUNDARIES_SIMPLE) if (simulation_type == SOLVE_TWO_BOUNDARIES_COMPLETE || simulation_type == SOLVE_TWO_BOUNDARIES_SIMPLE)
{ {
output << " g1 = spalloc(" << block_mfs << "*options_.periods, " output << " g1 = spalloc(" << block_mfs << "*Periods, "
<< block_mfs << "*(options_.periods+" << max_leadlag_block[block].first+max_leadlag_block[block].second+1 << ")" << block_mfs << "*(Periods+" << max_leadlag_block[block].first+max_leadlag_block[block].second+1 << ")"
<< ", " << nze << "*options_.periods);\n"; << ", " << nze << "*Periods);\n";
} }
else else
{ {
...@@ -1882,7 +1881,7 @@ DynamicModel::writeSparseDynamicMFile(const string &dynamic_basename, const stri ...@@ -1882,7 +1881,7 @@ DynamicModel::writeSparseDynamicMFile(const string &dynamic_basename, const stri
break; break;
case SOLVE_TWO_BOUNDARIES_COMPLETE: case SOLVE_TWO_BOUNDARIES_COMPLETE:
case SOLVE_TWO_BOUNDARIES_SIMPLE: 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"; mDynamicModelFile << " residual(y_index_eq)=r(:,M_.maximum_lag+1);\n";
break; break;
default: default:
...@@ -2065,7 +2064,7 @@ DynamicModel::writeSparseDynamicMFile(const string &dynamic_basename, const stri ...@@ -2065,7 +2064,7 @@ DynamicModel::writeSparseDynamicMFile(const string &dynamic_basename, const stri
<<", options_.periods, " << max_leadlag_block[block].first <<", options_.periods, " << max_leadlag_block[block].first
<<", " << max_leadlag_block[block].second <<", " << max_leadlag_block[block].second
<<", " << blocks_linear[block] <<", " << 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 << " tmp = y(:,M_.block_structure.block(" << block + 1 << ").variable);\n";
mDynamicModelFile << " if any(isnan(tmp) | isinf(tmp))\n"; mDynamicModelFile << " if any(isnan(tmp) | isinf(tmp))\n";
mDynamicModelFile << " disp(['Inf or Nan value during the resolution of block " << block <<"']);\n"; mDynamicModelFile << " disp(['Inf or Nan value during the resolution of block " << block <<"']);\n";
......
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