Revert "preprocessor: write auxiliary variable definitions to matlab function"

This reverts commit ad81129a9b.
time-shift
Houtan Bastani 2015-12-01 11:41:55 +01:00
parent 9c42ebaa56
commit 4ff17d6191
4 changed files with 3 additions and 64 deletions

View File

@ -1515,42 +1515,6 @@ DynamicModel::writeModelEquationsCode_Block(string &file_name, const string &bin
code_file.close();
}
void
DynamicModel::writeDynamicAuxMFile(const string &dynamic_basename) const
{
string filename = dynamic_basename + "_aux.m";
ofstream mDynamicAuxFile;
mDynamicAuxFile.open(filename.c_str(), ios::out | ios::binary);
if (!mDynamicAuxFile.is_open())
{
cerr << "Error: Can't open file " << filename << " for writing" << endl;
exit(EXIT_FAILURE);
}
mDynamicAuxFile << "function auxvars = " << dynamic_basename << "_aux(y, x, params, steady_state, it_)"
<< endl
<< "%" << endl
<< "% Status : Computes auxiliary variables for Dynare" << endl
<< "%" << endl
<< "% Inputs :" << endl
<< "% y [#dynamic variables by 1] double vector of endogenous variables in the order stored" << endl
<< "% in M_.lead_lag_incidence; see the Manual" << endl
<< "% x [nperiods by M_.exo_nbr] double matrix of exogenous variables (in declaration order)" << endl
<< "% for all simulation periods" << endl
<< "% params [M_.param_nbr by 1] double vector of parameter values in declaration order" << endl
<< "% it_ scalar double time period for exogenous variables for which to evaluate the model" << endl
<< "%" << endl
<< "% Outputs:" << endl
<< "% auxvars [length(M_.aux_vars) by 1] definitions of auxiliary variables" << endl
<< "%" << endl
<< "%" << endl
<< "% Warning : this file is generated automatically by Dynare" << endl
<< "% from the model file (.mod)" << endl << endl;
writeModelAuxEquations(mDynamicAuxFile, oMatlabDynamicModel);
mDynamicAuxFile << "end" << endl;
mDynamicAuxFile.close();
}
void
DynamicModel::writeDynamicMFile(const string &dynamic_basename) const
{
@ -3559,10 +3523,7 @@ DynamicModel::writeDynamicFile(const string &basename, bool block, bool bytecode
else if (julia)
writeDynamicJuliaFile(basename);
else
{
writeDynamicMFile(t_basename);
writeDynamicAuxMFile(t_basename);
}
writeDynamicMFile(t_basename);
}
void

View File

@ -73,8 +73,7 @@ private:
//! Store the derivatives or the chainrule derivatives:map<pair< equation, pair< variable, lead_lag >, expr_t>
typedef map< pair< int, pair< int, int> >, expr_t> first_chain_rule_derivatives_t;
first_chain_rule_derivatives_t first_chain_rule_derivatives;
//! Writes auxiliary equations file (Matlab version)
void writeDynamicAuxMFile(const string &dynamic_basename) const;
//! Writes dynamic model file (Matlab version)
void writeDynamicMFile(const string &dynamic_basename) const;
//! Writes dynamic model file (Julia version)

View File

@ -1264,26 +1264,6 @@ ModelTree::writeModelEquations(ostream &output, ExprNodeOutputType output_type)
}
}
void
ModelTree::writeModelAuxEquations(ostream &output, ExprNodeOutputType output_type) const
{
int eq_ind = 0, av_ind = 0;
for (vector<int>::const_iterator it = equations_lineno.begin();
it != equations_lineno.end(); it++, eq_ind++)
if (*it == -1)
{
expr_t rhs = equations[eq_ind]->get_arg2();
if (IS_JULIA(output_type))
output << " @inbounds ";
output << "auxvars" << LEFT_ARRAY_SUBSCRIPT(output_type)
<< av_ind++ + ARRAY_SUBSCRIPT_OFFSET(output_type)
<< RIGHT_ARRAY_SUBSCRIPT(output_type)
<< " = ";
rhs->writeOutput(output, output_type, temporary_terms_t());
output << ";" << endl;
}
}
void
ModelTree::compileModelEquations(ostream &code_file, unsigned int &instruction_number, const temporary_terms_t &tt, const map_idx_t &map_idx, bool dynamic, bool steady_dynamic) const
{

View File

@ -173,11 +173,10 @@ protected:
void compileTemporaryTerms(ostream &code_file, unsigned int &instruction_number, const temporary_terms_t &tt, map_idx_t map_idx, bool dynamic, bool steady_dynamic) const;
//! Adds informations for simulation in a binary file
void Write_Inf_To_Bin_File(const string &basename, int &u_count_int, bool &file_open, bool is_two_boundaries, int block_mfs) const;
//! Writes model local variables
/*! No temporary term is used in the output, so that local parameters declarations can be safely put before temporary terms declaration in the output files */
void writeModelLocalVariables(ostream &output, ExprNodeOutputType output_type, deriv_node_temp_terms_t &tef_terms) const;
//! Writes model auxiliary equations
void writeModelAuxEquations(ostream &output, ExprNodeOutputType output_type) const;
//! Writes model equations
void writeModelEquations(ostream &output, ExprNodeOutputType output_type) const;
//! Compiles model equations