extended_preprocessor: fixed computation of steady state out of
steady_state_modeltime-shift
parent
9fd48df408
commit
98f3a04444
|
@ -45,6 +45,10 @@ DynareInfo::DynareInfo(map<string, int > exo_names_arg,
|
||||||
lead_lag_incidence(lead_lag_incidence_arg),
|
lead_lag_incidence(lead_lag_incidence_arg),
|
||||||
NNZDerivatives(NNZDerivatives_arg)
|
NNZDerivatives(NNZDerivatives_arg)
|
||||||
{
|
{
|
||||||
|
endo_nbr = endo_names.size();
|
||||||
|
exo_nbr = exo_names.size();
|
||||||
|
exo_det_nbr = exo_det_names.size();
|
||||||
|
param_nbr = param_names.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
DynareInfo::~DynareInfo()
|
DynareInfo::~DynareInfo()
|
||||||
|
|
|
@ -244,6 +244,7 @@ private:
|
||||||
vector<int> varobs;
|
vector<int> varobs;
|
||||||
vector<vector<int > >lead_lag_incidence;
|
vector<vector<int > >lead_lag_incidence;
|
||||||
vector<int> NNZDerivatives;
|
vector<int> NNZDerivatives;
|
||||||
|
int endo_nbr, exo_nbr, exo_det_nbr, param_nbr;
|
||||||
public:
|
public:
|
||||||
DynareInfo(map<string, int > exo_names_arg,
|
DynareInfo(map<string, int > exo_names_arg,
|
||||||
map<string, int > exo_det_names_arg,
|
map<string, int > exo_det_names_arg,
|
||||||
|
@ -308,6 +309,11 @@ public:
|
||||||
inline vector<vector<int > > get_lead_lag_incidence() { return lead_lag_incidence; };
|
inline vector<vector<int > > get_lead_lag_incidence() { return lead_lag_incidence; };
|
||||||
inline vector<int> get_NNZDerivatives() { return NNZDerivatives; };
|
inline vector<int> get_NNZDerivatives() { return NNZDerivatives; };
|
||||||
|
|
||||||
|
inline int get_endo_nbr(void) { return endo_nbr; };
|
||||||
|
inline int get_exo_nbr(void) { return exo_nbr; };
|
||||||
|
inline int get_exo_det_nbr(void) { return exo_det_nbr; };
|
||||||
|
inline int get_param_nbr(void) { return param_nbr; };
|
||||||
|
|
||||||
string get_exo_name_by_index(int index) throw (ValueNotSetException);
|
string get_exo_name_by_index(int index) throw (ValueNotSetException);
|
||||||
int get_exo_index_by_name(string name) throw (ValueNotSetException);
|
int get_exo_index_by_name(string name) throw (ValueNotSetException);
|
||||||
string get_exo_det_name_by_index(int index) throw (ValueNotSetException);
|
string get_exo_det_name_by_index(int index) throw (ValueNotSetException);
|
||||||
|
|
|
@ -4,8 +4,11 @@ test1.o : test1.cc ../dynare_cpp_driver.hh ../dynare_cpp_driver.cc
|
||||||
gcc -g -c test1.cc -I.. -I../../../mex/sources -I../../../mex/sources/estimation -I../../../mex/sources/estimation/libmat
|
gcc -g -c test1.cc -I.. -I../../../mex/sources -I../../../mex/sources/estimation -I../../../mex/sources/estimation/libmat
|
||||||
dynare_cpp_driver.o: ../dynare_cpp_driver.cc ../dynare_cpp_driver.hh
|
dynare_cpp_driver.o: ../dynare_cpp_driver.cc ../dynare_cpp_driver.hh
|
||||||
gcc -g -c ../dynare_cpp_driver.cc -I..
|
gcc -g -c ../dynare_cpp_driver.cc -I..
|
||||||
example1.o: example1.mod
|
example1.cc example1_steadystate.cc: example1.mod
|
||||||
$(DYNARE) example1.mod output=first
|
$(DYNARE) example1.mod output=first
|
||||||
|
example1.o: example1.cc
|
||||||
gcc -g -c example1.cc -I..
|
gcc -g -c example1.cc -I..
|
||||||
test1 : test1.o example1.o dynare_cpp_driver.o
|
example1_steadystate.o: example1_steadystate.cc
|
||||||
gcc -g -o test1 test1.o example1.o dynare_cpp_driver.o -lstdc++
|
gcc -g -c example1_steadystate.cc
|
||||||
|
test1 : test1.o example1.o example1_steadystate.o dynare_cpp_driver.o
|
||||||
|
gcc -g -o test1 test1.o example1.o example1_steadystate.o dynare_cpp_driver.o -lm -lstdc++
|
||||||
|
|
|
@ -86,7 +86,10 @@ enum ExprNodeOutputType
|
||||||
|| (output_type) == oMatlabDynamicSparseSteadyStateOperator \
|
|| (output_type) == oMatlabDynamicSparseSteadyStateOperator \
|
||||||
|| (output_type) == oSteadyStateFile)
|
|| (output_type) == oSteadyStateFile)
|
||||||
|
|
||||||
#define IS_C(output_type) ((output_type) == oCDynamicModel || (output_type) == oCStaticModel || (output_type) == oCDynamicSteadyStateOperator)
|
#define IS_C(output_type) ((output_type) == oCDynamicModel \
|
||||||
|
|| (output_type) == oCStaticModel \
|
||||||
|
|| (output_type) == oCDynamicSteadyStateOperator \
|
||||||
|
|| (output_type) == oCSteadyStateFile)
|
||||||
|
|
||||||
#define IS_LATEX(output_type) ((output_type) == oLatexStaticModel \
|
#define IS_LATEX(output_type) ((output_type) == oLatexStaticModel \
|
||||||
|| (output_type) == oLatexDynamicModel \
|
|| (output_type) == oLatexDynamicModel \
|
||||||
|
|
|
@ -158,14 +158,16 @@ SteadyStateModel::writeSteadyStateFileCC(const string &basename, bool ramsey_pol
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
output << "#include <math.h>" << endl;
|
||||||
|
|
||||||
if (cuda)
|
if (cuda)
|
||||||
output << "__global__ ";
|
output << "__global__ ";
|
||||||
|
|
||||||
output << "void steadystate("
|
output << "void steadystate("
|
||||||
<< "const double *exo_, const double *params_, double *ys_, int *info)" << endl
|
<< "const double *exo_, const double *params, double *ys_, int *info)" << endl
|
||||||
<< "// Steady state file generated by Dynare preprocessor" << endl
|
<< "// Steady state file generated by Dynare preprocessor" << endl
|
||||||
<< "{" << endl
|
<< "{" << endl
|
||||||
<< " info = 0;" << endl;
|
<< " *info = 0;" << endl;
|
||||||
|
|
||||||
if (recursive_order.size() == 0)
|
if (recursive_order.size() == 0)
|
||||||
{
|
{
|
||||||
|
@ -179,24 +181,18 @@ SteadyStateModel::writeSteadyStateFileCC(const string &basename, bool ramsey_pol
|
||||||
const vector<int> &symb_ids = recursive_order[i];
|
const vector<int> &symb_ids = recursive_order[i];
|
||||||
output << " ";
|
output << " ";
|
||||||
if (symb_ids.size() > 1)
|
if (symb_ids.size() > 1)
|
||||||
output << "[";
|
std::cout << "Error: in C, multiple returns are not permitted in steady_state_model" << std::endl;
|
||||||
for (size_t j = 0; j < symb_ids.size(); j++)
|
variable_node_map_t::const_iterator it = variable_node_map.find(make_pair(symb_ids[0], 0));
|
||||||
{
|
assert(it != variable_node_map.end());
|
||||||
variable_node_map_t::const_iterator it = variable_node_map.find(make_pair(symb_ids[j], 0));
|
if (it->second->get_type() == eModFileLocalVariable)
|
||||||
assert(it != variable_node_map.end());
|
output << "double ";
|
||||||
dynamic_cast<ExprNode *>(it->second)->writeOutput(output, oSteadyStateFile);
|
dynamic_cast<ExprNode *>(it->second)->writeOutput(output, oCSteadyStateFile);
|
||||||
if (j < symb_ids.size()-1)
|
|
||||||
output << ",";
|
|
||||||
}
|
|
||||||
if (symb_ids.size() > 1)
|
|
||||||
output << "]";
|
|
||||||
|
|
||||||
output << "=";
|
output << "=";
|
||||||
def_table.find(symb_ids)->second->writeOutput(output, oSteadyStateFile);
|
def_table.find(symb_ids)->second->writeOutput(output, oCSteadyStateFile);
|
||||||
output << ";" << endl;
|
output << ";" << endl;
|
||||||
}
|
}
|
||||||
output << " // Auxiliary equations" << endl;
|
output << " // Auxiliary equations" << endl;
|
||||||
static_model.writeAuxVarInitval(output, oSteadyStateFile);
|
static_model.writeAuxVarInitval(output, oCSteadyStateFile);
|
||||||
output << "}" << endl;
|
output << "}" << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue