Commit 8292da37 authored by sebastien's avatar sebastien
Browse files

Fixes for ticket #57

preprocessor:
* add a field "M_.orig_endo_nbr" containing the nbr of endogenous before adding aux vars
* always provide "M_.aux_vars" (define it to "[]" when there is no aux var)
* rename "M_.aux_vars().orig_endo_index" to "M_.aux_vars().orig_index"

M-files:
* for commands which accept a list of variables (stoch_simul, osr, estimation, dynasave, dynatype, datatomfile), when no variable is given, use only the set of original endogenous (without aux vars) as the default
* when displaying the decision rule, when there is aux vars in the state variables, replace them by their original name (with the right lag)
* in "steady", don't display aux vars
* special exception for ramsey policy: all vars (including aux vars) are displayed, because the system of aux vars from ramsey policy is not compatible with the aux vars from the preprocessor


git-svn-id: https://www.dynare.org/svn/dynare/trunk@3166 ac1d8469-bf42-47a9-8791-bf33cf982152
parent 05071c62
......@@ -203,23 +203,27 @@ SymbolTable::writeOutput(ostream &output) const throw (NotYetFrozenException)
output << "M_.Sigma_e = zeros(" << exo_nbr() << ", " << exo_nbr() << ");" << endl;
// Write the auxiliary variable table
for(int i = 0; i < (int) aux_vars.size(); i++)
{
output << "M_.aux_vars(" << i+1 << ").endo_index = " << getTypeSpecificID(aux_vars[i].symb_id)+1 << ";" << endl
<< "M_.aux_vars(" << i+1 << ").type = " << aux_vars[i].type << ";" << endl;
switch(aux_vars[i].type)
{
case avEndoLead:
case avExoLead:
case avExpectation:
break;
case avEndoLag:
case avExoLag:
output << "M_.aux_vars(" << i+1 << ").orig_endo_index = " << getTypeSpecificID(aux_vars[i].orig_symb_id)+1 << ";" << endl
<< "M_.aux_vars(" << i+1 << ").orig_lag = " << aux_vars[i].orig_lag << ";" << endl;
break;
}
}
output << "M_.orig_endo_nbr = " << endo_nbr() - aux_vars.size() << ";" << endl;
if (aux_vars.size() == 0)
output << "M_.aux_vars = [];" << endl;
else
for(int i = 0; i < (int) aux_vars.size(); i++)
{
output << "M_.aux_vars(" << i+1 << ").endo_index = " << getTypeSpecificID(aux_vars[i].symb_id)+1 << ";" << endl
<< "M_.aux_vars(" << i+1 << ").type = " << aux_vars[i].type << ";" << endl;
switch(aux_vars[i].type)
{
case avEndoLead:
case avExoLead:
case avExpectation:
break;
case avEndoLag:
case avExoLag:
output << "M_.aux_vars(" << i+1 << ").orig_index = " << getTypeSpecificID(aux_vars[i].orig_symb_id)+1 << ";" << endl
<< "M_.aux_vars(" << i+1 << ").orig_lead_lag = " << aux_vars[i].orig_lead_lag << ";" << endl;
break;
}
}
if (predeterminedNbr() > 0)
{
......@@ -260,14 +264,14 @@ SymbolTable::addLeadAuxiliaryVarInternal(bool endo, int index) throw (FrozenExce
}
int
SymbolTable::addLagAuxiliaryVarInternal(bool endo, int orig_symb_id, int orig_lag) throw (FrozenException)
SymbolTable::addLagAuxiliaryVarInternal(bool endo, int orig_symb_id, int orig_lead_lag) throw (FrozenException)
{
ostringstream varname;
if (endo)
varname << "AUX_ENDO_LAG_";
else
varname << "AUX_EXO_LAG_";
varname << orig_symb_id << "_" << -orig_lag;
varname << orig_symb_id << "_" << -orig_lead_lag;
int symb_id;
try
......@@ -284,7 +288,7 @@ SymbolTable::addLagAuxiliaryVarInternal(bool endo, int orig_symb_id, int orig_la
avi.symb_id = symb_id;
avi.type = (endo ? avEndoLag : avExoLag);
avi.orig_symb_id = orig_symb_id;
avi.orig_lag = orig_lag;
avi.orig_lead_lag = orig_lead_lag;
aux_vars.push_back(avi);
return symb_id;
......@@ -297,9 +301,9 @@ SymbolTable::addEndoLeadAuxiliaryVar(int index) throw (FrozenException)
}
int
SymbolTable::addEndoLagAuxiliaryVar(int orig_symb_id, int orig_lag) throw (FrozenException)
SymbolTable::addEndoLagAuxiliaryVar(int orig_symb_id, int orig_lead_lag) throw (FrozenException)
{
return addLagAuxiliaryVarInternal(true, orig_symb_id, orig_lag);
return addLagAuxiliaryVarInternal(true, orig_symb_id, orig_lead_lag);
}
int
......@@ -309,9 +313,9 @@ SymbolTable::addExoLeadAuxiliaryVar(int index) throw (FrozenException)
}
int
SymbolTable::addExoLagAuxiliaryVar(int orig_symb_id, int orig_lag) throw (FrozenException)
SymbolTable::addExoLagAuxiliaryVar(int orig_symb_id, int orig_lead_lag) throw (FrozenException)
{
return addLagAuxiliaryVarInternal(false, orig_symb_id, orig_lag);
return addLagAuxiliaryVarInternal(false, orig_symb_id, orig_lead_lag);
}
int
......
......@@ -46,7 +46,7 @@ struct AuxVarInfo
int symb_id; //!< Symbol ID of the auxiliary variable
aux_var_t type; //!< Its type
int orig_symb_id; //!< Symbol ID of the endo of the original model represented by this aux var. Not used for avEndoLead
int orig_lag; //!< Lead/lag of the endo of the original model represented by this aux var. Not used for avEndoLead
int orig_lead_lag; //!< Lead/lag of the endo of the original model represented by this aux var. Not used for avEndoLead
};
//! Stores the symbol table
......@@ -143,7 +143,7 @@ public:
private:
//! Factorized code for adding aux lag variables
int addLagAuxiliaryVarInternal(bool endo, int orig_symb_id, int orig_lag) throw (FrozenException);
int addLagAuxiliaryVarInternal(bool endo, int orig_symb_id, int orig_lead_lag) throw (FrozenException);
//! Factorized code for adding aux lead variables
int addLeadAuxiliaryVarInternal(bool endo, int index) throw (FrozenException);
......@@ -162,9 +162,9 @@ public:
//! Adds an auxiliary variable for endogenous with lag >= 2
/*!
\param[in] orig_symb_id symbol ID of the endogenous declared by the user that this new variable will represent
\param[in] orig_lag lag value such that this new variable will be equivalent to orig_symb_id(orig_lag)
\param[in] orig_lead_lag lag value such that this new variable will be equivalent to orig_symb_id(orig_lead_lag)
\return the symbol ID of the new symbol */
int addEndoLagAuxiliaryVar(int orig_symb_id, int orig_lag) throw (FrozenException);
int addEndoLagAuxiliaryVar(int orig_symb_id, int orig_lead_lag) throw (FrozenException);
//! Adds an auxiliary variable for endogenous with lead >= 1
/*!
\param[in] index Used to construct the variable name
......@@ -173,9 +173,9 @@ public:
//! Adds an auxiliary variable for exogenous with lag >= 1
/*!
\param[in] orig_symb_id symbol ID of the exogenous declared by the user that this new variable will represent
\param[in] orig_lag lag value such that this new variable will be equivalent to orig_symb_id(orig_lag)
\param[in] orig_lead_lag lag value such that this new variable will be equivalent to orig_symb_id(orig_lead_lag)
\return the symbol ID of the new symbol */
int addExoLagAuxiliaryVar(int orig_symb_id, int orig_lag) throw (FrozenException);
int addExoLagAuxiliaryVar(int orig_symb_id, int orig_lead_lag) throw (FrozenException);
//! Adds an auxiliary variable for the expectation operator
/*!
\param[in] information_set information set (possibly negative) of the expectation operator
......
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