v4 parser.src: undoing rev. 944
git-svn-id: https://www.dynare.org/svn/dynare/dynare_v4@945 ac1d8469-bf42-47a9-8791-bf33cf982152time-shift
parent
c04c947d4c
commit
68b552aef2
|
@ -23,7 +23,7 @@
|
|||
%token AR AUTOCORR
|
||||
%token BAYESIAN_IRF BETA_PDF
|
||||
%token CALIB CALIB_VAR CHECK CONF_SIG CORR COVAR
|
||||
%token DATAFILE DIAGNOSTIC DIFFUSE_D /*New*/ DLL /*EndNew*/ DOLLAR DR_ALGO DROP DSAMPLE DYN2VEC DYNASAVE DYNATYPE
|
||||
%token DATAFILE DIAGNOSTIC DIFFUSE_D DOLLAR DR_ALGO DROP DSAMPLE DYN2VEC DYNASAVE DYNATYPE
|
||||
%token END ENDVAL EQUAL ESTIMATION ESTIMATED_PARAMS ESTIMATED_PARAMS_BOUNDS ESTIMATED_PARAMS_INIT
|
||||
%token FILTERED_VARS FIRST_OBS FLOAT_NUMBER FORECAST FUNCTIONS
|
||||
%token GAMMA_PDF GRAPH
|
||||
|
@ -302,11 +302,6 @@
|
|||
| MODEL '(' USE_DLL ')' ';' {_parser->use_dll();
|
||||
_parser->initialize_model();}
|
||||
equation_list END {_parser->check_model();}
|
||||
/*New*/
|
||||
| MODEL '(' DLL ')' ';' {_parser->dll();
|
||||
_parser->initialize_model();}
|
||||
equation_list END {_parser->check_model();}
|
||||
/*EnbdNew*/
|
||||
;
|
||||
|
||||
equation_list
|
||||
|
@ -811,7 +806,7 @@
|
|||
|
||||
optim_options
|
||||
: list_optim_option
|
||||
| optim_options COMMA list_optim_option
|
||||
| optim_options COMMA list_optim_option;
|
||||
;
|
||||
|
||||
varobs
|
||||
|
|
|
@ -183,11 +183,6 @@ int sigma_e = 0;
|
|||
<DYNARE_STATEMENT>xls_range {return XLS_RANGE;}
|
||||
|
||||
<DYNARE_STATEMENT,DYNARE_BLOCK>use_dll {return USE_DLL;}
|
||||
|
||||
/* New */
|
||||
<DYNARE_STATEMENT,DYNARE_BLOCK>dll {return DLL;}
|
||||
/* EndNew */
|
||||
|
||||
<DYNARE_STATEMENT,DYNARE_BLOCK>linear {return LINEAR;}
|
||||
<DYNARE_STATEMENT,DYNARE_BLOCK>[,] {_scanner->do_operator(COMMA); return COMMA;}
|
||||
<DYNARE_STATEMENT,DYNARE_BLOCK>[\(\)] {return yytext[0];}
|
||||
|
|
|
@ -15,10 +15,6 @@
|
|||
#include "ComputingTasks.h"
|
||||
#include "TmpSymbolTable.h"
|
||||
#include "DynareParser.h"
|
||||
/*New*/
|
||||
#include "BlockTriangular.h"
|
||||
/*EndNew*/
|
||||
|
||||
|
||||
string dynare::parser::file_name = "";
|
||||
void dynare::parser::set_file_name(string fname)
|
||||
|
@ -90,12 +86,6 @@ dynare::Objects* dynare::parser::add_variable(Objects* var)
|
|||
variable_table.AddVariable(var->symbol,0);
|
||||
//cout << "add_model_token : " << var->ID << endl;
|
||||
NodeID id = model_tree.AddTerminal(var->symbol);
|
||||
/*New*/
|
||||
if (var->type == eEndogenous)
|
||||
{
|
||||
block_triangular.fill_IM(ModelParameters::eq_nbr, symbol_table.getID(var->symbol), 0);
|
||||
}
|
||||
/*EndNew*/
|
||||
return new Objects("", id, eTempResult);
|
||||
}
|
||||
dynare::Objects* dynare::parser::add_variable(Objects* var,Objects* olag)
|
||||
|
@ -116,14 +106,6 @@ dynare::Objects* dynare::parser::add_variable(Objects* var,Objects* olag)
|
|||
variable_table.AddVariable(var->symbol,lag);
|
||||
//cout << "add_model_token : " << var->ID << endl;
|
||||
NodeID id = model_tree.AddTerminal(var->symbol,lag);
|
||||
/*New*/
|
||||
if (var->type == eEndogenous)
|
||||
{
|
||||
//cout << "var->symbol : " << var->symbol << symbol_table.getID(var->symbol) << "\n";
|
||||
//cout << "ModelParameters::eq_nbr : " << ModelParameters::eq_nbr << "\n";
|
||||
block_triangular.fill_IM(ModelParameters::eq_nbr, symbol_table.getID(var->symbol), lag);
|
||||
}
|
||||
/*EndNew*/
|
||||
return new Objects("", id, eTempResult);
|
||||
}
|
||||
dynare::Objects* dynare::parser::get_symbol(Objects* obj)
|
||||
|
@ -252,38 +234,14 @@ void dynare::parser::hist_val(Objects* lhs, Objects* slag)
|
|||
}
|
||||
void dynare::parser::initialize_model(void)
|
||||
{
|
||||
/*New*/
|
||||
block_triangular.init_incidence_matrix();
|
||||
/*EndNew*/
|
||||
}
|
||||
void dynare::parser::use_dll(void)
|
||||
{
|
||||
// Setting variable mumber offset to use C outputs
|
||||
// Seetting variable momber offset to use C outputs
|
||||
model_tree.offset = 0;
|
||||
}
|
||||
|
||||
/*New*/
|
||||
void dynare::parser::dll(void)
|
||||
{
|
||||
// Seetting variable mumber offset to use C outputs
|
||||
model_tree.offset = 2;
|
||||
}
|
||||
/*EndNew*/
|
||||
|
||||
void dynare::parser::check_model(void)
|
||||
{
|
||||
/*New*/
|
||||
if (block_triangular.bt_verbose)
|
||||
{
|
||||
/*cout << "block_triangular.bt_verbose : " << block_triangular.bt_verbose << "\n";
|
||||
cout << "----------------------------------------------------------------------------\n";*/
|
||||
cout << "The gross incidence matrix \n";
|
||||
block_triangular.Print_IM(ModelParameters::endo_nbr);
|
||||
cout << "First ordering \n";
|
||||
}
|
||||
//block_triangular.Normalize_and_BlockDecompose_0();
|
||||
block_triangular.Normalize_and_BlockDecompose_Static_Model();
|
||||
/*EndNew*/
|
||||
symbol_table.clean();
|
||||
}
|
||||
void dynare::parser::finish(void)
|
||||
|
@ -317,18 +275,12 @@ void dynare::parser::finish(void)
|
|||
|
||||
cout << "Processing outputs ...\n";
|
||||
model_tree.setStaticModel();
|
||||
/*New*/
|
||||
if (model_tree.offset == 2)
|
||||
model_tree.setDynamicModel_New(block_triangular.ModelBlock,block_triangular.Index_Var_IM);
|
||||
else
|
||||
model_tree.setDynamicModel();
|
||||
if (model_tree.offset != 1)
|
||||
/*EndNew*/
|
||||
|
||||
if (model_tree.offset == 0)
|
||||
{
|
||||
model_tree.OpenCFiles(model_file_name+"_static", model_file_name+"_dynamic");
|
||||
/*New*/
|
||||
model_tree.SaveCFiles(block_triangular.ModelBlock);
|
||||
/*EndNew*/
|
||||
model_tree.SaveCFiles();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -86,11 +86,6 @@ void ModelTree::OpenMFiles(string iModelFileName1, string iModelFileName2)
|
|||
//------------------------------------------------------------------------------
|
||||
void ModelTree::OpenCFiles(string iModelFileName1, string iModelFileName2)
|
||||
{
|
||||
/*New*/
|
||||
string tmp_s;
|
||||
int i,j;
|
||||
/*EndNew*/
|
||||
|
||||
if (iModelFileName1.size())
|
||||
{
|
||||
iModelFileName1 += ".c";
|
||||
|
@ -108,66 +103,11 @@ void ModelTree::OpenCFiles(string iModelFileName1, string iModelFileName2)
|
|||
mStaticModelFile << " * from model file (.mod)\n\n";
|
||||
mStaticModelFile << " */\n";
|
||||
mStaticModelFile << "#include <math.h>\n";
|
||||
/*New*/
|
||||
if(offset==0)
|
||||
mStaticModelFile << "#include \"mex.h\"\n";
|
||||
else
|
||||
mStaticModelFile << "#include <stdlib.h>\n";
|
||||
/*EndNew*/
|
||||
mStaticModelFile << "#include \"mex.h\"\n";
|
||||
// A global variable for model parameters
|
||||
// A flobal variable for model parameters
|
||||
mStaticModelFile << "double *params;\n";
|
||||
if (iModelFileName2.size() && (computeJacobian||computeJacobianExo||computeHessian))
|
||||
{
|
||||
/*New*/
|
||||
if(offset==2)
|
||||
{
|
||||
iModelFileName2 += ".h";
|
||||
mDynamicModelFile.open(iModelFileName2.c_str(),ios::out|ios::binary);
|
||||
if (!mDynamicModelFile.is_open())
|
||||
{
|
||||
cout << "ModelTree::Open : Error : Can't open file " << iModelFileName2
|
||||
<< ".h for writing\n";
|
||||
exit(-1);
|
||||
}
|
||||
iModelFileName2.erase(iModelFileName2.end()-2,iModelFileName2.end());
|
||||
tmp_s=iModelFileName2;
|
||||
j=tmp_s.size();
|
||||
for(i=0;i<j;i++)
|
||||
if ((tmp_s[i]=='\\')||(tmp_s[i]=='.')||(tmp_s[i]==':'))
|
||||
tmp_s[i]='_';
|
||||
mDynamicModelFile << "#ifndef " << tmp_s << "\n";
|
||||
mDynamicModelFile << "#define " << tmp_s << "\n";
|
||||
mDynamicModelFile << "typedef struct Variable_l\n";
|
||||
mDynamicModelFile << "{\n";
|
||||
mDynamicModelFile << " int* Index;\n";
|
||||
mDynamicModelFile << "};\n";
|
||||
mDynamicModelFile << "typedef struct tBlock\n";
|
||||
mDynamicModelFile << "{\n";
|
||||
mDynamicModelFile << " int Size, Sized, Type, Max_Lead, Max_Lag, Simulation_Type, icc1_size;\n";
|
||||
mDynamicModelFile << " int *Variable, *dVariable, *Equation, *icc1, *ics;\n";
|
||||
mDynamicModelFile << " Variable_l *Incidence_M;\n";
|
||||
mDynamicModelFile << "};\n";
|
||||
mDynamicModelFile << "\n";
|
||||
mDynamicModelFile << "typedef struct tModel_Block\n";
|
||||
mDynamicModelFile << "{\n";
|
||||
mDynamicModelFile << " int Size;\n";
|
||||
mDynamicModelFile << " tBlock * List;\n";
|
||||
mDynamicModelFile << "};\n";
|
||||
mDynamicModelFile << "\n";
|
||||
mDynamicModelFile << "const int UNKNOWN=" << UNKNOWN << ";\n";
|
||||
mDynamicModelFile << "const int EVALUATE_FOREWARD=" << EVALUATE_FOREWARD << ";\n";
|
||||
mDynamicModelFile << "const int EVALUATE_BACKWARD=" << EVALUATE_BACKWARD << ";\n";
|
||||
mDynamicModelFile << "const int SOLVE_FOREWARD_SIMPLE=" << SOLVE_FOREWARD_SIMPLE << ";\n";
|
||||
mDynamicModelFile << "const int SOLVE_BACKWARD_SIMPLE=" << SOLVE_BACKWARD_SIMPLE << ";\n";
|
||||
mDynamicModelFile << "const int SOLVE_TWO_BOUNDARIES_SIMPLE=" << SOLVE_TWO_BOUNDARIES_SIMPLE << ";\n";
|
||||
mDynamicModelFile << "const int SOLVE_FOREWARD_COMPLETE=" << SOLVE_FOREWARD_COMPLETE << ";\n";
|
||||
mDynamicModelFile << "const int SOLVE_BACKWARD_COMPLETE=" << SOLVE_BACKWARD_COMPLETE << ";\n";
|
||||
mDynamicModelFile << "const int SOLVE_TWO_BOUNDARIES_COMPLETE=" << SOLVE_TWO_BOUNDARIES_COMPLETE << ";\n";
|
||||
mDynamicModelFile << "#endif\n";
|
||||
mDynamicModelFile.close();
|
||||
}
|
||||
/*EndNew*/
|
||||
iModelFileName2 += ".c";
|
||||
mDynamicModelFile.open(iModelFileName2.c_str(),ios::out|ios::binary);
|
||||
if (!mDynamicModelFile.is_open())
|
||||
|
@ -184,15 +124,7 @@ void ModelTree::OpenCFiles(string iModelFileName1, string iModelFileName2)
|
|||
mDynamicModelFile << " * from model file (.mod)\n\n";
|
||||
mDynamicModelFile << " */\n";
|
||||
mDynamicModelFile << "#include <math.h>\n";
|
||||
/*New*/
|
||||
if(offset==0)
|
||||
mDynamicModelFile << "#include \"mex.h\"\n";
|
||||
else
|
||||
{
|
||||
mDynamicModelFile << "#include <stdlib.h>\n";
|
||||
mDynamicModelFile << "#include \"" << iModelFileName2.c_str() << ".h\"\n";
|
||||
}
|
||||
/*EndNew*/
|
||||
// A flobal variable for model parameters
|
||||
mDynamicModelFile << "double *params;\n";
|
||||
// A global variable for it_
|
||||
|
@ -223,19 +155,12 @@ void ModelTree::SaveMFiles()
|
|||
}
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
/*New*/
|
||||
void ModelTree::SaveCFiles(Model_Block* ModelBlock)
|
||||
void ModelTree::SaveCFiles()
|
||||
{
|
||||
int i, j, k;
|
||||
/*EndNew*/
|
||||
if (mStaticModelFile.is_open())
|
||||
{
|
||||
// Writing the function Static
|
||||
mStaticModelFile << StaticOutput.str();
|
||||
/*New*/
|
||||
if (offset==0)
|
||||
{
|
||||
/*EndNew*/
|
||||
// Writing the gateway routine
|
||||
mStaticModelFile << "/* The gateway routine */\n";
|
||||
mStaticModelFile << "void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])\n";
|
||||
|
@ -278,16 +203,11 @@ void ModelTree::SaveCFiles(Model_Block* ModelBlock)
|
|||
mStaticModelFile << " Static(y, x, residual, g1);\n";
|
||||
mStaticModelFile << "}\n";
|
||||
mStaticModelFile.close();
|
||||
/*New*/
|
||||
}
|
||||
/*EndNew*/
|
||||
}
|
||||
if (mDynamicModelFile.is_open() && (computeJacobian||computeJacobianExo||computeHessian))
|
||||
{
|
||||
// Writing the function body
|
||||
mDynamicModelFile << DynamicOutput.str();
|
||||
if (offset==0)
|
||||
{
|
||||
// Writing the gateway routine
|
||||
mDynamicModelFile << "/* The gateway routine */\n";
|
||||
mDynamicModelFile << "void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])\n";
|
||||
|
@ -344,40 +264,6 @@ void ModelTree::SaveCFiles(Model_Block* ModelBlock)
|
|||
mDynamicModelFile << " /* Call the C subroutines. */\n";
|
||||
mDynamicModelFile << " Dynamic(y, x, residual, g1, g2);\n";
|
||||
mDynamicModelFile << "}\n";
|
||||
/*New*/
|
||||
}
|
||||
else
|
||||
{
|
||||
mDynamicModelFile << "void Dynamic_Init(tModel_Block *Model_Block)\n";
|
||||
mDynamicModelFile << " {\n";
|
||||
mDynamicModelFile << " Model_Block=(tModel_Block*)malloc(sizeof(tModel_Block));\n";
|
||||
mDynamicModelFile << " Model_Block->Size=" << ModelBlock->Size << ";\n";
|
||||
mDynamicModelFile << " Model_Block->List=(tBlock*)malloc(sizeof(tBlock)*Model_Block->Size);\n";
|
||||
for(i=0;i<ModelBlock->Size;i++)
|
||||
{
|
||||
mDynamicModelFile << " Model_Block->List[" << i << "].Size=" << ModelBlock->Block_List[i].Size << ";\n";
|
||||
mDynamicModelFile << " Model_Block->List[" << i << "].Type=" << ModelBlock->Block_List[i].Type << ";\n";
|
||||
mDynamicModelFile << " Model_Block->List[" << i << "].Sized=" << ModelBlock->Block_List[i].Sized << ";\n";
|
||||
mDynamicModelFile << " Model_Block->List[" << i << "].Max_Lag=" << ModelBlock->Block_List[i].Max_Lag << ";\n";
|
||||
mDynamicModelFile << " Model_Block->List[" << i << "].Max_Lead=" << ModelBlock->Block_List[i].Max_Lead << ";\n";
|
||||
mDynamicModelFile << " Model_Block->List[" << i << "].Simulation_Type=" << BlockTriangular::BlockSim_d(ModelBlock->Block_List[i].Simulation_Type) << ";\n";
|
||||
mDynamicModelFile << " Model_Block->List[" << i << "].Variable=(int*)malloc(Model_Block->List[" << i << "].Size*sizeof(int));\n";
|
||||
mDynamicModelFile << " Model_Block->List[" << i << "].Equation=(int*)malloc(Model_Block->List[" << i << "].Size*sizeof(int));\n";
|
||||
mDynamicModelFile << " Model_Block->List[" << i << "].icc1_size=" << ModelBlock->Block_List[i].icc1_size << ";\n";
|
||||
mDynamicModelFile << " Model_Block->List[" << i << "].icc1=(int*)malloc(Model_Block->List[" << i << "].icc1_size*sizeof(int));\n";
|
||||
mDynamicModelFile << " Model_Block->List[" << i << "].Incidence_M=(Variable_l*)malloc(Model_Block->List[" << i << "].Size*sizeof(*Model_Block->List[" << i << "].Incidence_M));\n";
|
||||
if(ModelBlock->Block_List[i].Sized>0)
|
||||
mDynamicModelFile << " Model_Block->List[" << i << "].dVariable=(int*)malloc(Model_Block->List[" << i << "].Sized*sizeof(int));\n";
|
||||
for(j=0;j<ModelBlock->Block_List[i].Size;j++)
|
||||
mDynamicModelFile << " Model_Block->List[" << i << "].Variable[" << j << "]=" << ModelBlock->Block_List[i].Variable_Sorted[j] << ";\n";
|
||||
for(j=0;j<ModelBlock->Block_List[i].Size;j++)
|
||||
mDynamicModelFile << " Model_Block->List[" << i << "].Equation[" << j << "]=" << ModelBlock->Block_List[i].Equation[j] << ";\n";
|
||||
for(j=0;j<ModelBlock->Block_List[i].Sized;j++)
|
||||
mDynamicModelFile << " Model_Block->List[" << i << "].dVariable[" << j << "]=" << ModelBlock->Block_List[i].dVariable[j] << ";\n";
|
||||
}
|
||||
mDynamicModelFile << " }\n";
|
||||
}
|
||||
/*EndNew*/
|
||||
mDynamicModelFile.close();
|
||||
}
|
||||
}
|
||||
|
@ -408,7 +294,7 @@ void ModelTree::derive(int iOrder)
|
|||
(*currentIT)->reference_count[0]++;
|
||||
}
|
||||
}
|
||||
//std::cout << "size " << EqualTokenIDs.size() << "\n";
|
||||
std::cout << "size " << EqualTokenIDs.size() << "\n";
|
||||
mDerivativeIndex.resize(iOrder);
|
||||
// Uncomment this to print model tree data
|
||||
/*
|
||||
|
@ -619,8 +505,7 @@ void ModelTree::derive(int iOrder)
|
|||
}
|
||||
}
|
||||
}
|
||||
if (currentIT == EndIT)
|
||||
break;
|
||||
if (currentIT == EndIT) break;
|
||||
}
|
||||
|
||||
// Treating equal tokens
|
||||
|
@ -838,8 +723,7 @@ string ModelTree::setStaticModel(void)
|
|||
model_output << "residual" << lpar << lEquationNBR+1 << rpar << "= lhs-rhs;" << endl;
|
||||
lEquationNBR++;
|
||||
}
|
||||
else
|
||||
break;
|
||||
else break;
|
||||
}
|
||||
else if ((*tree_it)->op_code != NoOpCode)
|
||||
{
|
||||
|
@ -940,613 +824,6 @@ string ModelTree::setStaticModel(void)
|
|||
current_order = d;
|
||||
return StaticOutput.str();
|
||||
}
|
||||
|
||||
|
||||
/*New*/
|
||||
|
||||
void reverse(char *s)
|
||||
{
|
||||
int c, i, j;
|
||||
for(i=0,j=strlen(s)-1;i<j;i++,j--)
|
||||
{
|
||||
c=s[i];
|
||||
s[i]=s[j];
|
||||
s[j]=c;
|
||||
}
|
||||
}
|
||||
|
||||
char* itoa(int n)
|
||||
{
|
||||
int i,sign,na;
|
||||
char* s;
|
||||
if((sign=n)<0)
|
||||
n=-n;
|
||||
i=1;
|
||||
na=n;
|
||||
do
|
||||
{
|
||||
i++;
|
||||
}
|
||||
while((na/=10)>0);
|
||||
if (sign<0)
|
||||
i++;
|
||||
s=(char*)malloc(i);
|
||||
i=0;
|
||||
do
|
||||
{
|
||||
s[i++]=n % 10+'0';
|
||||
}
|
||||
while((n/=10)>0);
|
||||
if (sign<0)
|
||||
s[i++]='-';
|
||||
s[i]='\0';
|
||||
reverse(s);
|
||||
return(s);
|
||||
}
|
||||
|
||||
char* strcopy(char *s,int pos1,int pos2)
|
||||
{
|
||||
int i;
|
||||
char* st;
|
||||
st=(char*)malloc(pos2-pos1+1);
|
||||
for(i=pos1;i<pos2;i++)
|
||||
st[i-pos1]=s[i];
|
||||
st[i-pos1]='\0';
|
||||
return(st);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
string ModelTree::setDynamicModel_New(Model_Block* ModelBlock, simple* Index_Var_IM)
|
||||
{
|
||||
TreeIterator tree_it,tree_it_f, G_tree_it;
|
||||
TreeIterator* list_tree_it;
|
||||
int lEquationNBR = 0;
|
||||
ostringstream lsymetric; // Used when writing symetric elements
|
||||
ostringstream model_output; // Used for storing model equations
|
||||
ostringstream model_tmp_output; // Used for storing tmp expressions for model equations
|
||||
ostringstream jacobian_output; // Used for storing jacobian equations
|
||||
ostringstream jacobian_tmp_output; // Used for storing tmp expressions for jacobian equations
|
||||
ostringstream hessian_output; // Used for storing Hessian equations
|
||||
ostringstream hessian_tmp_output; // Used for storing tmp expressions for Hessian equations
|
||||
string sModel,sOptimize,tmp_s;
|
||||
char* tmp_c;
|
||||
string Equationf[ModelBlock->Size];
|
||||
typedef struct vari
|
||||
{
|
||||
int Index;
|
||||
vari *pNext;
|
||||
};
|
||||
typedef struct variable
|
||||
{
|
||||
int Size;
|
||||
vari *list;
|
||||
vari *First_list;
|
||||
};
|
||||
string Jacobian[ModelBlock->Size],Jacobian_s[ModelBlock->Size];
|
||||
variable *v_Jacobian, *v_Jacobian_s;
|
||||
int i,j,k,l,l1,n,m,p;
|
||||
int d = current_order;
|
||||
bool finish, OK;
|
||||
int *Table, *leaded;
|
||||
int TableSize;
|
||||
v_Jacobian=(variable*)malloc(ModelBlock->Size*sizeof(*v_Jacobian));
|
||||
v_Jacobian_s=(variable*)malloc(ModelBlock->Size*sizeof(*v_Jacobian_s));
|
||||
leaded=(int*)malloc(ModelBlock->Size*sizeof(int));
|
||||
fill(ZeroEqZero->reference_count.begin(),
|
||||
ZeroEqZero->reference_count.end(),0);
|
||||
|
||||
// Clearing output string
|
||||
model_output.str("");
|
||||
sModel="";
|
||||
sOptimize="";
|
||||
jacobian_output.str("");
|
||||
// Getting equations from model tree
|
||||
// Starting from the end of equation
|
||||
// Searching for the next '=' operator,
|
||||
current_order = 1;
|
||||
lEquationNBR = 0;
|
||||
cout << "\tequations .. ";
|
||||
list_tree_it=(TreeIterator*)malloc(sizeof(*list_tree_it)*(ModelParameters::endo_nbr+1));
|
||||
tree_it = BeginModel;
|
||||
list_tree_it[lEquationNBR]=tree_it;
|
||||
for (; tree_it != mModelTree.end(); tree_it++)
|
||||
{
|
||||
if ((*tree_it)->op_code == EQUAL)
|
||||
{
|
||||
if ((*tree_it)->id1->type1 == eLocalParameter)
|
||||
;
|
||||
else if (lEquationNBR < ModelParameters::eq_nbr)
|
||||
{
|
||||
|
||||
lEquationNBR++;
|
||||
tree_it_f=tree_it;
|
||||
tree_it_f++;
|
||||
list_tree_it[lEquationNBR]=tree_it_f;
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
else if ((*tree_it)->op_code != NoOpCode)
|
||||
(*tree_it)->tmp_status = 0;
|
||||
}
|
||||
for(k=0;k<ModelBlock->Size;k++)
|
||||
{
|
||||
Jacobian[k]="";
|
||||
Jacobian_s[k]="";
|
||||
Equationf[k]="";
|
||||
leaded[k]=0;
|
||||
v_Jacobian[k].First_list=NULL;
|
||||
v_Jacobian[k].Size=0;
|
||||
v_Jacobian_s[k].First_list=NULL;
|
||||
v_Jacobian_s[k].Size=0;
|
||||
}
|
||||
G_tree_it=tree_it;
|
||||
G_tree_it--;
|
||||
|
||||
|
||||
lEquationNBR=0;
|
||||
Table=VariableTable::GetVariableTable(&TableSize);
|
||||
for(j=0;j<ModelBlock->Size;j++)
|
||||
{
|
||||
Equationf[j]="//Block ";
|
||||
Equationf[j]=Equationf[j]+itoa(j+1)+" "+BlockTriangular::BlockType0(ModelBlock->Block_List[j].Type)+"\n";
|
||||
ModelBlock->Block_List[j].Simulation_Type=UNKNOWN;
|
||||
for(i=0;i<ModelBlock->Block_List[j].Size;i++)
|
||||
{
|
||||
sModel=SymbolTable::getNameByID(eEndogenous,ModelBlock->Block_List[j].Variable[i]) ;
|
||||
ModelBlock->Block_List[j].Variable_Sorted[i]=VariableTable::GetVariableID(sModel, 0);
|
||||
Equationf[j]=Equationf[j]+"//equation "+itoa(ModelBlock->Block_List[j].Equation[i]+1)+" variable : "+
|
||||
sModel+" ("+itoa(ModelBlock->Block_List[j].Variable_Sorted[i])+")\n";
|
||||
finish=0;
|
||||
for(tree_it=list_tree_it[ModelBlock->Block_List[j].Equation[i]];/*!finish*/tree_it!=list_tree_it[ModelBlock->Block_List[j].Equation[i]+1];tree_it++)
|
||||
{
|
||||
if ((*tree_it)->op_code == EQUAL)
|
||||
{
|
||||
if ((*tree_it)->id1->type1 == eLocalParameter)
|
||||
{
|
||||
Equationf[j]=Equationf[j]+getExpression((*tree_it)->id1, eStaticEquations, lEquationNBR)+" = "+
|
||||
getExpression((*tree_it)->id2, eStaticEquations, lEquationNBR)+";\n";
|
||||
}
|
||||
else if (lEquationNBR < ModelParameters::eq_nbr)
|
||||
{
|
||||
if ((ModelBlock->Block_List[j].Type==PROLOGUE)||(ModelBlock->Block_List[j].Type==EPILOGUE))
|
||||
{
|
||||
sModel=getExpression(((*tree_it)->id2), eDynamicEquations, lEquationNBR);
|
||||
OK=1;
|
||||
for(k=0;k<TableSize;k++)
|
||||
if(Table[k*4+2]==ModelBlock->Block_List[j].Variable_Sorted[i])
|
||||
{
|
||||
n=Table[k*4];
|
||||
break;
|
||||
}
|
||||
for(k=0;k<TableSize;k++)
|
||||
if(Table[k*4]==n)
|
||||
{
|
||||
tmp_s="";
|
||||
tmp_s=tmp_s+"y["+itoa(Table[k*4+2])+"]";
|
||||
if ((int)sModel.find((char*)tmp_s.data(),0,sModel.size())>0)
|
||||
{
|
||||
if((ModelBlock->Block_List[j].Simulation_Type==SOLVE_TWO_BOUNDARIES_SIMPLE)||(Table[k*4+1]==0))
|
||||
{
|
||||
OK=0;
|
||||
if(ModelBlock->Block_List[j].Simulation_Type!=SOLVE_TWO_BOUNDARIES_SIMPLE)
|
||||
{
|
||||
if(ModelBlock->Block_List[j].Simulation_Type==EVALUATE_BACKWARD)
|
||||
ModelBlock->Block_List[j].Simulation_Type=SOLVE_BACKWARD_SIMPLE;
|
||||
else
|
||||
ModelBlock->Block_List[j].Simulation_Type=SOLVE_FOREWARD_SIMPLE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(Table[k*4+1]<0)
|
||||
if((ModelBlock->Block_List[j].Simulation_Type==UNKNOWN)||(ModelBlock->Block_List[j].Simulation_Type==EVALUATE_FOREWARD))
|
||||
ModelBlock->Block_List[j].Simulation_Type=EVALUATE_FOREWARD;
|
||||
else
|
||||
ModelBlock->Block_List[j].Simulation_Type=SOLVE_TWO_BOUNDARIES_SIMPLE;
|
||||
if(Table[k*4+1]>0)
|
||||
if((ModelBlock->Block_List[j].Simulation_Type==UNKNOWN)||(ModelBlock->Block_List[j].Simulation_Type==EVALUATE_BACKWARD))
|
||||
ModelBlock->Block_List[j].Simulation_Type=EVALUATE_BACKWARD;
|
||||
else
|
||||
ModelBlock->Block_List[j].Simulation_Type=SOLVE_TWO_BOUNDARIES_SIMPLE;
|
||||
}
|
||||
}
|
||||
}
|
||||
sModel=getExpression(((*tree_it)->id1), eDynamicEquations, lEquationNBR);
|
||||
tmp_s="";
|
||||
tmp_s=tmp_s+"y["+itoa(ModelBlock->Block_List[j].Variable_Sorted[i])+"]";
|
||||
if(tmp_s!=sModel)
|
||||
{
|
||||
OK=0;
|
||||
if((ModelBlock->Block_List[j].Simulation_Type==UNKNOWN)||(ModelBlock->Block_List[j].Simulation_Type==EVALUATE_FOREWARD))
|
||||
ModelBlock->Block_List[j].Simulation_Type=SOLVE_FOREWARD_SIMPLE;
|
||||
else if(ModelBlock->Block_List[j].Simulation_Type==EVALUATE_BACKWARD)
|
||||
ModelBlock->Block_List[j].Simulation_Type=SOLVE_BACKWARD_SIMPLE;
|
||||
}
|
||||
else
|
||||
if(ModelBlock->Block_List[j].Simulation_Type==UNKNOWN)
|
||||
ModelBlock->Block_List[j].Simulation_Type=EVALUATE_FOREWARD;
|
||||
if (!OK)
|
||||
Equationf[j]=Equationf[j]+"residual"+lpar+/*itoa(lEquationNBR+1)*/itoa(i+1)+rpar+"= ("+
|
||||
sModel+")-("+
|
||||
getExpression(((*tree_it)->id2), eDynamicEquations, lEquationNBR)+");\n";
|
||||
else
|
||||
Equationf[j]=Equationf[j]+
|
||||
sModel+"="+
|
||||
getExpression(((*tree_it)->id2), eDynamicEquations, lEquationNBR)+";\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
if((ModelBlock->Block_List[j].Max_Lag>0)&&(ModelBlock->Block_List[j].Max_Lead>0))
|
||||
ModelBlock->Block_List[j].Simulation_Type=SOLVE_TWO_BOUNDARIES_COMPLETE;
|
||||
else if((ModelBlock->Block_List[j].Max_Lag==0)&&(ModelBlock->Block_List[j].Max_Lead>0))
|
||||
ModelBlock->Block_List[j].Simulation_Type=SOLVE_BACKWARD_COMPLETE;
|
||||
else
|
||||
ModelBlock->Block_List[j].Simulation_Type=SOLVE_FOREWARD_COMPLETE;
|
||||
Equationf[j]=Equationf[j]+"residual"+lpar+/*itoa(lEquationNBR+1)*/itoa(i+1)+rpar+"= ("+
|
||||
getExpression(((*tree_it)->id1), eDynamicEquations, lEquationNBR)+")-("+
|
||||
getExpression(((*tree_it)->id2), eDynamicEquations, lEquationNBR)+");\n";
|
||||
}
|
||||
lEquationNBR++;
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
else if ((*tree_it)->op_code != NoOpCode)
|
||||
{
|
||||
if (optimize(*tree_it))
|
||||
{
|
||||
sModel="T";
|
||||
sModel=sModel+itoa((*tree_it)->idx);
|
||||
if (sOptimize=="")
|
||||
sOptimize=sModel;
|
||||
else
|
||||
if(offset==1)
|
||||
sOptimize=sOptimize+" "+sModel;
|
||||
else
|
||||
sOptimize=sOptimize+", "+sModel;
|
||||
Equationf[j]=Equationf[j]+sModel+"="+getExpression(*tree_it, eDynamicEquations, lEquationNBR)+";\n";
|
||||
(*tree_it)->tmp_status = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
(*tree_it)->tmp_status = 0;
|
||||
}
|
||||
}
|
||||
finish=(tree_it==list_tree_it[ModelBlock->Block_List[j].Equation[i]+1]);
|
||||
if(G_tree_it != mModelTree.end())
|
||||
{
|
||||
if ((*G_tree_it)->op_code != NoOpCode && (*G_tree_it)->op_code != EQUAL)
|
||||
{
|
||||
if (optimize(*G_tree_it) == 1)
|
||||
{
|
||||
sModel="T";
|
||||
sModel=sModel+itoa((*G_tree_it)->idx);
|
||||
if (sOptimize=="")
|
||||
sOptimize=sModel;
|
||||
else
|
||||
if(offset==1)
|
||||
sOptimize=sOptimize+" "+sModel;
|
||||
else
|
||||
sOptimize=sOptimize+", "+sModel;
|
||||
Equationf[j]=Equationf[j]+sModel+"="+getExpression(*G_tree_it, eDynamicEquations, lEquationNBR)+";\n";
|
||||
(*G_tree_it)->tmp_status = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
(*G_tree_it)->tmp_status = 0;
|
||||
}
|
||||
}
|
||||
G_tree_it++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for(k = 0; k < mDerivativeIndex[0].size(); k++)
|
||||
{
|
||||
if (computeJacobianExo || VariableTable::getType(mDerivativeIndex[0][k].derivators) == eEndogenous)
|
||||
{
|
||||
NodeID startJacobian = mDerivativeIndex[0][k].token_id;
|
||||
if (startJacobian != ZeroEqZero)
|
||||
{
|
||||
string exp = getExpression(startJacobian->id1, eDynamicDerivatives);
|
||||
ostringstream g1;
|
||||
j=ModelBlock->in_Block_Equ[mDerivativeIndex[0][k].equation_id];
|
||||
i=0;
|
||||
while((mDerivativeIndex[0][k].equation_id!=ModelBlock->Block_List[j].Equation[i])&&(i<ModelBlock->Block_List[j].Size))
|
||||
{
|
||||
i++;
|
||||
}
|
||||
n=VariableTable::getSortID(mDerivativeIndex[0][k].derivators);
|
||||
l=0;
|
||||
while((n!=Table[l*4+2])&&(l<TableSize))
|
||||
l++;
|
||||
l1=Table[l*4];
|
||||
finish=0;
|
||||
for(n=0;n<ModelBlock->Block_List[j].Size;n++)
|
||||
if(ModelBlock->Block_List[j].Variable[n]==l1)
|
||||
{
|
||||
finish=1;
|
||||
break;
|
||||
}
|
||||
if(finish)
|
||||
{
|
||||
g1.str("");
|
||||
m=-1;
|
||||
if(v_Jacobian[j].Size>0)
|
||||
{
|
||||
v_Jacobian[j].list=v_Jacobian[j].First_list;
|
||||
p=0;
|
||||
while((v_Jacobian[j].list->Index!=(VariableTable::getSortID(mDerivativeIndex[0][k].derivators)))&&(v_Jacobian[j].list->pNext!=NULL))
|
||||
{
|
||||
p++;
|
||||
v_Jacobian[j].list=v_Jacobian[j].list->pNext;
|
||||
}
|
||||
if(v_Jacobian[j].list->Index==(VariableTable::getSortID(mDerivativeIndex[0][k].derivators)))
|
||||
m= mDerivativeIndex[0][k].derivators;
|
||||
while(v_Jacobian[j].list->pNext!=NULL)
|
||||
v_Jacobian[j].list=v_Jacobian[j].list->pNext;
|
||||
}
|
||||
if(m<0)
|
||||
{
|
||||
if(offset!=2)
|
||||
g1 << " g1" << lpar << i+1 << "," << v_Jacobian[j].Size+1 << rpar;
|
||||
else
|
||||
g1 << " g1" << lpar << i+1 << "*" << itoa(ModelBlock->Block_List[j].Size) << "+" << v_Jacobian[j].Size+1 << rpar;
|
||||
Jacobian[j]=Jacobian[j]+g1.str()+"="+g1.str()+"+"+exp+"; /*"
|
||||
+SymbolTable::getNameByID(eEndogenous,VariableTable::/*getSortID*/VariableTable::getSymbolID(mDerivativeIndex[0][k].derivators))+
|
||||
+"("+itoa(VariableTable::getLag(mDerivativeIndex[0][k].derivators))+") "
|
||||
+itoa(VariableTable::getSortID(mDerivativeIndex[0][k].derivators))+"*/\n";
|
||||
if(v_Jacobian[j].First_list==NULL)
|
||||
{
|
||||
v_Jacobian[j].First_list=(vari*)malloc(sizeof(vari));
|
||||
v_Jacobian[j].list=v_Jacobian[j].First_list;
|
||||
}
|
||||
else
|
||||
{
|
||||
v_Jacobian[j].list->pNext=(vari*)malloc(sizeof(vari));
|
||||
v_Jacobian[j].list=v_Jacobian[j].list->pNext;
|
||||
}
|
||||
v_Jacobian[j].list->pNext=NULL;
|
||||
v_Jacobian[j].list->Index=VariableTable::getSortID(mDerivativeIndex[0][k].derivators);
|
||||
v_Jacobian[j].Size++;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(offset!=2)
|
||||
g1 << " g1" << lpar << i+1 << "," << p+1 << rpar;
|
||||
else
|
||||
g1 << " g1" << lpar << i+1 << "*" << itoa(ModelBlock->Block_List[j].Size) << "+" << p+1 << rpar;
|
||||
Jacobian[j]=Jacobian[j]+g1.str()+"="+g1.str()+"+"+exp+"; /*"
|
||||
+SymbolTable::getNameByID(eEndogenous,VariableTable::/*getSortID*/VariableTable::getSymbolID(m))+
|
||||
+"("+itoa(VariableTable::getLag(m))+") "
|
||||
+itoa(VariableTable::getSortID(m))+"*/\n";
|
||||
}
|
||||
if(Table[l*4+1]==0)
|
||||
{
|
||||
g1.str("");
|
||||
m=-1;
|
||||
if(v_Jacobian_s[j].Size>0)
|
||||
{
|
||||
v_Jacobian_s[j].list=v_Jacobian_s[j].First_list;
|
||||
p=0;
|
||||
while((v_Jacobian_s[j].list->Index!=(VariableTable::getSortID(mDerivativeIndex[0][k].derivators)))&&(v_Jacobian_s[j].list->pNext!=NULL))
|
||||
{
|
||||
p++;
|
||||
v_Jacobian_s[j].list=v_Jacobian_s[j].list->pNext;
|
||||
}
|
||||
if(v_Jacobian_s[j].list->Index==(VariableTable::getSortID(mDerivativeIndex[0][k].derivators)))
|
||||
m= mDerivativeIndex[0][k].derivators;
|
||||
while(v_Jacobian_s[j].list->pNext!=NULL)
|
||||
v_Jacobian_s[j].list=v_Jacobian_s[j].list->pNext;
|
||||
}
|
||||
if(m<0)
|
||||
{
|
||||
if(offset!=2)
|
||||
g1 << " g1" << lpar << i+1 << "," << v_Jacobian_s[j].Size+1 << rpar;
|
||||
else
|
||||
g1 << " g1" << lpar << i+1 << "*" << itoa(ModelBlock->Block_List[j].Size) << "+" << v_Jacobian_s[j].Size+1 << rpar;
|
||||
Jacobian_s[j]=Jacobian_s[j]+g1.str()+"="+g1.str()+"+"+exp+"; /*"
|
||||
+SymbolTable::getNameByID(eEndogenous,VariableTable::/*getSortID*/getSymbolID(mDerivativeIndex[0][k].derivators))+
|
||||
+"("+itoa(VariableTable::getLag(mDerivativeIndex[0][k].derivators))+") "
|
||||
+itoa(VariableTable::getSortID(mDerivativeIndex[0][k].derivators))+"*/\n";
|
||||
if(v_Jacobian_s[j].First_list==NULL)
|
||||
{
|
||||
v_Jacobian_s[j].First_list=(vari*)malloc(sizeof(vari));
|
||||
v_Jacobian_s[j].list=v_Jacobian_s[j].First_list;
|
||||
}
|
||||
else
|
||||
{
|
||||
v_Jacobian_s[j].list->pNext=(vari*)malloc(sizeof(vari));
|
||||
v_Jacobian_s[j].list=v_Jacobian_s[j].list->pNext;
|
||||
}
|
||||
v_Jacobian_s[j].list->pNext=NULL;
|
||||
v_Jacobian_s[j].list->Index=VariableTable::getSortID(mDerivativeIndex[0][k].derivators);
|
||||
v_Jacobian_s[j].Size++;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(offset!=2)
|
||||
g1 << " g1" << lpar << i+1 << "," << p+1 << rpar;
|
||||
else
|
||||
g1 << " g1" << lpar << i+1 << "*" << itoa(ModelBlock->Block_List[j].Size) << "+" << p+1 << rpar;
|
||||
Jacobian_s[j]=Jacobian_s[j]+g1.str()+"="+g1.str()+"+"+exp+"; /*"
|
||||
+SymbolTable::getNameByID(eEndogenous,VariableTable::/*getSortID*/getSymbolID(m))+
|
||||
+"("+itoa(VariableTable::getLag(m))+") "
|
||||
+itoa(VariableTable::getSortID(m))+"*/\n";
|
||||
}
|
||||
}
|
||||
if(Table[l*4+1]>0)
|
||||
leaded[j]=1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
finish=0;
|
||||
while(!finish)
|
||||
{
|
||||
if(G_tree_it != mModelTree.end())
|
||||
{
|
||||
if ((*G_tree_it)->op_code != NoOpCode && (*G_tree_it)->op_code != EQUAL)
|
||||
{
|
||||
if (optimize(*G_tree_it) == 1)
|
||||
{
|
||||
sModel="T";
|
||||
sModel=sModel+itoa((*G_tree_it)->idx);
|
||||
if (sOptimize=="")
|
||||
sOptimize=sModel;
|
||||
else
|
||||
if(offset==1)
|
||||
sOptimize=sOptimize+" "+sModel;
|
||||
else
|
||||
sOptimize=sOptimize+", "+sModel;
|
||||
Equationf[j]=Equationf[j]+sModel+"="+getExpression(*G_tree_it, eDynamicEquations, lEquationNBR)+";\n";
|
||||
(*G_tree_it)->tmp_status = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
(*G_tree_it)->tmp_status = 0;
|
||||
}
|
||||
}
|
||||
G_tree_it++;
|
||||
}
|
||||
else
|
||||
finish=1;
|
||||
}
|
||||
cout << "done \n";
|
||||
if (computeHessian)
|
||||
{
|
||||
// Getting Hessian from model tree
|
||||
// Starting from the end of equation
|
||||
// Searching for the next '=' operator,
|
||||
lEquationNBR = 0;
|
||||
cout << "\tHessian .. ";
|
||||
for (unsigned int i = 0; i < mDerivativeIndex[1].size(); i++)
|
||||
{
|
||||
NodeID startHessian = mDerivativeIndex[1][i].token_id;
|
||||
//cout << "ID = " << startHessian << " exp = " << exp << "\n";
|
||||
if (startHessian != ZeroEqZero)
|
||||
{
|
||||
string exp = getExpression(startHessian->id1, eDynamicDerivatives);
|
||||
|
||||
int varID1 = mDerivativeIndex[1][i].derivators/VariableTable::size();
|
||||
int varID2 = mDerivativeIndex[1][i].derivators-varID1*VariableTable::size();
|
||||
hessian_output << " g2" << lpar << mDerivativeIndex[1][i].equation_id+1 << ", " <<
|
||||
mDerivativeIndex[1][i].derivators+1 << rpar << " = " << exp << ";\n";
|
||||
// Treating symetric elements
|
||||
if (varID1 != varID2)
|
||||
lsymetric << " g2" << lpar << mDerivativeIndex[1][i].equation_id+1 << ", " <<
|
||||
varID2*VariableTable::size()+varID1+1 << rpar << " = " <<
|
||||
"g2" << lpar << mDerivativeIndex[1][i].equation_id+1 << ", " <<
|
||||
mDerivativeIndex[1][i].derivators+1 << rpar << ";\n";
|
||||
}
|
||||
|
||||
}
|
||||
cout << "done \n";
|
||||
}
|
||||
int nrows = ModelParameters::eq_nbr;
|
||||
if (offset == 1)
|
||||
{
|
||||
DynamicOutput << "global M_ it_\n";
|
||||
DynamicOutput << "global "+sOptimize+"\n";
|
||||
DynamicOutput << "if M_.param_nbr > 0\n params = M_.params;\nend\n";
|
||||
DynamicOutput << "\n\t%\n\t% Model equations\n\t%\n\n";
|
||||
DynamicOutput << "residual = zeros(" << nrows << ", 1);\n";
|
||||
|
||||
DynamicOutput << model_output.str();
|
||||
|
||||
if (computeJacobian || computeJacobianExo)
|
||||
{
|
||||
DynamicOutput << "if nargout >= 2,\n";
|
||||
// Writing initialization instruction for matrix g1
|
||||
DynamicOutput << " g1 = " <<
|
||||
"zeros(" << nrows << ", " << VariableTable::size() << ");\n" ;
|
||||
DynamicOutput << "\n\t%\n\t% Jacobian matrix\n\t%\n\n";
|
||||
DynamicOutput << jacobian_output.str();
|
||||
DynamicOutput << "end\n";
|
||||
}
|
||||
if (computeHessian)
|
||||
{
|
||||
DynamicOutput << "if nargout >= 3,\n";
|
||||
// Writing initialization instruction for matrix g2
|
||||
int ncols = VariableTable::size()*VariableTable::size();
|
||||
DynamicOutput << " g2 = " <<
|
||||
"sparse([],[],[]," << nrows << ", " << ncols << ", " <<
|
||||
5*ncols << ");\n";
|
||||
DynamicOutput << "\n\t%\n\t% Hessian matrix\n\t%\n\n";
|
||||
DynamicOutput << hessian_output.str() << lsymetric.str();
|
||||
DynamicOutput << "end;\n";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((offset==2)&&(sOptimize.size()>0))
|
||||
DynamicOutput << "double "+sOptimize+";\n";
|
||||
for(j=0;j<ModelBlock->Size;j++)
|
||||
{
|
||||
DynamicOutput << "void Dynamic" << j+1 << "(double *y, double *x, double *residual, double *g1, double *g2)\n";
|
||||
DynamicOutput << "{\n";
|
||||
if((ModelBlock->Block_List[j].Simulation_Type!=EVALUATE_FOREWARD)&&(ModelBlock->Block_List[j].Simulation_Type!=EVALUATE_BACKWARD))
|
||||
{
|
||||
v_Jacobian[j].list=v_Jacobian[j].First_list;
|
||||
v_Jacobian_s[j].list=v_Jacobian_s[j].First_list;
|
||||
if(leaded[j]==1)
|
||||
{
|
||||
ModelBlock->Block_List[j].Sized=v_Jacobian[j].Size;
|
||||
ModelBlock->Block_List[j].dVariable=(int*)malloc(v_Jacobian[j].Size*sizeof(int));
|
||||
for(i=0;i<v_Jacobian[j].Size;i++)
|
||||
{
|
||||
ModelBlock->Block_List[j].dVariable[i]=v_Jacobian[j].list->Index;
|
||||
v_Jacobian[j].list=v_Jacobian[j].list->pNext;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ModelBlock->Block_List[j].Sized=v_Jacobian_s[j].Size;
|
||||
ModelBlock->Block_List[j].dVariable=(int*)malloc(v_Jacobian[j].Size*sizeof(int));
|
||||
for(i=0;i<v_Jacobian_s[j].Size;i++)
|
||||
{
|
||||
ModelBlock->Block_List[j].dVariable[i]=v_Jacobian_s[j].list->Index;
|
||||
v_Jacobian_s[j].list=v_Jacobian_s[j].list->pNext;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ModelBlock->Block_List[j].Sized=0;
|
||||
}
|
||||
DynamicOutput << Equationf[j];
|
||||
if ((computeJacobian || computeJacobianExo)&&(ModelBlock->Block_List[j].Simulation_Type!=EVALUATE_FOREWARD)&&(ModelBlock->Block_List[j].Simulation_Type!=EVALUATE_BACKWARD))
|
||||
{
|
||||
DynamicOutput << " /* Jacobian */\n";
|
||||
DynamicOutput << " if (g1 == NULL) return;\n";
|
||||
DynamicOutput << " {\n";
|
||||
if(leaded[j]==1)
|
||||
DynamicOutput << Jacobian[j];
|
||||
else
|
||||
DynamicOutput << Jacobian_s[j];
|
||||
DynamicOutput << " }\n";
|
||||
}
|
||||
if (computeHessian)
|
||||
{
|
||||
DynamicOutput << " /* Hessian for endogenous and exogenous variables */\n";
|
||||
DynamicOutput << " if (g2 == NULL) return;\n";
|
||||
DynamicOutput << " {\n";
|
||||
DynamicOutput << hessian_output.str() << lsymetric.str();
|
||||
DynamicOutput << " }\n";
|
||||
}
|
||||
DynamicOutput << "}\n\n";
|
||||
}
|
||||
}
|
||||
current_order = d;
|
||||
free(leaded);
|
||||
return DynamicOutput.str();
|
||||
}
|
||||
/*EndNew*/
|
||||
|
||||
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
string ModelTree::setDynamicModel(void)
|
||||
{
|
||||
|
@ -1598,8 +875,7 @@ string ModelTree::setDynamicModel(void)
|
|||
model_output << "residual" << lpar << lEquationNBR+1 << rpar << "= lhs-rhs;" << endl;
|
||||
lEquationNBR++;
|
||||
}
|
||||
else
|
||||
break;
|
||||
else break;
|
||||
}
|
||||
else if ((*tree_it)->op_code != NoOpCode)
|
||||
{
|
||||
|
@ -2022,8 +1298,7 @@ inline string ModelTree::getArgument(NodeID id, Type type, EquationType iEquatio
|
|||
}
|
||||
else if (type == eNumericalConstant)
|
||||
{
|
||||
argument << NumericalConstants::get((int) id)
|
||||
;
|
||||
argument << NumericalConstants::get((int) id);
|
||||
}
|
||||
else if (type == eEndogenous || type == eExogenous || type == eExogenousDet)
|
||||
if (iEquationType == eStaticEquations || iEquationType == eStaticDerivatives)
|
||||
|
@ -2188,9 +1463,11 @@ void ModelTree::ModelInitialization(void)
|
|||
output << "M_.maximum_lag = " << ModelParameters::max_lag << ";\n";
|
||||
output << "M_.maximum_lead = " << ModelParameters::max_lead<< ";\n";
|
||||
if (ModelParameters::exo_nbr > 0)
|
||||
{}
|
||||
{
|
||||
}
|
||||
if (ModelParameters::exo_nbr > 0)
|
||||
{}
|
||||
{
|
||||
}
|
||||
if (ModelParameters::exo_nbr > 0)
|
||||
{
|
||||
output << "M_.maximum_exo_lag = " << ModelParameters::max_exo_lag << ";\n";
|
||||
|
|
|
@ -232,91 +232,3 @@ void VariableTable::Sort(void)
|
|||
*/
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
/*New*/
|
||||
int* VariableTable::GetVariableTable(int* Size)
|
||||
{
|
||||
int* Table;
|
||||
varKey key;
|
||||
int variable,id, ind;
|
||||
*Size=0;
|
||||
//cout << "S T L ID SVID PIDX\n";
|
||||
//cout << "mVariableIndex.size() : " << mVariableIndex.size() << "\n";
|
||||
for (id=0; id < mVariableIndex.size(); id++)
|
||||
{
|
||||
key = mVariableIndex[id];
|
||||
variable = mVariableTable[key];
|
||||
if(getType(variable)==eEndogenous)
|
||||
(*Size)++;
|
||||
}
|
||||
//cout << "*Size : " << (*Size) << "\n";
|
||||
Table=(int*)malloc((*Size)*sizeof(*Table)*4);
|
||||
ind=0;
|
||||
for (id=0; id < mVariableIndex.size(); id++)
|
||||
{
|
||||
//Type type = Types[VarToSort[id].second];
|
||||
//int lag = Lags[VarToSort[id].second];
|
||||
//int ID = IDs[VarToSort[id].second];
|
||||
key = mVariableIndex[id];
|
||||
variable = mVariableTable[key];
|
||||
if (getType(variable)==eEndogenous)
|
||||
{
|
||||
Table[ind*4]= getSymbolID(id);
|
||||
Table[ind*4+1]= key.second;
|
||||
Table[ind*4+2]= mPrintFormatIndex[id];
|
||||
Table[ind*4+3]= 1;
|
||||
ind++;
|
||||
//cout << SymbolTable::getNameByID(Types[id], IDs[id]) << " "
|
||||
// << Types[id] << " "
|
||||
// << Lags[id] << " "
|
||||
// << IDs[id] << " "
|
||||
// << mSortedVariableID[id] << " "
|
||||
// << mPrintFormatIndex[id] << "\n";
|
||||
}
|
||||
}
|
||||
return(Table);
|
||||
}
|
||||
|
||||
int VariableTable::GetVariableID(std::string name, int lead_lag)
|
||||
{
|
||||
int found=-1;
|
||||
varKey key;
|
||||
int variable;
|
||||
for (int id=0; id < mVariableIndex.size(); id++)
|
||||
{
|
||||
key=mVariableIndex[id];
|
||||
variable = mVariableTable[key];
|
||||
if((SymbolTable::getNameByID(getType(id), getSymbolID(variable))==name) && (lead_lag==key.second))
|
||||
found=mPrintFormatIndex[id];
|
||||
}
|
||||
return(found);
|
||||
}
|
||||
|
||||
|
||||
|
||||
int VariableTable::getIDS(int id, int lead_lag)
|
||||
{
|
||||
/*int found=-1;*/
|
||||
varKey key;
|
||||
int variable;
|
||||
/*for (int id=0; id < mVariableIndex.size(); id++)
|
||||
{*/
|
||||
key=mVariableIndex[id];
|
||||
variable = mVariableTable[key];
|
||||
/*if((SymbolTable::getNameByID(getType(id), getSymbolID(variable))==name) && (lead_lag==key.second))
|
||||
found=mPrintFormatIndex[id];
|
||||
}*/
|
||||
return(variable);
|
||||
}
|
||||
|
||||
|
||||
|
||||
std::string VariableTable::GetVariableName(int id)
|
||||
{
|
||||
varKey key;
|
||||
int variable;
|
||||
key=mVariableIndex[id];
|
||||
variable = mVariableTable[key];
|
||||
return SymbolTable::getNameByID(getType(id), getSymbolID(variable));
|
||||
}
|
||||
/*EndNew*/
|
||||
//------------------------------------------------------------------------------
|
||||
|
|
|
@ -42,144 +42,143 @@
|
|||
DATAFILE = 268,
|
||||
DIAGNOSTIC = 269,
|
||||
DIFFUSE_D = 270,
|
||||
DLL = 271,
|
||||
DOLLAR = 272,
|
||||
DR_ALGO = 273,
|
||||
DROP = 274,
|
||||
DSAMPLE = 275,
|
||||
DYN2VEC = 276,
|
||||
DYNASAVE = 277,
|
||||
DYNATYPE = 278,
|
||||
END = 279,
|
||||
ENDVAL = 280,
|
||||
EQUAL = 281,
|
||||
ESTIMATION = 282,
|
||||
ESTIMATED_PARAMS = 283,
|
||||
ESTIMATED_PARAMS_BOUNDS = 284,
|
||||
ESTIMATED_PARAMS_INIT = 285,
|
||||
FILTERED_VARS = 286,
|
||||
FIRST_OBS = 287,
|
||||
FLOAT_NUMBER = 288,
|
||||
FORECAST = 289,
|
||||
FUNCTIONS = 290,
|
||||
GAMMA_PDF = 291,
|
||||
GRAPH = 292,
|
||||
HISTVAL = 293,
|
||||
HP_FILTER = 294,
|
||||
HP_NGRID = 295,
|
||||
INITVAL = 296,
|
||||
INITVALF = 297,
|
||||
INT_NUMBER = 298,
|
||||
INV_GAMMA_PDF = 299,
|
||||
INV_GAMMA1_PDF = 300,
|
||||
INV_GAMMA2_PDF = 301,
|
||||
IRF = 302,
|
||||
KALMAN_ALGO = 303,
|
||||
KALMAN_TOL = 304,
|
||||
CONSTANT = 305,
|
||||
NOCONSTANT = 306,
|
||||
LAPLACE = 307,
|
||||
LIK_ALGO = 308,
|
||||
LIK_INIT = 309,
|
||||
LINEAR = 310,
|
||||
LOAD_MH_FILE = 311,
|
||||
LOGLINEAR = 312,
|
||||
MH_DROP = 313,
|
||||
MH_INIT_SCALE = 314,
|
||||
MH_JSCALE = 315,
|
||||
MH_MODE = 316,
|
||||
MH_NBLOCKS = 317,
|
||||
MH_REPLIC = 318,
|
||||
MODE_CHECK = 319,
|
||||
MODE_COMPUTE = 320,
|
||||
MODE_FILE = 321,
|
||||
MODEL = 322,
|
||||
MODEL_COMPARISON = 323,
|
||||
MODEL_COMPARISON_APPROXIMATION = 324,
|
||||
MODIFIEDHARMONICMEAN = 325,
|
||||
MOMENTS = 326,
|
||||
MOMENTS_VARENDO = 327,
|
||||
MSHOCKS = 328,
|
||||
NAME = 329,
|
||||
NOBS = 330,
|
||||
NOCORR = 331,
|
||||
NODIAGNOSTIC = 332,
|
||||
NOFUNCTIONS = 333,
|
||||
NOGRAPH = 334,
|
||||
XLS_SHEET = 335,
|
||||
XLS_RANGE = 336,
|
||||
NOMOMENTS = 337,
|
||||
NOPRINT = 338,
|
||||
NORMAL_PDF = 339,
|
||||
OBSERVATION_TRENDS = 340,
|
||||
OLR = 341,
|
||||
OLR_INST = 342,
|
||||
OLR_BETA = 343,
|
||||
OPTIM = 344,
|
||||
OPTIM_WEIGHTS = 345,
|
||||
ORDER = 346,
|
||||
OSR = 347,
|
||||
OSR_PARAMS = 348,
|
||||
PARAMETERS = 349,
|
||||
PERIODS = 350,
|
||||
PREFILTER = 351,
|
||||
PRESAMPLE = 352,
|
||||
PRINT = 353,
|
||||
PRIOR_TRUNC = 354,
|
||||
FILTER_STEP_AHEAD = 355,
|
||||
QZ_CRITERIUM = 356,
|
||||
RELATIVE_IRF = 357,
|
||||
REPLIC = 358,
|
||||
RESOL = 359,
|
||||
RPLOT = 360,
|
||||
SHOCKS = 361,
|
||||
SIGMA_E = 362,
|
||||
SIMUL = 363,
|
||||
SIMUL_ALGO = 364,
|
||||
SIMUL_SEED = 365,
|
||||
SMOOTHER = 366,
|
||||
SOLVE_ALGO = 367,
|
||||
STDERR = 368,
|
||||
STEADY = 369,
|
||||
STOCH_SIMUL = 370,
|
||||
TEX = 371,
|
||||
TEX_NAME = 372,
|
||||
UNIFORM_PDF = 373,
|
||||
UNIT_ROOT_VARS = 374,
|
||||
USE_DLL = 375,
|
||||
VALUES = 376,
|
||||
VAR = 377,
|
||||
VAREXO = 378,
|
||||
VAREXO_DET = 379,
|
||||
VAROBS = 380,
|
||||
XTICK = 381,
|
||||
XTICKLABEL = 382,
|
||||
COMMA = 383,
|
||||
MINUS = 384,
|
||||
PLUS = 385,
|
||||
DIVIDE = 386,
|
||||
TIMES = 387,
|
||||
UMINUS = 388,
|
||||
POWER = 389,
|
||||
FACTORIAL = 390,
|
||||
EXP = 391,
|
||||
LOG = 392,
|
||||
LOG10 = 393,
|
||||
LN = 394,
|
||||
SIN = 395,
|
||||
COS = 396,
|
||||
TAN = 397,
|
||||
ASIN = 398,
|
||||
ACOS = 399,
|
||||
ATAN = 400,
|
||||
SINH = 401,
|
||||
COSH = 402,
|
||||
TANH = 403,
|
||||
ASINH = 404,
|
||||
ACOSH = 405,
|
||||
ATANH = 406,
|
||||
SQRT = 407,
|
||||
ASSIGN = 408
|
||||
DOLLAR = 271,
|
||||
DR_ALGO = 272,
|
||||
DROP = 273,
|
||||
DSAMPLE = 274,
|
||||
DYN2VEC = 275,
|
||||
DYNASAVE = 276,
|
||||
DYNATYPE = 277,
|
||||
END = 278,
|
||||
ENDVAL = 279,
|
||||
EQUAL = 280,
|
||||
ESTIMATION = 281,
|
||||
ESTIMATED_PARAMS = 282,
|
||||
ESTIMATED_PARAMS_BOUNDS = 283,
|
||||
ESTIMATED_PARAMS_INIT = 284,
|
||||
FILTERED_VARS = 285,
|
||||
FIRST_OBS = 286,
|
||||
FLOAT_NUMBER = 287,
|
||||
FORECAST = 288,
|
||||
FUNCTIONS = 289,
|
||||
GAMMA_PDF = 290,
|
||||
GRAPH = 291,
|
||||
HISTVAL = 292,
|
||||
HP_FILTER = 293,
|
||||
HP_NGRID = 294,
|
||||
INITVAL = 295,
|
||||
INITVALF = 296,
|
||||
INT_NUMBER = 297,
|
||||
INV_GAMMA_PDF = 298,
|
||||
INV_GAMMA1_PDF = 299,
|
||||
INV_GAMMA2_PDF = 300,
|
||||
IRF = 301,
|
||||
KALMAN_ALGO = 302,
|
||||
KALMAN_TOL = 303,
|
||||
CONSTANT = 304,
|
||||
NOCONSTANT = 305,
|
||||
LAPLACE = 306,
|
||||
LIK_ALGO = 307,
|
||||
LIK_INIT = 308,
|
||||
LINEAR = 309,
|
||||
LOAD_MH_FILE = 310,
|
||||
LOGLINEAR = 311,
|
||||
MH_DROP = 312,
|
||||
MH_INIT_SCALE = 313,
|
||||
MH_JSCALE = 314,
|
||||
MH_MODE = 315,
|
||||
MH_NBLOCKS = 316,
|
||||
MH_REPLIC = 317,
|
||||
MODE_CHECK = 318,
|
||||
MODE_COMPUTE = 319,
|
||||
MODE_FILE = 320,
|
||||
MODEL = 321,
|
||||
MODEL_COMPARISON = 322,
|
||||
MODEL_COMPARISON_APPROXIMATION = 323,
|
||||
MODIFIEDHARMONICMEAN = 324,
|
||||
MOMENTS = 325,
|
||||
MOMENTS_VARENDO = 326,
|
||||
MSHOCKS = 327,
|
||||
NAME = 328,
|
||||
NOBS = 329,
|
||||
NOCORR = 330,
|
||||
NODIAGNOSTIC = 331,
|
||||
NOFUNCTIONS = 332,
|
||||
NOGRAPH = 333,
|
||||
XLS_SHEET = 334,
|
||||
XLS_RANGE = 335,
|
||||
NOMOMENTS = 336,
|
||||
NOPRINT = 337,
|
||||
NORMAL_PDF = 338,
|
||||
OBSERVATION_TRENDS = 339,
|
||||
OLR = 340,
|
||||
OLR_INST = 341,
|
||||
OLR_BETA = 342,
|
||||
OPTIM = 343,
|
||||
OPTIM_WEIGHTS = 344,
|
||||
ORDER = 345,
|
||||
OSR = 346,
|
||||
OSR_PARAMS = 347,
|
||||
PARAMETERS = 348,
|
||||
PERIODS = 349,
|
||||
PREFILTER = 350,
|
||||
PRESAMPLE = 351,
|
||||
PRINT = 352,
|
||||
PRIOR_TRUNC = 353,
|
||||
FILTER_STEP_AHEAD = 354,
|
||||
QZ_CRITERIUM = 355,
|
||||
RELATIVE_IRF = 356,
|
||||
REPLIC = 357,
|
||||
RESOL = 358,
|
||||
RPLOT = 359,
|
||||
SHOCKS = 360,
|
||||
SIGMA_E = 361,
|
||||
SIMUL = 362,
|
||||
SIMUL_ALGO = 363,
|
||||
SIMUL_SEED = 364,
|
||||
SMOOTHER = 365,
|
||||
SOLVE_ALGO = 366,
|
||||
STDERR = 367,
|
||||
STEADY = 368,
|
||||
STOCH_SIMUL = 369,
|
||||
TEX = 370,
|
||||
TEX_NAME = 371,
|
||||
UNIFORM_PDF = 372,
|
||||
UNIT_ROOT_VARS = 373,
|
||||
USE_DLL = 374,
|
||||
VALUES = 375,
|
||||
VAR = 376,
|
||||
VAREXO = 377,
|
||||
VAREXO_DET = 378,
|
||||
VAROBS = 379,
|
||||
XTICK = 380,
|
||||
XTICKLABEL = 381,
|
||||
COMMA = 382,
|
||||
MINUS = 383,
|
||||
PLUS = 384,
|
||||
DIVIDE = 385,
|
||||
TIMES = 386,
|
||||
UMINUS = 387,
|
||||
POWER = 388,
|
||||
FACTORIAL = 389,
|
||||
EXP = 390,
|
||||
LOG = 391,
|
||||
LOG10 = 392,
|
||||
LN = 393,
|
||||
SIN = 394,
|
||||
COS = 395,
|
||||
TAN = 396,
|
||||
ASIN = 397,
|
||||
ACOS = 398,
|
||||
ATAN = 399,
|
||||
SINH = 400,
|
||||
COSH = 401,
|
||||
TANH = 402,
|
||||
ASINH = 403,
|
||||
ACOSH = 404,
|
||||
ATANH = 405,
|
||||
SQRT = 406,
|
||||
ASSIGN = 407
|
||||
};
|
||||
#endif
|
||||
/* Tokens. */
|
||||
|
@ -196,144 +195,143 @@
|
|||
#define DATAFILE 268
|
||||
#define DIAGNOSTIC 269
|
||||
#define DIFFUSE_D 270
|
||||
#define DLL 271
|
||||
#define DOLLAR 272
|
||||
#define DR_ALGO 273
|
||||
#define DROP 274
|
||||
#define DSAMPLE 275
|
||||
#define DYN2VEC 276
|
||||
#define DYNASAVE 277
|
||||
#define DYNATYPE 278
|
||||
#define END 279
|
||||
#define ENDVAL 280
|
||||
#define EQUAL 281
|
||||
#define ESTIMATION 282
|
||||
#define ESTIMATED_PARAMS 283
|
||||
#define ESTIMATED_PARAMS_BOUNDS 284
|
||||
#define ESTIMATED_PARAMS_INIT 285
|
||||
#define FILTERED_VARS 286
|
||||
#define FIRST_OBS 287
|
||||
#define FLOAT_NUMBER 288
|
||||
#define FORECAST 289
|
||||
#define FUNCTIONS 290
|
||||
#define GAMMA_PDF 291
|
||||
#define GRAPH 292
|
||||
#define HISTVAL 293
|
||||
#define HP_FILTER 294
|
||||
#define HP_NGRID 295
|
||||
#define INITVAL 296
|
||||
#define INITVALF 297
|
||||
#define INT_NUMBER 298
|
||||
#define INV_GAMMA_PDF 299
|
||||
#define INV_GAMMA1_PDF 300
|
||||
#define INV_GAMMA2_PDF 301
|
||||
#define IRF 302
|
||||
#define KALMAN_ALGO 303
|
||||
#define KALMAN_TOL 304
|
||||
#define CONSTANT 305
|
||||
#define NOCONSTANT 306
|
||||
#define LAPLACE 307
|
||||
#define LIK_ALGO 308
|
||||
#define LIK_INIT 309
|
||||
#define LINEAR 310
|
||||
#define LOAD_MH_FILE 311
|
||||
#define LOGLINEAR 312
|
||||
#define MH_DROP 313
|
||||
#define MH_INIT_SCALE 314
|
||||
#define MH_JSCALE 315
|
||||
#define MH_MODE 316
|
||||
#define MH_NBLOCKS 317
|
||||
#define MH_REPLIC 318
|
||||
#define MODE_CHECK 319
|
||||
#define MODE_COMPUTE 320
|
||||
#define MODE_FILE 321
|
||||
#define MODEL 322
|
||||
#define MODEL_COMPARISON 323
|
||||
#define MODEL_COMPARISON_APPROXIMATION 324
|
||||
#define MODIFIEDHARMONICMEAN 325
|
||||
#define MOMENTS 326
|
||||
#define MOMENTS_VARENDO 327
|
||||
#define MSHOCKS 328
|
||||
#define NAME 329
|
||||
#define NOBS 330
|
||||
#define NOCORR 331
|
||||
#define NODIAGNOSTIC 332
|
||||
#define NOFUNCTIONS 333
|
||||
#define NOGRAPH 334
|
||||
#define XLS_SHEET 335
|
||||
#define XLS_RANGE 336
|
||||
#define NOMOMENTS 337
|
||||
#define NOPRINT 338
|
||||
#define NORMAL_PDF 339
|
||||
#define OBSERVATION_TRENDS 340
|
||||
#define OLR 341
|
||||
#define OLR_INST 342
|
||||
#define OLR_BETA 343
|
||||
#define OPTIM 344
|
||||
#define OPTIM_WEIGHTS 345
|
||||
#define ORDER 346
|
||||
#define OSR 347
|
||||
#define OSR_PARAMS 348
|
||||
#define PARAMETERS 349
|
||||
#define PERIODS 350
|
||||
#define PREFILTER 351
|
||||
#define PRESAMPLE 352
|
||||
#define PRINT 353
|
||||
#define PRIOR_TRUNC 354
|
||||
#define FILTER_STEP_AHEAD 355
|
||||
#define QZ_CRITERIUM 356
|
||||
#define RELATIVE_IRF 357
|
||||
#define REPLIC 358
|
||||
#define RESOL 359
|
||||
#define RPLOT 360
|
||||
#define SHOCKS 361
|
||||
#define SIGMA_E 362
|
||||
#define SIMUL 363
|
||||
#define SIMUL_ALGO 364
|
||||
#define SIMUL_SEED 365
|
||||
#define SMOOTHER 366
|
||||
#define SOLVE_ALGO 367
|
||||
#define STDERR 368
|
||||
#define STEADY 369
|
||||
#define STOCH_SIMUL 370
|
||||
#define TEX 371
|
||||
#define TEX_NAME 372
|
||||
#define UNIFORM_PDF 373
|
||||
#define UNIT_ROOT_VARS 374
|
||||
#define USE_DLL 375
|
||||
#define VALUES 376
|
||||
#define VAR 377
|
||||
#define VAREXO 378
|
||||
#define VAREXO_DET 379
|
||||
#define VAROBS 380
|
||||
#define XTICK 381
|
||||
#define XTICKLABEL 382
|
||||
#define COMMA 383
|
||||
#define MINUS 384
|
||||
#define PLUS 385
|
||||
#define DIVIDE 386
|
||||
#define TIMES 387
|
||||
#define UMINUS 388
|
||||
#define POWER 389
|
||||
#define FACTORIAL 390
|
||||
#define EXP 391
|
||||
#define LOG 392
|
||||
#define LOG10 393
|
||||
#define LN 394
|
||||
#define SIN 395
|
||||
#define COS 396
|
||||
#define TAN 397
|
||||
#define ASIN 398
|
||||
#define ACOS 399
|
||||
#define ATAN 400
|
||||
#define SINH 401
|
||||
#define COSH 402
|
||||
#define TANH 403
|
||||
#define ASINH 404
|
||||
#define ACOSH 405
|
||||
#define ATANH 406
|
||||
#define SQRT 407
|
||||
#define ASSIGN 408
|
||||
#define DOLLAR 271
|
||||
#define DR_ALGO 272
|
||||
#define DROP 273
|
||||
#define DSAMPLE 274
|
||||
#define DYN2VEC 275
|
||||
#define DYNASAVE 276
|
||||
#define DYNATYPE 277
|
||||
#define END 278
|
||||
#define ENDVAL 279
|
||||
#define EQUAL 280
|
||||
#define ESTIMATION 281
|
||||
#define ESTIMATED_PARAMS 282
|
||||
#define ESTIMATED_PARAMS_BOUNDS 283
|
||||
#define ESTIMATED_PARAMS_INIT 284
|
||||
#define FILTERED_VARS 285
|
||||
#define FIRST_OBS 286
|
||||
#define FLOAT_NUMBER 287
|
||||
#define FORECAST 288
|
||||
#define FUNCTIONS 289
|
||||
#define GAMMA_PDF 290
|
||||
#define GRAPH 291
|
||||
#define HISTVAL 292
|
||||
#define HP_FILTER 293
|
||||
#define HP_NGRID 294
|
||||
#define INITVAL 295
|
||||
#define INITVALF 296
|
||||
#define INT_NUMBER 297
|
||||
#define INV_GAMMA_PDF 298
|
||||
#define INV_GAMMA1_PDF 299
|
||||
#define INV_GAMMA2_PDF 300
|
||||
#define IRF 301
|
||||
#define KALMAN_ALGO 302
|
||||
#define KALMAN_TOL 303
|
||||
#define CONSTANT 304
|
||||
#define NOCONSTANT 305
|
||||
#define LAPLACE 306
|
||||
#define LIK_ALGO 307
|
||||
#define LIK_INIT 308
|
||||
#define LINEAR 309
|
||||
#define LOAD_MH_FILE 310
|
||||
#define LOGLINEAR 311
|
||||
#define MH_DROP 312
|
||||
#define MH_INIT_SCALE 313
|
||||
#define MH_JSCALE 314
|
||||
#define MH_MODE 315
|
||||
#define MH_NBLOCKS 316
|
||||
#define MH_REPLIC 317
|
||||
#define MODE_CHECK 318
|
||||
#define MODE_COMPUTE 319
|
||||
#define MODE_FILE 320
|
||||
#define MODEL 321
|
||||
#define MODEL_COMPARISON 322
|
||||
#define MODEL_COMPARISON_APPROXIMATION 323
|
||||
#define MODIFIEDHARMONICMEAN 324
|
||||
#define MOMENTS 325
|
||||
#define MOMENTS_VARENDO 326
|
||||
#define MSHOCKS 327
|
||||
#define NAME 328
|
||||
#define NOBS 329
|
||||
#define NOCORR 330
|
||||
#define NODIAGNOSTIC 331
|
||||
#define NOFUNCTIONS 332
|
||||
#define NOGRAPH 333
|
||||
#define XLS_SHEET 334
|
||||
#define XLS_RANGE 335
|
||||
#define NOMOMENTS 336
|
||||
#define NOPRINT 337
|
||||
#define NORMAL_PDF 338
|
||||
#define OBSERVATION_TRENDS 339
|
||||
#define OLR 340
|
||||
#define OLR_INST 341
|
||||
#define OLR_BETA 342
|
||||
#define OPTIM 343
|
||||
#define OPTIM_WEIGHTS 344
|
||||
#define ORDER 345
|
||||
#define OSR 346
|
||||
#define OSR_PARAMS 347
|
||||
#define PARAMETERS 348
|
||||
#define PERIODS 349
|
||||
#define PREFILTER 350
|
||||
#define PRESAMPLE 351
|
||||
#define PRINT 352
|
||||
#define PRIOR_TRUNC 353
|
||||
#define FILTER_STEP_AHEAD 354
|
||||
#define QZ_CRITERIUM 355
|
||||
#define RELATIVE_IRF 356
|
||||
#define REPLIC 357
|
||||
#define RESOL 358
|
||||
#define RPLOT 359
|
||||
#define SHOCKS 360
|
||||
#define SIGMA_E 361
|
||||
#define SIMUL 362
|
||||
#define SIMUL_ALGO 363
|
||||
#define SIMUL_SEED 364
|
||||
#define SMOOTHER 365
|
||||
#define SOLVE_ALGO 366
|
||||
#define STDERR 367
|
||||
#define STEADY 368
|
||||
#define STOCH_SIMUL 369
|
||||
#define TEX 370
|
||||
#define TEX_NAME 371
|
||||
#define UNIFORM_PDF 372
|
||||
#define UNIT_ROOT_VARS 373
|
||||
#define USE_DLL 374
|
||||
#define VALUES 375
|
||||
#define VAR 376
|
||||
#define VAREXO 377
|
||||
#define VAREXO_DET 378
|
||||
#define VAROBS 379
|
||||
#define XTICK 380
|
||||
#define XTICKLABEL 381
|
||||
#define COMMA 382
|
||||
#define MINUS 383
|
||||
#define PLUS 384
|
||||
#define DIVIDE 385
|
||||
#define TIMES 386
|
||||
#define UMINUS 387
|
||||
#define POWER 388
|
||||
#define FACTORIAL 389
|
||||
#define EXP 390
|
||||
#define LOG 391
|
||||
#define LOG10 392
|
||||
#define LN 393
|
||||
#define SIN 394
|
||||
#define COS 395
|
||||
#define TAN 396
|
||||
#define ASIN 397
|
||||
#define ACOS 398
|
||||
#define ATAN 399
|
||||
#define SINH 400
|
||||
#define COSH 401
|
||||
#define TANH 402
|
||||
#define ASINH 403
|
||||
#define ACOSH 404
|
||||
#define ATANH 405
|
||||
#define SQRT 406
|
||||
#define ASSIGN 407
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -19,9 +19,6 @@
|
|||
#include "ComputingTasks.h"
|
||||
#include "TmpSymbolTable.h"
|
||||
#include "Objects.h"
|
||||
/*New*/
|
||||
#include "BlockTriangular.h"
|
||||
/*EndNew*/
|
||||
#ifndef YLMM_basic_parser
|
||||
#include "ylmm/basic_parser.hh"
|
||||
#endif
|
||||
|
@ -80,9 +77,6 @@ namespace dynare
|
|||
/*! Value of option linear */
|
||||
int linear;
|
||||
EstimationParams estim_params;
|
||||
/*New*/
|
||||
BlockTriangular block_triangular;
|
||||
/*EndNew*/
|
||||
/*! Prints an arror to stdout */
|
||||
static void error(const char* m)
|
||||
{
|
||||
|
@ -130,9 +124,6 @@ namespace dynare
|
|||
void initialize_model(void);
|
||||
/*! Sets variable offset of ModelTree class to use C output */
|
||||
void use_dll(void);
|
||||
/*New*/
|
||||
void dll(void);
|
||||
/*EndNew*/
|
||||
/*! Adds an endogenous variable to SymbolTable*/
|
||||
Objects* add_endogenous(Objects* name, Objects* tex_name = new Objects("",NULL, eUNDEF));
|
||||
/*! Adds an exogenous variable to SymbolTable*/
|
||||
|
|
|
@ -20,9 +20,6 @@
|
|||
#include "NumericalConstants.h"
|
||||
#include "ModelTypes.h"
|
||||
#include "DataTree.h"
|
||||
/*New*/
|
||||
#include "BlockTriangular.h"
|
||||
/*EndNew*/
|
||||
//------------------------------------------------------------------------------
|
||||
/*!
|
||||
\class ModelTree
|
||||
|
@ -96,11 +93,8 @@ class ModelTree : public DataTree
|
|||
void OpenCFiles(std::string iModelFileName1, std::string iModelFileName2 = "");
|
||||
/*! Saves output string into output M files */
|
||||
void SaveMFiles();
|
||||
|
||||
/*! Saves output string into output C files */
|
||||
/*New*/
|
||||
void SaveCFiles(Model_Block* ModelBlock);
|
||||
/*EndNew*/
|
||||
void SaveCFiles();
|
||||
/*! Computes derivatives of ModelTree */
|
||||
void derive(int iOrder);
|
||||
/*!
|
||||
|
@ -115,12 +109,6 @@ class ModelTree : public DataTree
|
|||
- 1st order and 2nd order derivatives with respect to endogenous, exogenous, exogenous_det (in specific order)
|
||||
*/
|
||||
std::string setDynamicModel(void);
|
||||
|
||||
/*New*/
|
||||
std::string setDynamicModel_New(Model_Block* ModelBlock, simple* Index_Var_IM);
|
||||
/*EndNew*/
|
||||
|
||||
|
||||
/*! Writes initialization of various Matlab variables */
|
||||
void ModelInitialization(void);
|
||||
/*! Returns string output for main file */
|
||||
|
|
|
@ -76,12 +76,6 @@ class VariableTable
|
|||
inline static int getPrintIndex(int iVarID);
|
||||
/*! Sorts variable table */
|
||||
static void Sort(void);
|
||||
/*New*/
|
||||
static int* GetVariableTable(int* Size);
|
||||
static int GetVariableID(std::string name, int lead_lag);
|
||||
static std::string GetVariableName(int id);
|
||||
static int getIDS(int id, int lead_lag);
|
||||
/*EndNew*/
|
||||
};
|
||||
inline int VariableTable::getSortID(int iVarID)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue