From feec20209d391a1d51c2e8d2052fed297098d836 Mon Sep 17 00:00:00 2001 From: sebastien Date: Wed, 21 Feb 2007 23:28:16 +0000 Subject: [PATCH] v4 parser: merged Fehrat's changes git-svn-id: https://www.dynare.org/svn/dynare/dynare_v4@1190 ac1d8469-bf42-47a9-8791-bf33cf982152 --- parser.src/BlockTriangular.cc | 1000 ++++++ parser.src/ComputingTasks.cc | 37 + parser.src/DataTree.cc | 4 +- parser.src/DynareBison.cc | 3651 +++++++++++----------- parser.src/DynareBison.yy | 47 +- parser.src/DynareFlex.ll | 7 +- parser.src/ExprNode.cc | 326 +- parser.src/Makefile | 8 +- parser.src/ModFile.cc | 19 +- parser.src/ModelBlocks.cc | 332 ++ parser.src/ModelNormalization.cc | 524 ++++ parser.src/ModelTree.cc | 1238 +++++++- parser.src/Model_Graph.cc | 1056 +++++++ parser.src/ParsingDriver.cc | 156 + parser.src/SymbolGaussElim.cc | 1907 +++++++++++ parser.src/VariableTable.cc | 42 + parser.src/include/BlockTriangular.hh | 173 + parser.src/include/ComputingTasks.hh | 21 + parser.src/include/DataTree.hh | 23 +- parser.src/include/DynareBison.hh | 269 +- parser.src/include/ExprNode.hh | 68 +- parser.src/include/ModFile.hh | 3 +- parser.src/include/ModelBlocks.hh | 37 + parser.src/include/ModelNormalization.hh | 90 + parser.src/include/ModelTree.hh | 18 +- parser.src/include/Model_Graph.hh | 63 + parser.src/include/ParsingDriver.hh | 16 + parser.src/include/SymbolGaussElim.hh | 92 + parser.src/include/VariableTable.hh | 25 +- parser.src/include/interprete.hh | 51 + parser.src/interprete.cc | 95 + 31 files changed, 9375 insertions(+), 2023 deletions(-) create mode 100644 parser.src/BlockTriangular.cc create mode 100644 parser.src/ModelBlocks.cc create mode 100644 parser.src/ModelNormalization.cc create mode 100644 parser.src/Model_Graph.cc create mode 100644 parser.src/SymbolGaussElim.cc create mode 100644 parser.src/include/BlockTriangular.hh create mode 100644 parser.src/include/ModelBlocks.hh create mode 100644 parser.src/include/ModelNormalization.hh create mode 100644 parser.src/include/Model_Graph.hh create mode 100644 parser.src/include/SymbolGaussElim.hh create mode 100644 parser.src/include/interprete.hh create mode 100644 parser.src/interprete.cc diff --git a/parser.src/BlockTriangular.cc b/parser.src/BlockTriangular.cc new file mode 100644 index 000000000..bb9231132 --- /dev/null +++ b/parser.src/BlockTriangular.cc @@ -0,0 +1,1000 @@ +/*! \file + \version 1.0 + \date 16/07/2006 + \par This file implements the BlockTriangular class methodes. +*/ +//TODO Apply Block Decomposition to the static model + + +//------------------------------------------------------------------------------ +#include +#include +#include +#include +#include +#include +using namespace std; +//------------------------------------------------------------------------------ +#include "BlockTriangular.hh" +//------------------------------------------------------------------------------ + +BlockTriangular::BlockTriangular(const SymbolTable &symbol_table_arg) : + symbol_table(symbol_table_arg) +{ + bt_verbose = 0; + ModelBlock = NULL; + Model_Max_Lead = 0; + Model_Max_Lag = 0; + periods = 0; +} + + + +//------------------------------------------------------------------------------ +BlockTriangular::~BlockTriangular() +{ + // Empty +} + +//------------------------------------------------------------------------------ +//For a lead or a lag build the Incidence Matrix structures +List_IM* +BlockTriangular::Build_IM(int lead_lag) +{ + List_IM* pIM = new List_IM; + int i; + Last_IM->pNext = pIM; + pIM->IM = (bool*)malloc(endo_nbr * endo_nbr * sizeof(pIM->IM[0])); + for(i = 0;i < endo_nbr*endo_nbr;i++) + pIM->IM[i] = 0; + pIM->lead_lag = lead_lag; + if(lead_lag > 0) + { + if(lead_lag > Model_Max_Lead) + Model_Max_Lead = lead_lag; + } + else + { + if( -lead_lag > Model_Max_Lag) + Model_Max_Lag = -lead_lag; + } + pIM->pNext = NULL; + Last_IM = pIM; + return (pIM); +} + +//------------------------------------------------------------------------------ +// initialize all the incidence matrix structures +void +BlockTriangular::init_incidence_matrix(int nb_endo) +{ + int i; + endo_nbr = nb_endo; + First_IM = new List_IM; + First_IM->IM = (bool*)malloc(nb_endo * nb_endo * sizeof(First_IM->IM[0])); + for(i = 0;i < nb_endo*nb_endo;i++) + First_IM->IM[i] = 0; + First_IM->lead_lag = 0; + First_IM->pNext = NULL; + Last_IM = First_IM; + //cout << "init_incidence_matrix done \n"; +} + + +void +BlockTriangular::Free_IM(List_IM* First_IM) +{ + List_IM *Cur_IM, *SFirst_IM; + Cur_IM = SFirst_IM = First_IM; + while(Cur_IM) + { + First_IM = Cur_IM->pNext; + free(Cur_IM->IM); + Cur_IM = First_IM; + } + free(SFirst_IM); +} + +//------------------------------------------------------------------------------ +// Return the inceidence matrix related to a lead or a lag +List_IM* +BlockTriangular::Get_IM(int lead_lag) +{ + List_IM* Cur_IM; + Cur_IM = First_IM; + while ((Cur_IM != NULL) && (Cur_IM->lead_lag != lead_lag)) + Cur_IM = Cur_IM->pNext; + return (Cur_IM); +} + +bool* +BlockTriangular::bGet_IM(int lead_lag) +{ + List_IM* Cur_IM; + Cur_IM = First_IM; + while ((Cur_IM != NULL) && (Cur_IM->lead_lag != lead_lag)) + { + Cur_IM = Cur_IM->pNext; + } + if((Cur_IM->lead_lag != lead_lag) || (Cur_IM==NULL)) + { + cout << "the incidence matrix with lag " << lead_lag << " does not exist !!"; + exit(-1); + } + return (Cur_IM->IM); +} + +//------------------------------------------------------------------------------ +// Fill the incidence matrix related to a lead or a lag +void +BlockTriangular::fill_IM(int equation, int variable_endo, int lead_lag) +{ + List_IM* Cur_IM; + //cout << "equation=" << equation << " variable_endo=" << variable_endo << " lead_lag=" << lead_lag << "\n"; + Cur_IM = Get_IM(lead_lag); + if(equation >= endo_nbr) + { + cout << "Error : The model has more equations (at least " << equation + 1 << ") than declared endogenous variables (" << endo_nbr << ")\n"; + system("PAUSE"); + exit( -1); + } + if (!Cur_IM) + Cur_IM = Build_IM(lead_lag); + Cur_IM->IM[equation*endo_nbr + variable_endo] = 1; +} + +//------------------------------------------------------------------------------ +// unFill the incidence matrix related to a lead or a lag +void +BlockTriangular::unfill_IM(int equation, int variable_endo, int lead_lag) +{ + List_IM* Cur_IM; + //cout << "lead_lag=" << lead_lag << "\n"; + Cur_IM = Get_IM(lead_lag); + /*if(equation >= endo_nbr) + { + cout << "Error : The model has more equations (at least " << equation + 1 << ") than declared endogenous variables (" << endo_nbr << ")\n"; + system("PAUSE"); + exit( -1); + }*/ + if (!Cur_IM) + Cur_IM = Build_IM(lead_lag); + Cur_IM->IM[equation*endo_nbr + variable_endo] = 0; + /*system("pause");*/ +} + + +//------------------------------------------------------------------------------ +//Print azn incidence matrix +void +BlockTriangular::Print_SIM(bool* IM, int n) +{ + int i, j; + for(i = 0;i < n;i++) + { + cout << " "; + for(j = 0;j < n;j++) + cout << IM[i*n + j] << " "; + cout << "\n"; + } +} + +//------------------------------------------------------------------------------ +//Print all incidence matrix +void +BlockTriangular::Print_IM(int n) +{ + List_IM* Cur_IM; + Cur_IM = First_IM; + cout << "-------------------------------------------------------------------\n"; + while(Cur_IM) + { + cout << "Incidence matrix for lead_lag = " << Cur_IM->lead_lag << "\n"; + Print_SIM(Cur_IM->IM, n); + Cur_IM = Cur_IM->pNext; + } +} + + +//------------------------------------------------------------------------------ +// Swap rows and columns of the incidence matrix +void +BlockTriangular::swap_IM_c(bool *SIM, int pos1, int pos2, int pos3, simple* Index_Var_IM, simple* Index_Equ_IM, int n) +{ + int tmp_i, j; + bool tmp_b; + /* We exchange equation (row)...*/ + if(pos1 != pos2) + { + tmp_i = Index_Equ_IM[pos1].index; + Index_Equ_IM[pos1].index = Index_Equ_IM[pos2].index; + Index_Equ_IM[pos2].index = tmp_i; + for(j = 0;j < n;j++) + { + tmp_b = SIM[pos1 * n + j]; + SIM[pos1*n + j] = SIM[pos2 * n + j]; + SIM[pos2*n + j] = tmp_b; + } + } + /* ...and variables (colomn)*/ + if(pos1 != pos3) + { + tmp_i = Index_Var_IM[pos1].index; + Index_Var_IM[pos1].index = Index_Var_IM[pos3].index; + Index_Var_IM[pos3].index = tmp_i; + for(j = 0;j < n;j++) + { + tmp_b = SIM[j * n + pos1]; + SIM[j*n + pos1] = SIM[j * n + pos3]; + SIM[j*n + pos3] = tmp_b; + } + } +} + +//------------------------------------------------------------------------------ +// Find the prologue and the epilogue of the model +void +BlockTriangular::Prologue_Epilogue(bool* IM, int* prologue, int* epilogue, int n, simple* Index_Var_IM, simple* Index_Equ_IM) +{ + bool modifie = 1; + int i, j, k, l = 0; + /*Looking for a prologue */ + *prologue = 0; + while(modifie) + { + modifie = 0; + for(i = *prologue;i < n;i++) + { + k = 0; + for(j = *prologue;j < n;j++) + { + if(IM[i*n + j]) + { + k++; + l = j; + } + } + if ((k == 1) /* && (l==i)*/) + { + modifie = 1; + swap_IM_c(IM, *prologue, i, l, Index_Var_IM, Index_Equ_IM, n); + Index_Equ_IM[*prologue].available = 0; + Index_Var_IM[*prologue].available = 0; + (*prologue)++; + } + } + } + *epilogue = 0; + modifie = 1; + while(modifie) + { + modifie = 0; + for(i = *prologue;i < n - *epilogue;i++) + { + k = 0; + for(j = *prologue;j < n - *epilogue;j++) + { + if(IM[j*n + i]) + { + k++; + l = j; + } + } + if ((k == 1) /* && (l==i)*/) + { + modifie = 1; + swap_IM_c(IM, n - (1 + *epilogue), l, i, Index_Var_IM, Index_Equ_IM, n); + Index_Equ_IM[n - (1 + *epilogue)].available = 0; + Index_Var_IM[n - (1 + *epilogue)].available = 0; + (*epilogue)++; + } + } + } +} + + +void +BlockTriangular::getMax_Lead_Lag(int var, int equ, int *lead, int *lag) +{ + List_IM* Cur_IM; + Cur_IM = First_IM->pNext; + (*lead) = (*lag) = 0; + while(Cur_IM) + { + if(Cur_IM->IM[equ*endo_nbr + var]) + { + if(Cur_IM->lead_lag > 0) + { + if ((*lead) < Cur_IM->lead_lag) + *lead = Cur_IM->lead_lag; + } + else + { + if ((*lag) < abs(Cur_IM->lead_lag)) + *lag = abs(Cur_IM->lead_lag); + } + } + Cur_IM = Cur_IM->pNext; + } +} + +void +BlockTriangular::getMax_Lead_Lag_B(int size, int* Equation, int *Variable, int *lead, int *lag) +{ + List_IM* Cur_IM; + int i, j; + Cur_IM = First_IM->pNext; + (*lead) = (*lag) = 0; + while(Cur_IM) + { + for(i = 0;i < size;i++) + { + for(j = 0;j < size;j++) + { + if(Cur_IM->IM[Equation[i]*endo_nbr + Variable[j]]) + { + if(Cur_IM->lead_lag > 0) + { + if ((*lead) < Cur_IM->lead_lag) + *lead = Cur_IM->lead_lag; + } + else + { + if ((*lag) < abs(Cur_IM->lead_lag)) + *lag = abs(Cur_IM->lead_lag); + } + } + } + } + Cur_IM = Cur_IM->pNext; + } +} + + +void +BlockTriangular::Allocate_Block(int size, int *count_Equ, int *count_Block, int type, Model_Block * ModelBlock, int* Table, int TableSize) +{ + int i, j, k, l, ls, m, i_1, Lead, Lag, size_list_lead_var, first_count_equ, i1; + int *list_lead_var, *tmp_size, *tmp_var, *tmp_endo, nb_lead_lag_endo; + List_IM *Cur_IM; + bool *IM, OK; + ModelBlock->Periods = periods; + if ((type == PROLOGUE) || (type == EPILOGUE)) + { + for(i = 0;i < size;i++) + { + ModelBlock->Block_List[*count_Block].is_linear=true; + ModelBlock->Block_List[*count_Block].Size = 1; + ModelBlock->Block_List[*count_Block].Type = type; + ModelBlock->Block_List[*count_Block].Simulation_Type = UNKNOWN; + ModelBlock->Block_List[*count_Block].Temporary_terms=new temporary_terms_type (); + ModelBlock->Block_List[*count_Block].Temporary_terms->clear(); + list_lead_var = (int*)malloc(Model_Max_Lead * endo_nbr * sizeof(int)); + size_list_lead_var = 0; + tmp_endo = (int*)malloc((Model_Max_Lead + Model_Max_Lag + 1) * sizeof(int)); + tmp_size = (int*)malloc((Model_Max_Lead + Model_Max_Lag + 1) * sizeof(int)); + tmp_var = (int*)malloc(sizeof(int)); + memset(tmp_size, 0, (Model_Max_Lead + Model_Max_Lag + 1)*sizeof(int)); + memset(tmp_endo, 0, (Model_Max_Lead + Model_Max_Lag + 1)*sizeof(int)); + nb_lead_lag_endo = Lead = Lag = 0; + Cur_IM = First_IM; + while(Cur_IM) + { + k = Cur_IM->lead_lag; + i_1 = Index_Var_IM[*count_Equ].index * endo_nbr; + if(k > 0) + { + if(Cur_IM->IM[i_1 + Index_Equ_IM[ /*j*/*count_Equ].index]) + { + nb_lead_lag_endo++; + tmp_size[Model_Max_Lag + k]++; + if(k > Lead) + { + Lead = k; + list_lead_var[size_list_lead_var] = Index_Var_IM[*count_Equ].index + size * (k - 1); + size_list_lead_var++; + } + } + } + else + { + k = -k; + if(Cur_IM->IM[i_1 + Index_Equ_IM[ /*j*/*count_Equ].index]) + { + tmp_size[Model_Max_Lag - k]++; + nb_lead_lag_endo++; + if(k > Lag) + { + Lag = k; + } + } + } + Cur_IM = Cur_IM->pNext; + } + ModelBlock->Block_List[*count_Block].Max_Lag = Lag; + ModelBlock->Block_List[*count_Block].Max_Lead = Lead; + free(list_lead_var); + ModelBlock->Block_List[*count_Block].Equation = (int*)malloc(sizeof(int)); + ModelBlock->Block_List[*count_Block].Variable = (int*)malloc(sizeof(int)); + ModelBlock->Block_List[*count_Block].Variable_Sorted = (int*)malloc(sizeof(int)); + ModelBlock->Block_List[*count_Block].Equation[0] = Index_Equ_IM[*count_Equ].index; + ModelBlock->Block_List[*count_Block].Variable[0] = Index_Var_IM[*count_Equ].index; + ModelBlock->Block_List[*count_Block].Variable_Sorted[0] = -1; + ModelBlock->in_Block_Equ[Index_Equ_IM[*count_Equ].index] = *count_Block; + ModelBlock->in_Block_Var[Index_Var_IM[*count_Equ].index] = *count_Block; + ModelBlock->in_Equ_of_Block[Index_Equ_IM[*count_Equ].index] = ModelBlock->in_Var_of_Block[Index_Var_IM[*count_Equ].index] = 0; + Index_Equ_IM[*count_Equ].block = *count_Block; + if ((Lead > 0) && (Lag > 0)) + { + ModelBlock->Block_List[*count_Block].Simulation_Type = SOLVE_TWO_BOUNDARIES_SIMPLE; + ModelBlock->Block_List[*count_Block].IM_lead_lag = (IM_compact*)malloc((Lead + Lag + 1) * sizeof(IM_compact)); + ModelBlock->Block_List[*count_Block].Nb_Lead_Lag_Endo = nb_lead_lag_endo; + ModelBlock->Block_List[*count_Block].variable_dyn_index = (int*)malloc(nb_lead_lag_endo * sizeof(int)); + ModelBlock->Block_List[*count_Block].variable_dyn_leadlag = (int*)malloc(nb_lead_lag_endo * sizeof(int)); + ls = l = 1; + i1 = 0; + for(i = 0;i < Lead + Lag + 1;i++) + { + ModelBlock->Block_List[*count_Block].IM_lead_lag[i].size = tmp_size[Model_Max_Lag - Lag + i]; + ModelBlock->Block_List[*count_Block].IM_lead_lag[i].nb_endo = tmp_size[Model_Max_Lag - Lag + i]; + ModelBlock->Block_List[*count_Block].IM_lead_lag[i].u = (int*)malloc(tmp_size[Model_Max_Lag - Lag + i] * sizeof(int)); + ModelBlock->Block_List[*count_Block].IM_lead_lag[i].us = (int*)malloc(tmp_size[Model_Max_Lag - Lag + i] * sizeof(int)); + ModelBlock->Block_List[*count_Block].IM_lead_lag[i].Var = (int*)malloc(tmp_size[Model_Max_Lag - Lag + i] * sizeof(int)); + ModelBlock->Block_List[*count_Block].IM_lead_lag[i].Equ = (int*)malloc(tmp_size[Model_Max_Lag - Lag + i] * sizeof(int)); + ModelBlock->Block_List[*count_Block].IM_lead_lag[i].Var_Index = (int*)malloc(tmp_size[Model_Max_Lag - Lag + i] * sizeof(int)); + ModelBlock->Block_List[*count_Block].IM_lead_lag[i].Equ_Index = (int*)malloc(tmp_size[Model_Max_Lag - Lag + i] * sizeof(int)); + ModelBlock->Block_List[*count_Block].IM_lead_lag[i].Var_dyn_Index = (int*)malloc(tmp_size[Model_Max_Lag - Lag + i] * sizeof(int)); + ModelBlock->Block_List[*count_Block].IM_lead_lag[i].u_init = l; + IM = bGet_IM(i - Lag); + if(IM == NULL) + { + cout << "Error IM(" << i - Lag << ") doesn't exist\n"; + exit( -1); + } + if(IM[Index_Var_IM[*count_Equ].index + Index_Equ_IM[*count_Equ].index*endo_nbr]) + { + ModelBlock->Block_List[*count_Block].variable_dyn_index[i1] = Index_Var_IM[*count_Equ].index; + ModelBlock->Block_List[*count_Block].variable_dyn_leadlag[i1] = i - Lag; + tmp_var[0] = i1; + i1++; + } + m = 0; + i_1 = Index_Equ_IM[*count_Equ].index * endo_nbr; + if(IM[Index_Var_IM[*count_Equ].index + i_1]) + { + if(i == Lag) + { + ModelBlock->Block_List[*count_Block].IM_lead_lag[i].us[m] = ls; + ls++; + } + ModelBlock->Block_List[*count_Block].IM_lead_lag[i].u[m] = l; + ModelBlock->Block_List[*count_Block].IM_lead_lag[i].Equ[m] = 0; + ModelBlock->Block_List[*count_Block].IM_lead_lag[i].Var[m] = 0; + ModelBlock->Block_List[*count_Block].IM_lead_lag[i].Equ_Index[m] = Index_Equ_IM[*count_Equ].index; + ModelBlock->Block_List[*count_Block].IM_lead_lag[i].Var_Index[m] = Index_Var_IM[*count_Equ].index; + ModelBlock->Block_List[*count_Block].IM_lead_lag[i].Var_dyn_Index[m] = ModelBlock->Block_List[*count_Block].variable_dyn_index[tmp_var[0]]; + l++; + m++; + } + ModelBlock->Block_List[*count_Block].IM_lead_lag[i].u_finish = l - 1; + } + } + else if((Lead > 0) && (Lag == 0)) + ModelBlock->Block_List[*count_Block].Simulation_Type = SOLVE_BACKWARD_SIMPLE; + else + ModelBlock->Block_List[*count_Block].Simulation_Type = SOLVE_FOREWARD_SIMPLE; + (*count_Equ)++; + (*count_Block)++; + free(tmp_size); + free(tmp_endo); + } + } + else + { + ModelBlock->Block_List[*count_Block].is_linear=true; + ModelBlock->Block_List[*count_Block].Size = size; + ModelBlock->Block_List[*count_Block].Type = type; + ModelBlock->Block_List[*count_Block].Temporary_terms=new temporary_terms_type (); + ModelBlock->Block_List[*count_Block].Temporary_terms->clear(); + ModelBlock->Block_List[*count_Block].Simulation_Type = UNKNOWN; + ModelBlock->Block_List[*count_Block].Equation = (int*)malloc(ModelBlock->Block_List[*count_Block].Size * sizeof(int)); + ModelBlock->Block_List[*count_Block].Variable = (int*)malloc(ModelBlock->Block_List[*count_Block].Size * sizeof(int)); + ModelBlock->Block_List[*count_Block].Variable_Sorted = (int*)malloc(ModelBlock->Block_List[*count_Block].Size * sizeof(int)); + Lead = Lag = 0; + first_count_equ = *count_Equ; + tmp_var = (int*)malloc(size * sizeof(int)); + tmp_endo = (int*)malloc((Model_Max_Lead + Model_Max_Lag + 1) * sizeof(int)); + tmp_size = (int*)malloc((Model_Max_Lead + Model_Max_Lag + 1) * sizeof(int)); + memset(tmp_size, 0, (Model_Max_Lead + Model_Max_Lag + 1)*sizeof(int)); + memset(tmp_endo, 0, (Model_Max_Lead + Model_Max_Lag + 1)*sizeof(int)); + nb_lead_lag_endo = 0; + for(i = 0;i < size;i++) + { + Index_Equ_IM[*count_Equ].block = *count_Block; + ModelBlock->Block_List[*count_Block].Equation[i] = Index_Equ_IM[*count_Equ].index; + ModelBlock->Block_List[*count_Block].Variable[i] = Index_Var_IM[*count_Equ].index; + ModelBlock->Block_List[*count_Block].Variable_Sorted[i] = -1; + ModelBlock->in_Block_Equ[Index_Equ_IM[*count_Equ].index] = *count_Block; + ModelBlock->in_Block_Var[Index_Var_IM[*count_Equ].index] = *count_Block; + ModelBlock->in_Equ_of_Block[Index_Equ_IM[*count_Equ].index] = ModelBlock->in_Var_of_Block[Index_Var_IM[*count_Equ].index] = i; + Cur_IM = First_IM; + i_1 = Index_Var_IM[*count_Equ].index; + while(Cur_IM) + { + k = Cur_IM->lead_lag; + OK = false; + if(k >= 0) + { + for(j = 0;j < size;j++) + { + if(Cur_IM->IM[i_1 + Index_Equ_IM[first_count_equ + j].index*endo_nbr]) + { + tmp_size[Model_Max_Lag + k]++; + if (!OK) + { + tmp_endo[Model_Max_Lag + k]++; + nb_lead_lag_endo++; + OK = true; + } + if(k > Lead) + Lead = k; + } + } + } + else + { + k = -k; + for(j = 0;j < size;j++) + { + if(Cur_IM->IM[i_1 + Index_Equ_IM[first_count_equ + j].index*endo_nbr]) + { + tmp_size[Model_Max_Lag - k]++; + if (!OK) + { + tmp_endo[Model_Max_Lag - k]++; + nb_lead_lag_endo++; + OK = true; + } + if(k > Lag) + Lag = k; + } + } + } + Cur_IM = Cur_IM->pNext; + } + (*count_Equ)++; + } + if ((Lag > 0) && (Lead > 0)) + ModelBlock->Block_List[*count_Block].Simulation_Type = SOLVE_TWO_BOUNDARIES_COMPLETE; + else if(size > 1) + { + if(Lead > 0) + ModelBlock->Block_List[*count_Block].Simulation_Type = SOLVE_BACKWARD_COMPLETE; + else + ModelBlock->Block_List[*count_Block].Simulation_Type = SOLVE_FOREWARD_COMPLETE; + } + else + { + if(Lead > 0) + ModelBlock->Block_List[*count_Block].Simulation_Type = SOLVE_BACKWARD_SIMPLE; + else + ModelBlock->Block_List[*count_Block].Simulation_Type = SOLVE_FOREWARD_SIMPLE; + } + ModelBlock->Block_List[*count_Block].Max_Lag = Lag; + ModelBlock->Block_List[*count_Block].Max_Lead = Lead; + ModelBlock->Block_List[*count_Block].IM_lead_lag = (IM_compact*)malloc((Lead + Lag + 1) * sizeof(IM_compact)); + ls = l = size; + i1 = 0; + ModelBlock->Block_List[*count_Block].Nb_Lead_Lag_Endo = nb_lead_lag_endo; + ModelBlock->Block_List[*count_Block].variable_dyn_index = (int*)malloc(nb_lead_lag_endo * sizeof(int)); + ModelBlock->Block_List[*count_Block].variable_dyn_leadlag = (int*)malloc(nb_lead_lag_endo * sizeof(int)); + for(i = 0;i < Lead + Lag + 1;i++) + { + ModelBlock->Block_List[*count_Block].IM_lead_lag[i].size = tmp_size[Model_Max_Lag - Lag + i]; + ModelBlock->Block_List[*count_Block].IM_lead_lag[i].nb_endo = tmp_endo[Model_Max_Lag - Lag + i]; + ModelBlock->Block_List[*count_Block].IM_lead_lag[i].u = (int*)malloc(tmp_size[Model_Max_Lag - Lag + i] * sizeof(int)); + ModelBlock->Block_List[*count_Block].IM_lead_lag[i].us = (int*)malloc(tmp_size[Model_Max_Lag - Lag + i] * sizeof(int)); + ModelBlock->Block_List[*count_Block].IM_lead_lag[i].Var = (int*)malloc(tmp_size[Model_Max_Lag - Lag + i] * sizeof(int)); + ModelBlock->Block_List[*count_Block].IM_lead_lag[i].Equ = (int*)malloc(tmp_size[Model_Max_Lag - Lag + i] * sizeof(int)); + ModelBlock->Block_List[*count_Block].IM_lead_lag[i].Var_Index = (int*)malloc(tmp_size[Model_Max_Lag - Lag + i] * sizeof(int)); + ModelBlock->Block_List[*count_Block].IM_lead_lag[i].Equ_Index = (int*)malloc(tmp_size[Model_Max_Lag - Lag + i] * sizeof(int)); + ModelBlock->Block_List[*count_Block].IM_lead_lag[i].Var_dyn_Index = (int*)malloc(tmp_size[Model_Max_Lag - Lag + i] * sizeof(int)); + ModelBlock->Block_List[*count_Block].IM_lead_lag[i].u_init = l; + IM = bGet_IM(i - Lag); + if(IM != NULL) + { + } + else + { + cout << "Error IM(" << i - Lag << ") doesn't exist\n"; + exit( -1); + } + for(j = first_count_equ;j < size + first_count_equ;j++) + { + i_1 = Index_Var_IM[j].index; + m = 0; + for(k = first_count_equ;k < size + first_count_equ;k++) + if(IM[i_1 + Index_Equ_IM[k].index*endo_nbr]) + m++; + if(m > 0) + { + ModelBlock->Block_List[*count_Block].variable_dyn_index[i1] = i_1; + ModelBlock->Block_List[*count_Block].variable_dyn_leadlag[i1] = i - Lag; + tmp_var[j - first_count_equ] = i1; + i1++; + } + } + m = 0; + for(j = first_count_equ;j < size + first_count_equ;j++) + { + i_1 = Index_Equ_IM[j].index * endo_nbr; + for(k = first_count_equ;k < size + first_count_equ;k++) + if(IM[Index_Var_IM[k].index + i_1]) + { + if(i == Lag) + { + ModelBlock->Block_List[*count_Block].IM_lead_lag[i].us[m] = ls; + ls++; + } + ModelBlock->Block_List[*count_Block].IM_lead_lag[i].u[m] = l; + ModelBlock->Block_List[*count_Block].IM_lead_lag[i].Equ[m] = j - first_count_equ; + ModelBlock->Block_List[*count_Block].IM_lead_lag[i].Var[m] = k - first_count_equ; + ModelBlock->Block_List[*count_Block].IM_lead_lag[i].Equ_Index[m] = Index_Equ_IM[j].index; + ModelBlock->Block_List[*count_Block].IM_lead_lag[i].Var_Index[m] = Index_Var_IM[k].index; + ModelBlock->Block_List[*count_Block].IM_lead_lag[i].Var_dyn_Index[m] = ModelBlock->Block_List[*count_Block].variable_dyn_index[tmp_var[k - first_count_equ]]; + l++; + m++; + } + } + ModelBlock->Block_List[*count_Block].IM_lead_lag[i].u_finish = l - 1; + } + (*count_Block)++; + free(tmp_size); + free(tmp_endo); + free(tmp_var); + } +} + + +void +BlockTriangular::Free_Block(Model_Block* ModelBlock) +{ + int blk, i; +#ifdef DEBUG + + cout << "Free_Block\n"; +#endif + + for(blk = 0;blk < ModelBlock->Size;blk++) + { + + if ((ModelBlock->Block_List[blk].Type == PROLOGUE) || (ModelBlock->Block_List[blk].Type == EPILOGUE)) + { + free(ModelBlock->Block_List[blk].Equation); + free(ModelBlock->Block_List[blk].Variable); + free(ModelBlock->Block_List[blk].Variable_Sorted); + } + else + { + free(ModelBlock->Block_List[blk].Equation); + free(ModelBlock->Block_List[blk].Variable); + free(ModelBlock->Block_List[blk].Variable_Sorted); + for(i = 0;i < ModelBlock->Block_List[blk].Max_Lag + ModelBlock->Block_List[blk].Max_Lead + 1;i++) + { + free(ModelBlock->Block_List[blk].IM_lead_lag[i].u); + free(ModelBlock->Block_List[blk].IM_lead_lag[i].us); + free(ModelBlock->Block_List[blk].IM_lead_lag[i].Equ); + free(ModelBlock->Block_List[blk].IM_lead_lag[i].Var); + free(ModelBlock->Block_List[blk].IM_lead_lag[i].Equ_Index); + free(ModelBlock->Block_List[blk].IM_lead_lag[i].Var_Index); + } + free(ModelBlock->Block_List[blk].IM_lead_lag); + } + } + free(ModelBlock->in_Block_Equ); + free(ModelBlock->in_Block_Var); + free(ModelBlock->in_Equ_of_Block); + free(ModelBlock->in_Var_of_Block); + free(ModelBlock->Block_List); + free(ModelBlock); +} + +//------------------------------------------------------------------------------ +// Normalize each equation of the model (endgenous_i = f_i(endogenous_1, ..., endogenous_n) - in order to apply strong connex components search algorithm - +// and find the optimal blocks triangular decomposition +bool +BlockTriangular::Normalize_and_BlockDecompose(bool* IM, Model_Block* ModelBlock, int n, int* prologue, int* epilogue, simple* Index_Var_IM, simple* Index_Equ_IM, bool Do_Normalization, bool mixing, bool* IM_0 ) +{ + int i, j, Nb_TotalBlocks, Nb_RecursBlocks; + int count_Block, count_Equ; + block_result_t* res; + List_IM * p_First_IM, *p_Cur_IM, *Cur_IM; + Equation_set* Equation_gr = (Equation_set*) malloc(sizeof(Equation_set)); + p_First_IM = (List_IM*)malloc(sizeof(*p_First_IM)); + p_Cur_IM = p_First_IM; + Cur_IM = First_IM; + i = endo_nbr * endo_nbr; + while(Cur_IM) + { + p_Cur_IM->lead_lag = Cur_IM->lead_lag; + p_Cur_IM->IM = (bool*)malloc(i * sizeof(bool)); + memcpy ( p_Cur_IM->IM, Cur_IM->IM, i); + Cur_IM = Cur_IM->pNext; + if(Cur_IM) + { + p_Cur_IM->pNext = (List_IM*)malloc(sizeof(*p_Cur_IM)); + p_Cur_IM = p_Cur_IM->pNext; + } + else + p_Cur_IM->pNext = NULL; + } + Prologue_Epilogue(IM, prologue, epilogue, n, Index_Var_IM, Index_Equ_IM); + if(bt_verbose) + { + cout << "prologue : " << *prologue << " epilogue : " << *epilogue << "\n"; + Print_SIM(IM, n); + for(i = 0;i < n;i++) + cout << "Index_Var_IM[" << i << "]=" << Index_Var_IM[i].index << " Index_Equ_IM[" << i << "]=" << Index_Equ_IM[i].index << "\n"; + } + if(Do_Normalization) + { + cout << "Normalizing the model ...\n"; + if(mixing) + { + bool* SIM0; + SIM0 = (bool*)malloc(n * n * sizeof(bool)); + for(i = 0;i < n*n;i++) + SIM0[i] = IM_0[i]; + for(i = 0;i < n;i++) + for(j = 0;j < n;j++) + IM_0[i*n + j] = SIM0[Index_Equ_IM[i].index * n + Index_Var_IM[j].index]; + free(SIM0); + normalization.Normalize(n, *prologue, *epilogue, IM_0, Index_Equ_IM, Equation_gr, 1, IM); + } + else + normalization.Normalize(n, *prologue, *epilogue, IM, Index_Equ_IM, Equation_gr, 0, 0); + } + else + normalization.Gr_to_IM_basic(n, *prologue, *epilogue, IM, Equation_gr, false); + cout << "Finding the optimal block decomposition of the model ...\n"; + if(bt_verbose) + blocks.Print_Equation_gr(Equation_gr); + res = blocks.sc(Equation_gr); + if(bt_verbose) + blocks.block_result_print(res); + if ((*prologue) || (*epilogue)) + j = 1; + else + j = 0; + for(i = 0;i < res->n_sets;i++) + if ((res->sets_f[i] - res->sets_s[i] + 1) > j) + j = res->sets_f[i] - res->sets_s[i] + 1; + Nb_RecursBlocks = *prologue + *epilogue; + Nb_TotalBlocks = res->n_sets + Nb_RecursBlocks; + cout << Nb_TotalBlocks << " block(s) found:\n"; + cout << " " << Nb_RecursBlocks << " recursive block(s) and " << res->n_sets << " simultaneous block(s). \n"; + cout << " the largest simultaneous block has " << j << " equation(s). \n"; + ModelBlock->Size = Nb_TotalBlocks; + ModelBlock->Periods = periods; + ModelBlock->in_Block_Equ = (int*)malloc(n * sizeof(int)); + ModelBlock->in_Block_Var = (int*)malloc(n * sizeof(int)); + ModelBlock->in_Equ_of_Block = (int*)malloc(n * sizeof(int)); + ModelBlock->in_Var_of_Block = (int*)malloc(n * sizeof(int)); + ModelBlock->Block_List = (Block*)malloc(sizeof(ModelBlock->Block_List[0]) * Nb_TotalBlocks); + blocks.block_result_to_IM(res, IM, *prologue, endo_nbr, Index_Equ_IM, Index_Var_IM); + Free_IM(p_First_IM); + count_Equ = count_Block = 0; + if (*prologue) + Allocate_Block(*prologue, &count_Equ, &count_Block, PROLOGUE, ModelBlock, Table, TableSize); + for(j = 0;j < res->n_sets;j++) + { + if(res->sets_f[res->ordered[j]] == res->sets_s[res->ordered[j]]) + Allocate_Block(res->sets_f[res->ordered[j]] - res->sets_s[res->ordered[j]] + 1, &count_Equ, &count_Block, PROLOGUE, ModelBlock, Table, TableSize); + else + Allocate_Block(res->sets_f[res->ordered[j]] - res->sets_s[res->ordered[j]] + 1, &count_Equ, &count_Block, SIMULTANS, ModelBlock, Table, TableSize); + } + if (*epilogue) + Allocate_Block(*epilogue, &count_Equ, &count_Block, EPILOGUE, ModelBlock, Table, TableSize); + return 0; +} + + + + +//------------------------------------------------------------------------------ +// For the contemparenous simultaneities +// normalize each equation of the model +// and find the optimal block triangular decomposition +void +BlockTriangular::Normalize_and_BlockDecompose_0() +{ + int i; + List_IM* Cur_IM; +#ifdef DEBUG + + cout << "Normalize_and_BlockDecompose_0 \n"; +#endif + + Index_Equ_IM = (simple*)malloc(endo_nbr * sizeof(*Index_Equ_IM)); + for(i = 0;i < endo_nbr;i++) + { + Index_Equ_IM[i].index = i; + Index_Equ_IM[i].available = 1; + } + Index_Var_IM = (simple*)malloc(endo_nbr * sizeof(*Index_Var_IM)); + for(i = 0;i < endo_nbr;i++) + { + Index_Var_IM[i].index = i; + Index_Var_IM[i].available = 1; + } + Cur_IM = Get_IM(0); + Normalize_and_BlockDecompose(Cur_IM->IM, ModelBlock, endo_nbr, &prologue, &epilogue, Index_Var_IM, Index_Equ_IM, 1, 0, NULL); +} + + +//------------------------------------------------------------------------------ +// normalize each equation of the statitic model +// and find the optimal block triangular decomposition +void +BlockTriangular::Normalize_and_BlockDecompose_Inside_Earth() +{ + bool *SIM, *SIM1; + int i, j, blk, Size, Nb_blk, k, k1, k2, n0, n, k1_block; + int prologue, epilogue; + bool OK; + simple *Index_Equ_IM, *Index_Var_IM; + Model_Block *ModelBlock_Earth; + //First create a the incidence matrix of each stack block + n0 = endo_nbr; + for(blk = 0;blk < ModelBlock->Size;blk++) + { + if(ModelBlock->Block_List[blk].Type == SIMULTANS) + { + Size = (n = ModelBlock->Block_List[blk].Size) * (Nb_blk = (max(ModelBlock->Block_List[blk].Max_Lag, ModelBlock->Block_List[blk].Max_Lead)) + 1); + SIM = (bool*)malloc(Size * Size * sizeof(*SIM)); + memset (SIM, 0, Size*Size*sizeof(*SIM)); + k1_block = n * n * Nb_blk; + for(k1 = 0;k1 < Nb_blk;k1++) + { + for(k2 = 0;k2 < Nb_blk;k2++) + { + k = k2 - k1; + OK = 1; + if(k < 0) + if( -k > ModelBlock->Block_List[blk].Max_Lag) + OK = 0; + if(k > 0) + if(k > ModelBlock->Block_List[blk].Max_Lead) + OK = 0; + if(OK) + { + SIM1 = Get_IM(k)->IM; + for(i = 0;i < n;i++) + for(j = 0;j < n;j++) + SIM[i*Size + k1*k1_block + j + k2*n] = SIM1[ModelBlock->Block_List[blk].Equation[i] * n0 + ModelBlock->Block_List[blk].Variable[j]]; + } + } + } + if(bt_verbose) + cout << "incidence matrix for the static model (unsorted) \n"; + Index_Equ_IM = (simple*)malloc(Size * sizeof(*Index_Equ_IM)); + for(i = 0;i < Size;i++) + { + Index_Equ_IM[i].index = i; + Index_Equ_IM[i].available = 1; + } + Index_Var_IM = (simple*)malloc(Size * sizeof(*Index_Var_IM)); + for(i = 0;i < Size;i++) + { + Index_Var_IM[i].index = i; + Index_Var_IM[i].available = 1; + } + ModelBlock_Earth = (Model_Block*)malloc(sizeof(Model_Block)); + Normalize_and_BlockDecompose(SIM, ModelBlock_Earth, Size, &prologue, &epilogue, Index_Var_IM, Index_Equ_IM, 0, 0, NULL); + } + } +} + +//------------------------------------------------------------------------------ +// normalize each equation of the statitic model +// and find the optimal block triangular decomposition +void +BlockTriangular::Normalize_and_BlockDecompose_Static_Model() +{ + bool* SIM; + List_IM* Cur_IM; + int i; + //First create a static model incidence matrix + SIM = (bool*)malloc(endo_nbr * endo_nbr * sizeof(*SIM)); + for(i = 0;i < endo_nbr*endo_nbr;i++) + { + SIM[i] = 0; + Cur_IM = First_IM; + while(Cur_IM) + { + SIM[i] = (SIM[i]) || (Cur_IM->IM[i]); + Cur_IM = Cur_IM->pNext; + } + } + if(bt_verbose) + { + cout << "incidence matrix for the static model (unsorted) \n"; + Print_SIM(SIM, endo_nbr); + } + Index_Equ_IM = (simple*)malloc(endo_nbr * sizeof(*Index_Equ_IM)); + for(i = 0;i < endo_nbr;i++) + { + Index_Equ_IM[i].index = i; + Index_Equ_IM[i].available = 1; + } + Index_Var_IM = (simple*)malloc(endo_nbr * sizeof(*Index_Var_IM)); + for(i = 0;i < endo_nbr;i++) + { + Index_Var_IM[i].index = i; + Index_Var_IM[i].available = 1; + } + if(ModelBlock != NULL) + Free_Block(ModelBlock); + ModelBlock = (Model_Block*)malloc(sizeof(*ModelBlock)); + Normalize_and_BlockDecompose(SIM, ModelBlock, endo_nbr, &prologue, &epilogue, Index_Var_IM, Index_Equ_IM, 1, 0, NULL); +} + + +//------------------------------------------------------------------------------ +// normalize each equation of the dynamic model +// and find the optimal block triangular decomposition of the static model +void +BlockTriangular::Normalize_and_BlockDecompose_Static_0_Model() +{ + bool* SIM, *SIM_0; + List_IM* Cur_IM; + int i; + //First create a static model incidence matrix + SIM = (bool*)malloc(endo_nbr * endo_nbr * sizeof(*SIM)); + for(i = 0;i < endo_nbr*endo_nbr;i++) + { + SIM[i] = 0; + Cur_IM = First_IM; + while(Cur_IM) + { + SIM[i] = (SIM[i]) || (Cur_IM->IM[i]); + Cur_IM = Cur_IM->pNext; + } + } + if(bt_verbose) + { + cout << "incidence matrix for the static model (unsorted) \n"; + Print_SIM(SIM, endo_nbr); + } + Index_Equ_IM = (simple*)malloc(endo_nbr * sizeof(*Index_Equ_IM)); + for(i = 0;i < endo_nbr;i++) + { + Index_Equ_IM[i].index = i; + Index_Equ_IM[i].available = 1; + } + Index_Var_IM = (simple*)malloc(endo_nbr * sizeof(*Index_Var_IM)); + for(i = 0;i < endo_nbr;i++) + { + Index_Var_IM[i].index = i; + Index_Var_IM[i].available = 1; + } + if(ModelBlock != NULL) + Free_Block(ModelBlock); + ModelBlock = (Model_Block*)malloc(sizeof(*ModelBlock)); + Cur_IM = Get_IM(0); + SIM_0 = (bool*)malloc(endo_nbr * endo_nbr * sizeof(*SIM_0)); + for(i = 0;i < endo_nbr*endo_nbr;i++) + SIM_0[i] = Cur_IM->IM[i]; + Normalize_and_BlockDecompose(SIM, ModelBlock, endo_nbr, &prologue, &epilogue, Index_Var_IM, Index_Equ_IM, 1, 1, SIM_0); + if(bt_verbose) + for(i = 0;i < endo_nbr;i++) + cout << "Block=" << Index_Equ_IM[i].block << " Equ=" << Index_Equ_IM[i].index << " Var= " << Index_Var_IM[i].index << " " << symbol_table.getNameByID(eEndogenous, Index_Var_IM[i].index) << "\n"; +} + +void +BlockTriangular::SetVariableTable(int *Table, int Size, int HSize) +{ + BlockTriangular::Table = Table; + TableSize = Size; +} + diff --git a/parser.src/ComputingTasks.cc b/parser.src/ComputingTasks.cc index 85be18e65..42be74bf4 100644 --- a/parser.src/ComputingTasks.cc +++ b/parser.src/ComputingTasks.cc @@ -60,6 +60,33 @@ SimulStatement::writeOutput(ostream &output, const string &basename) const output << "simul(oo_.dr);\n"; } +SimulSparseStatement::SimulSparseStatement(const OptionsList &options_list_arg) : + options_list(options_list_arg) +{ +} + +void +SimulSparseStatement::checkPass(ModFileStructure &mod_file_struct) +{ + mod_file_struct.simul_present = true; +} + +void +SimulSparseStatement::writeOutput(ostream &output, const string &basename) const +{ + options_list.writeOutput(output); + output << "if ~ options_.initval_file\n"; + output << " make_y_;\n"; + output << " make_ex_;\n"; + output << "end\n"; + output << "disp('compiling...');\n"; + if (compiler == 0) + output << "mex " << filename << "_dynamic.c;\n"; + else + output << "mex " << filename << "_dynamic.cc;\n"; + output << "oo_.endo_simul=" << filename << "_dynamic;\n"; +} + StochSimulStatement::StochSimulStatement(const TmpSymbolTable &tmp_symbol_table_arg, const OptionsList &options_list_arg) : tmp_symbol_table(tmp_symbol_table_arg), @@ -205,6 +232,16 @@ PeriodsStatement::writeOutput(ostream &output, const string &basename) const output << "options_.simul = 1;" << endl; } +CutoffStatement::CutoffStatement(int cutoff_arg) : cutoff(cutoff_arg) +{ +} + +void +CutoffStatement::writeOutput(ostream &output, const string &basename) const +{ + output << "options_.cutoff = " << cutoff << ";" << endl; +} + DsampleStatement::DsampleStatement(int val1_arg) : val1(val1_arg), val2(-1) { } diff --git a/parser.src/DataTree.cc b/parser.src/DataTree.cc index f6d3f3962..00b3458e7 100644 --- a/parser.src/DataTree.cc +++ b/parser.src/DataTree.cc @@ -5,8 +5,10 @@ DataTree::DataTree(SymbolTable &symbol_table_arg, NumericalConstants &num_constants_arg) : symbol_table(symbol_table_arg), num_constants(num_constants_arg), + node_counter(0), variable_table(symbol_table_arg), - offset(1) + offset(1), + compiler(LCC_COMPILE) { Zero = AddNumConstant("0.0"); One = AddNumConstant("1.0"); diff --git a/parser.src/DynareBison.cc b/parser.src/DynareBison.cc index 4db451366..6bc8a3e60 100644 --- a/parser.src/DynareBison.cc +++ b/parser.src/DynareBison.cc @@ -278,7 +278,7 @@ namespace yy // Initialize the location filenames yylloc.begin.filename = yylloc.end.filename = &driver.file; } - /* Line 555 of yacc.c. */ + /* Line 547 of yacc.c. */ #line 283 "DynareBison.cc" /* Initialize the stacks. The initial state will be pushed in yynewstate, since the latter expects the semantical and the @@ -394,760 +394,804 @@ namespace yy YY_REDUCE_PRINT (yyn); switch (yyn) { - case 45: -#line 142 "DynareBison.yy" + case 46: +#line 143 "DynareBison.yy" { driver.dsample((yysemantic_stack_[(3) - (2)].string_val));;} break; - case 46: -#line 143 "DynareBison.yy" + case 47: +#line 144 "DynareBison.yy" {driver.dsample((yysemantic_stack_[(4) - (2)].string_val), (yysemantic_stack_[(4) - (3)].string_val));;} break; - case 47: -#line 146 "DynareBison.yy" + case 48: +#line 147 "DynareBison.yy" {driver.rplot();;} break; - case 52: -#line 166 "DynareBison.yy" + case 53: +#line 167 "DynareBison.yy" { driver.declare_endogenous((yysemantic_stack_[(2) - (2)].string_val)); ;} break; - case 53: -#line 168 "DynareBison.yy" + case 54: +#line 169 "DynareBison.yy" { driver.declare_endogenous((yysemantic_stack_[(3) - (3)].string_val)); ;} break; - case 54: -#line 170 "DynareBison.yy" + case 55: +#line 171 "DynareBison.yy" { driver.declare_endogenous((yysemantic_stack_[(1) - (1)].string_val)); ;} break; - case 55: -#line 172 "DynareBison.yy" + case 56: +#line 173 "DynareBison.yy" { driver.declare_endogenous((yysemantic_stack_[(3) - (2)].string_val), (yysemantic_stack_[(3) - (3)].string_val)); ;} break; - case 56: -#line 174 "DynareBison.yy" + case 57: +#line 175 "DynareBison.yy" { driver.declare_endogenous((yysemantic_stack_[(4) - (3)].string_val), (yysemantic_stack_[(4) - (4)].string_val)); ;} break; - case 57: -#line 176 "DynareBison.yy" + case 58: +#line 177 "DynareBison.yy" { driver.declare_endogenous((yysemantic_stack_[(2) - (1)].string_val), (yysemantic_stack_[(2) - (2)].string_val)); ;} break; - case 58: -#line 181 "DynareBison.yy" + case 59: +#line 182 "DynareBison.yy" { driver.declare_exogenous((yysemantic_stack_[(2) - (2)].string_val)); ;} break; - case 59: -#line 183 "DynareBison.yy" + case 60: +#line 184 "DynareBison.yy" { driver.declare_exogenous((yysemantic_stack_[(3) - (3)].string_val)); ;} break; - case 60: -#line 185 "DynareBison.yy" + case 61: +#line 186 "DynareBison.yy" { driver.declare_exogenous((yysemantic_stack_[(1) - (1)].string_val)); ;} break; - case 61: -#line 187 "DynareBison.yy" + case 62: +#line 188 "DynareBison.yy" { driver.declare_exogenous((yysemantic_stack_[(3) - (2)].string_val), (yysemantic_stack_[(3) - (3)].string_val)); ;} break; - case 62: -#line 189 "DynareBison.yy" + case 63: +#line 190 "DynareBison.yy" { driver.declare_exogenous((yysemantic_stack_[(4) - (3)].string_val), (yysemantic_stack_[(4) - (4)].string_val)); ;} break; - case 63: -#line 191 "DynareBison.yy" + case 64: +#line 192 "DynareBison.yy" { driver.declare_exogenous((yysemantic_stack_[(2) - (1)].string_val), (yysemantic_stack_[(2) - (2)].string_val)); ;} break; - case 64: -#line 196 "DynareBison.yy" + case 65: +#line 197 "DynareBison.yy" { driver.declare_exogenous_det((yysemantic_stack_[(2) - (2)].string_val)); ;} break; - case 65: -#line 198 "DynareBison.yy" + case 66: +#line 199 "DynareBison.yy" { driver.declare_exogenous_det((yysemantic_stack_[(3) - (3)].string_val)); ;} break; - case 66: -#line 200 "DynareBison.yy" + case 67: +#line 201 "DynareBison.yy" { driver.declare_exogenous_det((yysemantic_stack_[(1) - (1)].string_val)); ;} break; - case 67: -#line 202 "DynareBison.yy" + case 68: +#line 203 "DynareBison.yy" { driver.declare_exogenous_det((yysemantic_stack_[(3) - (2)].string_val), (yysemantic_stack_[(3) - (3)].string_val)); ;} break; - case 68: -#line 204 "DynareBison.yy" + case 69: +#line 205 "DynareBison.yy" { driver.declare_exogenous_det((yysemantic_stack_[(4) - (3)].string_val), (yysemantic_stack_[(4) - (4)].string_val)); ;} break; - case 69: -#line 206 "DynareBison.yy" + case 70: +#line 207 "DynareBison.yy" { driver.declare_exogenous_det((yysemantic_stack_[(2) - (1)].string_val), (yysemantic_stack_[(2) - (2)].string_val)); ;} break; - case 70: -#line 211 "DynareBison.yy" + case 71: +#line 212 "DynareBison.yy" { driver.declare_parameter((yysemantic_stack_[(2) - (2)].string_val)); ;} break; - case 71: -#line 213 "DynareBison.yy" + case 72: +#line 214 "DynareBison.yy" { driver.declare_parameter((yysemantic_stack_[(3) - (3)].string_val)); ;} break; - case 72: -#line 215 "DynareBison.yy" + case 73: +#line 216 "DynareBison.yy" { driver.declare_parameter((yysemantic_stack_[(1) - (1)].string_val)); ;} break; - case 73: -#line 217 "DynareBison.yy" + case 74: +#line 218 "DynareBison.yy" { driver.declare_parameter((yysemantic_stack_[(3) - (2)].string_val), (yysemantic_stack_[(3) - (3)].string_val)); ;} break; - case 74: -#line 219 "DynareBison.yy" + case 75: +#line 220 "DynareBison.yy" { driver.declare_parameter((yysemantic_stack_[(4) - (3)].string_val), (yysemantic_stack_[(4) - (4)].string_val)); ;} break; - case 75: -#line 221 "DynareBison.yy" + case 76: +#line 222 "DynareBison.yy" { driver.declare_parameter((yysemantic_stack_[(2) - (1)].string_val), (yysemantic_stack_[(2) - (2)].string_val)); ;} break; - case 76: -#line 226 "DynareBison.yy" + case 77: +#line 227 "DynareBison.yy" { driver.periods((yysemantic_stack_[(3) - (2)].string_val)); ;} break; - case 77: -#line 230 "DynareBison.yy" + case 78: +#line 231 "DynareBison.yy" { driver.periods((yysemantic_stack_[(4) - (3)].string_val)); ;} break; - case 78: -#line 238 "DynareBison.yy" - {driver.init_param((yysemantic_stack_[(4) - (1)].string_val), (yysemantic_stack_[(4) - (3)].exp_val));;} - break; - case 79: -#line 243 "DynareBison.yy" - { (yyval.exp_val) = (yysemantic_stack_[(3) - (2)].exp_val);;} +#line 238 "DynareBison.yy" + { + driver.cutoff((yysemantic_stack_[(3) - (2)].string_val)); + ;} break; case 80: -#line 245 "DynareBison.yy" - {(yyval.exp_val) = driver.add_expression_variable((yysemantic_stack_[(1) - (1)].string_val));;} +#line 242 "DynareBison.yy" + { + driver.cutoff((yysemantic_stack_[(4) - (3)].string_val)); + ;} break; case 81: -#line 247 "DynareBison.yy" - {(yyval.exp_val) = driver.add_expression_constant((yysemantic_stack_[(1) - (1)].string_val));;} +#line 249 "DynareBison.yy" + {driver.init_param((yysemantic_stack_[(4) - (1)].string_val), (yysemantic_stack_[(4) - (3)].exp_val));;} break; case 82: -#line 249 "DynareBison.yy" - {(yyval.exp_val) = driver.add_expression_constant((yysemantic_stack_[(1) - (1)].string_val));;} +#line 254 "DynareBison.yy" + { (yyval.exp_val) = (yysemantic_stack_[(3) - (2)].exp_val);;} break; case 83: -#line 251 "DynareBison.yy" - {(yyval.exp_val) = driver.add_expression_token((yysemantic_stack_[(3) - (1)].exp_val), (yysemantic_stack_[(3) - (3)].exp_val), token::PLUS);;} +#line 256 "DynareBison.yy" + {(yyval.exp_val) = driver.add_expression_variable((yysemantic_stack_[(1) - (1)].string_val));;} break; case 84: -#line 253 "DynareBison.yy" - {(yyval.exp_val) = driver.add_expression_token((yysemantic_stack_[(3) - (1)].exp_val), (yysemantic_stack_[(3) - (3)].exp_val), token::MINUS);;} +#line 258 "DynareBison.yy" + {(yyval.exp_val) = driver.add_expression_constant((yysemantic_stack_[(1) - (1)].string_val));;} break; case 85: -#line 255 "DynareBison.yy" - {(yyval.exp_val) = driver.add_expression_token((yysemantic_stack_[(3) - (1)].exp_val), (yysemantic_stack_[(3) - (3)].exp_val), token::DIVIDE);;} +#line 260 "DynareBison.yy" + {(yyval.exp_val) = driver.add_expression_constant((yysemantic_stack_[(1) - (1)].string_val));;} break; case 86: -#line 257 "DynareBison.yy" - {(yyval.exp_val) = driver.add_expression_token((yysemantic_stack_[(3) - (1)].exp_val), (yysemantic_stack_[(3) - (3)].exp_val), token::TIMES);;} +#line 262 "DynareBison.yy" + {(yyval.exp_val) = driver.add_expression_token((yysemantic_stack_[(3) - (1)].exp_val), (yysemantic_stack_[(3) - (3)].exp_val), token::PLUS);;} break; case 87: -#line 259 "DynareBison.yy" - {(yyval.exp_val) = driver.add_expression_token((yysemantic_stack_[(3) - (1)].exp_val), (yysemantic_stack_[(3) - (3)].exp_val), token::POWER);;} +#line 264 "DynareBison.yy" + {(yyval.exp_val) = driver.add_expression_token((yysemantic_stack_[(3) - (1)].exp_val), (yysemantic_stack_[(3) - (3)].exp_val), token::MINUS);;} break; case 88: -#line 261 "DynareBison.yy" - {(yyval.exp_val) = driver.add_expression_token((yysemantic_stack_[(2) - (2)].exp_val), token::UMINUS);;} +#line 266 "DynareBison.yy" + {(yyval.exp_val) = driver.add_expression_token((yysemantic_stack_[(3) - (1)].exp_val), (yysemantic_stack_[(3) - (3)].exp_val), token::DIVIDE);;} break; case 89: -#line 263 "DynareBison.yy" - {(yyval.exp_val) = (yysemantic_stack_[(2) - (2)].exp_val);;} +#line 268 "DynareBison.yy" + {(yyval.exp_val) = driver.add_expression_token((yysemantic_stack_[(3) - (1)].exp_val), (yysemantic_stack_[(3) - (3)].exp_val), token::TIMES);;} break; case 90: -#line 265 "DynareBison.yy" - {(yyval.exp_val) = driver.add_expression_token((yysemantic_stack_[(4) - (3)].exp_val), token::EXP);;} +#line 270 "DynareBison.yy" + {(yyval.exp_val) = driver.add_expression_token((yysemantic_stack_[(3) - (1)].exp_val), (yysemantic_stack_[(3) - (3)].exp_val), token::POWER);;} break; case 91: -#line 267 "DynareBison.yy" - {(yyval.exp_val) = driver.add_expression_token((yysemantic_stack_[(4) - (3)].exp_val), token::LOG);;} +#line 272 "DynareBison.yy" + {(yyval.exp_val) = driver.add_expression_token((yysemantic_stack_[(2) - (2)].exp_val), token::UMINUS);;} break; case 92: -#line 269 "DynareBison.yy" - {(yyval.exp_val) = driver.add_expression_token((yysemantic_stack_[(4) - (3)].exp_val), token::LOG10);;} +#line 274 "DynareBison.yy" + {(yyval.exp_val) = (yysemantic_stack_[(2) - (2)].exp_val);;} break; case 93: -#line 271 "DynareBison.yy" - {(yyval.exp_val) = driver.add_expression_token((yysemantic_stack_[(4) - (3)].exp_val), token::SIN);;} +#line 276 "DynareBison.yy" + {(yyval.exp_val) = driver.add_expression_token((yysemantic_stack_[(4) - (3)].exp_val), token::EXP);;} break; case 94: -#line 273 "DynareBison.yy" - {(yyval.exp_val) = driver.add_expression_token((yysemantic_stack_[(4) - (3)].exp_val), token::COS);;} +#line 278 "DynareBison.yy" + {(yyval.exp_val) = driver.add_expression_token((yysemantic_stack_[(4) - (3)].exp_val), token::LOG);;} break; case 95: -#line 275 "DynareBison.yy" - {(yyval.exp_val) = driver.add_expression_token((yysemantic_stack_[(4) - (3)].exp_val), token::TAN);;} +#line 280 "DynareBison.yy" + {(yyval.exp_val) = driver.add_expression_token((yysemantic_stack_[(4) - (3)].exp_val), token::LOG10);;} break; case 96: -#line 277 "DynareBison.yy" - {(yyval.exp_val) = driver.add_expression_token((yysemantic_stack_[(4) - (3)].exp_val), token::ASIN);;} +#line 282 "DynareBison.yy" + {(yyval.exp_val) = driver.add_expression_token((yysemantic_stack_[(4) - (3)].exp_val), token::SIN);;} break; case 97: -#line 279 "DynareBison.yy" - {(yyval.exp_val) = driver.add_expression_token((yysemantic_stack_[(4) - (3)].exp_val), token::ACOS);;} +#line 284 "DynareBison.yy" + {(yyval.exp_val) = driver.add_expression_token((yysemantic_stack_[(4) - (3)].exp_val), token::COS);;} break; case 98: -#line 281 "DynareBison.yy" - {(yyval.exp_val) = driver.add_expression_token((yysemantic_stack_[(4) - (3)].exp_val), token::ATAN);;} +#line 286 "DynareBison.yy" + {(yyval.exp_val) = driver.add_expression_token((yysemantic_stack_[(4) - (3)].exp_val), token::TAN);;} break; case 99: -#line 283 "DynareBison.yy" - {(yyval.exp_val) = driver.add_expression_token((yysemantic_stack_[(4) - (3)].exp_val), token::SQRT);;} +#line 288 "DynareBison.yy" + {(yyval.exp_val) = driver.add_expression_token((yysemantic_stack_[(4) - (3)].exp_val), token::ASIN);;} break; case 100: -#line 285 "DynareBison.yy" - {(yyval.exp_val) = driver.add_expression_token((yysemantic_stack_[(4) - (3)].exp_val), (yysemantic_stack_[(4) - (1)].string_val));;} +#line 290 "DynareBison.yy" + {(yyval.exp_val) = driver.add_expression_token((yysemantic_stack_[(4) - (3)].exp_val), token::ACOS);;} break; case 101: -#line 287 "DynareBison.yy" - {(yyval.exp_val) = driver.add_expression_token((yysemantic_stack_[(4) - (3)].exp_val), (yysemantic_stack_[(4) - (1)].string_val));;} +#line 292 "DynareBison.yy" + {(yyval.exp_val) = driver.add_expression_token((yysemantic_stack_[(4) - (3)].exp_val), token::ATAN);;} break; case 102: -#line 292 "DynareBison.yy" - {(yyval.exp_val) = driver.add_expression_token((yysemantic_stack_[(3) - (1)].exp_val), (yysemantic_stack_[(3) - (3)].exp_val), token::COMMA);;} +#line 294 "DynareBison.yy" + {(yyval.exp_val) = driver.add_expression_token((yysemantic_stack_[(4) - (3)].exp_val), token::SQRT);;} break; case 103: -#line 294 "DynareBison.yy" - {(yyval.exp_val) = driver.add_expression_token((yysemantic_stack_[(3) - (1)].exp_val), (yysemantic_stack_[(3) - (3)].exp_val), token::COMMA);;} +#line 296 "DynareBison.yy" + {(yyval.exp_val) = driver.add_expression_token((yysemantic_stack_[(4) - (3)].exp_val), (yysemantic_stack_[(4) - (1)].string_val));;} break; case 104: #line 298 "DynareBison.yy" - {driver.end_initval();;} + {(yyval.exp_val) = driver.add_expression_token((yysemantic_stack_[(4) - (3)].exp_val), (yysemantic_stack_[(4) - (1)].string_val));;} break; case 105: #line 303 "DynareBison.yy" - {driver.end_endval();;} + {(yyval.exp_val) = driver.add_expression_token((yysemantic_stack_[(3) - (1)].exp_val), (yysemantic_stack_[(3) - (3)].exp_val), token::COMMA);;} + break; + + case 106: +#line 305 "DynareBison.yy" + {(yyval.exp_val) = driver.add_expression_token((yysemantic_stack_[(3) - (1)].exp_val), (yysemantic_stack_[(3) - (3)].exp_val), token::COMMA);;} + break; + + case 107: +#line 309 "DynareBison.yy" + {driver.end_initval();;} break; case 108: -#line 313 "DynareBison.yy" - {driver.init_val((yysemantic_stack_[(4) - (1)].string_val), (yysemantic_stack_[(4) - (3)].exp_val));;} +#line 311 "DynareBison.yy" + {driver.end_initval();;} break; case 109: -#line 318 "DynareBison.yy" - { driver.end_histval(); ;} +#line 315 "DynareBison.yy" + {driver.init_val_filename((yysemantic_stack_[(3) - (3)].string_val));;} break; - case 112: -#line 328 "DynareBison.yy" - {driver.hist_val((yysemantic_stack_[(7) - (1)].string_val), (yysemantic_stack_[(7) - (3)].string_val), (yysemantic_stack_[(7) - (6)].exp_val));;} + case 110: +#line 320 "DynareBison.yy" + {driver.end_endval();;} break; case 113: -#line 332 "DynareBison.yy" - { driver.begin_model(); ;} +#line 330 "DynareBison.yy" + {driver.init_val((yysemantic_stack_[(4) - (1)].string_val), (yysemantic_stack_[(4) - (3)].exp_val));;} break; - case 115: -#line 333 "DynareBison.yy" - { driver.begin_model(); ;} + case 114: +#line 335 "DynareBison.yy" + { driver.end_histval(); ;} break; case 117: -#line 335 "DynareBison.yy" - { driver.begin_model(); driver.use_dll(); ;} +#line 345 "DynareBison.yy" + {driver.hist_val((yysemantic_stack_[(7) - (1)].string_val), (yysemantic_stack_[(7) - (3)].string_val), (yysemantic_stack_[(7) - (6)].exp_val));;} + break; + + case 120: +#line 353 "DynareBison.yy" + { driver.init_compiler(0); ;} + break; + + case 121: +#line 354 "DynareBison.yy" + { driver.init_compiler(1); ;} break; case 123: -#line 348 "DynareBison.yy" - {(yyval.model_val) = driver.add_model_equal((yysemantic_stack_[(4) - (1)].model_val), (yysemantic_stack_[(4) - (3)].model_val));;} - break; - - case 124: -#line 350 "DynareBison.yy" - {(yyval.model_val) = driver.add_model_equal_with_zero_rhs((yysemantic_stack_[(2) - (1)].model_val));;} +#line 359 "DynareBison.yy" + { driver.begin_model(); ;} break; case 125: -#line 354 "DynareBison.yy" - {(yyval.model_val) = (yysemantic_stack_[(3) - (2)].model_val);;} +#line 360 "DynareBison.yy" + { driver.begin_model(); ;} break; case 127: -#line 357 "DynareBison.yy" - {(yyval.model_val) = driver.add_model_constant((yysemantic_stack_[(1) - (1)].string_val));;} - break; - - case 128: -#line 359 "DynareBison.yy" - {(yysemantic_stack_[(1) - (1)].string_val)->append(".0"); (yyval.model_val) = driver.add_model_constant((yysemantic_stack_[(1) - (1)].string_val));;} +#line 362 "DynareBison.yy" + { driver.begin_model(); driver.use_dll(); ;} break; case 129: -#line 361 "DynareBison.yy" - {(yyval.model_val) = driver.add_model_plus((yysemantic_stack_[(3) - (1)].model_val), (yysemantic_stack_[(3) - (3)].model_val));;} - break; - - case 130: -#line 363 "DynareBison.yy" - {(yyval.model_val) = driver.add_model_minus((yysemantic_stack_[(3) - (1)].model_val), (yysemantic_stack_[(3) - (3)].model_val));;} +#line 364 "DynareBison.yy" + { driver.sparse_dll(); driver.begin_model(); ;} break; case 131: -#line 365 "DynareBison.yy" - {(yyval.model_val) = driver.add_model_divide((yysemantic_stack_[(3) - (1)].model_val), (yysemantic_stack_[(3) - (3)].model_val));;} - break; - - case 132: -#line 367 "DynareBison.yy" - {(yyval.model_val) = driver.add_model_times((yysemantic_stack_[(3) - (1)].model_val), (yysemantic_stack_[(3) - (3)].model_val));;} - break; - - case 133: -#line 369 "DynareBison.yy" - {(yyval.model_val) = driver.add_model_power((yysemantic_stack_[(3) - (1)].model_val), (yysemantic_stack_[(3) - (3)].model_val));;} - break; - - case 134: -#line 371 "DynareBison.yy" - { (yyval.model_val) = driver.add_model_uminus((yysemantic_stack_[(2) - (2)].model_val));;} - break; - - case 135: -#line 373 "DynareBison.yy" - {(yyval.model_val) = (yysemantic_stack_[(2) - (2)].model_val);;} - break; - - case 136: -#line 375 "DynareBison.yy" - {(yyval.model_val) = driver.add_model_exp((yysemantic_stack_[(4) - (3)].model_val));;} +#line 366 "DynareBison.yy" + { driver.sparse_dll(); driver.begin_model(); ;} break; case 137: -#line 377 "DynareBison.yy" - {(yyval.model_val) = driver.add_model_log((yysemantic_stack_[(4) - (3)].model_val));;} +#line 379 "DynareBison.yy" + {(yyval.model_val) = driver.add_model_equal((yysemantic_stack_[(4) - (1)].model_val), (yysemantic_stack_[(4) - (3)].model_val));;} break; case 138: -#line 379 "DynareBison.yy" - {(yyval.model_val) = driver.add_model_log10((yysemantic_stack_[(4) - (3)].model_val));;} +#line 381 "DynareBison.yy" + {(yyval.model_val) = driver.add_model_equal_with_zero_rhs((yysemantic_stack_[(2) - (1)].model_val));;} break; case 139: -#line 381 "DynareBison.yy" - {(yyval.model_val) = driver.add_model_sin((yysemantic_stack_[(4) - (3)].model_val));;} - break; - - case 140: -#line 383 "DynareBison.yy" - {(yyval.model_val) = driver.add_model_cos((yysemantic_stack_[(4) - (3)].model_val));;} +#line 385 "DynareBison.yy" + {(yyval.model_val) = (yysemantic_stack_[(3) - (2)].model_val);;} break; case 141: -#line 385 "DynareBison.yy" - {(yyval.model_val) = driver.add_model_tan((yysemantic_stack_[(4) - (3)].model_val));;} +#line 388 "DynareBison.yy" + {(yyval.model_val) = driver.add_model_constant((yysemantic_stack_[(1) - (1)].string_val));;} break; case 142: -#line 387 "DynareBison.yy" - {(yyval.model_val) = driver.add_model_asin((yysemantic_stack_[(4) - (3)].model_val));;} +#line 390 "DynareBison.yy" + {(yysemantic_stack_[(1) - (1)].string_val)->append(".0"); (yyval.model_val) = driver.add_model_constant((yysemantic_stack_[(1) - (1)].string_val));;} break; case 143: -#line 389 "DynareBison.yy" - {(yyval.model_val) = driver.add_model_acos((yysemantic_stack_[(4) - (3)].model_val));;} +#line 392 "DynareBison.yy" + {(yyval.model_val) = driver.add_model_plus((yysemantic_stack_[(3) - (1)].model_val), (yysemantic_stack_[(3) - (3)].model_val));;} break; case 144: -#line 391 "DynareBison.yy" - {(yyval.model_val) = driver.add_model_atan((yysemantic_stack_[(4) - (3)].model_val));;} +#line 394 "DynareBison.yy" + {(yyval.model_val) = driver.add_model_minus((yysemantic_stack_[(3) - (1)].model_val), (yysemantic_stack_[(3) - (3)].model_val));;} break; case 145: -#line 393 "DynareBison.yy" - {(yyval.model_val) = driver.add_model_sqrt((yysemantic_stack_[(4) - (3)].model_val));;} +#line 396 "DynareBison.yy" + {(yyval.model_val) = driver.add_model_divide((yysemantic_stack_[(3) - (1)].model_val), (yysemantic_stack_[(3) - (3)].model_val));;} break; case 146: -#line 397 "DynareBison.yy" - {driver.declare_and_init_local_parameter((yysemantic_stack_[(5) - (2)].string_val), (yysemantic_stack_[(5) - (4)].model_val));;} +#line 398 "DynareBison.yy" + {(yyval.model_val) = driver.add_model_times((yysemantic_stack_[(3) - (1)].model_val), (yysemantic_stack_[(3) - (3)].model_val));;} break; case 147: -#line 401 "DynareBison.yy" - {(yyval.model_val) = driver.add_model_variable((yysemantic_stack_[(1) - (1)].string_val));;} +#line 400 "DynareBison.yy" + {(yyval.model_val) = driver.add_model_power((yysemantic_stack_[(3) - (1)].model_val), (yysemantic_stack_[(3) - (3)].model_val));;} break; case 148: -#line 403 "DynareBison.yy" - {(yyval.model_val) = driver.add_model_variable((yysemantic_stack_[(4) - (1)].string_val), (yysemantic_stack_[(4) - (3)].string_val));;} +#line 402 "DynareBison.yy" + { (yyval.model_val) = driver.add_model_uminus((yysemantic_stack_[(2) - (2)].model_val));;} break; case 149: -#line 407 "DynareBison.yy" - {driver.end_shocks();;} +#line 404 "DynareBison.yy" + {(yyval.model_val) = (yysemantic_stack_[(2) - (2)].model_val);;} break; case 150: -#line 411 "DynareBison.yy" - {driver.end_mshocks();;} +#line 406 "DynareBison.yy" + {(yyval.model_val) = driver.add_model_exp((yysemantic_stack_[(4) - (3)].model_val));;} + break; + + case 151: +#line 408 "DynareBison.yy" + {(yyval.model_val) = driver.add_model_log((yysemantic_stack_[(4) - (3)].model_val));;} + break; + + case 152: +#line 410 "DynareBison.yy" + {(yyval.model_val) = driver.add_model_log10((yysemantic_stack_[(4) - (3)].model_val));;} break; case 153: -#line 421 "DynareBison.yy" - {driver.add_det_shock((yysemantic_stack_[(9) - (2)].string_val));;} +#line 412 "DynareBison.yy" + {(yyval.model_val) = driver.add_model_sin((yysemantic_stack_[(4) - (3)].model_val));;} break; case 154: -#line 423 "DynareBison.yy" - {driver.add_stderr_shock((yysemantic_stack_[(6) - (2)].string_val), (yysemantic_stack_[(6) - (5)].exp_val));;} +#line 414 "DynareBison.yy" + {(yyval.model_val) = driver.add_model_cos((yysemantic_stack_[(4) - (3)].model_val));;} break; case 155: -#line 425 "DynareBison.yy" - {driver.add_var_shock((yysemantic_stack_[(5) - (2)].string_val), (yysemantic_stack_[(5) - (4)].exp_val));;} +#line 416 "DynareBison.yy" + {(yyval.model_val) = driver.add_model_tan((yysemantic_stack_[(4) - (3)].model_val));;} break; case 156: -#line 427 "DynareBison.yy" - {driver.add_covar_shock((yysemantic_stack_[(7) - (2)].string_val), (yysemantic_stack_[(7) - (4)].string_val), (yysemantic_stack_[(7) - (6)].exp_val));;} +#line 418 "DynareBison.yy" + {(yyval.model_val) = driver.add_model_asin((yysemantic_stack_[(4) - (3)].model_val));;} break; case 157: -#line 429 "DynareBison.yy" - {driver.add_correl_shock((yysemantic_stack_[(7) - (2)].string_val), (yysemantic_stack_[(7) - (4)].string_val), (yysemantic_stack_[(7) - (6)].exp_val));;} +#line 420 "DynareBison.yy" + {(yyval.model_val) = driver.add_model_acos((yysemantic_stack_[(4) - (3)].model_val));;} break; case 158: -#line 434 "DynareBison.yy" - {driver.add_period((yysemantic_stack_[(2) - (2)].string_val));;} +#line 422 "DynareBison.yy" + {(yyval.model_val) = driver.add_model_atan((yysemantic_stack_[(4) - (3)].model_val));;} break; case 159: -#line 436 "DynareBison.yy" - {driver.add_period((yysemantic_stack_[(4) - (2)].string_val),(yysemantic_stack_[(4) - (4)].string_val));;} +#line 424 "DynareBison.yy" + {(yyval.model_val) = driver.add_model_sqrt((yysemantic_stack_[(4) - (3)].model_val));;} break; case 160: -#line 438 "DynareBison.yy" - {driver.add_period((yysemantic_stack_[(3) - (3)].string_val));;} +#line 428 "DynareBison.yy" + {driver.declare_and_init_local_parameter((yysemantic_stack_[(5) - (2)].string_val), (yysemantic_stack_[(5) - (4)].model_val));;} break; case 161: -#line 440 "DynareBison.yy" - {driver.add_period((yysemantic_stack_[(5) - (3)].string_val), (yysemantic_stack_[(5) - (5)].string_val));;} +#line 432 "DynareBison.yy" + {(yyval.model_val) = driver.add_model_variable((yysemantic_stack_[(1) - (1)].string_val));;} break; case 162: -#line 442 "DynareBison.yy" - {driver.add_period((yysemantic_stack_[(3) - (1)].string_val), (yysemantic_stack_[(3) - (3)].string_val));;} +#line 434 "DynareBison.yy" + {(yyval.model_val) = driver.add_model_variable((yysemantic_stack_[(4) - (1)].string_val), (yysemantic_stack_[(4) - (3)].string_val));;} break; case 163: -#line 444 "DynareBison.yy" - {driver.add_period((yysemantic_stack_[(1) - (1)].string_val));;} +#line 438 "DynareBison.yy" + {driver.end_shocks();;} break; case 164: -#line 450 "DynareBison.yy" - {driver.add_value((yysemantic_stack_[(2) - (2)].string_val));;} - break; - - case 165: -#line 452 "DynareBison.yy" - {driver.add_value((yysemantic_stack_[(2) - (2)].string_val));;} - break; - - case 166: -#line 454 "DynareBison.yy" - {driver.add_value((yysemantic_stack_[(2) - (2)].string_val));;} +#line 442 "DynareBison.yy" + {driver.end_mshocks();;} break; case 167: -#line 456 "DynareBison.yy" - {driver.add_value((yysemantic_stack_[(1) - (1)].string_val));;} +#line 452 "DynareBison.yy" + {driver.add_det_shock((yysemantic_stack_[(9) - (2)].string_val));;} break; case 168: -#line 458 "DynareBison.yy" - {driver.add_value((yysemantic_stack_[(1) - (1)].string_val));;} +#line 454 "DynareBison.yy" + {driver.add_stderr_shock((yysemantic_stack_[(6) - (2)].string_val), (yysemantic_stack_[(6) - (5)].exp_val));;} break; case 169: -#line 460 "DynareBison.yy" - {driver.add_value((yysemantic_stack_[(1) - (1)].string_val));;} +#line 456 "DynareBison.yy" + {driver.add_var_shock((yysemantic_stack_[(5) - (2)].string_val), (yysemantic_stack_[(5) - (4)].exp_val));;} break; case 170: -#line 462 "DynareBison.yy" - {driver.add_value((yysemantic_stack_[(4) - (3)].exp_val));;} +#line 458 "DynareBison.yy" + {driver.add_covar_shock((yysemantic_stack_[(7) - (2)].string_val), (yysemantic_stack_[(7) - (4)].string_val), (yysemantic_stack_[(7) - (6)].exp_val));;} break; case 171: -#line 464 "DynareBison.yy" - {driver.add_value((yysemantic_stack_[(3) - (2)].exp_val));;} +#line 460 "DynareBison.yy" + {driver.add_correl_shock((yysemantic_stack_[(7) - (2)].string_val), (yysemantic_stack_[(7) - (4)].string_val), (yysemantic_stack_[(7) - (6)].exp_val));;} break; case 172: -#line 469 "DynareBison.yy" - {driver.do_sigma_e();;} +#line 465 "DynareBison.yy" + {driver.add_period((yysemantic_stack_[(2) - (2)].string_val));;} break; case 173: -#line 474 "DynareBison.yy" - {driver.end_of_row();;} +#line 467 "DynareBison.yy" + {driver.add_period((yysemantic_stack_[(4) - (2)].string_val),(yysemantic_stack_[(4) - (4)].string_val));;} break; case 174: -#line 476 "DynareBison.yy" - {driver.end_of_row();;} +#line 469 "DynareBison.yy" + {driver.add_period((yysemantic_stack_[(3) - (3)].string_val));;} break; case 175: -#line 481 "DynareBison.yy" - {driver.add_to_row((yysemantic_stack_[(5) - (4)].exp_val));;} +#line 471 "DynareBison.yy" + {driver.add_period((yysemantic_stack_[(5) - (3)].string_val), (yysemantic_stack_[(5) - (5)].string_val));;} break; case 176: -#line 483 "DynareBison.yy" - {driver.add_to_row((yysemantic_stack_[(3) - (3)].string_val));;} +#line 473 "DynareBison.yy" + {driver.add_period((yysemantic_stack_[(3) - (1)].string_val), (yysemantic_stack_[(3) - (3)].string_val));;} break; case 177: -#line 485 "DynareBison.yy" - {driver.add_to_row((yysemantic_stack_[(3) - (3)].string_val));;} +#line 475 "DynareBison.yy" + {driver.add_period((yysemantic_stack_[(1) - (1)].string_val));;} break; case 178: -#line 487 "DynareBison.yy" - {driver.add_to_row((yysemantic_stack_[(4) - (3)].exp_val));;} +#line 481 "DynareBison.yy" + {driver.add_value((yysemantic_stack_[(2) - (2)].string_val));;} break; case 179: -#line 489 "DynareBison.yy" - {driver.add_to_row((yysemantic_stack_[(2) - (2)].string_val));;} +#line 483 "DynareBison.yy" + {driver.add_value((yysemantic_stack_[(2) - (2)].string_val));;} break; case 180: -#line 491 "DynareBison.yy" - {driver.add_to_row((yysemantic_stack_[(2) - (2)].string_val));;} +#line 485 "DynareBison.yy" + {driver.add_value((yysemantic_stack_[(2) - (2)].string_val));;} break; case 181: -#line 493 "DynareBison.yy" - {driver.add_to_row((yysemantic_stack_[(3) - (2)].exp_val));;} +#line 487 "DynareBison.yy" + {driver.add_value((yysemantic_stack_[(1) - (1)].string_val));;} break; case 182: -#line 495 "DynareBison.yy" - {driver.add_to_row((yysemantic_stack_[(1) - (1)].string_val));;} +#line 489 "DynareBison.yy" + {driver.add_value((yysemantic_stack_[(1) - (1)].string_val));;} break; case 183: -#line 497 "DynareBison.yy" - {driver.add_to_row((yysemantic_stack_[(1) - (1)].string_val));;} +#line 491 "DynareBison.yy" + {driver.add_value((yysemantic_stack_[(1) - (1)].string_val));;} break; case 184: -#line 502 "DynareBison.yy" +#line 493 "DynareBison.yy" + {driver.add_value((yysemantic_stack_[(4) - (3)].exp_val));;} + break; + + case 185: +#line 495 "DynareBison.yy" + {driver.add_value((yysemantic_stack_[(3) - (2)].exp_val));;} + break; + + case 186: +#line 500 "DynareBison.yy" + {driver.do_sigma_e();;} + break; + + case 187: +#line 505 "DynareBison.yy" + {driver.end_of_row();;} + break; + + case 188: +#line 507 "DynareBison.yy" + {driver.end_of_row();;} + break; + + case 189: +#line 512 "DynareBison.yy" + {driver.add_to_row((yysemantic_stack_[(5) - (4)].exp_val));;} + break; + + case 190: +#line 514 "DynareBison.yy" + {driver.add_to_row((yysemantic_stack_[(3) - (3)].string_val));;} + break; + + case 191: +#line 516 "DynareBison.yy" + {driver.add_to_row((yysemantic_stack_[(3) - (3)].string_val));;} + break; + + case 192: +#line 518 "DynareBison.yy" + {driver.add_to_row((yysemantic_stack_[(4) - (3)].exp_val));;} + break; + + case 193: +#line 520 "DynareBison.yy" + {driver.add_to_row((yysemantic_stack_[(2) - (2)].string_val));;} + break; + + case 194: +#line 522 "DynareBison.yy" + {driver.add_to_row((yysemantic_stack_[(2) - (2)].string_val));;} + break; + + case 195: +#line 524 "DynareBison.yy" + {driver.add_to_row((yysemantic_stack_[(3) - (2)].exp_val));;} + break; + + case 196: +#line 526 "DynareBison.yy" + {driver.add_to_row((yysemantic_stack_[(1) - (1)].string_val));;} + break; + + case 197: +#line 528 "DynareBison.yy" + {driver.add_to_row((yysemantic_stack_[(1) - (1)].string_val));;} + break; + + case 198: +#line 533 "DynareBison.yy" { driver.steady(); ;} break; - case 185: -#line 506 "DynareBison.yy" + case 199: +#line 537 "DynareBison.yy" {driver.steady();;} break; - case 189: -#line 518 "DynareBison.yy" + case 203: +#line 549 "DynareBison.yy" {driver.check();;} break; - case 190: -#line 520 "DynareBison.yy" + case 204: +#line 551 "DynareBison.yy" {driver.check();;} break; - case 194: -#line 532 "DynareBison.yy" - {driver.simul();;} + case 208: +#line 563 "DynareBison.yy" + {driver.simulate();;} break; - case 195: -#line 534 "DynareBison.yy" - {driver.simul();;} + case 209: +#line 565 "DynareBison.yy" + {driver.simulate();;} break; - case 199: -#line 546 "DynareBison.yy" + case 213: +#line 577 "DynareBison.yy" {driver.stoch_simul();;} break; - case 200: -#line 548 "DynareBison.yy" + case 214: +#line 579 "DynareBison.yy" {driver.stoch_simul();;} break; - case 201: -#line 550 "DynareBison.yy" + case 215: +#line 581 "DynareBison.yy" {driver.stoch_simul();;} break; - case 202: -#line 552 "DynareBison.yy" + case 216: +#line 583 "DynareBison.yy" {driver.stoch_simul();;} break; - case 224: -#line 582 "DynareBison.yy" + case 239: +#line 614 "DynareBison.yy" {driver.add_tmp_var((yysemantic_stack_[(2) - (2)].string_val));;} break; - case 225: -#line 584 "DynareBison.yy" + case 240: +#line 616 "DynareBison.yy" {driver.add_tmp_var((yysemantic_stack_[(4) - (2)].string_val), (yysemantic_stack_[(4) - (4)].string_val));;} break; - case 226: -#line 586 "DynareBison.yy" + case 241: +#line 618 "DynareBison.yy" {driver.add_tmp_var((yysemantic_stack_[(3) - (3)].string_val));;} break; - case 227: -#line 588 "DynareBison.yy" + case 242: +#line 620 "DynareBison.yy" {driver.add_tmp_var((yysemantic_stack_[(5) - (3)].string_val), (yysemantic_stack_[(5) - (5)].string_val));;} break; - case 228: -#line 590 "DynareBison.yy" + case 243: +#line 622 "DynareBison.yy" {driver.add_tmp_var((yysemantic_stack_[(1) - (1)].string_val));;} break; - case 229: -#line 592 "DynareBison.yy" + case 244: +#line 624 "DynareBison.yy" {driver.add_tmp_var((yysemantic_stack_[(3) - (1)].string_val), (yysemantic_stack_[(3) - (3)].string_val));;} break; - case 230: -#line 597 "DynareBison.yy" + case 245: +#line 629 "DynareBison.yy" {(yyval.string_val) = (yysemantic_stack_[(2) - (2)].string_val);;} break; - case 231: -#line 599 "DynareBison.yy" + case 246: +#line 631 "DynareBison.yy" {(yysemantic_stack_[(2) - (2)].string_val)->insert(0, "-"); (yyval.string_val) = (yysemantic_stack_[(2) - (2)].string_val);;} break; - case 232: -#line 601 "DynareBison.yy" + case 247: +#line 633 "DynareBison.yy" {(yyval.string_val) = (yysemantic_stack_[(1) - (1)].string_val);;} break; - case 233: -#line 606 "DynareBison.yy" + case 248: +#line 638 "DynareBison.yy" {(yyval.string_val) = (yysemantic_stack_[(2) - (2)].string_val);;} break; - case 234: -#line 608 "DynareBison.yy" + case 249: +#line 640 "DynareBison.yy" {(yysemantic_stack_[(2) - (2)].string_val)->insert(0, "-"); (yyval.string_val) = (yysemantic_stack_[(2) - (2)].string_val);;} break; - case 235: -#line 610 "DynareBison.yy" + case 250: +#line 642 "DynareBison.yy" {(yyval.string_val) = (yysemantic_stack_[(1) - (1)].string_val);;} break; - case 236: -#line 615 "DynareBison.yy" + case 251: +#line 647 "DynareBison.yy" { driver.estimated_params(); ;} break; - case 237: -#line 620 "DynareBison.yy" + case 252: +#line 652 "DynareBison.yy" {driver.add_estimated_params_element();;} break; - case 238: -#line 622 "DynareBison.yy" + case 253: +#line 654 "DynareBison.yy" {driver.add_estimated_params_element();;} break; - case 240: -#line 631 "DynareBison.yy" + case 255: +#line 663 "DynareBison.yy" {driver.estim_params.type = 1; driver.estim_params.name = *(yysemantic_stack_[(2) - (2)].string_val); delete (yysemantic_stack_[(2) - (2)].string_val); ;} break; - case 241: -#line 636 "DynareBison.yy" + case 256: +#line 668 "DynareBison.yy" {driver.estim_params.type = 2; driver.estim_params.name = *(yysemantic_stack_[(1) - (1)].string_val); delete (yysemantic_stack_[(1) - (1)].string_val); ;} break; - case 242: -#line 641 "DynareBison.yy" + case 257: +#line 673 "DynareBison.yy" {driver.estim_params.type = 3; driver.estim_params.name = *(yysemantic_stack_[(4) - (2)].string_val); driver.estim_params.name2 = *(yysemantic_stack_[(4) - (4)].string_val); @@ -1156,16 +1200,16 @@ namespace yy ;} break; - case 243: -#line 651 "DynareBison.yy" + case 258: +#line 683 "DynareBison.yy" { driver.estim_params.prior=*(yysemantic_stack_[(3) - (1)].string_val); delete (yysemantic_stack_[(3) - (1)].string_val); ;} break; - case 244: -#line 656 "DynareBison.yy" + case 259: +#line 688 "DynareBison.yy" {driver.estim_params.init_val=*(yysemantic_stack_[(5) - (1)].string_val); driver.estim_params.prior=*(yysemantic_stack_[(5) - (3)].string_val); delete (yysemantic_stack_[(5) - (1)].string_val); @@ -1173,8 +1217,8 @@ namespace yy ;} break; - case 245: -#line 662 "DynareBison.yy" + case 260: +#line 694 "DynareBison.yy" {driver.estim_params.init_val=*(yysemantic_stack_[(9) - (1)].string_val); driver.estim_params.low_bound=*(yysemantic_stack_[(9) - (3)].string_val); driver.estim_params.up_bound=*(yysemantic_stack_[(9) - (5)].string_val); @@ -1186,16 +1230,16 @@ namespace yy ;} break; - case 246: -#line 672 "DynareBison.yy" + case 261: +#line 704 "DynareBison.yy" { driver.estim_params.init_val=*(yysemantic_stack_[(1) - (1)].string_val); delete (yysemantic_stack_[(1) - (1)].string_val); ;} break; - case 247: -#line 677 "DynareBison.yy" + case 262: +#line 709 "DynareBison.yy" {driver.estim_params.init_val=*(yysemantic_stack_[(5) - (1)].string_val); driver.estim_params.low_bound=*(yysemantic_stack_[(5) - (3)].string_val); driver.estim_params.up_bound=*(yysemantic_stack_[(5) - (5)].string_val); @@ -1205,8 +1249,8 @@ namespace yy ;} break; - case 248: -#line 688 "DynareBison.yy" + case 263: +#line 720 "DynareBison.yy" {driver.estim_params.mean=*(yysemantic_stack_[(3) - (1)].string_val); driver.estim_params.std=*(yysemantic_stack_[(3) - (3)].string_val); delete (yysemantic_stack_[(3) - (1)].string_val); @@ -1214,8 +1258,8 @@ namespace yy ;} break; - case 249: -#line 694 "DynareBison.yy" + case 264: +#line 726 "DynareBison.yy" {driver.estim_params.mean=*(yysemantic_stack_[(5) - (1)].string_val); driver.estim_params.std=*(yysemantic_stack_[(5) - (3)].string_val); driver.estim_params.p3=*(yysemantic_stack_[(5) - (5)].string_val); @@ -1225,8 +1269,8 @@ namespace yy ;} break; - case 250: -#line 702 "DynareBison.yy" + case 265: +#line 734 "DynareBison.yy" {driver.estim_params.mean=*(yysemantic_stack_[(7) - (1)].string_val); driver.estim_params.std=*(yysemantic_stack_[(7) - (3)].string_val); driver.estim_params.p3=*(yysemantic_stack_[(7) - (5)].string_val); @@ -1238,8 +1282,8 @@ namespace yy ;} break; - case 251: -#line 712 "DynareBison.yy" + case 266: +#line 744 "DynareBison.yy" {driver.estim_params.mean=*(yysemantic_stack_[(9) - (1)].string_val); driver.estim_params.std=*(yysemantic_stack_[(9) - (3)].string_val); driver.estim_params.p3=*(yysemantic_stack_[(9) - (5)].string_val); @@ -1253,23 +1297,23 @@ namespace yy ;} break; - case 252: -#line 726 "DynareBison.yy" + case 267: +#line 758 "DynareBison.yy" { driver.estimated_params_init(); ;} break; - case 253: -#line 730 "DynareBison.yy" + case 268: +#line 762 "DynareBison.yy" {driver.add_estimated_params_element();;} break; - case 254: -#line 732 "DynareBison.yy" + case 269: +#line 764 "DynareBison.yy" {driver.add_estimated_params_element();;} break; - case 255: -#line 736 "DynareBison.yy" + case 270: +#line 768 "DynareBison.yy" {driver.estim_params.type = 1; driver.estim_params.name = *(yysemantic_stack_[(5) - (2)].string_val); driver.estim_params.init_val=*(yysemantic_stack_[(5) - (4)].string_val); @@ -1278,8 +1322,8 @@ namespace yy ;} break; - case 256: -#line 743 "DynareBison.yy" + case 271: +#line 775 "DynareBison.yy" {driver.estim_params.type = 3; driver.estim_params.name = *(yysemantic_stack_[(7) - (2)].string_val); driver.estim_params.name2 = *(yysemantic_stack_[(7) - (4)].string_val); @@ -1290,8 +1334,8 @@ namespace yy ;} break; - case 257: -#line 752 "DynareBison.yy" + case 272: +#line 784 "DynareBison.yy" {driver.estim_params.type = 2; driver.estim_params.name = *(yysemantic_stack_[(4) - (1)].string_val); driver.estim_params.init_val=*(yysemantic_stack_[(4) - (3)].string_val); @@ -1300,23 +1344,23 @@ namespace yy ;} break; - case 258: -#line 761 "DynareBison.yy" + case 273: +#line 793 "DynareBison.yy" { driver.estimated_params_bounds(); ;} break; - case 259: -#line 765 "DynareBison.yy" + case 274: +#line 797 "DynareBison.yy" {driver.add_estimated_params_element();;} break; - case 260: -#line 767 "DynareBison.yy" + case 275: +#line 799 "DynareBison.yy" {driver.add_estimated_params_element();;} break; - case 261: -#line 771 "DynareBison.yy" + case 276: +#line 803 "DynareBison.yy" {driver.estim_params.type = 1; driver.estim_params.name = *(yysemantic_stack_[(7) - (2)].string_val); driver.estim_params.low_bound=*(yysemantic_stack_[(7) - (4)].string_val); @@ -1327,8 +1371,8 @@ namespace yy ;} break; - case 262: -#line 780 "DynareBison.yy" + case 277: +#line 812 "DynareBison.yy" {driver.estim_params.type = 3; driver.estim_params.name = *(yysemantic_stack_[(9) - (2)].string_val); driver.estim_params.name2 = *(yysemantic_stack_[(9) - (4)].string_val); @@ -1341,8 +1385,8 @@ namespace yy ;} break; - case 263: -#line 791 "DynareBison.yy" + case 278: +#line 823 "DynareBison.yy" {driver.estim_params.type = 2; driver.estim_params.name = *(yysemantic_stack_[(6) - (1)].string_val); driver.estim_params.low_bound=*(yysemantic_stack_[(6) - (3)].string_val); @@ -1353,708 +1397,713 @@ namespace yy ;} break; - case 264: -#line 803 "DynareBison.yy" + case 279: +#line 835 "DynareBison.yy" {(yyval.string_val) = new string("1");;} break; - case 265: -#line 805 "DynareBison.yy" + case 280: +#line 837 "DynareBison.yy" {(yyval.string_val) = new string("2");;} break; - case 266: -#line 807 "DynareBison.yy" + case 281: +#line 839 "DynareBison.yy" {(yyval.string_val) = new string("3");;} break; - case 267: -#line 809 "DynareBison.yy" + case 282: +#line 841 "DynareBison.yy" {(yyval.string_val) = new string("4");;} break; - case 268: -#line 811 "DynareBison.yy" + case 283: +#line 843 "DynareBison.yy" {(yyval.string_val) = new string("5");;} break; - case 269: -#line 815 "DynareBison.yy" + case 284: +#line 847 "DynareBison.yy" {(yyval.string_val) = new string("NaN");;} break; - case 273: -#line 820 "DynareBison.yy" + case 288: +#line 852 "DynareBison.yy" {(yysemantic_stack_[(2) - (2)].string_val)->insert(0, "-"); (yyval.string_val) = (yysemantic_stack_[(2) - (2)].string_val);;} break; - case 274: -#line 822 "DynareBison.yy" + case 289: +#line 854 "DynareBison.yy" {(yysemantic_stack_[(2) - (2)].string_val)->insert(0, "-"); (yyval.string_val) = (yysemantic_stack_[(2) - (2)].string_val);;} break; - case 275: -#line 829 "DynareBison.yy" + case 290: +#line 861 "DynareBison.yy" {driver.run_estimation();;} break; - case 276: -#line 831 "DynareBison.yy" + case 291: +#line 863 "DynareBison.yy" {driver.run_estimation();;} break; - case 277: -#line 833 "DynareBison.yy" + case 292: +#line 865 "DynareBison.yy" {driver.run_estimation();;} break; - case 278: -#line 835 "DynareBison.yy" + case 293: +#line 867 "DynareBison.yy" {driver.run_estimation();;} break; - case 320: -#line 886 "DynareBison.yy" + case 335: +#line 918 "DynareBison.yy" {driver.run_prior_analysis();;} break; - case 321: -#line 888 "DynareBison.yy" - {driver.run_prior_analysis();;} - break; - - case 337: -#line 914 "DynareBison.yy" - {driver.run_posterior_analysis();;} - break; - - case 338: -#line 916 "DynareBison.yy" - {driver.run_posterior_analysis();;} - break; - - case 339: + case 336: #line 920 "DynareBison.yy" - {driver.optim_options_string((yysemantic_stack_[(7) - (2)].string_val), (yysemantic_stack_[(7) - (6)].string_val));;} - break; - - case 340: -#line 921 "DynareBison.yy" - {driver.optim_options_num((yysemantic_stack_[(5) - (2)].string_val), (yysemantic_stack_[(5) - (5)].string_val));;} - break; - - case 343: -#line 931 "DynareBison.yy" - {driver.set_varobs();;} - break; - - case 344: -#line 936 "DynareBison.yy" - { driver.set_trends(); ;} - break; - - case 347: -#line 945 "DynareBison.yy" - {driver.set_trend_element((yysemantic_stack_[(5) - (1)].string_val), (yysemantic_stack_[(5) - (3)].exp_val));;} - break; - - case 348: -#line 948 "DynareBison.yy" - {driver.set_unit_root_vars();;} - break; - - case 349: -#line 952 "DynareBison.yy" - { driver.optim_weights(); ;} - break; - - case 350: -#line 956 "DynareBison.yy" - {driver.set_optim_weights((yysemantic_stack_[(4) - (2)].string_val), (yysemantic_stack_[(4) - (3)].exp_val));;} - break; - - case 351: -#line 958 "DynareBison.yy" - {driver.set_optim_weights((yysemantic_stack_[(6) - (2)].string_val), (yysemantic_stack_[(6) - (4)].string_val), (yysemantic_stack_[(6) - (5)].exp_val));;} + {driver.run_prior_analysis();;} break; case 352: -#line 960 "DynareBison.yy" - {driver.set_optim_weights((yysemantic_stack_[(3) - (1)].string_val), (yysemantic_stack_[(3) - (2)].exp_val));;} +#line 946 "DynareBison.yy" + {driver.run_posterior_analysis();;} break; case 353: -#line 962 "DynareBison.yy" - {driver.set_optim_weights((yysemantic_stack_[(5) - (1)].string_val), (yysemantic_stack_[(5) - (3)].string_val), (yysemantic_stack_[(5) - (4)].exp_val));;} +#line 948 "DynareBison.yy" + {driver.run_posterior_analysis();;} break; case 354: -#line 965 "DynareBison.yy" - {driver.set_osr_params();;} +#line 952 "DynareBison.yy" + {driver.optim_options_string((yysemantic_stack_[(7) - (2)].string_val), (yysemantic_stack_[(7) - (6)].string_val));;} break; case 355: -#line 968 "DynareBison.yy" - {driver.run_osr();;} - break; - - case 356: -#line 969 "DynareBison.yy" - {driver.run_osr();;} - break; - - case 357: -#line 970 "DynareBison.yy" - {driver.run_osr();;} +#line 953 "DynareBison.yy" + {driver.optim_options_num((yysemantic_stack_[(5) - (2)].string_val), (yysemantic_stack_[(5) - (5)].string_val));;} break; case 358: -#line 971 "DynareBison.yy" - {driver.run_osr();;} +#line 963 "DynareBison.yy" + {driver.set_varobs();;} break; case 359: -#line 974 "DynareBison.yy" - {driver.run_olr();;} - break; - - case 360: -#line 975 "DynareBison.yy" - {driver.run_olr();;} - break; - - case 361: -#line 976 "DynareBison.yy" - {driver.run_olr();;} +#line 968 "DynareBison.yy" + { driver.set_trends(); ;} break; case 362: #line 977 "DynareBison.yy" - {driver.run_olr();;} + {driver.set_trend_element((yysemantic_stack_[(5) - (1)].string_val), (yysemantic_stack_[(5) - (3)].exp_val));;} + break; + + case 363: +#line 980 "DynareBison.yy" + {driver.set_unit_root_vars();;} + break; + + case 364: +#line 984 "DynareBison.yy" + { driver.optim_weights(); ;} + break; + + case 365: +#line 988 "DynareBison.yy" + {driver.set_optim_weights((yysemantic_stack_[(4) - (2)].string_val), (yysemantic_stack_[(4) - (3)].exp_val));;} + break; + + case 366: +#line 990 "DynareBison.yy" + {driver.set_optim_weights((yysemantic_stack_[(6) - (2)].string_val), (yysemantic_stack_[(6) - (4)].string_val), (yysemantic_stack_[(6) - (5)].exp_val));;} break; case 367: -#line 988 "DynareBison.yy" - {driver.set_olr_inst();;} +#line 992 "DynareBison.yy" + {driver.set_optim_weights((yysemantic_stack_[(3) - (1)].string_val), (yysemantic_stack_[(3) - (2)].exp_val));;} break; case 368: -#line 992 "DynareBison.yy" - { driver.run_calib_var(); ;} +#line 994 "DynareBison.yy" + {driver.set_optim_weights((yysemantic_stack_[(5) - (1)].string_val), (yysemantic_stack_[(5) - (3)].string_val), (yysemantic_stack_[(5) - (4)].exp_val));;} + break; + + case 369: +#line 997 "DynareBison.yy" + {driver.set_osr_params();;} + break; + + case 370: +#line 1000 "DynareBison.yy" + {driver.run_osr();;} break; case 371: -#line 999 "DynareBison.yy" - {driver.set_calib_var((yysemantic_stack_[(5) - (1)].string_val), (yysemantic_stack_[(5) - (2)].string_val), (yysemantic_stack_[(5) - (4)].exp_val));;} +#line 1001 "DynareBison.yy" + {driver.run_osr();;} break; case 372: -#line 1000 "DynareBison.yy" - {driver.set_calib_covar((yysemantic_stack_[(7) - (1)].string_val), (yysemantic_stack_[(7) - (3)].string_val), (yysemantic_stack_[(7) - (4)].string_val), (yysemantic_stack_[(7) - (6)].exp_val));;} +#line 1002 "DynareBison.yy" + {driver.run_osr();;} break; case 373: -#line 1001 "DynareBison.yy" - {driver.set_calib_ac((yysemantic_stack_[(9) - (2)].string_val), (yysemantic_stack_[(9) - (4)].string_val), (yysemantic_stack_[(9) - (6)].string_val), (yysemantic_stack_[(9) - (8)].exp_val));;} +#line 1003 "DynareBison.yy" + {driver.run_osr();;} break; case 374: -#line 1004 "DynareBison.yy" - { (yyval.string_val) = new string("1"); ;} +#line 1006 "DynareBison.yy" + {driver.run_olr();;} break; case 375: -#line 1005 "DynareBison.yy" - {(yyval.string_val) = (yysemantic_stack_[(3) - (2)].string_val);;} +#line 1007 "DynareBison.yy" + {driver.run_olr();;} break; case 376: -#line 1006 "DynareBison.yy" - {(yyval.string_val) = (yysemantic_stack_[(3) - (2)].string_val);;} +#line 1008 "DynareBison.yy" + {driver.run_olr();;} break; case 377: #line 1009 "DynareBison.yy" - {driver.run_calib(0);;} - break; - - case 378: -#line 1010 "DynareBison.yy" - {driver.run_calib(1);;} - break; - - case 379: -#line 1013 "DynareBison.yy" - {driver.run_dynatype((yysemantic_stack_[(5) - (3)].string_val));;} - break; - - case 380: -#line 1014 "DynareBison.yy" - {driver.run_dynatype((yysemantic_stack_[(6) - (3)].string_val));;} - break; - - case 381: -#line 1015 "DynareBison.yy" - {driver.run_dynatype((yysemantic_stack_[(3) - (2)].string_val));;} + {driver.run_olr();;} break; case 382: -#line 1016 "DynareBison.yy" - {driver.run_dynatype((yysemantic_stack_[(7) - (3)].string_val), (yysemantic_stack_[(7) - (5)].string_val));;} +#line 1020 "DynareBison.yy" + {driver.set_olr_inst();;} break; case 383: -#line 1017 "DynareBison.yy" - {driver.run_dynatype((yysemantic_stack_[(8) - (3)].string_val), (yysemantic_stack_[(8) - (5)].string_val));;} - break; - - case 384: -#line 1018 "DynareBison.yy" - {driver.run_dynatype((yysemantic_stack_[(5) - (2)].string_val),(yysemantic_stack_[(5) - (4)].string_val));;} - break; - - case 385: -#line 1020 "DynareBison.yy" - {driver.run_dynasave((yysemantic_stack_[(5) - (3)].string_val));;} +#line 1024 "DynareBison.yy" + { driver.run_calib_var(); ;} break; case 386: -#line 1021 "DynareBison.yy" - {driver.run_dynasave((yysemantic_stack_[(6) - (3)].string_val));;} +#line 1031 "DynareBison.yy" + {driver.set_calib_var((yysemantic_stack_[(5) - (1)].string_val), (yysemantic_stack_[(5) - (2)].string_val), (yysemantic_stack_[(5) - (4)].exp_val));;} break; case 387: -#line 1022 "DynareBison.yy" - {driver.run_dynasave((yysemantic_stack_[(3) - (2)].string_val));;} +#line 1032 "DynareBison.yy" + {driver.set_calib_covar((yysemantic_stack_[(7) - (1)].string_val), (yysemantic_stack_[(7) - (3)].string_val), (yysemantic_stack_[(7) - (4)].string_val), (yysemantic_stack_[(7) - (6)].exp_val));;} break; case 388: -#line 1023 "DynareBison.yy" - {driver.run_dynasave((yysemantic_stack_[(7) - (3)].string_val), (yysemantic_stack_[(7) - (5)].string_val));;} +#line 1033 "DynareBison.yy" + {driver.set_calib_ac((yysemantic_stack_[(9) - (2)].string_val), (yysemantic_stack_[(9) - (4)].string_val), (yysemantic_stack_[(9) - (6)].string_val), (yysemantic_stack_[(9) - (8)].exp_val));;} break; case 389: -#line 1024 "DynareBison.yy" - {driver.run_dynasave((yysemantic_stack_[(8) - (3)].string_val), (yysemantic_stack_[(8) - (5)].string_val));;} +#line 1036 "DynareBison.yy" + { (yyval.string_val) = new string("1"); ;} break; case 390: -#line 1025 "DynareBison.yy" - {driver.run_dynasave((yysemantic_stack_[(5) - (2)].string_val), (yysemantic_stack_[(5) - (4)].string_val));;} +#line 1037 "DynareBison.yy" + {(yyval.string_val) = (yysemantic_stack_[(3) - (2)].string_val);;} break; case 391: -#line 1028 "DynareBison.yy" - {driver.run_model_comparison();;} +#line 1038 "DynareBison.yy" + {(yyval.string_val) = (yysemantic_stack_[(3) - (2)].string_val);;} + break; + + case 392: +#line 1041 "DynareBison.yy" + {driver.run_calib(0);;} + break; + + case 393: +#line 1042 "DynareBison.yy" + {driver.run_calib(1);;} + break; + + case 394: +#line 1045 "DynareBison.yy" + {driver.run_dynatype((yysemantic_stack_[(5) - (3)].string_val));;} + break; + + case 395: +#line 1046 "DynareBison.yy" + {driver.run_dynatype((yysemantic_stack_[(6) - (3)].string_val));;} + break; + + case 396: +#line 1047 "DynareBison.yy" + {driver.run_dynatype((yysemantic_stack_[(3) - (2)].string_val));;} break; case 397: -#line 1040 "DynareBison.yy" - {driver.add_mc_filename((yysemantic_stack_[(1) - (1)].string_val));;} +#line 1048 "DynareBison.yy" + {driver.run_dynatype((yysemantic_stack_[(7) - (3)].string_val), (yysemantic_stack_[(7) - (5)].string_val));;} break; case 398: -#line 1041 "DynareBison.yy" - {driver.add_mc_filename((yysemantic_stack_[(3) - (3)].string_val));;} +#line 1049 "DynareBison.yy" + {driver.run_dynatype((yysemantic_stack_[(8) - (3)].string_val), (yysemantic_stack_[(8) - (5)].string_val));;} break; case 399: -#line 1042 "DynareBison.yy" - {driver.add_mc_filename((yysemantic_stack_[(4) - (1)].string_val), (yysemantic_stack_[(4) - (3)].string_val));;} +#line 1050 "DynareBison.yy" + {driver.run_dynatype((yysemantic_stack_[(5) - (2)].string_val),(yysemantic_stack_[(5) - (4)].string_val));;} break; case 400: -#line 1043 "DynareBison.yy" - {driver.add_mc_filename((yysemantic_stack_[(6) - (3)].string_val), (yysemantic_stack_[(6) - (5)].string_val));;} +#line 1052 "DynareBison.yy" + {driver.run_dynasave((yysemantic_stack_[(5) - (3)].string_val));;} break; case 401: -#line 1046 "DynareBison.yy" - {(yyval.string_val) = (yysemantic_stack_[(1) - (1)].string_val);;} +#line 1053 "DynareBison.yy" + {driver.run_dynasave((yysemantic_stack_[(6) - (3)].string_val));;} break; case 402: -#line 1047 "DynareBison.yy" - {(yysemantic_stack_[(2) - (1)].string_val)->append(*(yysemantic_stack_[(2) - (2)].string_val)); delete (yysemantic_stack_[(2) - (2)].string_val); (yyval.string_val) = (yysemantic_stack_[(2) - (1)].string_val);;} +#line 1054 "DynareBison.yy" + {driver.run_dynasave((yysemantic_stack_[(3) - (2)].string_val));;} + break; + + case 403: +#line 1055 "DynareBison.yy" + {driver.run_dynasave((yysemantic_stack_[(7) - (3)].string_val), (yysemantic_stack_[(7) - (5)].string_val));;} break; case 404: -#line 1051 "DynareBison.yy" - { (yyval.string_val) = new string("\\"); ;} +#line 1056 "DynareBison.yy" + {driver.run_dynasave((yysemantic_stack_[(8) - (3)].string_val), (yysemantic_stack_[(8) - (5)].string_val));;} break; case 405: -#line 1052 "DynareBison.yy" - { (yyval.string_val) = new string("/"); ;} +#line 1057 "DynareBison.yy" + {driver.run_dynasave((yysemantic_stack_[(5) - (2)].string_val), (yysemantic_stack_[(5) - (4)].string_val));;} break; case 406: -#line 1053 "DynareBison.yy" - { (yyval.string_val) = new string(":"); ;} - break; - - case 407: -#line 1054 "DynareBison.yy" - { (yyval.string_val) = new string("."); ;} - break; - - case 408: -#line 1057 "DynareBison.yy" - { driver.begin_planner_objective(); ;} - break; - - case 409: -#line 1057 "DynareBison.yy" - { driver.end_planner_objective((yysemantic_stack_[(3) - (3)].model_val)); ;} - break; - - case 411: -#line 1061 "DynareBison.yy" - {driver.ramsey_policy();;} +#line 1060 "DynareBison.yy" + {driver.run_model_comparison();;} break; case 412: -#line 1063 "DynareBison.yy" - {driver.ramsey_policy();;} +#line 1072 "DynareBison.yy" + {driver.add_mc_filename((yysemantic_stack_[(1) - (1)].string_val));;} break; case 413: -#line 1065 "DynareBison.yy" - {driver.ramsey_policy();;} +#line 1073 "DynareBison.yy" + {driver.add_mc_filename((yysemantic_stack_[(3) - (3)].string_val));;} break; case 414: -#line 1067 "DynareBison.yy" - {driver.ramsey_policy();;} +#line 1074 "DynareBison.yy" + {driver.add_mc_filename((yysemantic_stack_[(4) - (1)].string_val), (yysemantic_stack_[(4) - (3)].string_val));;} + break; + + case 415: +#line 1075 "DynareBison.yy" + {driver.add_mc_filename((yysemantic_stack_[(6) - (3)].string_val), (yysemantic_stack_[(6) - (5)].string_val));;} + break; + + case 416: +#line 1078 "DynareBison.yy" + {(yyval.string_val) = (yysemantic_stack_[(1) - (1)].string_val);;} + break; + + case 417: +#line 1079 "DynareBison.yy" + {(yysemantic_stack_[(2) - (1)].string_val)->append(*(yysemantic_stack_[(2) - (2)].string_val)); delete (yysemantic_stack_[(2) - (2)].string_val); (yyval.string_val) = (yysemantic_stack_[(2) - (1)].string_val);;} break; case 419: -#line 1079 "DynareBison.yy" - {driver.option_num("dr_algo", (yysemantic_stack_[(3) - (3)].string_val));;} +#line 1083 "DynareBison.yy" + { (yyval.string_val) = new string("\\"); ;} break; case 420: -#line 1080 "DynareBison.yy" - {driver.option_num("solve_algo", (yysemantic_stack_[(3) - (3)].string_val));;} +#line 1084 "DynareBison.yy" + { (yyval.string_val) = new string("/"); ;} break; case 421: -#line 1081 "DynareBison.yy" - {driver.option_num("simul_algo", (yysemantic_stack_[(3) - (3)].string_val));;} +#line 1085 "DynareBison.yy" + { (yyval.string_val) = new string(":"); ;} break; case 422: -#line 1082 "DynareBison.yy" - {driver.linear();;} +#line 1086 "DynareBison.yy" + { (yyval.string_val) = new string("."); ;} break; case 423: -#line 1083 "DynareBison.yy" - {driver.option_num("order", (yysemantic_stack_[(3) - (3)].string_val));;} +#line 1089 "DynareBison.yy" + { driver.begin_planner_objective(); ;} break; case 424: -#line 1084 "DynareBison.yy" - {driver.option_num("replic", (yysemantic_stack_[(3) - (3)].string_val));;} - break; - - case 425: -#line 1085 "DynareBison.yy" - {driver.option_num("drop", (yysemantic_stack_[(3) - (3)].string_val));;} +#line 1089 "DynareBison.yy" + { driver.end_planner_objective((yysemantic_stack_[(3) - (3)].model_val)); ;} break; case 426: -#line 1086 "DynareBison.yy" - {driver.option_num("ar", (yysemantic_stack_[(3) - (3)].string_val));;} +#line 1093 "DynareBison.yy" + {driver.ramsey_policy();;} break; case 427: -#line 1087 "DynareBison.yy" - {driver.option_num("nocorr", "1");;} +#line 1095 "DynareBison.yy" + {driver.ramsey_policy();;} break; case 428: -#line 1088 "DynareBison.yy" - {driver.option_num("nofunctions", "1");;} +#line 1097 "DynareBison.yy" + {driver.ramsey_policy();;} break; case 429: -#line 1089 "DynareBison.yy" - {driver.option_num("nomoments", "1");;} - break; - - case 430: -#line 1090 "DynareBison.yy" - {driver.option_num("irf", (yysemantic_stack_[(3) - (3)].string_val));;} - break; - - case 431: -#line 1091 "DynareBison.yy" - {driver.option_num("hp_filter", (yysemantic_stack_[(3) - (3)].string_val));;} - break; - - case 432: -#line 1092 "DynareBison.yy" - {driver.option_num("hp_ngrid", (yysemantic_stack_[(3) - (3)].string_val));;} - break; - - case 433: -#line 1093 "DynareBison.yy" - {driver.option_num("periods", (yysemantic_stack_[(3) - (3)].string_val)); driver.option_num("simul", "1");;} +#line 1099 "DynareBison.yy" + {driver.ramsey_policy();;} break; case 434: -#line 1094 "DynareBison.yy" - {driver.option_num("simul", "1");;} +#line 1111 "DynareBison.yy" + {driver.option_num("dr_algo", (yysemantic_stack_[(3) - (3)].string_val));;} break; case 435: -#line 1095 "DynareBison.yy" - { driver.option_num("simul_seed", (yysemantic_stack_[(3) - (3)].string_val));} +#line 1112 "DynareBison.yy" + {driver.option_num("solve_algo", (yysemantic_stack_[(3) - (3)].string_val));;} break; case 436: -#line 1096 "DynareBison.yy" - { driver.option_num("qz_criterium", (yysemantic_stack_[(3) - (3)].string_val));} +#line 1113 "DynareBison.yy" + {driver.option_num("simul_algo", (yysemantic_stack_[(3) - (3)].string_val));;} break; case 437: -#line 1097 "DynareBison.yy" - { driver.option_num("qz_criterium", (yysemantic_stack_[(3) - (3)].string_val));} +#line 1114 "DynareBison.yy" + {driver.linear();;} break; case 438: -#line 1099 "DynareBison.yy" - {driver.option_str("datafile", (yysemantic_stack_[(3) - (3)].string_val));;} +#line 1115 "DynareBison.yy" + {driver.option_num("order", (yysemantic_stack_[(3) - (3)].string_val));;} break; case 439: -#line 1100 "DynareBison.yy" - {driver.option_num("nobs", (yysemantic_stack_[(3) - (3)].string_val));;} +#line 1116 "DynareBison.yy" + {driver.option_num("replic", (yysemantic_stack_[(3) - (3)].string_val));;} break; case 440: -#line 1101 "DynareBison.yy" - {driver.option_num("nobs", (yysemantic_stack_[(3) - (3)].string_val));;} +#line 1117 "DynareBison.yy" + {driver.option_num("drop", (yysemantic_stack_[(3) - (3)].string_val));;} break; case 441: -#line 1103 "DynareBison.yy" - {driver.option_num("first_obs", (yysemantic_stack_[(3) - (3)].string_val));;} +#line 1118 "DynareBison.yy" + {driver.option_num("ar", (yysemantic_stack_[(3) - (3)].string_val));;} break; case 442: -#line 1104 "DynareBison.yy" - {driver.option_num("prefilter", (yysemantic_stack_[(3) - (3)].string_val));;} +#line 1119 "DynareBison.yy" + {driver.option_num("nocorr", "1");;} break; case 443: -#line 1105 "DynareBison.yy" - {driver.option_num("presample", (yysemantic_stack_[(3) - (3)].string_val));;} +#line 1120 "DynareBison.yy" + {driver.option_num("nofunctions", "1");;} break; case 444: -#line 1106 "DynareBison.yy" - {driver.option_num("lik_algo", (yysemantic_stack_[(3) - (3)].string_val));;} +#line 1121 "DynareBison.yy" + {driver.option_num("nomoments", "1");;} break; case 445: -#line 1107 "DynareBison.yy" - {driver.option_num("lik_init", (yysemantic_stack_[(3) - (3)].string_val));;} +#line 1122 "DynareBison.yy" + {driver.option_num("irf", (yysemantic_stack_[(3) - (3)].string_val));;} break; case 446: -#line 1108 "DynareBison.yy" - {driver.option_num("nograph","1");;} +#line 1123 "DynareBison.yy" + {driver.option_num("hp_filter", (yysemantic_stack_[(3) - (3)].string_val));;} break; case 447: -#line 1109 "DynareBison.yy" - {driver.option_num("nograph", "0");;} +#line 1124 "DynareBison.yy" + {driver.option_num("hp_ngrid", (yysemantic_stack_[(3) - (3)].string_val));;} break; case 448: -#line 1110 "DynareBison.yy" - {driver.option_num("conf_sig", (yysemantic_stack_[(3) - (3)].string_val));;} +#line 1125 "DynareBison.yy" + {driver.option_num("periods", (yysemantic_stack_[(3) - (3)].string_val)); driver.option_num("simul", "1");;} break; case 449: -#line 1111 "DynareBison.yy" - {driver.option_num("mh_replic", (yysemantic_stack_[(3) - (3)].string_val));;} +#line 1126 "DynareBison.yy" + {driver.option_num("cutoff", (yysemantic_stack_[(3) - (3)].string_val));;} break; case 450: -#line 1112 "DynareBison.yy" - {driver.option_num("mh_drop", (yysemantic_stack_[(3) - (3)].string_val));;} +#line 1127 "DynareBison.yy" + {driver.option_num("simul", "1");;} break; case 451: -#line 1113 "DynareBison.yy" - {driver.option_num("mh_jscale", (yysemantic_stack_[(3) - (3)].string_val));;} +#line 1128 "DynareBison.yy" + { driver.option_num("simul_seed", (yysemantic_stack_[(3) - (3)].string_val));} + break; + + case 452: +#line 1129 "DynareBison.yy" + { driver.option_num("qz_criterium", (yysemantic_stack_[(3) - (3)].string_val));} break; case 453: -#line 1115 "DynareBison.yy" - {driver.option_num("mh_init_scale", (yysemantic_stack_[(3) - (3)].string_val));;} +#line 1130 "DynareBison.yy" + { driver.option_num("qz_criterium", (yysemantic_stack_[(3) - (3)].string_val));} break; case 454: -#line 1116 "DynareBison.yy" - {driver.option_num("mh_init_scale", (yysemantic_stack_[(3) - (3)].string_val));;} +#line 1132 "DynareBison.yy" + {driver.option_str("datafile", (yysemantic_stack_[(3) - (3)].string_val));;} break; case 455: -#line 1117 "DynareBison.yy" - {driver.option_str("mode_file", (yysemantic_stack_[(3) - (3)].string_val));;} +#line 1133 "DynareBison.yy" + {driver.option_num("nobs", (yysemantic_stack_[(3) - (3)].string_val));;} break; case 456: -#line 1118 "DynareBison.yy" - {driver.option_num("mode_compute", (yysemantic_stack_[(3) - (3)].string_val));;} +#line 1134 "DynareBison.yy" + {driver.option_num("nobs", (yysemantic_stack_[(3) - (3)].string_val));;} break; case 457: -#line 1119 "DynareBison.yy" - {driver.option_num("mode_check", "1");;} +#line 1136 "DynareBison.yy" + {driver.option_num("first_obs", (yysemantic_stack_[(3) - (3)].string_val));;} break; case 458: -#line 1120 "DynareBison.yy" - {driver.option_num("prior_trunc", (yysemantic_stack_[(3) - (3)].string_val));;} +#line 1137 "DynareBison.yy" + {driver.option_num("prefilter", (yysemantic_stack_[(3) - (3)].string_val));;} break; case 459: -#line 1121 "DynareBison.yy" - {driver.option_num("mh_mode", (yysemantic_stack_[(3) - (3)].string_val));;} +#line 1138 "DynareBison.yy" + {driver.option_num("presample", (yysemantic_stack_[(3) - (3)].string_val));;} break; case 460: -#line 1122 "DynareBison.yy" - {driver.option_num("mh_nblck", (yysemantic_stack_[(3) - (3)].string_val));;} +#line 1139 "DynareBison.yy" + {driver.option_num("lik_algo", (yysemantic_stack_[(3) - (3)].string_val));;} break; case 461: -#line 1123 "DynareBison.yy" - {driver.option_num("load_mh_file", "1");;} +#line 1140 "DynareBison.yy" + {driver.option_num("lik_init", (yysemantic_stack_[(3) - (3)].string_val));;} break; case 462: -#line 1124 "DynareBison.yy" - {driver.option_num("loglinear", "1");;} +#line 1141 "DynareBison.yy" + {driver.option_num("nograph","1");;} break; case 463: -#line 1125 "DynareBison.yy" - {driver.option_num("nodiagnostic", "1");;} +#line 1142 "DynareBison.yy" + {driver.option_num("nograph", "0");;} break; case 464: -#line 1126 "DynareBison.yy" - {driver.option_num("bayesian_irf", "1");;} +#line 1143 "DynareBison.yy" + {driver.option_num("conf_sig", (yysemantic_stack_[(3) - (3)].string_val));;} break; case 465: -#line 1127 "DynareBison.yy" - {driver.option_num("TeX", "1");;} +#line 1144 "DynareBison.yy" + {driver.option_num("mh_replic", (yysemantic_stack_[(3) - (3)].string_val));;} break; case 466: -#line 1128 "DynareBison.yy" - {driver.option_num("forecast", (yysemantic_stack_[(3) - (3)].string_val));;} +#line 1145 "DynareBison.yy" + {driver.option_num("mh_drop", (yysemantic_stack_[(3) - (3)].string_val));;} break; case 467: -#line 1129 "DynareBison.yy" - {driver.option_num("smoother", "1");;} - break; - - case 468: -#line 1130 "DynareBison.yy" - {driver.option_num("moments_varendo", "1");;} +#line 1146 "DynareBison.yy" + {driver.option_num("mh_jscale", (yysemantic_stack_[(3) - (3)].string_val));;} break; case 469: -#line 1131 "DynareBison.yy" - {driver.option_num("filtered_vars", "1");;} +#line 1148 "DynareBison.yy" + {driver.option_num("mh_init_scale", (yysemantic_stack_[(3) - (3)].string_val));;} break; case 470: -#line 1132 "DynareBison.yy" - {driver.option_num("relative_irf", "1");;} +#line 1149 "DynareBison.yy" + {driver.option_num("mh_init_scale", (yysemantic_stack_[(3) - (3)].string_val));;} break; case 471: -#line 1133 "DynareBison.yy" - {driver.option_num("kalman_algo", (yysemantic_stack_[(3) - (3)].string_val));;} +#line 1150 "DynareBison.yy" + {driver.option_str("mode_file", (yysemantic_stack_[(3) - (3)].string_val));;} break; case 472: -#line 1134 "DynareBison.yy" - {driver.option_num("kalman_tol", (yysemantic_stack_[(3) - (3)].string_val));;} +#line 1151 "DynareBison.yy" + {driver.option_num("mode_compute", (yysemantic_stack_[(3) - (3)].string_val));;} break; case 473: -#line 1135 "DynareBison.yy" - {driver.option_num("olr_beta", (yysemantic_stack_[(3) - (3)].string_val));;} +#line 1152 "DynareBison.yy" + {driver.option_num("mode_check", "1");;} break; case 474: -#line 1138 "DynareBison.yy" - { driver.option_str("model_comparison_approximation", "Laplace"); ;} +#line 1153 "DynareBison.yy" + {driver.option_num("prior_trunc", (yysemantic_stack_[(3) - (3)].string_val));;} break; case 475: -#line 1140 "DynareBison.yy" - { driver.option_str("model_comparison_approximation", "MODIFIEDHARMONICMEAN"); ;} +#line 1154 "DynareBison.yy" + {driver.option_num("mh_mode", (yysemantic_stack_[(3) - (3)].string_val));;} break; case 476: -#line 1142 "DynareBison.yy" - {driver.option_num("noprint", "0");;} +#line 1155 "DynareBison.yy" + {driver.option_num("mh_nblck", (yysemantic_stack_[(3) - (3)].string_val));;} break; case 477: -#line 1143 "DynareBison.yy" - {driver.option_num("noprint", "1");;} +#line 1156 "DynareBison.yy" + {driver.option_num("load_mh_file", "1");;} break; case 478: -#line 1144 "DynareBison.yy" - {driver.option_str("xls_sheet", (yysemantic_stack_[(3) - (3)].string_val));;} +#line 1157 "DynareBison.yy" + {driver.option_num("loglinear", "1");;} break; case 479: -#line 1145 "DynareBison.yy" - {driver.option_str("xls_range", (yysemantic_stack_[(3) - (3)].string_val));;} +#line 1158 "DynareBison.yy" + {driver.option_num("nodiagnostic", "1");;} break; case 480: -#line 1146 "DynareBison.yy" - {driver.option_num("filter_step_ahead", (yysemantic_stack_[(3) - (3)].string_val));;} +#line 1159 "DynareBison.yy" + {driver.option_num("bayesian_irf", "1");;} break; case 481: -#line 1147 "DynareBison.yy" - {driver.option_num("noconstant", "0");;} +#line 1160 "DynareBison.yy" + {driver.option_num("TeX", "1");;} break; case 482: -#line 1148 "DynareBison.yy" - {driver.option_num("noconstant", "1");;} +#line 1161 "DynareBison.yy" + {driver.option_num("forecast", (yysemantic_stack_[(3) - (3)].string_val));;} break; case 483: -#line 1149 "DynareBison.yy" - {driver.option_num("load_mh_file", "-1");;} +#line 1162 "DynareBison.yy" + {driver.option_num("smoother", "1");;} break; case 484: -#line 1150 "DynareBison.yy" - {driver.option_num("planner_discount",(yysemantic_stack_[(3) - (3)].string_val));;} +#line 1163 "DynareBison.yy" + {driver.option_num("moments_varendo", "1");;} break; case 485: -#line 1153 "DynareBison.yy" +#line 1164 "DynareBison.yy" + {driver.option_num("filtered_vars", "1");;} + break; + + case 486: +#line 1165 "DynareBison.yy" + {driver.option_num("relative_irf", "1");;} + break; + + case 487: +#line 1166 "DynareBison.yy" + {driver.option_num("kalman_algo", (yysemantic_stack_[(3) - (3)].string_val));;} + break; + + case 488: +#line 1167 "DynareBison.yy" + {driver.option_num("kalman_tol", (yysemantic_stack_[(3) - (3)].string_val));;} + break; + + case 489: +#line 1168 "DynareBison.yy" + {driver.option_num("olr_beta", (yysemantic_stack_[(3) - (3)].string_val));;} + break; + + case 490: +#line 1171 "DynareBison.yy" + { driver.option_str("model_comparison_approximation", "Laplace"); ;} + break; + + case 491: +#line 1173 "DynareBison.yy" + { driver.option_str("model_comparison_approximation", "MODIFIEDHARMONICMEAN"); ;} + break; + + case 492: +#line 1175 "DynareBison.yy" + {driver.option_num("noprint", "0");;} + break; + + case 493: +#line 1176 "DynareBison.yy" + {driver.option_num("noprint", "1");;} + break; + + case 494: +#line 1177 "DynareBison.yy" + {driver.option_str("xls_sheet", (yysemantic_stack_[(3) - (3)].string_val));;} + break; + + case 495: +#line 1178 "DynareBison.yy" + {driver.option_str("xls_range", (yysemantic_stack_[(3) - (3)].string_val));;} + break; + + case 496: +#line 1179 "DynareBison.yy" + {driver.option_num("filter_step_ahead", (yysemantic_stack_[(3) - (3)].string_val));;} + break; + + case 497: +#line 1180 "DynareBison.yy" + {driver.option_num("noconstant", "0");;} + break; + + case 498: +#line 1181 "DynareBison.yy" + {driver.option_num("noconstant", "1");;} + break; + + case 499: +#line 1182 "DynareBison.yy" + {driver.option_num("load_mh_file", "-1");;} + break; + + case 500: +#line 1183 "DynareBison.yy" + {driver.option_num("planner_discount",(yysemantic_stack_[(3) - (3)].string_val));;} + break; + + case 501: +#line 1186 "DynareBison.yy" { (yysemantic_stack_[(3) - (1)].string_val)->append(":"); (yysemantic_stack_[(3) - (1)].string_val)->append(*(yysemantic_stack_[(3) - (3)].string_val)); @@ -2063,18 +2112,18 @@ namespace yy ;} break; - case 487: -#line 1162 "DynareBison.yy" + case 503: +#line 1195 "DynareBison.yy" { (yysemantic_stack_[(3) - (1)].string_val)->append(":"); (yysemantic_stack_[(3) - (1)].string_val)->append(*(yysemantic_stack_[(3) - (3)].string_val)); delete (yysemantic_stack_[(3) - (3)].string_val); (yyval.string_val) = (yysemantic_stack_[(3) - (1)].string_val); ;} break; - case 488: -#line 1165 "DynareBison.yy" + case 504: +#line 1198 "DynareBison.yy" { (yysemantic_stack_[(2) - (2)].string_val)->insert(0, "["); (yyval.string_val) = (yysemantic_stack_[(2) - (2)].string_val);;} break; - case 489: -#line 1167 "DynareBison.yy" + case 505: +#line 1200 "DynareBison.yy" { (yysemantic_stack_[(2) - (1)].string_val)->append(" "); (yysemantic_stack_[(2) - (1)].string_val)->append(*(yysemantic_stack_[(2) - (2)].string_val)); @@ -2083,14 +2132,14 @@ namespace yy ;} break; - case 490: -#line 1175 "DynareBison.yy" + case 506: +#line 1208 "DynareBison.yy" { (yysemantic_stack_[(2) - (1)].string_val)->append("]"); (yyval.string_val) = (yysemantic_stack_[(2) - (1)].string_val); ;} break; /* Line 675 of lalr1.cc. */ -#line 2094 "DynareBison.cc" +#line 2143 "DynareBison.cc" default: break; } YY_SYMBOL_PRINT ("-> $$ =", yyr1_[yyn], &yyval, &yyloc); @@ -2297,111 +2346,115 @@ namespace yy /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing STATE-NUM. */ - const short int parser::yypact_ninf_ = -864; + const short int parser::yypact_ninf_ = -911; const short int parser::yypact_[] = { - 803, 146, -48, 190, 71, 182, 188, -31, -14, -26, - -24, -9, 82, 133, 309, 185, 150, 103, 237, 77, - 286, 239, 204, 286, 329, 84, -864, 282, 297, 286, - 311, 493, 462, 486, 209, 234, 286, 453, 474, 488, - 286, 517, -864, -864, -864, -864, -864, -864, -864, -864, - -864, -864, -864, -864, -864, -864, -864, -864, -864, -864, - -864, -864, -864, -864, -864, -864, -864, -864, -864, -864, - -864, -864, -864, -864, -864, -864, -864, -864, -864, -864, - -864, -864, -864, -864, -864, 543, 64, -864, 460, 24, - 131, 514, 137, 526, 556, 617, -864, 643, -6, 32, - 196, 197, 586, 556, -864, 174, 14, 81, 363, 590, - -864, 901, 217, 291, 591, -864, 901, 292, 302, 548, - 367, 625, 520, 673, 412, 412, 368, 81, 518, -864, - 583, -864, 460, -864, 952, 379, -864, 857, 439, 440, - 559, 444, 563, 445, 567, 451, 483, -864, -864, 535, - 640, -51, 260, -864, 686, -30, -864, -864, 571, -864, - -864, 654, 193, -864, 655, 246, 701, 46, -864, 659, - -864, 704, -864, 705, 706, -864, 710, 712, -864, 713, - 714, 715, 720, 721, -864, -864, 722, 726, 727, 733, - 735, 736, -864, -864, 737, 738, -864, 739, -864, -864, - -864, 742, 743, 744, 745, -864, -864, 746, 751, -20, - -864, -864, -864, -864, -864, -864, -864, -864, -864, -864, - -864, -864, -864, -864, -864, -864, -864, -864, -864, -864, - -864, -864, -864, -864, -864, -864, -864, -864, -864, -864, - -864, -864, -864, -864, -864, -864, -864, -864, -864, -864, - 767, 682, -864, 729, -864, 732, 52, -864, 671, 748, - 677, 749, 203, -864, 750, 678, 752, 240, -864, 674, - 49, -864, 54, 181, -864, 679, 689, 778, -864, -864, - 127, -864, -864, -864, -864, 758, 773, 68, -864, -864, - -864, 694, 363, 363, 700, 708, 724, 730, 731, 753, - 760, 761, 762, 765, 363, 821, 768, 58, -864, 829, - 832, 844, 845, 848, -864, -864, -864, 852, 855, 859, - 860, -864, 862, -864, 868, 869, -864, -864, 142, -864, - -864, -864, -864, -864, -864, -864, -864, -864, -864, -864, - -864, -864, -864, -864, -864, -864, -864, -864, -864, -864, - -864, 241, 63, 149, -864, -864, -864, 786, 847, -864, - 770, -864, -864, -864, 777, 673, 673, 779, 781, 783, - 789, 794, 795, 804, 814, 816, 817, 673, 663, -864, - 172, -864, -864, -864, -864, -864, -864, -864, -864, -864, - -864, -864, -864, -864, -864, 201, -864, 78, 18, 219, - -864, -864, 336, -864, -864, 406, -864, -864, 931, -864, - 423, -864, -864, -864, -864, -864, 813, 898, -864, -864, - 854, 905, -864, -864, 864, 907, -864, -864, 837, 838, - 919, 254, 963, -864, -864, 951, 460, 846, -864, 849, - -11, 926, 865, 255, 932, 363, -864, -864, -864, 973, - 950, 870, 979, 980, 983, 985, 993, 996, 998, 1002, - 357, 1012, 1006, 1010, 1016, 1022, 1008, 12, 922, 1037, - 1044, 1020, 1030, 1050, 643, 256, 1057, 1080, 1081, -864, - -864, -864, 47, 1082, 220, 1083, -864, -864, 1103, 220, - 1105, -864, -864, 175, -864, -864, -864, 1070, 17, -864, - 132, -864, 1011, 1018, 395, 14, 278, 1106, 36, -864, - -864, 363, 1015, 513, 363, 363, 363, 363, 363, 363, - 363, 363, 363, 363, 629, 363, 363, 363, 363, 363, - -864, 363, -864, -864, 1137, 1144, 1157, 1168, 1175, 220, - 1190, 1196, 499, 1199, 1210, 1212, 901, 276, 1186, 1061, - -864, 648, 281, -864, 1147, -864, 175, 1132, 555, 673, - 673, 673, 673, 673, 673, 673, 673, 673, 673, 719, - 673, 673, 673, 673, 673, 1117, 412, 293, 315, -864, - -864, -864, 363, 461, 22, 583, 1128, 460, 1130, 952, - 326, 1250, 857, 369, -864, 1172, -864, 1173, -864, 1189, - -864, 1247, 1151, 1155, 1156, 363, -864, -864, -864, -864, - -864, 497, 1158, -864, -864, 503, 1159, 1067, -864, -864, - 1262, 5, -864, -864, -864, -864, -864, -864, -864, -864, - -864, -864, -864, -864, -864, -864, -864, -864, -864, -864, - -864, 1152, -864, -864, -864, -864, 1161, -864, -864, -864, - 505, -864, 1241, 1242, -864, -864, -864, -864, -864, -864, - -864, -864, 537, 1166, 1191, 1192, 1246, 1194, 220, 1251, - 1174, 220, -864, 1279, 1281, 1176, 1298, -864, -864, -864, - 673, -864, -864, -864, -864, -864, -864, -864, -864, -864, - -864, -864, 401, 184, -864, 1256, 363, 1258, 20, 709, - 434, 725, 808, 853, 883, 889, 903, 916, 934, 941, - 947, -864, 513, 513, 1015, 1015, 1197, 954, -864, -864, - -864, -864, -864, -864, -864, -864, -864, -864, -864, -864, - -864, -864, -864, 521, 363, -864, 1260, 1074, -864, 522, - -864, 1180, 961, 967, 974, 981, 987, 994, 1001, 1007, - 1014, 1021, -864, 555, 555, 1132, 1132, 1197, -864, -864, - -864, 531, -864, 581, 1027, 18, 1183, -864, -864, 37, - 363, -864, -864, -864, -864, -864, -864, 585, -864, -864, - -864, 595, -864, -864, -864, 1182, 1307, -864, -864, 1085, - -864, 376, -864, 386, -864, 1184, -864, -864, -864, 1265, - -864, 452, 1266, -864, -864, -864, -864, -864, -864, 220, - 47, 1213, 220, 1214, 1215, -864, 1193, -864, -864, 1311, - 673, 1092, 181, 181, 278, -864, 220, -864, 1316, 1098, - 1317, 1302, 363, 363, -864, 363, -864, -864, -864, -864, - -864, -864, -864, -864, -864, -864, -864, 1198, -864, 1108, - 363, -864, -864, -864, -864, -864, -864, -864, -864, -864, - -864, -864, -864, -864, -864, -864, -864, 22, -864, -864, - -864, 363, 1034, -864, -864, 1151, 363, -864, -864, 596, - -864, 597, 1303, 1195, 1152, -864, -864, -864, 1222, 1223, - 1224, 220, 1203, 220, 220, -864, 363, 1116, -864, 43, - 69, 207, 1202, 363, -864, 363, 1201, 66, 1122, 734, - 734, -864, -864, 1131, 1041, -864, 1328, 1140, -864, -864, - -864, 1230, -864, 220, 220, 220, 1231, -864, 1209, 1211, - 1146, -864, -864, -864, 220, -864, 1154, 1164, 1318, 1206, - 1319, 1244, -864, -864, -864, 363, -864, 19, 1238, -864, - 1239, 220, -864, -864, -864, 1216, -864, -864, -864, 1323, - 1217, 72, 1170, 1299, -864, 220, 212, 1219, -864, -864, - 1329, -864, -864, 582, 598, 363, 62, -864, -864, -864, - 1218, 1245, 1249, -864, -864, -864, -864, 1047, -864, -864, - 363, -864, -864, -864, 220, 220, -864, 1054, 1252, -864, - -864, 220, -864 + 964, 185, -38, 411, 268, 35, -6, 62, -23, 117, + -10, 81, 114, 119, 475, 478, -34, 148, 105, 166, + 158, 225, 189, 160, 225, 291, 99, -911, 214, 344, + 225, 371, 400, 505, 538, 187, 209, 225, 462, 468, + 474, 225, 658, -911, -911, -911, -911, -911, -911, -911, + -911, -911, -911, -911, -911, -911, -911, -911, -911, -911, + -911, -911, -911, -911, -911, -911, -911, -911, -911, -911, + -911, -911, -911, -911, -911, -911, -911, -911, -911, -911, + -911, -911, -911, -911, -911, -911, -911, 535, 52, -911, + 479, 552, 441, 12, 108, 527, 430, 533, 543, 577, + -911, 772, 164, 40, 208, 219, 560, 543, 576, -911, + 289, 226, 53, 243, 569, -911, 1088, 261, 262, 572, + -911, 1088, 263, 276, 493, 303, 616, 494, 829, 250, + 250, 337, 53, 507, -911, 570, -911, 479, -911, 1133, + 373, -911, 1018, 379, 380, 548, 386, 559, 389, 574, + 390, 392, -911, -911, 540, 612, -16, 439, -911, 673, + -33, -911, -911, 561, -911, 562, -911, -911, 628, 277, + -911, 639, 299, 686, 58, -911, 643, -911, 692, -911, + 694, 696, -911, 697, 701, -911, 702, 703, 705, 712, + 713, -911, -911, 718, 720, 726, 727, 729, 732, -911, + -911, 733, 734, -911, 743, -911, -911, -911, 747, 749, + 750, 751, -911, -911, 761, 765, -31, -911, -911, -911, + -911, -911, -911, -911, -911, -911, -911, -911, -911, -911, + -911, -911, -911, -911, -911, -911, -911, -911, -911, -911, + -911, -911, -911, -911, -911, -911, -911, -911, -911, -911, + -911, -911, -911, -911, -911, -911, -911, 773, 707, -911, + 728, -911, 730, 193, -911, 678, 737, 681, 740, 205, + -911, 741, 685, 744, 207, -911, 662, 61, -911, 64, + 795, 668, 753, -911, -9, 695, 706, 825, -911, -911, + 138, -911, -911, -911, -911, 784, 789, 91, -911, -911, + -911, 715, 243, 243, 717, 719, 721, 724, 725, 735, + 745, 752, 754, 756, 243, 602, 757, 251, -911, 833, + 836, 839, 845, 853, 854, -911, -911, -911, 859, 860, + 876, 877, -911, 889, -911, 895, 897, -911, -911, 145, + -911, -911, -911, -911, -911, -911, -911, -911, -911, -911, + -911, -911, -911, -911, -911, -911, -911, -911, -911, -911, + -911, -911, -911, 566, 369, 172, -911, -911, -911, 810, + 858, -911, 779, -911, -911, -911, 783, 829, 829, 785, + 796, 797, 798, 799, 800, 802, 804, 805, 808, 829, + 541, -911, 173, -911, -911, -911, -911, -911, -911, -911, + -911, -911, -911, -911, -911, -911, -911, 175, -911, 93, + 29, 266, -911, -911, 279, -911, -911, 385, -911, -911, + 911, -911, 401, -911, -911, -911, -911, -911, 844, 891, + -911, -911, 846, 905, -911, -911, 861, 906, -911, -911, + 831, 835, 912, 425, 973, -911, -911, 946, 479, 849, + -911, -911, 850, -14, 931, 856, -1, 933, 243, -911, + -911, -911, 971, 941, 864, 978, 979, 981, 983, 984, + 985, 990, 991, 517, 1005, 997, 998, 999, 1000, 977, + 6, 892, 1006, 1008, 1023, 989, 993, 772, 54, 994, + 1046, 944, -911, -911, -911, 60, 945, 184, 947, -911, + -911, 950, 184, 952, -911, -911, 19, -911, -911, -911, + 1003, 930, 1011, 30, -911, 23, -911, 43, -911, 934, + 939, 239, 226, -21, 956, 49, -911, -911, 243, 957, + -49, 243, 243, 243, 243, 243, 243, 243, 243, 243, + 243, 635, 243, 243, 243, 243, 243, -911, 243, -911, + -911, 1058, 1061, 1060, 1065, 1067, 1072, 184, 1077, 1079, + 531, 1087, 1089, 1093, 1088, 112, 1055, 1194, -911, 803, + 218, -911, 1014, -911, 19, 1013, 465, 829, 829, 829, + 829, 829, 829, 829, 829, 829, 829, 709, 829, 829, + 829, 829, 829, 986, 250, 236, 252, -911, -911, -911, + 243, 341, 59, 570, 988, 479, 1009, 1133, 260, 1111, + 1018, 273, -911, 1031, -911, 1033, -911, 1040, -911, 1116, + 1015, 1010, 1016, 243, -911, -911, -911, -911, -911, 393, + 1017, -911, -911, 398, 1027, 1201, -911, -911, 1118, 4, + -911, -911, -911, -911, -911, -911, -911, -911, -911, -911, + -911, -911, -911, -911, -911, -911, -911, -911, -911, 1032, + -911, -911, -911, -911, 1021, -911, -911, -911, 428, -911, + 1097, 1100, -911, -911, -911, -911, -911, -911, -911, -911, + 532, 1041, 1063, 1068, 1131, 1076, 184, 1135, 1057, 184, + -911, 1173, 1175, 1066, -911, 543, 1185, -911, -911, -911, + 829, -911, -911, -911, 404, -911, -911, 1070, -911, -911, + -911, -911, -911, -911, -911, -911, -911, -911, -30, 274, + -911, 1152, 243, 1158, -25, 663, 408, 722, 781, 794, + 865, 879, 885, 968, 982, 1012, 1024, -911, -49, -49, + 957, 957, 1101, 1052, -911, -911, -911, -911, -911, -911, + -911, -911, -911, -911, -911, -911, -911, -911, -911, -911, + 440, 243, -911, 1160, 1207, -911, 452, -911, 1084, 1069, + 1083, 1096, 1114, 1121, 1127, 1134, 1141, 1147, 1154, -911, + 465, 465, 1013, 1013, 1101, -911, -911, -911, 456, -911, + 477, 1161, 29, 1090, -911, -911, 57, 243, -911, -911, + -911, -911, -911, -911, 487, -911, -911, -911, 488, -911, + -911, -911, 1094, 1229, -911, -911, 1217, -911, 286, -911, + 288, -911, 1105, -911, -911, -911, 1191, -911, 414, 1198, + -911, -911, -911, -911, -911, -911, 184, 60, 1214, 184, + 1215, 1216, -911, 1138, -911, -911, 1257, 375, 829, 1225, + 43, -911, 753, 753, 753, -21, -911, 184, -911, 1277, + 1231, 1284, 1307, 243, 243, -911, 243, -911, -911, -911, + -911, -911, -911, -911, -911, -911, -911, -911, 1171, -911, + 1240, 243, -911, -911, -911, -911, -911, -911, -911, -911, + -911, -911, -911, -911, -911, -911, -911, -911, 59, -911, + -911, -911, 243, 1167, -911, -911, 1015, 243, -911, -911, + 530, -911, 564, 1310, 1206, 1032, -911, -911, -911, 1238, + 1239, 1245, 184, 1178, 184, 184, -911, 243, -911, 1249, + -911, -911, 1224, 56, 213, 482, 335, 1235, 243, -911, + 243, 1222, 28, 1255, 787, 787, -911, -911, 1263, 1174, + -911, 1365, 1273, -911, -911, -911, 1268, -911, 184, 184, + 184, 1270, -911, 1248, 1250, 1279, -911, 753, -911, -911, + -911, 184, -911, 1286, 1297, 1369, 1264, 1378, 1301, -911, + -911, -911, 243, -911, 18, 1295, -911, 1311, 184, -911, + -911, -911, 512, 1272, -911, -911, -911, 1389, 1285, 74, + 1304, 1370, -911, 184, 217, 1291, -911, -911, -911, 1400, + -911, -911, 539, 542, 243, 72, -911, -911, -911, 1287, + 1316, 1318, -911, -911, -911, -911, 1181, -911, -911, 243, + -911, -911, -911, 184, 184, -911, 1187, 1319, -911, -911, + 184, -911 }; /* YYDEFACT[S] -- default rule to reduce with in state S when YYTABLE @@ -2412,153 +2465,159 @@ namespace yy { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 408, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 423, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 2, 4, 27, 28, 42, 43, 44, 41, - 5, 10, 7, 8, 9, 6, 11, 12, 13, 14, - 15, 16, 17, 21, 23, 22, 18, 19, 20, 24, - 25, 26, 29, 30, 31, 36, 37, 32, 33, 34, - 35, 38, 39, 40, 377, 0, 0, 189, 0, 0, - 0, 0, 0, 0, 0, 228, 275, 0, 0, 0, - 0, 0, 0, 0, 113, 0, 0, 0, 0, 0, - 359, 0, 0, 0, 0, 355, 0, 0, 0, 72, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 194, - 0, 184, 0, 199, 0, 0, 411, 0, 0, 0, - 54, 0, 60, 0, 66, 0, 0, 1, 3, 0, - 0, 374, 0, 370, 0, 0, 192, 193, 0, 45, - 387, 0, 0, 381, 0, 0, 0, 0, 107, 0, - 464, 0, 481, 0, 0, 469, 0, 0, 447, 0, - 0, 0, 0, 0, 461, 462, 0, 0, 0, 0, - 0, 0, 483, 457, 0, 0, 468, 0, 482, 463, - 446, 0, 0, 0, 0, 467, 465, 0, 0, 0, - 280, 316, 305, 281, 282, 283, 284, 285, 286, 287, - 288, 289, 290, 291, 292, 293, 294, 295, 296, 297, - 298, 299, 300, 301, 302, 303, 304, 306, 307, 308, - 309, 310, 311, 312, 313, 314, 315, 317, 318, 319, - 224, 0, 277, 0, 241, 0, 0, 238, 0, 0, - 0, 0, 0, 260, 0, 0, 0, 0, 254, 0, - 0, 111, 0, 0, 422, 0, 0, 0, 477, 476, - 0, 393, 394, 395, 396, 0, 0, 0, 152, 81, - 82, 80, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 346, 0, - 0, 0, 0, 0, 427, 428, 429, 0, 0, 0, - 0, 470, 0, 434, 0, 0, 364, 365, 0, 205, - 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, - 216, 218, 219, 220, 221, 222, 223, 217, 363, 361, - 367, 0, 0, 0, 357, 354, 75, 70, 0, 51, - 0, 76, 127, 128, 147, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 409, 126, - 0, 323, 328, 324, 325, 326, 327, 329, 330, 331, - 332, 333, 334, 335, 336, 0, 47, 0, 0, 0, - 197, 198, 0, 187, 188, 0, 204, 201, 0, 417, - 0, 416, 418, 413, 348, 57, 52, 0, 48, 63, - 58, 0, 49, 69, 64, 0, 50, 343, 0, 0, - 0, 0, 0, 368, 369, 0, 0, 0, 46, 0, - 0, 0, 0, 0, 0, 0, 105, 106, 229, 0, + 0, 0, 0, 2, 4, 28, 29, 43, 44, 45, + 42, 5, 6, 11, 8, 9, 10, 7, 12, 13, + 14, 15, 16, 17, 18, 22, 24, 23, 19, 20, + 21, 25, 26, 27, 30, 31, 32, 37, 38, 33, + 34, 35, 36, 39, 40, 41, 392, 0, 0, 203, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 243, + 290, 0, 0, 0, 0, 0, 0, 0, 0, 123, + 0, 0, 0, 0, 0, 374, 0, 0, 0, 0, + 370, 0, 0, 0, 73, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 208, 0, 198, 0, 213, 0, + 0, 426, 0, 0, 0, 55, 0, 61, 0, 67, + 0, 0, 1, 3, 0, 0, 389, 0, 385, 0, + 0, 206, 207, 0, 79, 0, 46, 402, 0, 0, + 396, 0, 0, 0, 0, 112, 0, 480, 0, 497, + 0, 0, 485, 0, 0, 463, 0, 0, 0, 0, + 0, 477, 478, 0, 0, 0, 0, 0, 0, 499, + 473, 0, 0, 484, 0, 498, 479, 462, 0, 0, + 0, 0, 483, 481, 0, 0, 0, 295, 331, 320, + 296, 297, 298, 299, 300, 301, 302, 303, 304, 305, + 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, + 316, 317, 318, 319, 321, 322, 323, 324, 325, 326, + 327, 328, 329, 330, 332, 333, 334, 239, 0, 292, + 0, 256, 0, 0, 253, 0, 0, 0, 0, 0, + 275, 0, 0, 0, 0, 269, 0, 0, 116, 0, + 0, 0, 0, 437, 0, 0, 0, 0, 493, 492, + 0, 408, 409, 410, 411, 0, 0, 0, 166, 84, + 85, 83, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 361, 0, + 0, 0, 0, 0, 0, 442, 443, 444, 0, 0, + 0, 0, 486, 0, 450, 0, 0, 379, 380, 0, + 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, + 229, 230, 232, 233, 234, 235, 236, 237, 238, 231, + 378, 376, 382, 0, 0, 0, 372, 369, 76, 71, + 0, 52, 0, 77, 141, 142, 161, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 424, 140, 0, 338, 343, 339, 340, 341, 342, 344, + 345, 346, 347, 348, 349, 350, 351, 0, 48, 0, + 0, 0, 211, 212, 0, 201, 202, 0, 218, 215, + 0, 432, 0, 431, 433, 428, 363, 58, 53, 0, + 49, 64, 59, 0, 50, 70, 65, 0, 51, 358, + 0, 0, 0, 0, 0, 383, 384, 0, 0, 0, + 80, 47, 0, 0, 0, 0, 0, 0, 0, 110, + 111, 244, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 226, 0, 240, - 236, 237, 269, 0, 269, 0, 258, 259, 0, 269, - 0, 252, 253, 0, 109, 110, 104, 0, 0, 121, - 0, 122, 0, 0, 0, 0, 0, 0, 0, 150, - 151, 0, 88, 89, 0, 0, 0, 0, 0, 0, + 241, 0, 255, 251, 252, 284, 0, 284, 0, 273, + 274, 0, 284, 0, 267, 268, 0, 114, 115, 107, + 0, 0, 0, 0, 135, 0, 136, 0, 131, 0, + 0, 0, 0, 0, 0, 0, 164, 165, 0, 91, + 92, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 81, 0, 359, + 360, 0, 0, 0, 0, 0, 0, 284, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 364, 0, + 0, 74, 72, 78, 0, 148, 149, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 78, 0, 344, 345, 0, 0, 0, 0, 0, 269, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 349, 0, 0, 73, 71, 77, 0, 134, 135, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 149, - 182, 183, 0, 0, 174, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 55, 53, 61, 59, 67, 65, - 378, 0, 374, 0, 0, 0, 420, 191, 190, 390, - 385, 0, 0, 384, 379, 0, 0, 0, 448, 438, - 0, 0, 480, 441, 466, 430, 471, 472, 444, 445, - 450, 453, 454, 451, 459, 460, 449, 456, 455, 440, - 439, 0, 442, 443, 458, 478, 0, 479, 279, 276, - 0, 225, 0, 0, 264, 271, 265, 270, 267, 272, - 266, 268, 0, 0, 0, 246, 0, 0, 269, 0, - 0, 269, 232, 0, 0, 0, 0, 114, 119, 120, - 0, 124, 117, 115, 474, 475, 392, 403, 405, 406, - 407, 404, 0, 397, 401, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 79, 84, 83, 85, 86, 87, 0, 426, 419, - 425, 431, 432, 473, 423, 433, 437, 436, 424, 421, - 435, 366, 360, 0, 0, 352, 0, 0, 356, 0, - 74, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 125, 130, 129, 131, 132, 133, 410, 322, - 320, 0, 337, 0, 0, 0, 0, 179, 180, 0, - 0, 196, 195, 186, 185, 203, 200, 0, 484, 415, - 412, 0, 56, 62, 68, 0, 0, 376, 375, 0, - 386, 0, 380, 0, 108, 486, 488, 490, 489, 0, - 341, 0, 0, 278, 227, 242, 274, 273, 239, 269, - 269, 0, 269, 0, 0, 257, 0, 231, 230, 0, - 0, 0, 0, 0, 0, 391, 269, 402, 0, 0, - 0, 0, 0, 0, 100, 0, 101, 90, 91, 92, - 93, 94, 95, 96, 97, 98, 99, 0, 362, 0, - 0, 350, 358, 148, 136, 137, 138, 139, 140, 141, - 142, 143, 144, 145, 321, 338, 181, 173, 172, 176, - 177, 0, 0, 202, 414, 374, 0, 371, 388, 0, - 382, 0, 0, 0, 0, 452, 485, 243, 0, 0, - 0, 269, 0, 269, 269, 255, 0, 0, 123, 0, - 0, 398, 0, 0, 155, 0, 163, 0, 0, 102, - 103, 347, 353, 0, 0, 178, 0, 0, 389, 383, - 487, 0, 342, 269, 269, 269, 0, 263, 0, 0, - 0, 146, 118, 116, 269, 399, 0, 0, 0, 158, - 0, 0, 154, 351, 175, 0, 372, 269, 248, 244, - 247, 269, 261, 256, 112, 0, 157, 156, 162, 0, - 160, 0, 0, 0, 340, 269, 0, 0, 400, 159, - 0, 235, 169, 0, 0, 0, 0, 168, 167, 373, - 0, 249, 0, 262, 161, 234, 233, 0, 166, 153, - 0, 165, 164, 339, 269, 269, 171, 0, 250, 245, - 170, 269, 251 + 0, 0, 0, 0, 0, 0, 0, 163, 196, 197, + 0, 0, 188, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 56, 54, 62, 60, 68, 66, 393, 0, + 389, 0, 0, 0, 435, 205, 204, 405, 400, 0, + 0, 399, 394, 0, 0, 0, 464, 454, 0, 0, + 496, 457, 482, 445, 487, 488, 460, 461, 466, 469, + 470, 467, 475, 476, 465, 472, 471, 456, 455, 0, + 458, 459, 474, 494, 0, 495, 294, 291, 0, 240, + 0, 0, 279, 286, 280, 285, 282, 287, 281, 283, + 0, 0, 0, 261, 0, 0, 284, 0, 0, 284, + 247, 0, 0, 0, 109, 0, 0, 124, 133, 134, + 0, 138, 121, 120, 0, 119, 122, 0, 127, 125, + 490, 491, 407, 418, 420, 421, 422, 419, 0, 412, + 416, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 82, 87, 86, + 88, 89, 90, 0, 441, 449, 434, 440, 446, 447, + 489, 438, 448, 453, 452, 439, 436, 451, 381, 375, + 0, 0, 367, 0, 0, 371, 0, 75, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 139, + 144, 143, 145, 146, 147, 425, 337, 335, 0, 352, + 0, 0, 0, 0, 193, 194, 0, 0, 210, 209, + 200, 199, 217, 214, 0, 500, 430, 427, 0, 57, + 63, 69, 0, 0, 391, 390, 0, 401, 0, 395, + 0, 113, 502, 504, 506, 505, 0, 356, 0, 0, + 293, 242, 257, 289, 288, 254, 284, 284, 0, 284, + 0, 0, 272, 0, 246, 245, 0, 0, 0, 0, + 0, 129, 0, 0, 0, 0, 406, 284, 417, 0, + 0, 0, 0, 0, 0, 103, 0, 104, 93, 94, + 95, 96, 97, 98, 99, 100, 101, 102, 0, 377, + 0, 0, 365, 373, 162, 150, 151, 152, 153, 154, + 155, 156, 157, 158, 159, 336, 353, 195, 187, 186, + 190, 191, 0, 0, 216, 429, 389, 0, 386, 403, + 0, 397, 0, 0, 0, 0, 468, 501, 258, 0, + 0, 0, 284, 0, 284, 284, 270, 0, 108, 0, + 137, 118, 0, 0, 0, 0, 413, 0, 0, 169, + 0, 177, 0, 0, 105, 106, 362, 368, 0, 0, + 192, 0, 0, 404, 398, 503, 0, 357, 284, 284, + 284, 0, 278, 0, 0, 0, 160, 0, 132, 128, + 126, 284, 414, 0, 0, 0, 172, 0, 0, 168, + 366, 189, 0, 387, 284, 263, 259, 262, 284, 276, + 271, 117, 0, 0, 171, 170, 176, 0, 174, 0, + 0, 0, 355, 284, 0, 0, 130, 415, 173, 0, + 250, 183, 0, 0, 0, 0, 182, 181, 388, 0, + 264, 0, 277, 175, 249, 248, 0, 180, 167, 0, + 179, 178, 354, 284, 284, 185, 0, 265, 260, 184, + 284, 266 }; /* YYPGOTO[NTERM-NUM]. */ const short int parser::yypgoto_[] = { - -864, -864, 1327, -864, -864, -864, -864, -864, -864, -864, - -864, -864, -864, -864, -864, -864, -286, -864, -864, -864, - 1268, -128, -864, -864, 1102, -864, -864, -864, -864, -178, - -493, -99, -484, -864, -864, -864, 1248, -216, -864, -864, - -864, -864, 609, -864, -864, 790, -864, -864, 940, -864, - -864, 793, -864, -864, -112, -19, -547, 403, -864, -864, - 1124, -864, -864, -863, -864, -864, 1114, -864, -864, 1120, - -777, -444, -864, -864, 909, -864, 1259, 809, -864, 502, - -864, -864, -864, -864, 1084, -864, -864, -864, -864, -864, - -864, 841, 1272, -864, -864, -864, 1237, -573, -864, -864, - -864, -864, -864, 885, -864, 568, -663, -864, -864, -864, - -864, -864, 801, -864, -86, -864, 1289, -864, -864, -864, - -864, -864, -864, -864, -89, -864, -864, -107, -864, -864, - -864, -864, -864, -864, -864, -864, -864, -864, -85, -84, - -864, -864, -864, -864, -864, -864, -864, -864, -78, -864, - -864, -864, -864, -864, -77, -71, -70, -69, -66, -65, - -864, -864, -864, -864, -864, -864, -864, -63, -56, -55, - -864, -864, -864, -864, -864, 774, -864, 929 + -911, -911, 1405, -911, -911, -911, -911, -911, -911, -911, + -911, -911, -911, -911, -911, -911, -911, -296, -911, -911, + -911, -911, -102, -172, -911, -911, 1172, -911, 598, -911, + -911, -911, -911, -911, -911, -779, -494, -108, -488, -911, + -911, -911, 1320, -253, -911, -911, -911, -911, 659, -911, + -911, 851, -911, -911, 1002, -911, -911, 852, -911, -911, + -100, -20, -520, 442, -911, -911, 1195, -911, -911, -910, + -911, -911, 1180, -911, -911, 1190, -794, -471, -911, -911, + 974, -911, 1330, 868, -911, 549, -911, -911, -911, -911, + 1146, -911, -911, -911, -911, -911, -911, 901, 1345, -911, + -911, -911, 1312, -584, -911, -911, -911, -911, -911, 948, + -911, 613, -678, -911, -911, -911, -911, -911, 857, -911, + -79, -911, 1361, -911, -911, -911, -911, -911, -911, -911, + -92, -911, -911, -112, -477, -911, -911, -911, -911, -911, + -911, -911, -911, -911, -911, -93, -89, -911, -911, -911, + -911, -911, -911, -911, -911, -88, -911, -911, -911, -911, + -911, -87, -74, -73, -72, -71, -69, -911, -911, -911, + -911, -911, -911, -911, -68, -67, -66, -911, -911, -911, + -911, -911, 834, -911, 992 }; /* YYDEFGOTO[NTERM-NUM]. */ const short int parser::yydefgoto_[] = { - -1, 41, 42, 43, 44, 45, 46, 47, 48, 49, - 141, 143, 145, 120, 50, 51, 305, 700, 52, 53, - 167, 168, 54, 270, 271, 55, 273, 823, 822, 498, - 499, 500, 501, 379, 56, 57, 287, 288, 907, 976, - 58, 583, 584, 59, 402, 403, 60, 155, 156, 61, - 399, 400, 62, 405, 326, 98, 675, 978, 63, 256, - 257, 258, 663, 887, 64, 267, 268, 65, 262, 263, - 664, 888, 66, 209, 210, 67, 380, 381, 68, 800, - 801, 69, 70, 307, 308, 71, 72, 352, 73, 74, - 75, 327, 328, 76, 77, 152, 153, 432, 78, 79, - 80, 81, 280, 281, 692, 693, 694, 82, 123, 575, - 83, 410, 411, 329, 330, 331, 332, 333, 334, 335, - 336, 337, 338, 339, 340, 341, 342, 343, 344, 345, - 346, 213, 214, 215, 216, 217, 218, 219, 383, 384, - 222, 223, 224, 225, 226, 227, 228, 229, 385, 231, - 232, 233, 234, 235, 386, 387, 388, 389, 390, 391, - 347, 242, 243, 348, 282, 283, 284, 392, 393, 394, - 247, 248, 249, 412, 647, 796, 621, 622 + -1, 42, 43, 44, 45, 46, 47, 48, 49, 50, + 146, 148, 150, 125, 51, 52, 53, 315, 726, 54, + 281, 55, 174, 175, 56, 277, 278, 704, 705, 57, + 282, 854, 853, 932, 707, 513, 514, 515, 516, 391, + 58, 59, 297, 298, 942, 1015, 60, 601, 602, 61, + 414, 415, 62, 160, 161, 63, 411, 412, 64, 417, + 337, 102, 693, 1017, 65, 263, 264, 265, 681, 918, + 66, 274, 275, 67, 269, 270, 682, 919, 68, 216, + 217, 69, 392, 393, 70, 827, 828, 71, 72, 317, + 318, 73, 74, 364, 75, 76, 77, 338, 339, 78, + 79, 157, 158, 444, 80, 81, 82, 83, 290, 291, + 718, 719, 720, 84, 128, 593, 85, 422, 423, 340, + 341, 342, 343, 344, 345, 346, 347, 348, 349, 350, + 351, 352, 353, 354, 355, 356, 357, 358, 220, 221, + 222, 223, 224, 225, 226, 395, 396, 229, 230, 231, + 232, 233, 234, 235, 236, 397, 238, 239, 240, 241, + 242, 398, 399, 400, 401, 402, 403, 359, 249, 250, + 360, 292, 293, 294, 404, 405, 406, 254, 255, 256, + 424, 665, 823, 639, 640 }; /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If @@ -2568,292 +2627,308 @@ namespace yy const short int parser::yytable_[] = { - 112, 113, 157, 117, 118, 678, 512, 513, 212, 741, - 126, 211, 220, 221, 679, 135, 138, 139, 524, 230, - 236, 146, 406, 401, 378, 409, 237, 238, 239, 786, - 827, 240, 241, 889, 244, 382, 382, 677, 665, 447, - 667, 245, 246, 795, 253, 670, 404, 362, 580, 655, - 639, 95, 767, 654, 95, 363, 581, 657, 696, 250, - 768, 949, 158, 932, 253, 549, 446, 869, 150, 494, - 430, 510, 480, 362, 496, 870, 277, 655, 532, 656, - 285, 363, 364, 550, 659, 657, 658, 278, 509, 933, - 285, 436, 971, 285, 431, 723, 86, 254, 579, 362, - 672, 474, 971, 279, 939, 831, 121, 363, 364, 89, - 672, 166, 659, 94, 269, 251, 437, 254, 99, 166, - 100, 660, 122, 306, 832, 108, 475, 988, 551, 151, - 96, 97, 999, 610, 364, 101, 255, 972, 252, 365, - 366, 662, 95, 769, 447, 367, 368, 369, 370, 371, - 372, 373, 374, 375, 680, 797, 255, 697, 661, 617, - 376, 620, 377, 582, 497, 365, 366, 770, 159, 662, - 963, 367, 368, 369, 370, 371, 372, 373, 374, 375, - 698, 510, 871, 286, 973, 974, 376, 940, 377, 982, - 497, 365, 366, 286, 973, 974, 286, 367, 368, 369, - 370, 371, 372, 373, 374, 375, 989, 990, 259, 264, - 941, 362, 376, 672, 377, 259, 497, 975, 654, 363, - 274, 110, 111, 486, 813, 699, 102, 816, 701, 702, - 703, 704, 705, 706, 707, 708, 709, 710, 827, 712, - 713, 714, 715, 716, 656, 717, 364, 90, 505, 687, - 655, 658, 264, 92, 570, 571, 572, 573, 657, 574, - 491, 260, 265, 546, 150, 737, 557, 558, 260, 95, - 546, 289, 687, 506, 95, 160, 681, 103, 569, 290, - 433, 163, 250, 161, 603, 659, 660, 275, 547, 164, - 84, 85, 604, 576, 107, 552, 764, 673, 674, 95, - 261, 266, 916, 365, 366, 265, 291, 261, 688, 367, - 368, 369, 370, 371, 372, 373, 374, 375, 577, 789, - 95, 95, 576, 661, 376, 151, 377, 91, 497, 826, - 106, 688, 689, 93, 87, 88, 690, 691, 251, 440, - 585, 95, 662, 687, 266, 441, 95, 578, 115, 116, - 157, 95, 934, 133, 134, 689, 250, 250, 95, 690, - 691, 349, 548, 292, 293, 586, 890, 250, 892, 294, - 295, 296, 297, 298, 299, 300, 301, 302, 136, 137, - 95, 109, 902, 114, 303, 212, 304, 631, 211, 220, - 221, 95, 443, 289, 119, 632, 230, 236, 444, 614, - 649, 290, 688, 237, 238, 239, 678, 678, 240, 241, - 829, 244, 251, 251, 977, 679, 679, 170, 245, 246, - 732, 611, 171, 251, 615, 738, 689, 124, 291, 991, - 690, 691, 357, 250, 95, 350, 354, 760, 684, 174, - 175, 95, 125, 177, 250, 178, 355, 926, 849, 928, - 929, 95, 179, 104, 105, 127, 650, 587, 685, 762, - 742, 743, 744, 745, 746, 747, 748, 749, 750, 751, - 776, 753, 754, 755, 756, 757, 196, 775, 401, 948, - 409, 950, 588, 200, 872, 292, 293, 382, 358, 251, - 955, 294, 295, 296, 297, 298, 299, 300, 301, 302, - 251, 404, 204, 964, 250, 250, 303, 967, 304, 416, - 420, 359, 396, 780, 205, 128, 424, 147, 140, 206, - 878, 981, 824, 407, 1, 2, 3, 589, 733, 726, - 880, 207, 208, 739, 4, 5, 6, 727, 7, 142, - 8, 9, 10, 11, 592, 825, 908, 909, 250, 910, - 998, 12, 590, 144, 13, 835, 149, 1002, 761, 763, - 251, 251, 250, 154, 913, 417, 421, 806, 250, 593, - 250, 777, 425, 884, 781, 807, 14, 15, 16, 162, - 836, 821, 17, 413, 414, 914, 250, 250, 418, 422, - 917, 165, 18, 19, 20, 426, 250, 21, 885, 22, - 23, 24, 25, 26, 251, 765, 129, 130, 27, 28, - 930, 766, 985, 29, 30, 31, 32, 936, 251, 937, - 817, 166, 33, 34, 251, 35, 251, 427, 986, 36, - 131, 132, 37, 38, 39, 40, 818, 527, 528, 169, - 529, 790, 251, 251, 899, 900, 250, 792, 170, 803, - 250, 269, 251, 171, 172, 306, 351, 173, 356, 962, - 250, 250, 250, 360, 361, 848, 852, 398, 319, 415, - 174, 175, 176, 419, 177, 864, 178, 423, 289, 572, - 573, 428, 574, 179, 180, 181, 290, 182, 183, 987, - 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, - 194, 195, 251, 362, 997, 429, 251, 196, 435, 197, - 198, 363, 199, 291, 200, 438, 251, 251, 251, 439, - 442, 897, 201, 445, 448, 865, 449, 450, 451, 873, - 202, 203, 452, 204, 453, 454, 455, 456, 364, 874, - 918, 919, 457, 458, 459, 205, 154, 477, 460, 461, - 206, 525, 526, 527, 528, 462, 529, 463, 464, 465, - 466, 467, 207, 208, 468, 469, 470, 471, 472, 736, - 292, 293, 879, 473, 881, 711, 294, 295, 296, 297, - 298, 299, 300, 301, 302, 570, 571, 572, 573, 476, - 574, 303, 482, 304, 478, 365, 366, 479, 484, 489, - 504, 367, 368, 369, 370, 371, 372, 373, 374, 375, - 1, 2, 3, 483, 485, 488, 376, 490, 377, 493, - 4, 5, 6, 507, 7, 502, 8, 9, 10, 11, - 833, 525, 526, 527, 528, 503, 529, 12, 508, 511, - 13, 570, 571, 572, 573, 514, 574, 525, 526, 527, - 528, 534, 529, 515, 535, 834, 525, 526, 527, 528, - 309, 529, 14, 15, 16, 752, 536, 537, 17, 516, - 538, 837, 310, 311, 539, 517, 518, 540, 18, 19, - 20, 541, 542, 21, 543, 22, 23, 24, 25, 26, - 544, 545, 312, 313, 27, 28, 553, 179, 519, 29, - 30, 31, 32, 274, 309, 520, 521, 522, 33, 34, - 523, 35, 554, 531, 555, 36, 310, 311, 37, 38, - 39, 40, 556, 594, 559, 314, 560, 315, 561, 316, - 525, 526, 527, 528, 562, 529, 312, 313, 318, 563, - 564, 179, 319, 525, 526, 527, 528, 274, 529, 565, - 320, 321, 322, 591, 838, 309, 323, 324, 325, 566, - 154, 567, 568, 595, 596, 530, 408, 310, 311, 314, - 597, 315, 599, 316, 598, 525, 526, 527, 528, 317, - 529, 600, 318, 601, 602, 605, 319, 312, 313, 606, - 608, 612, 179, 609, 320, 321, 322, 616, 274, 839, - 323, 324, 325, 618, 154, 525, 526, 527, 528, 613, - 529, 525, 526, 527, 528, 619, 529, 623, 624, 620, - 314, 625, 315, 626, 316, 525, 526, 527, 528, 840, - 529, 627, 630, 318, 628, 841, 629, 319, 525, 526, - 527, 528, 633, 529, 634, 320, 321, 322, 635, 842, - 644, 323, 324, 325, 636, 154, 525, 526, 527, 528, - 637, 529, 843, 525, 526, 527, 528, 641, 529, 525, - 526, 527, 528, 638, 529, 642, 525, 526, 527, 528, - 844, 529, 643, 570, 571, 572, 573, 845, 574, 570, - 571, 572, 573, 846, 574, 645, 570, 571, 572, 573, - 847, 574, 652, 570, 571, 572, 573, 854, 574, 570, - 571, 572, 573, 855, 574, 646, 570, 571, 572, 573, - 856, 574, 651, 570, 571, 572, 573, 857, 574, 570, - 571, 572, 573, 858, 574, 676, 570, 571, 572, 573, - 859, 574, 529, 570, 571, 572, 573, 860, 574, 525, - 526, 527, 528, 861, 529, 682, 525, 526, 527, 528, - 862, 529, 683, 525, 526, 527, 528, 863, 529, 525, - 526, 527, 528, 866, 529, 718, 525, 526, 527, 528, - 915, 529, 719, 525, 526, 527, 528, 944, 529, 525, - 526, 527, 528, 996, 529, 720, 525, 526, 527, 528, - 1000, 529, 653, 666, 668, 735, 721, 525, 526, 527, - 528, 794, 529, 722, 570, 571, 572, 573, 851, 574, - 525, 526, 527, 528, 669, 529, 671, 695, 724, 877, - 525, 526, 527, 528, 725, 529, 898, 728, 570, 571, - 572, 573, 904, 574, 525, 526, 527, 528, 729, 529, - 730, 734, 912, 525, 526, 527, 528, 740, 529, 574, - 931, 758, 525, 526, 527, 528, 942, 529, 525, 526, - 527, 528, 772, 529, 774, 943, 525, 526, 527, 528, - 778, 529, 782, 783, 946, 785, 525, 526, 527, 528, - 954, 529, 525, 526, 527, 528, 431, 529, 956, 784, - 795, 787, 788, 799, 791, 793, 804, 805, 957, 802, - 808, 811, 809, 810, 979, 812, 814, 817, 815, 818, - 820, 828, 819, 830, -1, 850, 853, 868, 875, 876, - 883, 886, 882, 896, 891, 893, 894, 895, 903, 905, - 906, 920, 911, 923, 924, 925, 921, 927, 935, 938, - 945, 947, 951, 952, 959, 953, 958, 960, 961, 965, - 966, 969, 968, 983, 980, 970, 994, 984, 148, 993, - 995, 272, 495, 1001, 867, 397, 607, 773, 771, 992, - 481, 492, 487, 648, 395, 759, 922, 731, 353, 434, - 686, 533, 901, 779, 276, 798, 640 + 117, 118, 460, 122, 123, 279, 529, 530, 227, 219, + 131, 162, 228, 237, 243, 140, 143, 144, 541, 698, + 390, 151, 218, 413, 683, 699, 685, 244, 245, 246, + 247, 688, 248, 251, 252, 253, 813, 394, 394, 418, + 706, 858, 421, 920, 527, 822, 700, 657, 713, 986, + 673, 697, 260, 165, 768, 99, 155, 320, 416, 675, + 690, 598, 374, 94, 862, 295, 672, 567, 99, 976, + 599, 375, 722, 933, 934, 935, 93, 968, 702, 459, + 544, 545, 507, 546, 863, 509, 750, 677, 374, 900, + 703, 794, 673, 448, 674, 487, 855, 375, 901, 376, + 795, 675, 676, 295, 1010, 295, 1010, 460, 714, 261, + 442, 88, 526, 690, 597, 690, 111, 517, 449, 856, + 488, 156, 126, 99, 1038, 376, 98, 173, 113, 677, + 276, 96, 715, 173, 443, 628, 716, 717, 678, 103, + 127, 1027, 518, 1011, 95, 680, 691, 692, 632, 262, + 588, 589, 590, 591, 977, 592, 527, 377, 378, 824, + 638, 166, 635, 379, 380, 381, 382, 383, 384, 385, + 386, 387, 701, 296, 1001, 723, 679, 978, 388, 600, + 389, 99, 512, 377, 378, 796, 99, 680, 992, 379, + 380, 381, 382, 383, 384, 385, 386, 387, 724, 1012, + 1013, 1012, 1013, 667, 388, 260, 389, 902, 512, 797, + 1021, 296, 97, 296, 493, 840, 673, 266, 843, 271, + 266, 1028, 1029, 672, 1014, 675, 499, 99, 504, 99, + 104, 271, 725, 257, 969, 727, 728, 729, 730, 731, + 732, 733, 734, 735, 736, 374, 738, 739, 740, 741, + 742, 674, 743, 677, 375, 177, 99, 167, 858, 676, + 178, 759, 261, 105, 522, 168, 100, 101, 106, 575, + 576, 564, 549, 764, 267, 299, 272, 267, 99, 181, + 182, 587, 376, 184, 300, 710, 185, 99, 272, 523, + 258, 91, 287, 186, 99, 678, 565, 112, 564, 594, + 92, 594, 262, 288, 791, 99, 711, 115, 116, 120, + 121, 680, 301, 259, 268, 114, 273, 268, 203, 289, + 316, 99, 951, 570, 595, 207, 596, 816, 273, 99, + 257, 257, 257, 679, 86, 87, 138, 139, 119, 283, + 377, 378, 99, 713, 211, 257, 379, 380, 381, 382, + 383, 384, 385, 386, 387, 99, 212, 99, 141, 142, + 124, 388, 213, 389, 129, 512, 921, 765, 923, 162, + 302, 303, 369, 706, 214, 215, 304, 305, 306, 307, + 308, 309, 310, 311, 312, 787, 937, 258, 258, 258, + 568, 313, 603, 314, 227, 219, 928, 284, 228, 237, + 243, 789, 258, 714, 713, 605, 257, 285, 218, 803, + 361, 362, 366, 244, 245, 246, 247, 604, 248, 251, + 252, 253, 807, 133, 857, 367, 860, 715, 453, 370, + 606, 716, 717, 629, 454, 909, 633, 911, 569, 698, + 698, 698, 257, 155, 173, 699, 699, 699, 257, 257, + 456, 961, 371, 963, 964, 428, 457, 621, 432, 436, + 445, 257, 257, 258, 714, 880, 622, 257, 668, 769, + 770, 771, 772, 773, 774, 775, 776, 777, 778, 1016, + 780, 781, 782, 783, 784, 971, 408, 985, 715, 987, + 792, 413, 716, 717, 130, 1030, 793, 257, 698, 258, + 993, 903, 394, 970, 699, 258, 258, 802, 156, 257, + 421, 607, 429, 1002, 374, 433, 437, 1005, 258, 258, + 132, 257, 419, 375, 258, 257, 416, 610, 425, 426, + 850, 145, 1020, 1006, 866, 430, 608, 147, 434, 438, + 915, 439, 817, 149, 374, 760, 257, 819, 154, 649, + 766, 376, 611, 375, 258, 851, 257, 257, 650, 867, + 89, 90, 1037, 753, 833, 916, 258, 943, 944, 1041, + 945, 1024, 754, 834, 1025, 788, 790, 830, 258, 170, + 844, 376, 258, 845, 163, 948, 159, 171, 804, 879, + 164, 808, 849, 847, 590, 591, 169, 592, 299, 257, + 176, 883, 172, 258, 280, 895, 949, 300, 368, 377, + 378, 952, 173, 258, 258, 379, 380, 381, 382, 383, + 384, 385, 386, 387, 107, 108, 896, 109, 110, 276, + 388, 965, 389, 257, 512, 301, 904, 905, 316, 377, + 378, 363, 973, 373, 974, 379, 380, 381, 382, 383, + 384, 385, 386, 387, 134, 135, 258, 372, 152, 330, + 388, 410, 389, 427, 512, 1, 2, 3, 588, 589, + 590, 591, 4, 592, 431, 460, 5, 6, 7, 953, + 8, 441, 9, 10, 11, 12, 1000, 136, 137, 435, + 258, 440, 566, 302, 303, 13, 447, 452, 14, 304, + 305, 306, 307, 308, 309, 310, 311, 312, 455, 458, + 450, 451, 461, 954, 313, 462, 314, 463, 1026, 464, + 465, 15, 16, 17, 466, 467, 468, 18, 469, 542, + 543, 544, 545, 1036, 546, 470, 471, 19, 20, 21, + 929, 472, 22, 473, 23, 24, 25, 26, 27, 474, + 475, 547, 476, 28, 29, 477, 478, 479, 30, 31, + 32, 33, 542, 543, 544, 545, 480, 546, 34, 35, + 481, 36, 482, 483, 484, 37, 490, 177, 38, 39, + 40, 41, 178, 179, 485, 374, 737, 180, 486, 864, + 542, 543, 544, 545, 375, 546, 489, 491, 910, 492, + 912, 181, 182, 183, 495, 184, 496, 497, 185, 498, + 501, 502, 506, 503, 865, 186, 187, 188, 510, 511, + 189, 190, 376, 191, 192, 193, 194, 195, 196, 197, + 198, 199, 200, 201, 202, 299, 588, 589, 590, 591, + 203, 592, 204, 205, 300, 206, 519, 207, 521, 542, + 543, 544, 545, 524, 546, 208, 551, 520, 525, 552, + 779, 374, 553, 209, 210, 528, 211, 531, 554, 532, + 375, 533, 301, 868, 534, 535, 555, 556, 212, 159, + 377, 378, 557, 558, 213, 536, 379, 380, 381, 382, + 383, 384, 385, 386, 387, 537, 214, 215, 376, 559, + 560, 388, 538, 389, 539, 512, 540, 548, 542, 543, + 544, 545, 561, 546, 542, 543, 544, 545, 562, 546, + 563, 542, 543, 544, 545, 571, 546, 572, 573, 763, + 302, 303, 869, 574, 609, 577, 304, 305, 306, 307, + 308, 309, 310, 311, 312, 870, 578, 579, 580, 581, + 582, 313, 583, 314, 584, 585, 377, 378, 586, 612, + 613, 614, 379, 380, 381, 382, 383, 384, 385, 386, + 387, 1, 2, 3, 615, 617, 616, 388, 4, 389, + 618, 620, 5, 6, 7, 619, 8, 624, 9, 10, + 11, 12, 542, 543, 544, 545, 623, 546, 626, 627, + 630, 13, 634, 636, 14, 631, 542, 543, 544, 545, + 637, 546, 542, 543, 544, 545, 871, 546, 638, 641, + 642, 319, 643, 648, 644, 645, 646, 15, 16, 17, + 872, 647, 320, 18, 321, 322, 873, 651, 652, 653, + 654, 655, 659, 19, 20, 21, 656, 660, 22, 661, + 23, 24, 25, 26, 27, 662, 323, 324, 663, 28, + 29, 186, 664, 669, 30, 31, 32, 33, 283, 670, + 671, 684, 694, 686, 34, 35, 687, 36, 689, 695, + 696, 37, 721, 708, 38, 39, 40, 41, 709, 546, + 325, 319, 326, 745, 327, 542, 543, 544, 545, 744, + 546, 746, 320, 329, 321, 322, 747, 330, 748, 542, + 543, 544, 545, 749, 546, 331, 332, 333, 751, 874, + 752, 334, 335, 336, 761, 159, 323, 324, 755, 767, + 756, 186, 420, 875, 757, 785, 319, 799, 283, 542, + 543, 544, 545, 805, 546, 592, 809, 320, 810, 321, + 322, 542, 543, 544, 545, 811, 546, 812, 801, 822, + 325, 814, 326, 876, 327, 443, 831, 815, 818, 832, + 328, 323, 324, 329, 829, 877, 186, 330, 820, 542, + 543, 544, 545, 283, 546, 331, 332, 333, 826, 836, + 835, 334, 335, 336, 837, 159, 588, 589, 590, 591, + 838, 592, 839, 878, 841, 325, 842, 326, 848, 327, + 588, 589, 590, 591, 844, 592, 845, 846, 329, 852, + 885, 859, 330, 588, 589, 590, 591, 861, 592, 881, + 331, 332, 333, -1, 886, 884, 334, 335, 336, 899, + 159, 588, 589, 590, 591, 906, 592, 887, 588, 589, + 590, 591, 907, 592, 588, 589, 590, 591, 913, 592, + 914, 588, 589, 590, 591, 888, 592, 917, 588, 589, + 590, 591, 889, 592, 588, 589, 590, 591, 890, 592, + 927, 588, 589, 590, 591, 891, 592, 926, 542, 543, + 544, 545, 892, 546, 542, 543, 544, 545, 893, 546, + 938, 542, 543, 544, 545, 894, 546, 940, 542, 543, + 544, 545, 897, 546, 542, 543, 544, 545, 950, 546, + 946, 542, 543, 544, 545, 981, 546, 962, 542, 543, + 544, 545, 1035, 546, 542, 543, 544, 545, 1039, 546, + 922, 924, 925, 762, 542, 543, 544, 545, 941, 546, + 821, 955, 588, 589, 590, 591, 882, 592, 542, 543, + 544, 545, 956, 546, 958, 959, 908, 542, 543, 544, + 545, 960, 546, 967, 930, 975, 588, 589, 590, 591, + 939, 592, 542, 543, 544, 545, 972, 546, 982, 947, + 542, 543, 544, 545, 984, 546, 988, 989, 966, 990, + 542, 543, 544, 545, 979, 546, 542, 543, 544, 545, + 996, 546, 980, 542, 543, 544, 545, 997, 546, 998, + 999, 1003, 983, 1007, 542, 543, 544, 545, 991, 546, + 1008, 542, 543, 544, 545, 994, 546, 1004, 1009, 1019, + 1022, 1023, 1033, 1032, 1034, 1040, 995, 153, 931, 508, + 625, 898, 409, 1018, 505, 798, 800, 1031, 494, 500, + 407, 666, 786, 550, 957, 758, 365, 806, 936, 446, + 712, 286, 658, 825 }; /* YYCHECK. */ const unsigned short int parser::yycheck_[] = { - 19, 20, 88, 22, 23, 498, 292, 293, 97, 556, - 29, 97, 97, 97, 498, 34, 35, 36, 304, 97, - 97, 40, 134, 130, 123, 137, 97, 97, 97, 602, - 693, 97, 97, 810, 97, 124, 125, 20, 482, 167, - 484, 97, 97, 38, 12, 489, 132, 30, 30, 30, - 38, 65, 30, 6, 65, 38, 38, 38, 22, 65, - 38, 924, 38, 20, 12, 351, 20, 30, 4, 20, - 121, 287, 20, 30, 20, 38, 62, 30, 20, 32, - 12, 38, 65, 20, 65, 38, 39, 73, 20, 20, - 12, 121, 30, 12, 145, 539, 144, 65, 20, 30, - 38, 121, 30, 89, 38, 85, 22, 38, 65, 38, - 38, 65, 65, 144, 65, 121, 146, 65, 144, 65, - 144, 74, 38, 65, 104, 22, 146, 65, 65, 65, - 144, 145, 995, 144, 65, 144, 104, 65, 144, 122, - 123, 122, 65, 121, 272, 128, 129, 130, 131, 132, - 133, 134, 135, 136, 22, 150, 104, 121, 111, 445, - 143, 149, 145, 145, 147, 122, 123, 145, 144, 122, - 151, 128, 129, 130, 131, 132, 133, 134, 135, 136, - 144, 397, 145, 115, 122, 123, 143, 121, 145, 966, - 147, 122, 123, 115, 122, 123, 115, 128, 129, 130, - 131, 132, 133, 134, 135, 136, 144, 145, 12, 12, - 144, 30, 143, 38, 145, 12, 147, 145, 6, 38, - 46, 144, 145, 20, 668, 511, 144, 671, 514, 515, - 516, 517, 518, 519, 520, 521, 522, 523, 901, 525, - 526, 527, 528, 529, 32, 531, 65, 65, 121, 65, - 30, 39, 12, 65, 122, 123, 124, 125, 38, 127, - 20, 65, 65, 121, 4, 551, 365, 366, 65, 65, - 121, 30, 65, 146, 65, 144, 144, 144, 377, 38, - 20, 144, 65, 152, 30, 65, 74, 113, 146, 152, - 144, 145, 38, 121, 144, 146, 582, 122, 123, 65, - 104, 104, 875, 122, 123, 65, 65, 104, 124, 128, - 129, 130, 131, 132, 133, 134, 135, 136, 146, 605, - 65, 65, 121, 111, 143, 65, 145, 145, 147, 145, - 145, 124, 148, 145, 144, 145, 152, 153, 121, 146, - 121, 65, 122, 65, 104, 152, 65, 146, 144, 145, - 436, 65, 145, 144, 145, 148, 65, 65, 65, 152, - 153, 144, 121, 122, 123, 146, 810, 65, 812, 128, - 129, 130, 131, 132, 133, 134, 135, 136, 144, 145, - 65, 144, 826, 144, 143, 474, 145, 30, 474, 474, - 474, 65, 146, 30, 65, 38, 474, 474, 152, 144, - 144, 38, 124, 474, 474, 474, 899, 900, 474, 474, - 696, 474, 121, 121, 961, 899, 900, 5, 474, 474, - 144, 440, 10, 121, 443, 144, 148, 145, 65, 976, - 152, 153, 65, 65, 65, 144, 144, 144, 43, 27, - 28, 65, 145, 31, 65, 33, 144, 891, 734, 893, - 894, 65, 40, 144, 145, 144, 475, 121, 63, 144, - 559, 560, 561, 562, 563, 564, 565, 566, 567, 568, - 144, 570, 571, 572, 573, 574, 64, 589, 585, 923, - 592, 925, 146, 71, 770, 122, 123, 576, 121, 121, - 934, 128, 129, 130, 131, 132, 133, 134, 135, 136, - 121, 587, 90, 947, 65, 65, 143, 951, 145, 65, - 65, 144, 144, 144, 102, 22, 65, 0, 65, 107, - 144, 965, 121, 144, 7, 8, 9, 121, 547, 30, - 144, 119, 120, 552, 17, 18, 19, 38, 21, 65, - 23, 24, 25, 26, 121, 144, 832, 833, 65, 835, - 994, 34, 146, 65, 37, 121, 13, 1001, 577, 578, - 121, 121, 65, 103, 850, 121, 121, 30, 65, 146, - 65, 590, 121, 121, 593, 38, 59, 60, 61, 65, - 146, 680, 65, 144, 144, 871, 65, 65, 144, 144, - 876, 65, 75, 76, 77, 144, 65, 80, 146, 82, - 83, 84, 85, 86, 121, 144, 144, 145, 91, 92, - 896, 150, 30, 96, 97, 98, 99, 903, 121, 905, - 38, 65, 105, 106, 121, 108, 121, 144, 30, 112, - 144, 145, 115, 116, 117, 118, 38, 124, 125, 22, - 127, 144, 121, 121, 822, 823, 65, 144, 5, 144, - 65, 65, 121, 10, 11, 65, 65, 14, 110, 945, - 65, 65, 65, 38, 144, 144, 144, 149, 85, 110, - 27, 28, 29, 110, 31, 144, 33, 110, 30, 124, - 125, 146, 127, 40, 41, 42, 38, 44, 45, 975, - 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, - 57, 58, 121, 30, 990, 65, 121, 64, 22, 66, - 67, 38, 69, 65, 71, 144, 121, 121, 121, 65, - 65, 820, 79, 22, 65, 144, 22, 22, 22, 144, - 87, 88, 22, 90, 22, 22, 22, 22, 65, 144, - 144, 144, 22, 22, 22, 102, 103, 65, 22, 22, - 107, 122, 123, 124, 125, 22, 127, 22, 22, 22, - 22, 22, 119, 120, 22, 22, 22, 22, 22, 121, - 122, 123, 791, 22, 793, 146, 128, 129, 130, 131, - 132, 133, 134, 135, 136, 122, 123, 124, 125, 22, - 127, 143, 121, 145, 65, 122, 123, 65, 121, 121, - 22, 128, 129, 130, 131, 132, 133, 134, 135, 136, - 7, 8, 9, 65, 65, 65, 143, 65, 145, 145, - 17, 18, 19, 65, 21, 146, 23, 24, 25, 26, - 121, 122, 123, 124, 125, 146, 127, 34, 65, 145, - 37, 122, 123, 124, 125, 145, 127, 122, 123, 124, - 125, 22, 127, 145, 22, 146, 122, 123, 124, 125, - 3, 127, 59, 60, 61, 146, 22, 22, 65, 145, - 22, 146, 15, 16, 22, 145, 145, 22, 75, 76, - 77, 22, 22, 80, 22, 82, 83, 84, 85, 86, - 22, 22, 35, 36, 91, 92, 110, 40, 145, 96, - 97, 98, 99, 46, 3, 145, 145, 145, 105, 106, - 145, 108, 65, 145, 144, 112, 15, 16, 115, 116, - 117, 118, 145, 110, 145, 68, 145, 70, 145, 72, - 122, 123, 124, 125, 145, 127, 35, 36, 81, 145, - 145, 40, 85, 122, 123, 124, 125, 46, 127, 145, - 93, 94, 95, 22, 146, 3, 99, 100, 101, 145, - 103, 145, 145, 65, 110, 144, 109, 15, 16, 68, - 65, 70, 65, 72, 110, 122, 123, 124, 125, 78, - 127, 144, 81, 145, 65, 22, 85, 35, 36, 38, - 144, 65, 40, 144, 93, 94, 95, 65, 46, 146, - 99, 100, 101, 30, 103, 122, 123, 124, 125, 144, - 127, 122, 123, 124, 125, 65, 127, 38, 38, 149, - 68, 38, 70, 38, 72, 122, 123, 124, 125, 146, - 127, 38, 30, 81, 38, 146, 38, 85, 122, 123, - 124, 125, 30, 127, 38, 93, 94, 95, 38, 146, - 30, 99, 100, 101, 38, 103, 122, 123, 124, 125, - 38, 127, 146, 122, 123, 124, 125, 145, 127, 122, - 123, 124, 125, 65, 127, 38, 122, 123, 124, 125, - 146, 127, 38, 122, 123, 124, 125, 146, 127, 122, - 123, 124, 125, 146, 127, 65, 122, 123, 124, 125, - 146, 127, 22, 122, 123, 124, 125, 146, 127, 122, - 123, 124, 125, 146, 127, 65, 122, 123, 124, 125, - 146, 127, 65, 122, 123, 124, 125, 146, 127, 122, - 123, 124, 125, 146, 127, 65, 122, 123, 124, 125, - 146, 127, 127, 122, 123, 124, 125, 146, 127, 122, - 123, 124, 125, 146, 127, 144, 122, 123, 124, 125, - 146, 127, 144, 122, 123, 124, 125, 146, 127, 122, - 123, 124, 125, 146, 127, 38, 122, 123, 124, 125, - 146, 127, 38, 122, 123, 124, 125, 146, 127, 122, - 123, 124, 125, 146, 127, 38, 122, 123, 124, 125, - 146, 127, 121, 121, 121, 144, 38, 122, 123, 124, - 125, 144, 127, 38, 122, 123, 124, 125, 144, 127, - 122, 123, 124, 125, 121, 127, 121, 121, 38, 144, - 122, 123, 124, 125, 38, 127, 144, 38, 122, 123, - 124, 125, 144, 127, 122, 123, 124, 125, 38, 127, - 38, 65, 144, 122, 123, 124, 125, 110, 127, 127, - 144, 144, 122, 123, 124, 125, 144, 127, 122, 123, - 124, 125, 144, 127, 144, 144, 122, 123, 124, 125, - 30, 127, 110, 110, 144, 38, 122, 123, 124, 125, - 144, 127, 122, 123, 124, 125, 145, 127, 144, 110, - 38, 146, 146, 151, 146, 146, 65, 65, 144, 148, - 144, 65, 121, 121, 144, 121, 65, 38, 144, 38, - 22, 65, 146, 65, 127, 65, 146, 144, 146, 22, - 65, 65, 148, 22, 121, 121, 121, 144, 22, 22, - 38, 38, 144, 121, 121, 121, 151, 144, 146, 148, - 22, 121, 121, 144, 148, 144, 38, 38, 114, 121, - 121, 38, 146, 144, 65, 148, 121, 38, 41, 151, - 121, 103, 270, 121, 765, 127, 436, 587, 585, 976, - 256, 267, 262, 474, 125, 576, 884, 546, 116, 152, - 505, 307, 824, 592, 105, 621, 467 + 20, 21, 174, 23, 24, 107, 302, 303, 101, 101, + 30, 90, 101, 101, 101, 35, 36, 37, 314, 513, + 128, 41, 101, 135, 495, 513, 497, 101, 101, 101, + 101, 502, 101, 101, 101, 101, 620, 129, 130, 139, + 517, 719, 142, 837, 297, 41, 23, 41, 69, 959, + 32, 21, 12, 41, 574, 69, 4, 14, 137, 41, + 41, 32, 32, 69, 89, 12, 6, 363, 69, 41, + 41, 41, 23, 852, 853, 854, 41, 21, 35, 21, + 129, 130, 21, 132, 109, 21, 557, 69, 32, 32, + 47, 32, 32, 126, 34, 126, 126, 41, 41, 69, + 41, 41, 42, 12, 32, 12, 32, 279, 129, 69, + 126, 149, 21, 41, 21, 41, 150, 126, 151, 149, + 151, 69, 23, 69, 1034, 69, 149, 69, 23, 69, + 69, 69, 153, 69, 150, 149, 157, 158, 78, 149, + 41, 69, 151, 69, 150, 127, 127, 128, 149, 109, + 127, 128, 129, 130, 126, 132, 409, 127, 128, 155, + 154, 149, 458, 133, 134, 135, 136, 137, 138, 139, + 140, 141, 149, 120, 156, 126, 116, 149, 148, 150, + 150, 69, 152, 127, 128, 126, 69, 127, 967, 133, + 134, 135, 136, 137, 138, 139, 140, 141, 149, 127, + 128, 127, 128, 149, 148, 12, 150, 150, 152, 150, + 1004, 120, 150, 120, 21, 686, 32, 12, 689, 12, + 12, 149, 150, 6, 150, 41, 21, 69, 21, 69, + 149, 12, 528, 69, 21, 531, 532, 533, 534, 535, + 536, 537, 538, 539, 540, 32, 542, 543, 544, 545, + 546, 34, 548, 69, 41, 5, 69, 149, 936, 42, + 10, 149, 69, 149, 126, 157, 149, 150, 149, 377, + 378, 126, 21, 569, 69, 32, 69, 69, 69, 29, + 30, 389, 69, 33, 41, 46, 36, 69, 69, 151, + 126, 23, 66, 43, 69, 78, 151, 149, 126, 126, + 32, 126, 109, 77, 600, 69, 67, 149, 150, 149, + 150, 127, 69, 149, 109, 149, 109, 109, 68, 93, + 69, 69, 906, 151, 151, 75, 151, 623, 109, 69, + 69, 69, 69, 116, 149, 150, 149, 150, 149, 50, + 127, 128, 69, 69, 94, 69, 133, 134, 135, 136, + 137, 138, 139, 140, 141, 69, 106, 69, 149, 150, + 69, 148, 112, 150, 150, 152, 837, 149, 839, 448, + 127, 128, 69, 850, 124, 125, 133, 134, 135, 136, + 137, 138, 139, 140, 141, 149, 857, 126, 126, 126, + 21, 148, 126, 150, 487, 487, 21, 108, 487, 487, + 487, 149, 126, 129, 69, 126, 69, 118, 487, 149, + 149, 149, 149, 487, 487, 487, 487, 151, 487, 487, + 487, 487, 149, 23, 150, 149, 722, 153, 151, 126, + 151, 157, 158, 453, 157, 149, 456, 149, 69, 933, + 934, 935, 69, 4, 69, 933, 934, 935, 69, 69, + 151, 922, 149, 924, 925, 69, 157, 32, 69, 69, + 21, 69, 69, 126, 129, 761, 41, 69, 488, 577, + 578, 579, 580, 581, 582, 583, 584, 585, 586, 999, + 588, 589, 590, 591, 592, 150, 149, 958, 153, 960, + 149, 603, 157, 158, 150, 1015, 155, 69, 992, 126, + 971, 797, 594, 21, 992, 126, 126, 607, 69, 69, + 610, 126, 126, 984, 32, 126, 126, 988, 126, 126, + 149, 69, 149, 41, 126, 69, 605, 126, 149, 149, + 126, 69, 1003, 21, 126, 149, 151, 69, 149, 149, + 126, 149, 149, 69, 32, 565, 69, 149, 13, 32, + 570, 69, 151, 41, 126, 151, 69, 69, 41, 151, + 149, 150, 1033, 32, 32, 151, 126, 863, 864, 1040, + 866, 32, 41, 41, 32, 595, 596, 149, 126, 149, + 41, 69, 126, 41, 32, 881, 107, 157, 608, 149, + 149, 611, 700, 695, 129, 130, 69, 132, 32, 69, + 23, 149, 69, 126, 28, 149, 902, 41, 115, 127, + 128, 907, 69, 126, 126, 133, 134, 135, 136, 137, + 138, 139, 140, 141, 149, 150, 149, 149, 150, 69, + 148, 927, 150, 69, 152, 69, 149, 149, 69, 127, + 128, 69, 938, 149, 940, 133, 134, 135, 136, 137, + 138, 139, 140, 141, 149, 150, 126, 41, 0, 89, + 148, 154, 150, 115, 152, 7, 8, 9, 127, 128, + 129, 130, 14, 132, 115, 847, 18, 19, 20, 149, + 22, 69, 24, 25, 26, 27, 982, 149, 150, 115, + 126, 151, 126, 127, 128, 37, 23, 69, 40, 133, + 134, 135, 136, 137, 138, 139, 140, 141, 69, 23, + 149, 149, 69, 149, 148, 23, 150, 23, 1014, 23, + 23, 63, 64, 65, 23, 23, 23, 69, 23, 127, + 128, 129, 130, 1029, 132, 23, 23, 79, 80, 81, + 848, 23, 84, 23, 86, 87, 88, 89, 90, 23, + 23, 149, 23, 95, 96, 23, 23, 23, 100, 101, + 102, 103, 127, 128, 129, 130, 23, 132, 110, 111, + 23, 113, 23, 23, 23, 117, 69, 5, 120, 121, + 122, 123, 10, 11, 23, 32, 151, 15, 23, 126, + 127, 128, 129, 130, 41, 132, 23, 69, 818, 69, + 820, 29, 30, 31, 126, 33, 69, 126, 36, 69, + 69, 126, 150, 69, 151, 43, 44, 45, 23, 151, + 48, 49, 69, 51, 52, 53, 54, 55, 56, 57, + 58, 59, 60, 61, 62, 32, 127, 128, 129, 130, + 68, 132, 70, 71, 41, 73, 151, 75, 23, 127, + 128, 129, 130, 69, 132, 83, 23, 151, 69, 23, + 151, 32, 23, 91, 92, 150, 94, 150, 23, 150, + 41, 150, 69, 151, 150, 150, 23, 23, 106, 107, + 127, 128, 23, 23, 112, 150, 133, 134, 135, 136, + 137, 138, 139, 140, 141, 150, 124, 125, 69, 23, + 23, 148, 150, 150, 150, 152, 150, 150, 127, 128, + 129, 130, 23, 132, 127, 128, 129, 130, 23, 132, + 23, 127, 128, 129, 130, 115, 132, 69, 149, 126, + 127, 128, 151, 150, 23, 150, 133, 134, 135, 136, + 137, 138, 139, 140, 141, 151, 150, 150, 150, 150, + 150, 148, 150, 150, 150, 150, 127, 128, 150, 115, + 69, 115, 133, 134, 135, 136, 137, 138, 139, 140, + 141, 7, 8, 9, 69, 69, 115, 148, 14, 150, + 149, 69, 18, 19, 20, 150, 22, 41, 24, 25, + 26, 27, 127, 128, 129, 130, 23, 132, 149, 149, + 69, 37, 69, 32, 40, 149, 127, 128, 129, 130, + 69, 132, 127, 128, 129, 130, 151, 132, 154, 41, + 41, 3, 41, 32, 41, 41, 41, 63, 64, 65, + 151, 41, 14, 69, 16, 17, 151, 32, 41, 41, + 41, 41, 150, 79, 80, 81, 69, 41, 84, 41, + 86, 87, 88, 89, 90, 32, 38, 39, 69, 95, + 96, 43, 69, 69, 100, 101, 102, 103, 50, 23, + 126, 126, 69, 126, 110, 111, 126, 113, 126, 149, + 69, 117, 126, 149, 120, 121, 122, 123, 149, 132, + 72, 3, 74, 32, 76, 127, 128, 129, 130, 41, + 132, 41, 14, 85, 16, 17, 41, 89, 41, 127, + 128, 129, 130, 41, 132, 97, 98, 99, 41, 151, + 41, 103, 104, 105, 69, 107, 38, 39, 41, 115, + 41, 43, 114, 151, 41, 149, 3, 149, 50, 127, + 128, 129, 130, 32, 132, 132, 115, 14, 115, 16, + 17, 127, 128, 129, 130, 115, 132, 41, 149, 41, + 72, 151, 74, 151, 76, 150, 69, 151, 151, 69, + 82, 38, 39, 85, 153, 151, 43, 89, 151, 127, + 128, 129, 130, 50, 132, 97, 98, 99, 156, 126, + 149, 103, 104, 105, 126, 107, 127, 128, 129, 130, + 69, 132, 126, 151, 69, 72, 149, 74, 23, 76, + 127, 128, 129, 130, 41, 132, 41, 151, 85, 149, + 151, 69, 89, 127, 128, 129, 130, 69, 132, 69, + 97, 98, 99, 132, 151, 151, 103, 104, 105, 149, + 107, 127, 128, 129, 130, 151, 132, 151, 127, 128, + 129, 130, 23, 132, 127, 128, 129, 130, 153, 132, + 69, 127, 128, 129, 130, 151, 132, 69, 127, 128, + 129, 130, 151, 132, 127, 128, 129, 130, 151, 132, + 23, 127, 128, 129, 130, 151, 132, 149, 127, 128, + 129, 130, 151, 132, 127, 128, 129, 130, 151, 132, + 23, 127, 128, 129, 130, 151, 132, 23, 127, 128, + 129, 130, 151, 132, 127, 128, 129, 130, 151, 132, + 149, 127, 128, 129, 130, 151, 132, 149, 127, 128, + 129, 130, 151, 132, 127, 128, 129, 130, 151, 132, + 126, 126, 126, 149, 127, 128, 129, 130, 41, 132, + 149, 41, 127, 128, 129, 130, 149, 132, 127, 128, + 129, 130, 156, 132, 126, 126, 149, 127, 128, 129, + 130, 126, 132, 149, 149, 153, 127, 128, 129, 130, + 149, 132, 127, 128, 129, 130, 151, 132, 23, 149, + 127, 128, 129, 130, 126, 132, 126, 149, 149, 149, + 127, 128, 129, 130, 149, 132, 127, 128, 129, 130, + 41, 132, 149, 127, 128, 129, 130, 153, 132, 41, + 119, 126, 149, 151, 127, 128, 129, 130, 149, 132, + 41, 127, 128, 129, 130, 149, 132, 126, 153, 69, + 149, 41, 126, 156, 126, 126, 149, 42, 850, 277, + 448, 792, 132, 149, 274, 603, 605, 1015, 263, 269, + 130, 487, 594, 317, 915, 564, 121, 610, 855, 157, + 522, 110, 480, 639 }; /* STOS_[STATE-NUM] -- The (internal number of the) accessing @@ -2861,107 +2936,111 @@ namespace yy const unsigned short int parser::yystos_[] = { - 0, 7, 8, 9, 17, 18, 19, 21, 23, 24, - 25, 26, 34, 37, 59, 60, 61, 65, 75, 76, - 77, 80, 82, 83, 84, 85, 86, 91, 92, 96, - 97, 98, 99, 105, 106, 108, 112, 115, 116, 117, - 118, 155, 156, 157, 158, 159, 160, 161, 162, 163, - 168, 169, 172, 173, 176, 179, 188, 189, 194, 197, - 200, 203, 206, 212, 218, 221, 226, 229, 232, 235, - 236, 239, 240, 242, 243, 244, 247, 248, 252, 253, - 254, 255, 261, 264, 144, 145, 144, 144, 145, 38, - 65, 145, 65, 145, 144, 65, 144, 145, 209, 144, - 144, 144, 144, 144, 144, 145, 145, 144, 22, 144, - 144, 145, 209, 209, 144, 144, 145, 209, 209, 65, - 167, 22, 38, 262, 145, 145, 209, 144, 22, 144, - 145, 144, 145, 144, 145, 209, 144, 145, 209, 209, - 65, 164, 65, 165, 65, 166, 209, 0, 156, 13, - 4, 65, 249, 250, 103, 201, 202, 268, 38, 144, - 144, 152, 65, 144, 152, 65, 65, 174, 175, 22, - 5, 10, 11, 14, 27, 28, 29, 31, 33, 40, - 41, 42, 44, 45, 47, 48, 49, 50, 51, 52, - 53, 54, 55, 56, 57, 58, 64, 66, 67, 69, - 71, 79, 87, 88, 90, 102, 107, 119, 120, 227, - 228, 268, 278, 285, 286, 287, 288, 289, 290, 291, - 292, 293, 294, 295, 296, 297, 298, 299, 300, 301, - 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, - 312, 313, 315, 316, 321, 322, 323, 324, 325, 326, - 65, 121, 144, 12, 65, 104, 213, 214, 215, 12, - 65, 104, 222, 223, 12, 65, 104, 219, 220, 65, - 177, 178, 174, 180, 46, 113, 270, 62, 73, 89, - 256, 257, 318, 319, 320, 12, 115, 190, 191, 30, - 38, 65, 122, 123, 128, 129, 130, 131, 132, 133, - 134, 135, 136, 143, 145, 170, 65, 237, 238, 3, - 15, 16, 35, 36, 68, 70, 72, 78, 81, 85, - 93, 94, 95, 99, 100, 101, 208, 245, 246, 267, - 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, - 278, 279, 280, 281, 282, 283, 284, 314, 317, 144, - 144, 65, 241, 246, 144, 144, 110, 65, 121, 144, - 38, 144, 30, 38, 65, 122, 123, 128, 129, 130, - 131, 132, 133, 134, 135, 136, 143, 145, 185, 187, - 230, 231, 278, 292, 293, 302, 308, 309, 310, 311, - 312, 313, 321, 322, 323, 230, 144, 190, 149, 204, - 205, 281, 198, 199, 268, 207, 208, 144, 109, 208, - 265, 266, 327, 144, 144, 110, 65, 121, 144, 110, - 65, 121, 144, 110, 65, 121, 144, 144, 146, 65, - 121, 145, 251, 20, 250, 22, 121, 146, 144, 65, - 146, 152, 65, 146, 152, 22, 20, 175, 65, 22, - 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, - 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, - 22, 22, 22, 22, 121, 146, 22, 65, 65, 65, - 20, 214, 121, 65, 121, 65, 20, 223, 65, 121, - 65, 20, 220, 145, 20, 178, 20, 147, 183, 184, - 185, 186, 146, 146, 22, 121, 146, 65, 65, 20, - 191, 145, 170, 170, 145, 145, 145, 145, 145, 145, - 145, 145, 145, 145, 170, 122, 123, 124, 125, 127, - 144, 145, 20, 238, 22, 22, 22, 22, 22, 22, - 22, 22, 22, 22, 22, 22, 121, 146, 121, 170, - 20, 65, 146, 110, 65, 144, 145, 185, 185, 145, - 145, 145, 145, 145, 145, 145, 145, 145, 145, 185, - 122, 123, 124, 125, 127, 263, 121, 146, 146, 20, - 30, 38, 145, 195, 196, 121, 146, 121, 146, 121, - 146, 22, 121, 146, 110, 65, 110, 65, 110, 65, - 144, 145, 65, 30, 38, 22, 38, 202, 144, 144, - 144, 209, 65, 144, 144, 209, 65, 170, 30, 65, - 149, 330, 331, 38, 38, 38, 38, 38, 38, 38, - 30, 30, 38, 30, 38, 38, 38, 38, 65, 38, - 331, 145, 38, 38, 30, 65, 65, 328, 228, 144, - 209, 65, 22, 121, 6, 30, 32, 38, 39, 65, - 74, 111, 122, 216, 224, 225, 121, 225, 121, 121, - 225, 121, 38, 122, 123, 210, 65, 20, 184, 186, - 22, 144, 144, 144, 43, 63, 257, 65, 124, 148, - 152, 153, 258, 259, 260, 121, 22, 121, 144, 170, - 171, 170, 170, 170, 170, 170, 170, 170, 170, 170, - 170, 146, 170, 170, 170, 170, 170, 170, 38, 38, - 38, 38, 38, 225, 38, 38, 30, 38, 38, 38, - 38, 245, 144, 209, 65, 144, 121, 170, 144, 209, - 110, 210, 185, 185, 185, 185, 185, 185, 185, 185, - 185, 185, 146, 185, 185, 185, 185, 185, 144, 231, - 144, 209, 144, 209, 170, 144, 150, 30, 38, 121, - 145, 205, 144, 199, 144, 208, 144, 209, 30, 266, - 144, 209, 110, 110, 110, 38, 251, 146, 146, 170, - 144, 146, 144, 146, 144, 38, 329, 150, 329, 151, - 233, 234, 148, 144, 65, 65, 30, 38, 144, 121, - 121, 65, 121, 225, 65, 144, 225, 38, 38, 146, - 22, 185, 182, 181, 121, 144, 145, 260, 65, 170, - 65, 85, 104, 121, 146, 121, 146, 146, 146, 146, - 146, 146, 146, 146, 146, 146, 146, 146, 144, 170, - 65, 144, 144, 146, 146, 146, 146, 146, 146, 146, - 146, 146, 146, 146, 144, 144, 146, 196, 144, 30, - 38, 145, 170, 144, 144, 146, 22, 144, 144, 209, - 144, 209, 148, 65, 121, 146, 65, 217, 225, 224, - 225, 121, 225, 121, 121, 144, 22, 185, 144, 183, - 183, 259, 225, 22, 144, 22, 38, 192, 170, 170, - 170, 144, 144, 170, 170, 146, 251, 170, 144, 144, - 38, 151, 233, 121, 121, 121, 225, 144, 225, 225, - 170, 144, 20, 20, 145, 146, 170, 170, 148, 38, - 121, 144, 144, 144, 146, 22, 144, 121, 225, 217, - 225, 121, 144, 144, 144, 225, 144, 144, 38, 148, - 38, 114, 170, 151, 225, 121, 121, 225, 146, 38, - 148, 30, 65, 122, 123, 145, 193, 210, 211, 144, - 65, 225, 224, 144, 38, 30, 30, 170, 65, 144, - 145, 210, 211, 151, 121, 121, 146, 170, 225, 217, - 146, 121, 225 + 0, 7, 8, 9, 14, 18, 19, 20, 22, 24, + 25, 26, 27, 37, 40, 63, 64, 65, 69, 79, + 80, 81, 84, 86, 87, 88, 89, 90, 95, 96, + 100, 101, 102, 103, 110, 111, 113, 117, 120, 121, + 122, 123, 160, 161, 162, 163, 164, 165, 166, 167, + 168, 173, 174, 175, 178, 180, 183, 188, 199, 200, + 205, 208, 211, 214, 217, 223, 229, 232, 237, 240, + 243, 246, 247, 250, 251, 253, 254, 255, 258, 259, + 263, 264, 265, 266, 272, 275, 149, 150, 149, 149, + 150, 23, 32, 41, 69, 150, 69, 150, 149, 69, + 149, 150, 220, 149, 149, 149, 149, 149, 150, 149, + 150, 150, 149, 23, 149, 149, 150, 220, 220, 149, + 149, 150, 220, 220, 69, 172, 23, 41, 273, 150, + 150, 220, 149, 23, 149, 150, 149, 150, 149, 150, + 220, 149, 150, 220, 220, 69, 169, 69, 170, 69, + 171, 220, 0, 161, 13, 4, 69, 260, 261, 107, + 212, 213, 279, 32, 149, 41, 149, 149, 157, 69, + 149, 157, 69, 69, 181, 182, 23, 5, 10, 11, + 15, 29, 30, 31, 33, 36, 43, 44, 45, 48, + 49, 51, 52, 53, 54, 55, 56, 57, 58, 59, + 60, 61, 62, 68, 70, 71, 73, 75, 83, 91, + 92, 94, 106, 112, 124, 125, 238, 239, 279, 289, + 297, 298, 299, 300, 301, 302, 303, 304, 305, 306, + 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, + 317, 318, 319, 320, 321, 322, 323, 324, 325, 327, + 328, 333, 334, 335, 336, 337, 338, 69, 126, 149, + 12, 69, 109, 224, 225, 226, 12, 69, 109, 233, + 234, 12, 69, 109, 230, 231, 69, 184, 185, 181, + 28, 179, 189, 50, 108, 118, 281, 66, 77, 93, + 267, 268, 330, 331, 332, 12, 120, 201, 202, 32, + 41, 69, 127, 128, 133, 134, 135, 136, 137, 138, + 139, 140, 141, 148, 150, 176, 69, 248, 249, 3, + 14, 16, 17, 38, 39, 72, 74, 76, 82, 85, + 89, 97, 98, 99, 103, 104, 105, 219, 256, 257, + 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, + 288, 289, 290, 291, 292, 293, 294, 295, 296, 326, + 329, 149, 149, 69, 252, 257, 149, 149, 115, 69, + 126, 149, 41, 149, 32, 41, 69, 127, 128, 133, + 134, 135, 136, 137, 138, 139, 140, 141, 148, 150, + 196, 198, 241, 242, 289, 304, 305, 314, 320, 321, + 322, 323, 324, 325, 333, 334, 335, 241, 149, 201, + 154, 215, 216, 292, 209, 210, 279, 218, 219, 149, + 114, 219, 276, 277, 339, 149, 149, 115, 69, 126, + 149, 115, 69, 126, 149, 115, 69, 126, 149, 149, + 151, 69, 126, 150, 262, 21, 261, 23, 126, 151, + 149, 149, 69, 151, 157, 69, 151, 157, 23, 21, + 182, 69, 23, 23, 23, 23, 23, 23, 23, 23, + 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, + 23, 23, 23, 23, 23, 23, 23, 126, 151, 23, + 69, 69, 69, 21, 225, 126, 69, 126, 69, 21, + 234, 69, 126, 69, 21, 231, 150, 21, 185, 21, + 23, 151, 152, 194, 195, 196, 197, 126, 151, 151, + 151, 23, 126, 151, 69, 69, 21, 202, 150, 176, + 176, 150, 150, 150, 150, 150, 150, 150, 150, 150, + 150, 176, 127, 128, 129, 130, 132, 149, 150, 21, + 249, 23, 23, 23, 23, 23, 23, 23, 23, 23, + 23, 23, 23, 23, 126, 151, 126, 176, 21, 69, + 151, 115, 69, 149, 150, 196, 196, 150, 150, 150, + 150, 150, 150, 150, 150, 150, 150, 196, 127, 128, + 129, 130, 132, 274, 126, 151, 151, 21, 32, 41, + 150, 206, 207, 126, 151, 126, 151, 126, 151, 23, + 126, 151, 115, 69, 115, 69, 115, 69, 149, 150, + 69, 32, 41, 23, 41, 213, 149, 149, 149, 220, + 69, 149, 149, 220, 69, 176, 32, 69, 154, 342, + 343, 41, 41, 41, 41, 41, 41, 41, 32, 32, + 41, 32, 41, 41, 41, 41, 69, 41, 343, 150, + 41, 41, 32, 69, 69, 340, 239, 149, 220, 69, + 23, 126, 6, 32, 34, 41, 42, 69, 78, 116, + 127, 227, 235, 236, 126, 236, 126, 126, 236, 126, + 41, 127, 128, 221, 69, 149, 69, 21, 195, 197, + 23, 149, 35, 47, 186, 187, 293, 193, 149, 149, + 46, 67, 268, 69, 129, 153, 157, 158, 269, 270, + 271, 126, 23, 126, 149, 176, 177, 176, 176, 176, + 176, 176, 176, 176, 176, 176, 176, 151, 176, 176, + 176, 176, 176, 176, 41, 32, 41, 41, 41, 41, + 236, 41, 41, 32, 41, 41, 41, 41, 256, 149, + 220, 69, 149, 126, 176, 149, 220, 115, 221, 196, + 196, 196, 196, 196, 196, 196, 196, 196, 196, 151, + 196, 196, 196, 196, 196, 149, 242, 149, 220, 149, + 220, 176, 149, 155, 32, 41, 126, 150, 216, 149, + 210, 149, 219, 149, 220, 32, 277, 149, 220, 115, + 115, 115, 41, 262, 151, 151, 176, 149, 151, 149, + 151, 149, 41, 341, 155, 341, 156, 244, 245, 153, + 149, 69, 69, 32, 41, 149, 126, 126, 69, 126, + 236, 69, 149, 236, 41, 41, 151, 181, 23, 196, + 126, 151, 149, 191, 190, 126, 149, 150, 271, 69, + 176, 69, 89, 109, 126, 151, 126, 151, 151, 151, + 151, 151, 151, 151, 151, 151, 151, 151, 151, 149, + 176, 69, 149, 149, 151, 151, 151, 151, 151, 151, + 151, 151, 151, 151, 151, 149, 149, 151, 207, 149, + 32, 41, 150, 176, 149, 149, 151, 23, 149, 149, + 220, 149, 220, 153, 69, 126, 151, 69, 228, 236, + 235, 236, 126, 236, 126, 126, 149, 23, 21, 196, + 149, 187, 192, 194, 194, 194, 270, 236, 23, 149, + 23, 41, 203, 176, 176, 176, 149, 149, 176, 176, + 151, 262, 176, 149, 149, 41, 156, 244, 126, 126, + 126, 236, 149, 236, 236, 176, 149, 149, 21, 21, + 21, 150, 151, 176, 176, 153, 41, 126, 149, 149, + 149, 151, 23, 149, 126, 236, 228, 236, 126, 149, + 149, 149, 194, 236, 149, 149, 41, 153, 41, 119, + 176, 156, 236, 126, 126, 236, 21, 151, 41, 153, + 32, 69, 127, 128, 150, 204, 221, 222, 149, 69, + 236, 235, 149, 41, 32, 32, 176, 69, 149, 150, + 221, 222, 156, 126, 126, 151, 176, 236, 228, 151, + 126, 236 }; #if YYDEBUG @@ -2984,8 +3063,8 @@ namespace yy 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 378, 379, 380, 381, 382, 383, 384, 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, - 395, 396, 397, 398, 59, 40, 41, 35, 58, 91, - 93, 39, 46, 92 + 395, 396, 397, 398, 399, 400, 401, 402, 403, 59, + 40, 41, 35, 58, 91, 93, 39, 46, 92 }; #endif @@ -2993,56 +3072,57 @@ namespace yy const unsigned short int parser::yyr1_[] = { - 0, 154, 155, 155, 156, 156, 156, 156, 156, 156, - 156, 156, 156, 156, 156, 156, 156, 156, 156, 156, - 156, 156, 156, 156, 156, 156, 156, 156, 156, 156, - 156, 156, 156, 156, 156, 156, 156, 156, 156, 156, - 156, 157, 157, 157, 157, 158, 158, 159, 160, 161, - 162, 163, 164, 164, 164, 164, 164, 164, 165, 165, - 165, 165, 165, 165, 166, 166, 166, 166, 166, 166, - 167, 167, 167, 167, 167, 167, 168, 168, 169, 170, - 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, - 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, - 170, 170, 171, 171, 172, 173, 174, 174, 175, 176, - 177, 177, 178, 180, 179, 181, 179, 182, 179, 183, - 183, 183, 183, 184, 184, 185, 185, 185, 185, 185, - 185, 185, 185, 185, 185, 185, 185, 185, 185, 185, - 185, 185, 185, 185, 185, 185, 186, 187, 187, 188, - 189, 190, 190, 191, 191, 191, 191, 191, 192, 192, - 192, 192, 192, 192, 193, 193, 193, 193, 193, 193, - 193, 193, 194, 195, 195, 196, 196, 196, 196, 196, - 196, 196, 196, 196, 197, 197, 198, 198, 199, 200, - 200, 201, 201, 202, 203, 203, 204, 204, 205, 206, - 206, 206, 206, 207, 207, 208, 208, 208, 208, 208, - 208, 208, 208, 208, 208, 208, 208, 208, 208, 208, - 208, 208, 208, 208, 209, 209, 209, 209, 209, 209, - 210, 210, 210, 211, 211, 211, 212, 213, 213, 214, - 215, 215, 215, 216, 216, 216, 216, 216, 217, 217, - 217, 217, 218, 219, 219, 220, 220, 220, 221, 222, - 222, 223, 223, 223, 224, 224, 224, 224, 224, 225, - 225, 225, 225, 225, 225, 226, 226, 226, 226, 227, - 227, 228, 228, 228, 228, 228, 228, 228, 228, 228, - 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, - 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, - 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, - 229, 229, 230, 230, 231, 231, 231, 231, 231, 231, - 231, 231, 231, 231, 231, 231, 231, 232, 232, 233, - 233, 234, 234, 235, 236, 237, 237, 238, 239, 240, - 241, 241, 241, 241, 242, 243, 243, 243, 243, 244, - 244, 244, 244, 245, 245, 246, 246, 247, 248, 249, - 249, 250, 250, 250, 251, 251, 251, 252, 252, 253, - 253, 253, 253, 253, 253, 254, 254, 254, 254, 254, - 254, 255, 256, 256, 257, 257, 257, 258, 258, 258, - 258, 259, 259, 260, 260, 260, 260, 260, 262, 263, - 261, 264, 264, 264, 264, 265, 265, 266, 266, 267, - 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, - 278, 279, 280, 281, 282, 283, 284, 284, 285, 286, - 286, 287, 288, 289, 290, 291, 292, 292, 293, 294, - 295, 296, 297, 298, 298, 299, 300, 301, 302, 303, - 304, 305, 306, 307, 308, 309, 310, 311, 312, 313, - 314, 315, 316, 317, 318, 318, 319, 320, 321, 322, - 323, 324, 325, 326, 327, 328, 329, 329, 330, 330, - 331 + 0, 159, 160, 160, 161, 161, 161, 161, 161, 161, + 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, + 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, + 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, + 161, 161, 162, 162, 162, 162, 163, 163, 164, 165, + 166, 167, 168, 169, 169, 169, 169, 169, 169, 170, + 170, 170, 170, 170, 170, 171, 171, 171, 171, 171, + 171, 172, 172, 172, 172, 172, 172, 173, 173, 174, + 174, 175, 176, 176, 176, 176, 176, 176, 176, 176, + 176, 176, 176, 176, 176, 176, 176, 176, 176, 176, + 176, 176, 176, 176, 176, 177, 177, 178, 178, 179, + 180, 181, 181, 182, 183, 184, 184, 185, 186, 186, + 187, 187, 187, 189, 188, 190, 188, 191, 188, 192, + 188, 193, 188, 194, 194, 194, 194, 195, 195, 196, + 196, 196, 196, 196, 196, 196, 196, 196, 196, 196, + 196, 196, 196, 196, 196, 196, 196, 196, 196, 196, + 197, 198, 198, 199, 200, 201, 201, 202, 202, 202, + 202, 202, 203, 203, 203, 203, 203, 203, 204, 204, + 204, 204, 204, 204, 204, 204, 205, 206, 206, 207, + 207, 207, 207, 207, 207, 207, 207, 207, 208, 208, + 209, 209, 210, 211, 211, 212, 212, 213, 214, 214, + 215, 215, 216, 217, 217, 217, 217, 218, 218, 219, + 219, 219, 219, 219, 219, 219, 219, 219, 219, 219, + 219, 219, 219, 219, 219, 219, 219, 219, 219, 220, + 220, 220, 220, 220, 220, 221, 221, 221, 222, 222, + 222, 223, 224, 224, 225, 226, 226, 226, 227, 227, + 227, 227, 227, 228, 228, 228, 228, 229, 230, 230, + 231, 231, 231, 232, 233, 233, 234, 234, 234, 235, + 235, 235, 235, 235, 236, 236, 236, 236, 236, 236, + 237, 237, 237, 237, 238, 238, 239, 239, 239, 239, + 239, 239, 239, 239, 239, 239, 239, 239, 239, 239, + 239, 239, 239, 239, 239, 239, 239, 239, 239, 239, + 239, 239, 239, 239, 239, 239, 239, 239, 239, 239, + 239, 239, 239, 239, 239, 240, 240, 241, 241, 242, + 242, 242, 242, 242, 242, 242, 242, 242, 242, 242, + 242, 242, 243, 243, 244, 244, 245, 245, 246, 247, + 248, 248, 249, 250, 251, 252, 252, 252, 252, 253, + 254, 254, 254, 254, 255, 255, 255, 255, 256, 256, + 257, 257, 258, 259, 260, 260, 261, 261, 261, 262, + 262, 262, 263, 263, 264, 264, 264, 264, 264, 264, + 265, 265, 265, 265, 265, 265, 266, 267, 267, 268, + 268, 268, 269, 269, 269, 269, 270, 270, 271, 271, + 271, 271, 271, 273, 274, 272, 275, 275, 275, 275, + 276, 276, 277, 277, 278, 279, 280, 281, 282, 283, + 284, 285, 286, 287, 288, 289, 290, 291, 292, 293, + 294, 295, 296, 296, 297, 298, 298, 299, 300, 301, + 302, 303, 304, 304, 305, 306, 307, 308, 309, 310, + 310, 311, 312, 313, 314, 315, 316, 317, 318, 319, + 320, 321, 322, 323, 324, 325, 326, 327, 328, 329, + 330, 330, 331, 332, 333, 334, 335, 336, 337, 338, + 339, 340, 341, 341, 342, 342, 343 }; /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ @@ -3053,52 +3133,53 @@ namespace yy 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 3, 4, 3, 3, 3, - 3, 3, 2, 3, 1, 3, 4, 2, 2, 3, - 1, 3, 4, 2, 2, 3, 1, 3, 4, 2, - 2, 3, 1, 3, 4, 2, 3, 4, 4, 3, + 1, 1, 1, 1, 1, 1, 3, 4, 3, 3, + 3, 3, 3, 2, 3, 1, 3, 4, 2, 2, + 3, 1, 3, 4, 2, 2, 3, 1, 3, 4, + 2, 2, 3, 1, 3, 4, 2, 3, 4, 3, + 4, 4, 3, 1, 1, 1, 3, 3, 3, 3, + 3, 2, 2, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 3, 3, 4, 7, 3, + 4, 2, 1, 4, 4, 2, 1, 7, 3, 1, + 1, 1, 1, 0, 5, 0, 8, 0, 8, 0, + 10, 0, 8, 2, 2, 1, 1, 4, 2, 3, 1, 1, 1, 3, 3, 3, 3, 3, 2, 2, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 3, 3, 4, 4, 2, 1, 4, 4, - 2, 1, 7, 0, 5, 0, 8, 0, 8, 2, - 2, 1, 1, 4, 2, 3, 1, 1, 1, 3, - 3, 3, 3, 3, 2, 2, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 5, 1, 4, 4, - 4, 2, 1, 9, 6, 5, 7, 7, 2, 4, - 3, 5, 3, 1, 2, 2, 2, 1, 1, 1, - 4, 3, 6, 3, 1, 5, 3, 3, 4, 2, - 2, 3, 1, 1, 2, 5, 3, 1, 1, 2, - 5, 3, 1, 1, 2, 5, 3, 1, 1, 2, - 5, 3, 6, 3, 1, 1, 1, 1, 1, 1, + 5, 1, 4, 4, 4, 2, 1, 9, 6, 5, + 7, 7, 2, 4, 3, 5, 3, 1, 2, 2, + 2, 1, 1, 1, 4, 3, 6, 3, 1, 5, + 3, 3, 4, 2, 2, 3, 1, 1, 2, 5, + 3, 1, 1, 2, 5, 3, 1, 1, 2, 5, + 3, 1, 1, 2, 5, 3, 6, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 2, 4, 3, 5, 1, 3, - 2, 2, 1, 2, 2, 1, 4, 2, 1, 4, - 2, 1, 4, 3, 5, 9, 1, 5, 3, 5, - 7, 9, 4, 2, 1, 5, 7, 4, 4, 2, - 1, 7, 9, 6, 1, 1, 1, 1, 1, 0, - 1, 1, 1, 2, 2, 2, 5, 3, 6, 3, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, + 4, 3, 5, 1, 3, 2, 2, 1, 2, 2, + 1, 4, 2, 1, 4, 2, 1, 4, 3, 5, + 9, 1, 5, 3, 5, 7, 9, 4, 2, 1, + 5, 7, 4, 4, 2, 1, 7, 9, 6, 1, + 1, 1, 1, 1, 0, 1, 1, 1, 2, 2, + 2, 5, 3, 6, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 5, 6, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 5, 6, 3, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 5, 6, 7, - 5, 1, 3, 3, 4, 2, 1, 5, 3, 4, - 4, 6, 3, 5, 3, 2, 5, 3, 6, 2, - 5, 3, 6, 1, 1, 1, 3, 3, 4, 2, - 1, 5, 7, 9, 0, 3, 3, 2, 5, 5, - 6, 3, 7, 8, 5, 5, 6, 3, 7, 8, - 5, 6, 3, 1, 1, 1, 1, 1, 3, 4, - 6, 1, 2, 1, 1, 1, 1, 1, 0, 0, - 5, 2, 5, 3, 6, 3, 1, 1, 1, 3, - 3, 3, 1, 3, 3, 3, 3, 1, 1, 1, - 3, 3, 3, 3, 1, 3, 3, 3, 3, 3, - 3, 3, 3, 3, 3, 3, 1, 1, 3, 3, - 3, 3, 5, 3, 3, 3, 3, 1, 3, 3, - 3, 1, 1, 1, 1, 1, 3, 1, 1, 1, - 1, 3, 3, 3, 3, 3, 1, 1, 3, 3, - 3, 1, 1, 1, 3, 3, 1, 3, 2, 2, - 2 + 1, 1, 5, 6, 7, 5, 1, 3, 3, 4, + 2, 1, 5, 3, 4, 4, 6, 3, 5, 3, + 2, 5, 3, 6, 2, 5, 3, 6, 1, 1, + 1, 3, 3, 4, 2, 1, 5, 7, 9, 0, + 3, 3, 2, 5, 5, 6, 3, 7, 8, 5, + 5, 6, 3, 7, 8, 5, 6, 3, 1, 1, + 1, 1, 1, 3, 4, 6, 1, 2, 1, 1, + 1, 1, 1, 0, 0, 5, 2, 5, 3, 6, + 3, 1, 1, 1, 3, 3, 3, 1, 3, 3, + 3, 3, 1, 1, 1, 3, 3, 3, 3, 3, + 1, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 1, 1, 3, 3, 3, 3, 5, 3, + 3, 3, 3, 1, 3, 3, 3, 1, 1, 1, + 1, 1, 3, 1, 1, 1, 1, 3, 3, 3, + 3, 3, 1, 1, 3, 3, 3, 1, 1, 1, + 3, 3, 1, 3, 2, 2, 2 }; #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE @@ -3109,36 +3190,40 @@ namespace yy { "$end", "error", "$undefined", "AR", "AUTOCORR", "BAYESIAN_IRF", "BETA_PDF", "CALIB", "CALIB_VAR", "CHECK", "CONF_SIG", "CONSTANT", - "CORR", "COVAR", "DATAFILE", "DR_ALGO", "DROP", "DSAMPLE", "DYNASAVE", - "DYNATYPE", "END", "ENDVAL", "EQUAL", "ESTIMATION", "ESTIMATED_PARAMS", - "ESTIMATED_PARAMS_BOUNDS", "ESTIMATED_PARAMS_INIT", "FILTER_STEP_AHEAD", - "FILTERED_VARS", "FIRST_OBS", "FLOAT_NUMBER", "FORECAST", "GAMMA_PDF", - "GRAPH", "HISTVAL", "HP_FILTER", "HP_NGRID", "INITVAL", "INT_NUMBER", + "CORR", "COVAR", "CUTOFF", "DATAFILE", "DR_ALGO", "DROP", "DSAMPLE", + "DYNASAVE", "DYNATYPE", "END", "ENDVAL", "EQUAL", "ESTIMATION", + "ESTIMATED_PARAMS", "ESTIMATED_PARAMS_BOUNDS", "ESTIMATED_PARAMS_INIT", + "FILENAME", "FILTER_STEP_AHEAD", "FILTERED_VARS", "FIRST_OBS", + "FLOAT_NUMBER", "FORECAST", "GAMMA_PDF", "GCC_COMPILER", "GRAPH", + "HISTVAL", "HP_FILTER", "HP_NGRID", "INITVAL", "INT_NUMBER", "INV_GAMMA_PDF", "IRF", "KALMAN_ALGO", "KALMAN_TOL", "LAPLACE", - "LIK_ALGO", "LIK_INIT", "LINEAR", "LOAD_MH_FILE", "LOGLINEAR", "MH_DROP", - "MH_INIT_SCALE", "MH_JSCALE", "MH_MODE", "MH_NBLOCKS", "MH_REPLIC", - "MH_RECOVER", "MODE_CHECK", "MODE_COMPUTE", "MODE_FILE", "MODEL", - "MODEL_COMPARISON", "MSHOCKS", "MODEL_COMPARISON_APPROXIMATION", - "MODIFIEDHARMONICMEAN", "MOMENTS_VARENDO", "NAME", "NOBS", "NOCONSTANT", - "NOCORR", "NODIAGNOSTIC", "NOFUNCTIONS", "NOGRAPH", "NOMOMENTS", - "NOPRINT", "NORMAL_PDF", "OBSERVATION_TRENDS", "OLR", "OLR_INST", - "OLR_BETA", "OPTIM", "OPTIM_WEIGHTS", "ORDER", "OSR", "OSR_PARAMS", - "PARAMETERS", "PERIODS", "PLANNER_OBJECTIVE", "PREFILTER", "PRESAMPLE", - "PRINT", "PRIOR_TRUNC", "PRIOR_ANALYSIS", "POSTERIOR_ANALYSIS", - "QZ_CRITERIUM", "RELATIVE_IRF", "REPLIC", "RPLOT", "SHOCKS", "SIGMA_E", - "SIMUL", "SIMUL_ALGO", "SIMUL_SEED", "SMOOTHER", "SOLVE_ALGO", "STDERR", - "STEADY", "STOCH_SIMUL", "TEX", "RAMSEY_POLICY", "PLANNER_DISCOUNT", - "TEX_NAME", "UNIFORM_PDF", "UNIT_ROOT_VARS", "USE_DLL", "VALUES", "VAR", - "VAREXO", "VAREXO_DET", "VAROBS", "XLS_SHEET", "XLS_RANGE", "COMMA", - "MINUS", "PLUS", "DIVIDE", "TIMES", "UMINUS", "POWER", "EXP", "LOG", - "LOG10", "SIN", "COS", "TAN", "ASIN", "ACOS", "ATAN", "SINH", "COSH", - "TANH", "ASINH", "ACOSH", "ATANH", "SQRT", "';'", "'('", "')'", "'#'", - "':'", "'['", "']'", "'''", "'.'", "'\\\\'", "$accept", "statement_list", - "statement", "declaration", "dsample", "rplot", "var", "varexo", - "varexo_det", "parameters", "var_list", "varexo_list", "varexo_det_list", - "parameter_list", "periods", "init_param", "expression", - "comma_expression", "initval", "endval", "initval_list", "initval_elem", - "histval", "histval_list", "histval_elem", "model", "@1", "@2", "@3", + "LCC_COMPILER", "LIK_ALGO", "LIK_INIT", "LINEAR", "LOAD_MH_FILE", + "LOGLINEAR", "MH_DROP", "MH_INIT_SCALE", "MH_JSCALE", "MH_MODE", + "MH_NBLOCKS", "MH_REPLIC", "MH_RECOVER", "MODE_CHECK", "MODE_COMPUTE", + "MODE_FILE", "MODEL", "MODEL_COMPARISON", "MSHOCKS", + "MODEL_COMPARISON_APPROXIMATION", "MODIFIEDHARMONICMEAN", + "MOMENTS_VARENDO", "NAME", "NOBS", "NOCONSTANT", "NOCORR", + "NODIAGNOSTIC", "NOFUNCTIONS", "NOGRAPH", "NOMOMENTS", "NOPRINT", + "NORMAL_PDF", "OBSERVATION_TRENDS", "OLR", "OLR_INST", "OLR_BETA", + "OPTIM", "OPTIM_WEIGHTS", "ORDER", "OSR", "OSR_PARAMS", "PARAMETERS", + "PERIODS", "PLANNER_OBJECTIVE", "PREFILTER", "PRESAMPLE", "PRINT", + "PRIOR_TRUNC", "PRIOR_ANALYSIS", "POSTERIOR_ANALYSIS", "QZ_CRITERIUM", + "RELATIVE_IRF", "REPLIC", "RPLOT", "SHOCKS", "SIGMA_E", "SIMUL", + "SIMUL_ALGO", "SIMUL_SEED", "SMOOTHER", "SOLVE_ALGO", "SPARSE_DLL", + "STDERR", "STEADY", "STOCH_SIMUL", "TEX", "RAMSEY_POLICY", + "PLANNER_DISCOUNT", "TEX_NAME", "UNIFORM_PDF", "UNIT_ROOT_VARS", + "USE_DLL", "VALUES", "VAR", "VAREXO", "VAREXO_DET", "VAROBS", + "XLS_SHEET", "XLS_RANGE", "COMMA", "MINUS", "PLUS", "DIVIDE", "TIMES", + "UMINUS", "POWER", "EXP", "LOG", "LOG10", "SIN", "COS", "TAN", "ASIN", + "ACOS", "ATAN", "SINH", "COSH", "TANH", "ASINH", "ACOSH", "ATANH", + "SQRT", "';'", "'('", "')'", "'#'", "':'", "'['", "']'", "'''", "'.'", + "'\\\\'", "$accept", "statement_list", "statement", "declaration", + "dsample", "rplot", "var", "varexo", "varexo_det", "parameters", + "var_list", "varexo_list", "varexo_det_list", "parameter_list", + "periods", "cutoff", "init_param", "expression", "comma_expression", + "initval", "initval_option", "endval", "initval_list", "initval_elem", + "histval", "histval_list", "histval_elem", "model_sparse_options_list", + "model_sparse_options", "model", "@1", "@2", "@3", "@4", "@5", "equation_list", "equation", "hand_side", "pound_expression", "model_var", "shocks", "mshocks", "shock_list", "shock_elem", "period_list", "value_list", "sigma_e", "triangular_matrix", @@ -3160,18 +3245,18 @@ namespace yy "calib_var", "calib_var_list", "calib_arg1", "calib_arg2", "calib", "dynatype", "dynasave", "model_comparison", "model_comparison_options", "model_comparison_option", "filename_list", "filename", "filename_elem", - "planner_objective", "@4", "@5", "ramsey_policy", + "planner_objective", "@6", "@7", "ramsey_policy", "ramsey_policy_options_list", "ramsey_policy_options", "o_dr_algo", "o_solve_algo", "o_simul_algo", "o_linear", "o_order", "o_replic", "o_drop", "o_ar", "o_nocorr", "o_nofunctions", "o_nomoments", "o_irf", - "o_hp_filter", "o_hp_ngrid", "o_periods", "o_simul", "o_simul_seed", - "o_qz_criterium", "o_datafile", "o_nobs", "o_first_obs", "o_prefilter", - "o_presample", "o_lik_algo", "o_lik_init", "o_nograph", "o_conf_sig", - "o_mh_replic", "o_mh_drop", "o_mh_jscale", "o_optim", "o_mh_init_scale", - "o_mode_file", "o_mode_compute", "o_mode_check", "o_prior_trunc", - "o_mh_mode", "o_mh_nblcks", "o_load_mh_file", "o_loglinear", - "o_nodiagnostic", "o_bayesian_irf", "o_tex", "o_forecast", "o_smoother", - "o_moments_varendo", "o_filtered_vars", "o_relative_irf", + "o_hp_filter", "o_hp_ngrid", "o_periods", "o_cutoff", "o_simul", + "o_simul_seed", "o_qz_criterium", "o_datafile", "o_nobs", "o_first_obs", + "o_prefilter", "o_presample", "o_lik_algo", "o_lik_init", "o_nograph", + "o_conf_sig", "o_mh_replic", "o_mh_drop", "o_mh_jscale", "o_optim", + "o_mh_init_scale", "o_mode_file", "o_mode_compute", "o_mode_check", + "o_prior_trunc", "o_mh_mode", "o_mh_nblcks", "o_load_mh_file", + "o_loglinear", "o_nodiagnostic", "o_bayesian_irf", "o_tex", "o_forecast", + "o_smoother", "o_moments_varendo", "o_filtered_vars", "o_relative_irf", "o_kalman_algo", "o_kalman_tol", "o_olr_beta", "o_model_comparison_approximation", "o_print", "o_noprint", "o_xls_sheet", "o_xls_range", "o_filter_step_ahead", "o_constant", @@ -3185,179 +3270,186 @@ namespace yy const parser::rhs_number_type parser::yyrhs_[] = { - 155, 0, -1, 156, -1, 155, 156, -1, 157, -1, - 168, -1, 179, -1, 172, -1, 173, -1, 176, -1, - 169, -1, 188, -1, 189, -1, 194, -1, 197, -1, - 200, -1, 203, -1, 206, -1, 226, -1, 229, -1, - 232, -1, 212, -1, 221, -1, 218, -1, 235, -1, - 236, -1, 239, -1, 158, -1, 159, -1, 240, -1, - 242, -1, 243, -1, 248, -1, 252, -1, 253, -1, - 254, -1, 244, -1, 247, -1, 255, -1, 261, -1, - 264, -1, 163, -1, 160, -1, 161, -1, 162, -1, - 17, 38, 144, -1, 17, 38, 38, 144, -1, 96, - 209, 144, -1, 115, 164, 144, -1, 116, 165, 144, - -1, 117, 166, 144, -1, 84, 167, 144, -1, 164, - 65, -1, 164, 121, 65, -1, 65, -1, 164, 65, - 110, -1, 164, 121, 65, 110, -1, 65, 110, -1, - 165, 65, -1, 165, 121, 65, -1, 65, -1, 165, - 65, 110, -1, 165, 121, 65, 110, -1, 65, 110, - -1, 166, 65, -1, 166, 121, 65, -1, 65, -1, - 166, 65, 110, -1, 166, 121, 65, 110, -1, 65, - 110, -1, 167, 65, -1, 167, 121, 65, -1, 65, - -1, 167, 65, 110, -1, 167, 121, 65, 110, -1, - 65, 110, -1, 85, 38, 144, -1, 85, 22, 38, - 144, -1, 65, 22, 170, 144, -1, 145, 170, 146, - -1, 65, -1, 30, -1, 38, -1, 170, 123, 170, - -1, 170, 122, 170, -1, 170, 124, 170, -1, 170, - 125, 170, -1, 170, 127, 170, -1, 122, 170, -1, - 123, 170, -1, 128, 145, 170, 146, -1, 129, 145, - 170, 146, -1, 130, 145, 170, 146, -1, 131, 145, - 170, 146, -1, 132, 145, 170, 146, -1, 133, 145, - 170, 146, -1, 134, 145, 170, 146, -1, 135, 145, - 170, 146, -1, 136, 145, 170, 146, -1, 143, 145, - 170, 146, -1, 65, 145, 170, 146, -1, 65, 145, - 171, 146, -1, 170, 121, 170, -1, 171, 121, 170, - -1, 37, 144, 174, 20, -1, 21, 144, 174, 20, - -1, 174, 175, -1, 175, -1, 65, 22, 170, 144, - -1, 34, 144, 177, 20, -1, 177, 178, -1, 178, - -1, 65, 145, 210, 146, 22, 170, 144, -1, -1, - 59, 144, 180, 183, 20, -1, -1, 59, 145, 270, - 146, 144, 181, 183, 20, -1, -1, 59, 145, 113, - 146, 144, 182, 183, 20, -1, 183, 184, -1, 183, - 186, -1, 184, -1, 186, -1, 185, 22, 185, 144, - -1, 185, 144, -1, 145, 185, 146, -1, 187, -1, - 30, -1, 38, -1, 185, 123, 185, -1, 185, 122, - 185, -1, 185, 124, 185, -1, 185, 125, 185, -1, - 185, 127, 185, -1, 122, 185, -1, 123, 185, -1, - 128, 145, 185, 146, -1, 129, 145, 185, 146, -1, - 130, 145, 185, 146, -1, 131, 145, 185, 146, -1, - 132, 145, 185, 146, -1, 133, 145, 185, 146, -1, - 134, 145, 185, 146, -1, 135, 145, 185, 146, -1, - 136, 145, 185, 146, -1, 143, 145, 185, 146, -1, - 147, 65, 22, 185, 144, -1, 65, -1, 65, 145, - 210, 146, -1, 97, 144, 190, 20, -1, 61, 144, - 190, 20, -1, 190, 191, -1, 191, -1, 115, 65, - 144, 85, 192, 144, 114, 193, 144, -1, 115, 65, - 144, 104, 170, 144, -1, 115, 65, 22, 170, 144, - -1, 115, 65, 121, 65, 22, 170, 144, -1, 12, - 65, 121, 65, 22, 170, 144, -1, 192, 38, -1, - 192, 38, 148, 38, -1, 192, 121, 38, -1, 192, - 121, 38, 148, 38, -1, 38, 148, 38, -1, 38, - -1, 193, 211, -1, 193, 210, -1, 193, 65, -1, - 211, -1, 210, -1, 65, -1, 193, 145, 170, 146, - -1, 145, 170, 146, -1, 98, 22, 149, 195, 150, - 144, -1, 195, 144, 196, -1, 196, -1, 196, 121, - 145, 170, 146, -1, 196, 121, 30, -1, 196, 121, - 38, -1, 196, 145, 170, 146, -1, 196, 30, -1, - 196, 38, -1, 145, 170, 146, -1, 30, -1, 38, - -1, 105, 144, -1, 105, 145, 198, 146, 144, -1, - 198, 121, 199, -1, 199, -1, 268, -1, 9, 144, - -1, 9, 145, 201, 146, 144, -1, 201, 121, 202, - -1, 202, -1, 268, -1, 99, 144, -1, 99, 145, - 204, 146, 144, -1, 204, 121, 205, -1, 205, -1, - 281, -1, 106, 144, -1, 106, 145, 207, 146, 144, - -1, 106, 209, 144, -1, 106, 145, 207, 146, 209, - 144, -1, 207, 121, 208, -1, 208, -1, 267, -1, - 268, -1, 269, -1, 270, -1, 271, -1, 272, -1, - 273, -1, 274, -1, 275, -1, 276, -1, 277, -1, - 278, -1, 314, -1, 279, -1, 280, -1, 281, -1, - 282, -1, 283, -1, 284, -1, 209, 65, -1, 209, - 65, 22, 65, -1, 209, 121, 65, -1, 209, 121, - 65, 22, 65, -1, 65, -1, 65, 22, 65, -1, - 123, 38, -1, 122, 38, -1, 38, -1, 123, 30, - -1, 122, 30, -1, 30, -1, 24, 144, 213, 20, - -1, 213, 214, -1, 214, -1, 215, 121, 216, 144, - -1, 104, 65, -1, 65, -1, 12, 65, 121, 65, - -1, 224, 121, 217, -1, 225, 121, 224, 121, 217, - -1, 225, 121, 225, 121, 225, 121, 224, 121, 217, - -1, 225, -1, 225, 121, 225, 121, 225, -1, 225, - 121, 225, -1, 225, 121, 225, 121, 225, -1, 225, - 121, 225, 121, 225, 121, 225, -1, 225, 121, 225, - 121, 225, 121, 225, 121, 225, -1, 26, 144, 219, - 20, -1, 219, 220, -1, 220, -1, 104, 65, 121, - 225, 144, -1, 12, 65, 121, 65, 121, 225, 144, - -1, 65, 121, 225, 144, -1, 25, 144, 222, 20, - -1, 222, 223, -1, 223, -1, 104, 65, 121, 225, - 121, 225, 144, -1, 12, 65, 121, 65, 121, 225, - 121, 225, 144, -1, 65, 121, 225, 121, 225, 144, - -1, 6, -1, 32, -1, 74, -1, 39, -1, 111, - -1, -1, 38, -1, 30, -1, 65, -1, 122, 38, - -1, 122, 30, -1, 23, 144, -1, 23, 145, 227, - 146, 144, -1, 23, 209, 144, -1, 23, 145, 227, - 146, 209, 144, -1, 227, 121, 228, -1, 228, -1, - 285, -1, 286, -1, 287, -1, 288, -1, 289, -1, - 290, -1, 291, -1, 292, -1, 293, -1, 294, -1, - 295, -1, 296, -1, 297, -1, 298, -1, 299, -1, - 300, -1, 301, -1, 302, -1, 303, -1, 304, -1, - 305, -1, 306, -1, 307, -1, 308, -1, 278, -1, - 309, -1, 310, -1, 311, -1, 312, -1, 313, -1, - 315, -1, 316, -1, 321, -1, 322, -1, 323, -1, - 268, -1, 324, -1, 325, -1, 326, -1, 91, 145, - 230, 146, 144, -1, 91, 145, 230, 146, 209, 144, - -1, 230, 121, 231, -1, 231, -1, 292, -1, 293, - -1, 302, -1, 308, -1, 278, -1, 309, -1, 310, - -1, 311, -1, 312, -1, 313, -1, 321, -1, 322, - -1, 323, -1, 92, 145, 230, 146, 144, -1, 92, - 145, 230, 146, 209, 144, -1, 151, 65, 151, 121, - 151, 65, 151, -1, 151, 65, 151, 121, 225, -1, - 233, -1, 234, 121, 233, -1, 118, 209, 144, -1, - 75, 144, 237, 20, -1, 237, 238, -1, 238, -1, - 65, 145, 170, 146, 144, -1, 112, 209, 144, -1, - 80, 144, 241, 20, -1, 241, 65, 170, 144, -1, - 241, 65, 121, 65, 170, 144, -1, 65, 170, 144, - -1, 65, 121, 65, 170, 144, -1, 83, 209, 144, - -1, 82, 144, -1, 82, 145, 246, 146, 144, -1, - 82, 209, 144, -1, 82, 145, 246, 146, 209, 144, - -1, 76, 144, -1, 76, 145, 246, 146, 144, -1, - 76, 209, 144, -1, 76, 145, 246, 146, 209, 144, - -1, 317, -1, 208, -1, 245, -1, 246, 121, 245, - -1, 77, 209, 144, -1, 8, 144, 249, 20, -1, - 249, 250, -1, 250, -1, 65, 251, 22, 170, 144, - -1, 65, 121, 65, 251, 22, 170, 144, -1, 4, - 65, 145, 38, 146, 251, 22, 170, 144, -1, -1, - 145, 38, 146, -1, 145, 30, 146, -1, 7, 144, - -1, 7, 145, 13, 146, 144, -1, 19, 145, 65, - 146, 144, -1, 19, 145, 65, 146, 209, 144, -1, - 19, 65, 144, -1, 19, 145, 65, 152, 65, 146, - 144, -1, 19, 145, 65, 152, 65, 146, 209, 144, - -1, 19, 65, 152, 65, 144, -1, 18, 145, 65, - 146, 144, -1, 18, 145, 65, 146, 209, 144, -1, - 18, 65, 144, -1, 18, 145, 65, 152, 65, 146, - 144, -1, 18, 145, 65, 152, 65, 146, 209, 144, - -1, 18, 65, 152, 65, 144, -1, 60, 145, 256, - 146, 258, 144, -1, 256, 121, 257, -1, 257, -1, - 318, -1, 319, -1, 320, -1, 259, -1, 258, 121, - 259, -1, 259, 145, 225, 146, -1, 258, 121, 259, - 145, 225, 146, -1, 260, -1, 259, 260, -1, 65, - -1, 153, -1, 124, -1, 148, -1, 152, -1, -1, - -1, 86, 262, 185, 263, 144, -1, 108, 144, -1, - 108, 145, 265, 146, 144, -1, 108, 209, 144, -1, - 108, 145, 265, 146, 209, 144, -1, 265, 121, 266, - -1, 266, -1, 208, -1, 327, -1, 15, 22, 38, - -1, 103, 22, 38, -1, 100, 22, 38, -1, 46, - -1, 81, 22, 38, -1, 95, 22, 38, -1, 16, - 22, 38, -1, 3, 22, 38, -1, 68, -1, 70, - -1, 72, -1, 40, 22, 38, -1, 35, 22, 38, - -1, 36, 22, 38, -1, 85, 22, 38, -1, 99, - -1, 101, 22, 38, -1, 93, 22, 38, -1, 93, - 22, 30, -1, 14, 22, 65, -1, 66, 22, 331, - -1, 66, 22, 38, -1, 29, 22, 38, -1, 87, - 22, 38, -1, 88, 22, 38, -1, 44, 22, 38, - -1, 45, 22, 38, -1, 71, -1, 33, -1, 10, - 22, 30, -1, 54, 22, 38, -1, 49, 22, 30, - -1, 51, 22, 30, -1, 79, 22, 145, 234, 146, - -1, 50, 22, 30, -1, 50, 22, 38, -1, 58, - 22, 65, -1, 57, 22, 38, -1, 56, -1, 90, - 22, 30, -1, 52, 22, 38, -1, 53, 22, 38, - -1, 47, -1, 48, -1, 69, -1, 5, -1, 107, - -1, 31, 22, 38, -1, 102, -1, 64, -1, 28, - -1, 94, -1, 41, 22, 38, -1, 42, 22, 38, - -1, 78, 22, 225, -1, 62, 22, 43, -1, 62, - 22, 63, -1, 89, -1, 73, -1, 119, 22, 65, - -1, 120, 22, 328, -1, 27, 22, 331, -1, 11, - -1, 67, -1, 55, -1, 109, 22, 30, -1, 65, - 148, 65, -1, 38, -1, 38, 148, 38, -1, 149, - 329, -1, 330, 329, -1, 330, 150, -1 + 160, 0, -1, 161, -1, 160, 161, -1, 162, -1, + 173, -1, 174, -1, 188, -1, 178, -1, 180, -1, + 183, -1, 175, -1, 199, -1, 200, -1, 205, -1, + 208, -1, 211, -1, 214, -1, 217, -1, 237, -1, + 240, -1, 243, -1, 223, -1, 232, -1, 229, -1, + 246, -1, 247, -1, 250, -1, 163, -1, 164, -1, + 251, -1, 253, -1, 254, -1, 259, -1, 263, -1, + 264, -1, 265, -1, 255, -1, 258, -1, 266, -1, + 272, -1, 275, -1, 168, -1, 165, -1, 166, -1, + 167, -1, 18, 41, 149, -1, 18, 41, 41, 149, + -1, 100, 220, 149, -1, 120, 169, 149, -1, 121, + 170, 149, -1, 122, 171, 149, -1, 88, 172, 149, + -1, 169, 69, -1, 169, 126, 69, -1, 69, -1, + 169, 69, 115, -1, 169, 126, 69, 115, -1, 69, + 115, -1, 170, 69, -1, 170, 126, 69, -1, 69, + -1, 170, 69, 115, -1, 170, 126, 69, 115, -1, + 69, 115, -1, 171, 69, -1, 171, 126, 69, -1, + 69, -1, 171, 69, 115, -1, 171, 126, 69, 115, + -1, 69, 115, -1, 172, 69, -1, 172, 126, 69, + -1, 69, -1, 172, 69, 115, -1, 172, 126, 69, + 115, -1, 69, 115, -1, 89, 41, 149, -1, 89, + 23, 41, 149, -1, 14, 32, 149, -1, 14, 23, + 32, 149, -1, 69, 23, 176, 149, -1, 150, 176, + 151, -1, 69, -1, 32, -1, 41, -1, 176, 128, + 176, -1, 176, 127, 176, -1, 176, 129, 176, -1, + 176, 130, 176, -1, 176, 132, 176, -1, 127, 176, + -1, 128, 176, -1, 133, 150, 176, 151, -1, 134, + 150, 176, 151, -1, 135, 150, 176, 151, -1, 136, + 150, 176, 151, -1, 137, 150, 176, 151, -1, 138, + 150, 176, 151, -1, 139, 150, 176, 151, -1, 140, + 150, 176, 151, -1, 141, 150, 176, 151, -1, 148, + 150, 176, 151, -1, 69, 150, 176, 151, -1, 69, + 150, 177, 151, -1, 176, 126, 176, -1, 177, 126, + 176, -1, 40, 149, 181, 21, -1, 40, 150, 179, + 151, 149, 181, 21, -1, 28, 23, 69, -1, 22, + 149, 181, 21, -1, 181, 182, -1, 182, -1, 69, + 23, 176, 149, -1, 37, 149, 184, 21, -1, 184, + 185, -1, 185, -1, 69, 150, 221, 151, 23, 176, + 149, -1, 186, 126, 187, -1, 187, -1, 47, -1, + 35, -1, 293, -1, -1, 63, 149, 189, 194, 21, + -1, -1, 63, 150, 281, 151, 149, 190, 194, 21, + -1, -1, 63, 150, 118, 151, 149, 191, 194, 21, + -1, -1, 63, 150, 108, 126, 186, 151, 192, 149, + 194, 21, -1, -1, 63, 150, 108, 151, 193, 149, + 194, 21, -1, 194, 195, -1, 194, 197, -1, 195, + -1, 197, -1, 196, 23, 196, 149, -1, 196, 149, + -1, 150, 196, 151, -1, 198, -1, 32, -1, 41, + -1, 196, 128, 196, -1, 196, 127, 196, -1, 196, + 129, 196, -1, 196, 130, 196, -1, 196, 132, 196, + -1, 127, 196, -1, 128, 196, -1, 133, 150, 196, + 151, -1, 134, 150, 196, 151, -1, 135, 150, 196, + 151, -1, 136, 150, 196, 151, -1, 137, 150, 196, + 151, -1, 138, 150, 196, 151, -1, 139, 150, 196, + 151, -1, 140, 150, 196, 151, -1, 141, 150, 196, + 151, -1, 148, 150, 196, 151, -1, 152, 69, 23, + 196, 149, -1, 69, -1, 69, 150, 221, 151, -1, + 101, 149, 201, 21, -1, 65, 149, 201, 21, -1, + 201, 202, -1, 202, -1, 120, 69, 149, 89, 203, + 149, 119, 204, 149, -1, 120, 69, 149, 109, 176, + 149, -1, 120, 69, 23, 176, 149, -1, 120, 69, + 126, 69, 23, 176, 149, -1, 12, 69, 126, 69, + 23, 176, 149, -1, 203, 41, -1, 203, 41, 153, + 41, -1, 203, 126, 41, -1, 203, 126, 41, 153, + 41, -1, 41, 153, 41, -1, 41, -1, 204, 222, + -1, 204, 221, -1, 204, 69, -1, 222, -1, 221, + -1, 69, -1, 204, 150, 176, 151, -1, 150, 176, + 151, -1, 102, 23, 154, 206, 155, 149, -1, 206, + 149, 207, -1, 207, -1, 207, 126, 150, 176, 151, + -1, 207, 126, 32, -1, 207, 126, 41, -1, 207, + 150, 176, 151, -1, 207, 32, -1, 207, 41, -1, + 150, 176, 151, -1, 32, -1, 41, -1, 110, 149, + -1, 110, 150, 209, 151, 149, -1, 209, 126, 210, + -1, 210, -1, 279, -1, 9, 149, -1, 9, 150, + 212, 151, 149, -1, 212, 126, 213, -1, 213, -1, + 279, -1, 103, 149, -1, 103, 150, 215, 151, 149, + -1, 215, 126, 216, -1, 216, -1, 292, -1, 111, + 149, -1, 111, 150, 218, 151, 149, -1, 111, 220, + 149, -1, 111, 150, 218, 151, 220, 149, -1, 218, + 126, 219, -1, 219, -1, 278, -1, 279, -1, 280, + -1, 281, -1, 282, -1, 283, -1, 284, -1, 285, + -1, 286, -1, 287, -1, 288, -1, 289, -1, 326, + -1, 290, -1, 291, -1, 292, -1, 293, -1, 294, + -1, 295, -1, 296, -1, 220, 69, -1, 220, 69, + 23, 69, -1, 220, 126, 69, -1, 220, 126, 69, + 23, 69, -1, 69, -1, 69, 23, 69, -1, 128, + 41, -1, 127, 41, -1, 41, -1, 128, 32, -1, + 127, 32, -1, 32, -1, 25, 149, 224, 21, -1, + 224, 225, -1, 225, -1, 226, 126, 227, 149, -1, + 109, 69, -1, 69, -1, 12, 69, 126, 69, -1, + 235, 126, 228, -1, 236, 126, 235, 126, 228, -1, + 236, 126, 236, 126, 236, 126, 235, 126, 228, -1, + 236, -1, 236, 126, 236, 126, 236, -1, 236, 126, + 236, -1, 236, 126, 236, 126, 236, -1, 236, 126, + 236, 126, 236, 126, 236, -1, 236, 126, 236, 126, + 236, 126, 236, 126, 236, -1, 27, 149, 230, 21, + -1, 230, 231, -1, 231, -1, 109, 69, 126, 236, + 149, -1, 12, 69, 126, 69, 126, 236, 149, -1, + 69, 126, 236, 149, -1, 26, 149, 233, 21, -1, + 233, 234, -1, 234, -1, 109, 69, 126, 236, 126, + 236, 149, -1, 12, 69, 126, 69, 126, 236, 126, + 236, 149, -1, 69, 126, 236, 126, 236, 149, -1, + 6, -1, 34, -1, 78, -1, 42, -1, 116, -1, + -1, 41, -1, 32, -1, 69, -1, 127, 41, -1, + 127, 32, -1, 24, 149, -1, 24, 150, 238, 151, + 149, -1, 24, 220, 149, -1, 24, 150, 238, 151, + 220, 149, -1, 238, 126, 239, -1, 239, -1, 297, + -1, 298, -1, 299, -1, 300, -1, 301, -1, 302, + -1, 303, -1, 304, -1, 305, -1, 306, -1, 307, + -1, 308, -1, 309, -1, 310, -1, 311, -1, 312, + -1, 313, -1, 314, -1, 315, -1, 316, -1, 317, + -1, 318, -1, 319, -1, 320, -1, 289, -1, 321, + -1, 322, -1, 323, -1, 324, -1, 325, -1, 327, + -1, 328, -1, 333, -1, 334, -1, 335, -1, 279, + -1, 336, -1, 337, -1, 338, -1, 95, 150, 241, + 151, 149, -1, 95, 150, 241, 151, 220, 149, -1, + 241, 126, 242, -1, 242, -1, 304, -1, 305, -1, + 314, -1, 320, -1, 289, -1, 321, -1, 322, -1, + 323, -1, 324, -1, 325, -1, 333, -1, 334, -1, + 335, -1, 96, 150, 241, 151, 149, -1, 96, 150, + 241, 151, 220, 149, -1, 156, 69, 156, 126, 156, + 69, 156, -1, 156, 69, 156, 126, 236, -1, 244, + -1, 245, 126, 244, -1, 123, 220, 149, -1, 79, + 149, 248, 21, -1, 248, 249, -1, 249, -1, 69, + 150, 176, 151, 149, -1, 117, 220, 149, -1, 84, + 149, 252, 21, -1, 252, 69, 176, 149, -1, 252, + 69, 126, 69, 176, 149, -1, 69, 176, 149, -1, + 69, 126, 69, 176, 149, -1, 87, 220, 149, -1, + 86, 149, -1, 86, 150, 257, 151, 149, -1, 86, + 220, 149, -1, 86, 150, 257, 151, 220, 149, -1, + 80, 149, -1, 80, 150, 257, 151, 149, -1, 80, + 220, 149, -1, 80, 150, 257, 151, 220, 149, -1, + 329, -1, 219, -1, 256, -1, 257, 126, 256, -1, + 81, 220, 149, -1, 8, 149, 260, 21, -1, 260, + 261, -1, 261, -1, 69, 262, 23, 176, 149, -1, + 69, 126, 69, 262, 23, 176, 149, -1, 4, 69, + 150, 41, 151, 262, 23, 176, 149, -1, -1, 150, + 41, 151, -1, 150, 32, 151, -1, 7, 149, -1, + 7, 150, 13, 151, 149, -1, 20, 150, 69, 151, + 149, -1, 20, 150, 69, 151, 220, 149, -1, 20, + 69, 149, -1, 20, 150, 69, 157, 69, 151, 149, + -1, 20, 150, 69, 157, 69, 151, 220, 149, -1, + 20, 69, 157, 69, 149, -1, 19, 150, 69, 151, + 149, -1, 19, 150, 69, 151, 220, 149, -1, 19, + 69, 149, -1, 19, 150, 69, 157, 69, 151, 149, + -1, 19, 150, 69, 157, 69, 151, 220, 149, -1, + 19, 69, 157, 69, 149, -1, 64, 150, 267, 151, + 269, 149, -1, 267, 126, 268, -1, 268, -1, 330, + -1, 331, -1, 332, -1, 270, -1, 269, 126, 270, + -1, 270, 150, 236, 151, -1, 269, 126, 270, 150, + 236, 151, -1, 271, -1, 270, 271, -1, 69, -1, + 158, -1, 129, -1, 153, -1, 157, -1, -1, -1, + 90, 273, 196, 274, 149, -1, 113, 149, -1, 113, + 150, 276, 151, 149, -1, 113, 220, 149, -1, 113, + 150, 276, 151, 220, 149, -1, 276, 126, 277, -1, + 277, -1, 219, -1, 339, -1, 16, 23, 41, -1, + 107, 23, 41, -1, 104, 23, 41, -1, 50, -1, + 85, 23, 41, -1, 99, 23, 41, -1, 17, 23, + 41, -1, 3, 23, 41, -1, 72, -1, 74, -1, + 76, -1, 43, 23, 41, -1, 38, 23, 41, -1, + 39, 23, 41, -1, 89, 23, 41, -1, 14, 23, + 32, -1, 103, -1, 105, 23, 41, -1, 97, 23, + 41, -1, 97, 23, 32, -1, 15, 23, 69, -1, + 70, 23, 343, -1, 70, 23, 41, -1, 31, 23, + 41, -1, 91, 23, 41, -1, 92, 23, 41, -1, + 48, 23, 41, -1, 49, 23, 41, -1, 75, -1, + 36, -1, 10, 23, 32, -1, 58, 23, 41, -1, + 53, 23, 32, -1, 55, 23, 32, -1, 83, 23, + 150, 245, 151, -1, 54, 23, 32, -1, 54, 23, + 41, -1, 62, 23, 69, -1, 61, 23, 41, -1, + 60, -1, 94, 23, 32, -1, 56, 23, 41, -1, + 57, 23, 41, -1, 51, -1, 52, -1, 73, -1, + 5, -1, 112, -1, 33, 23, 41, -1, 106, -1, + 68, -1, 30, -1, 98, -1, 44, 23, 41, -1, + 45, 23, 41, -1, 82, 23, 236, -1, 66, 23, + 46, -1, 66, 23, 67, -1, 93, -1, 77, -1, + 124, 23, 69, -1, 125, 23, 340, -1, 29, 23, + 343, -1, 11, -1, 71, -1, 59, -1, 114, 23, + 32, -1, 69, 153, 69, -1, 41, -1, 41, 153, + 41, -1, 154, 341, -1, 342, 341, -1, 342, 155, + -1 }; /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in @@ -3369,52 +3461,53 @@ namespace yy 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, - 80, 82, 84, 86, 88, 90, 94, 99, 103, 107, - 111, 115, 119, 122, 126, 128, 132, 137, 140, 143, - 147, 149, 153, 158, 161, 164, 168, 170, 174, 179, - 182, 185, 189, 191, 195, 200, 203, 207, 212, 217, - 221, 223, 225, 227, 231, 235, 239, 243, 247, 250, - 253, 258, 263, 268, 273, 278, 283, 288, 293, 298, - 303, 308, 313, 317, 321, 326, 331, 334, 336, 341, - 346, 349, 351, 359, 360, 366, 367, 376, 377, 386, - 389, 392, 394, 396, 401, 404, 408, 410, 412, 414, - 418, 422, 426, 430, 434, 437, 440, 445, 450, 455, - 460, 465, 470, 475, 480, 485, 490, 496, 498, 503, - 508, 513, 516, 518, 528, 535, 541, 549, 557, 560, - 565, 569, 575, 579, 581, 584, 587, 590, 592, 594, - 596, 601, 605, 612, 616, 618, 624, 628, 632, 637, - 640, 643, 647, 649, 651, 654, 660, 664, 666, 668, - 671, 677, 681, 683, 685, 688, 694, 698, 700, 702, - 705, 711, 715, 722, 726, 728, 730, 732, 734, 736, - 738, 740, 742, 744, 746, 748, 750, 752, 754, 756, - 758, 760, 762, 764, 766, 769, 774, 778, 784, 786, - 790, 793, 796, 798, 801, 804, 806, 811, 814, 816, - 821, 824, 826, 831, 835, 841, 851, 853, 859, 863, - 869, 877, 887, 892, 895, 897, 903, 911, 916, 921, - 924, 926, 934, 944, 951, 953, 955, 957, 959, 961, - 962, 964, 966, 968, 971, 974, 977, 983, 987, 994, - 998, 1000, 1002, 1004, 1006, 1008, 1010, 1012, 1014, 1016, - 1018, 1020, 1022, 1024, 1026, 1028, 1030, 1032, 1034, 1036, - 1038, 1040, 1042, 1044, 1046, 1048, 1050, 1052, 1054, 1056, - 1058, 1060, 1062, 1064, 1066, 1068, 1070, 1072, 1074, 1076, - 1078, 1084, 1091, 1095, 1097, 1099, 1101, 1103, 1105, 1107, - 1109, 1111, 1113, 1115, 1117, 1119, 1121, 1123, 1129, 1136, - 1144, 1150, 1152, 1156, 1160, 1165, 1168, 1170, 1176, 1180, - 1185, 1190, 1197, 1201, 1207, 1211, 1214, 1220, 1224, 1231, - 1234, 1240, 1244, 1251, 1253, 1255, 1257, 1261, 1265, 1270, - 1273, 1275, 1281, 1289, 1299, 1300, 1304, 1308, 1311, 1317, - 1323, 1330, 1334, 1342, 1351, 1357, 1363, 1370, 1374, 1382, - 1391, 1397, 1404, 1408, 1410, 1412, 1414, 1416, 1418, 1422, - 1427, 1434, 1436, 1439, 1441, 1443, 1445, 1447, 1449, 1450, - 1451, 1457, 1460, 1466, 1470, 1477, 1481, 1483, 1485, 1487, - 1491, 1495, 1499, 1501, 1505, 1509, 1513, 1517, 1519, 1521, - 1523, 1527, 1531, 1535, 1539, 1541, 1545, 1549, 1553, 1557, - 1561, 1565, 1569, 1573, 1577, 1581, 1585, 1587, 1589, 1593, - 1597, 1601, 1605, 1611, 1615, 1619, 1623, 1627, 1629, 1633, - 1637, 1641, 1643, 1645, 1647, 1649, 1651, 1655, 1657, 1659, - 1661, 1663, 1667, 1671, 1675, 1679, 1683, 1685, 1687, 1691, - 1695, 1699, 1701, 1703, 1705, 1709, 1713, 1715, 1719, 1722, - 1725 + 80, 82, 84, 86, 88, 90, 92, 96, 101, 105, + 109, 113, 117, 121, 124, 128, 130, 134, 139, 142, + 145, 149, 151, 155, 160, 163, 166, 170, 172, 176, + 181, 184, 187, 191, 193, 197, 202, 205, 209, 214, + 218, 223, 228, 232, 234, 236, 238, 242, 246, 250, + 254, 258, 261, 264, 269, 274, 279, 284, 289, 294, + 299, 304, 309, 314, 319, 324, 328, 332, 337, 345, + 349, 354, 357, 359, 364, 369, 372, 374, 382, 386, + 388, 390, 392, 394, 395, 401, 402, 411, 412, 421, + 422, 433, 434, 443, 446, 449, 451, 453, 458, 461, + 465, 467, 469, 471, 475, 479, 483, 487, 491, 494, + 497, 502, 507, 512, 517, 522, 527, 532, 537, 542, + 547, 553, 555, 560, 565, 570, 573, 575, 585, 592, + 598, 606, 614, 617, 622, 626, 632, 636, 638, 641, + 644, 647, 649, 651, 653, 658, 662, 669, 673, 675, + 681, 685, 689, 694, 697, 700, 704, 706, 708, 711, + 717, 721, 723, 725, 728, 734, 738, 740, 742, 745, + 751, 755, 757, 759, 762, 768, 772, 779, 783, 785, + 787, 789, 791, 793, 795, 797, 799, 801, 803, 805, + 807, 809, 811, 813, 815, 817, 819, 821, 823, 825, + 828, 833, 837, 843, 845, 849, 852, 855, 857, 860, + 863, 865, 870, 873, 875, 880, 883, 885, 890, 894, + 900, 910, 912, 918, 922, 928, 936, 946, 951, 954, + 956, 962, 970, 975, 980, 983, 985, 993, 1003, 1010, + 1012, 1014, 1016, 1018, 1020, 1021, 1023, 1025, 1027, 1030, + 1033, 1036, 1042, 1046, 1053, 1057, 1059, 1061, 1063, 1065, + 1067, 1069, 1071, 1073, 1075, 1077, 1079, 1081, 1083, 1085, + 1087, 1089, 1091, 1093, 1095, 1097, 1099, 1101, 1103, 1105, + 1107, 1109, 1111, 1113, 1115, 1117, 1119, 1121, 1123, 1125, + 1127, 1129, 1131, 1133, 1135, 1137, 1143, 1150, 1154, 1156, + 1158, 1160, 1162, 1164, 1166, 1168, 1170, 1172, 1174, 1176, + 1178, 1180, 1182, 1188, 1195, 1203, 1209, 1211, 1215, 1219, + 1224, 1227, 1229, 1235, 1239, 1244, 1249, 1256, 1260, 1266, + 1270, 1273, 1279, 1283, 1290, 1293, 1299, 1303, 1310, 1312, + 1314, 1316, 1320, 1324, 1329, 1332, 1334, 1340, 1348, 1358, + 1359, 1363, 1367, 1370, 1376, 1382, 1389, 1393, 1401, 1410, + 1416, 1422, 1429, 1433, 1441, 1450, 1456, 1463, 1467, 1469, + 1471, 1473, 1475, 1477, 1481, 1486, 1493, 1495, 1498, 1500, + 1502, 1504, 1506, 1508, 1509, 1510, 1516, 1519, 1525, 1529, + 1536, 1540, 1542, 1544, 1546, 1550, 1554, 1558, 1560, 1564, + 1568, 1572, 1576, 1578, 1580, 1582, 1586, 1590, 1594, 1598, + 1602, 1604, 1608, 1612, 1616, 1620, 1624, 1628, 1632, 1636, + 1640, 1644, 1648, 1650, 1652, 1656, 1660, 1664, 1668, 1674, + 1678, 1682, 1686, 1690, 1692, 1696, 1700, 1704, 1706, 1708, + 1710, 1712, 1714, 1718, 1720, 1722, 1724, 1726, 1730, 1734, + 1738, 1742, 1746, 1748, 1750, 1754, 1758, 1762, 1764, 1766, + 1768, 1772, 1776, 1778, 1782, 1785, 1788 }; /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */ @@ -3425,52 +3518,53 @@ namespace yy 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, - 130, 135, 136, 137, 138, 142, 143, 146, 149, 153, - 157, 161, 165, 167, 169, 171, 173, 175, 180, 182, - 184, 186, 188, 190, 195, 197, 199, 201, 203, 205, - 210, 212, 214, 216, 218, 220, 225, 229, 237, 242, - 244, 246, 248, 250, 252, 254, 256, 258, 260, 262, - 264, 266, 268, 270, 272, 274, 276, 278, 280, 282, - 284, 286, 291, 293, 297, 302, 307, 308, 312, 317, - 322, 323, 327, 332, 332, 333, 333, 335, 335, 340, - 341, 342, 343, 347, 349, 354, 355, 356, 358, 360, - 362, 364, 366, 368, 370, 372, 374, 376, 378, 380, - 382, 384, 386, 388, 390, 392, 396, 400, 402, 407, - 411, 415, 416, 420, 422, 424, 426, 428, 433, 435, - 437, 439, 441, 443, 449, 451, 453, 455, 457, 459, - 461, 463, 468, 473, 475, 480, 482, 484, 486, 488, - 490, 492, 494, 496, 501, 505, 509, 510, 513, 517, - 519, 523, 524, 527, 531, 533, 537, 538, 541, 545, - 547, 549, 551, 555, 556, 559, 560, 561, 562, 563, - 564, 565, 566, 567, 568, 569, 570, 571, 572, 573, - 574, 575, 576, 577, 581, 583, 585, 587, 589, 591, - 596, 598, 600, 605, 607, 609, 614, 619, 621, 626, - 630, 635, 640, 650, 655, 661, 671, 676, 687, 693, - 701, 711, 725, 729, 731, 735, 742, 751, 760, 764, - 766, 770, 779, 790, 802, 804, 806, 808, 810, 815, - 816, 817, 818, 819, 821, 828, 830, 832, 834, 839, - 840, 843, 844, 845, 846, 847, 848, 849, 850, 851, - 852, 853, 854, 855, 856, 857, 858, 859, 860, 861, - 862, 863, 864, 865, 866, 867, 868, 869, 870, 871, - 872, 873, 874, 875, 876, 877, 878, 879, 880, 881, - 885, 887, 892, 893, 897, 898, 899, 900, 901, 902, - 903, 904, 905, 906, 907, 908, 909, 913, 915, 920, - 921, 925, 926, 930, 935, 940, 941, 944, 948, 951, - 955, 957, 959, 961, 965, 968, 969, 970, 971, 974, - 975, 976, 977, 980, 981, 984, 985, 988, 991, 995, - 996, 999, 1000, 1001, 1004, 1005, 1006, 1009, 1010, 1013, - 1014, 1015, 1016, 1017, 1018, 1020, 1021, 1022, 1023, 1024, - 1025, 1027, 1031, 1032, 1035, 1036, 1037, 1040, 1041, 1042, - 1043, 1046, 1047, 1050, 1051, 1052, 1053, 1054, 1057, 1057, - 1057, 1060, 1062, 1064, 1066, 1071, 1072, 1075, 1076, 1079, - 1080, 1081, 1082, 1083, 1084, 1085, 1086, 1087, 1088, 1089, - 1090, 1091, 1092, 1093, 1094, 1095, 1096, 1097, 1099, 1100, - 1101, 1103, 1104, 1105, 1106, 1107, 1108, 1109, 1110, 1111, - 1112, 1113, 1114, 1115, 1116, 1117, 1118, 1119, 1120, 1121, - 1122, 1123, 1124, 1125, 1126, 1127, 1128, 1129, 1130, 1131, - 1132, 1133, 1134, 1135, 1137, 1139, 1142, 1143, 1144, 1145, - 1146, 1147, 1148, 1149, 1150, 1152, 1160, 1161, 1165, 1166, - 1175 + 130, 131, 136, 137, 138, 139, 143, 144, 147, 150, + 154, 158, 162, 166, 168, 170, 172, 174, 176, 181, + 183, 185, 187, 189, 191, 196, 198, 200, 202, 204, + 206, 211, 213, 215, 217, 219, 221, 226, 230, 237, + 241, 248, 253, 255, 257, 259, 261, 263, 265, 267, + 269, 271, 273, 275, 277, 279, 281, 283, 285, 287, + 289, 291, 293, 295, 297, 302, 304, 308, 310, 315, + 319, 324, 325, 329, 334, 339, 340, 344, 348, 349, + 353, 354, 355, 359, 359, 360, 360, 362, 362, 364, + 364, 366, 366, 371, 372, 373, 374, 378, 380, 385, + 386, 387, 389, 391, 393, 395, 397, 399, 401, 403, + 405, 407, 409, 411, 413, 415, 417, 419, 421, 423, + 427, 431, 433, 438, 442, 446, 447, 451, 453, 455, + 457, 459, 464, 466, 468, 470, 472, 474, 480, 482, + 484, 486, 488, 490, 492, 494, 499, 504, 506, 511, + 513, 515, 517, 519, 521, 523, 525, 527, 532, 536, + 540, 541, 544, 548, 550, 554, 555, 558, 562, 564, + 568, 569, 572, 576, 578, 580, 582, 586, 587, 590, + 591, 592, 593, 594, 595, 596, 597, 598, 599, 600, + 601, 602, 603, 604, 605, 606, 607, 608, 609, 613, + 615, 617, 619, 621, 623, 628, 630, 632, 637, 639, + 641, 646, 651, 653, 658, 662, 667, 672, 682, 687, + 693, 703, 708, 719, 725, 733, 743, 757, 761, 763, + 767, 774, 783, 792, 796, 798, 802, 811, 822, 834, + 836, 838, 840, 842, 847, 848, 849, 850, 851, 853, + 860, 862, 864, 866, 871, 872, 875, 876, 877, 878, + 879, 880, 881, 882, 883, 884, 885, 886, 887, 888, + 889, 890, 891, 892, 893, 894, 895, 896, 897, 898, + 899, 900, 901, 902, 903, 904, 905, 906, 907, 908, + 909, 910, 911, 912, 913, 917, 919, 924, 925, 929, + 930, 931, 932, 933, 934, 935, 936, 937, 938, 939, + 940, 941, 945, 947, 952, 953, 957, 958, 962, 967, + 972, 973, 976, 980, 983, 987, 989, 991, 993, 997, + 1000, 1001, 1002, 1003, 1006, 1007, 1008, 1009, 1012, 1013, + 1016, 1017, 1020, 1023, 1027, 1028, 1031, 1032, 1033, 1036, + 1037, 1038, 1041, 1042, 1045, 1046, 1047, 1048, 1049, 1050, + 1052, 1053, 1054, 1055, 1056, 1057, 1059, 1063, 1064, 1067, + 1068, 1069, 1072, 1073, 1074, 1075, 1078, 1079, 1082, 1083, + 1084, 1085, 1086, 1089, 1089, 1089, 1092, 1094, 1096, 1098, + 1103, 1104, 1107, 1108, 1111, 1112, 1113, 1114, 1115, 1116, + 1117, 1118, 1119, 1120, 1121, 1122, 1123, 1124, 1125, 1126, + 1127, 1128, 1129, 1130, 1132, 1133, 1134, 1136, 1137, 1138, + 1139, 1140, 1141, 1142, 1143, 1144, 1145, 1146, 1147, 1148, + 1149, 1150, 1151, 1152, 1153, 1154, 1155, 1156, 1157, 1158, + 1159, 1160, 1161, 1162, 1163, 1164, 1165, 1166, 1167, 1168, + 1170, 1172, 1175, 1176, 1177, 1178, 1179, 1180, 1181, 1182, + 1183, 1185, 1193, 1194, 1198, 1199, 1208 }; // Print the state stack on the debug stream. @@ -3513,13 +3607,13 @@ namespace yy 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 147, 2, 2, 2, 151, - 145, 146, 2, 2, 2, 2, 152, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 148, 144, + 2, 2, 2, 2, 2, 152, 2, 2, 2, 156, + 150, 151, 2, 2, 2, 2, 157, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 153, 149, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 149, 153, 150, 2, 2, 2, 2, 2, 2, + 2, 154, 158, 155, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, @@ -3549,7 +3643,8 @@ namespace yy 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, - 135, 136, 137, 138, 139, 140, 141, 142, 143 + 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, + 145, 146, 147, 148 }; if ((unsigned int) t <= yyuser_token_number_max_) return translate_table[t]; @@ -3558,20 +3653,20 @@ namespace yy } const int parser::yyeof_ = 0; - const int parser::yylast_ = 1396; - const int parser::yynnts_ = 178; + const int parser::yylast_ = 1473; + const int parser::yynnts_ = 185; const int parser::yyempty_ = -2; - const int parser::yyfinal_ = 147; + const int parser::yyfinal_ = 152; const int parser::yyterror_ = 1; const int parser::yyerrcode_ = 256; - const int parser::yyntokens_ = 154; + const int parser::yyntokens_ = 159; - const unsigned int parser::yyuser_token_number_max_ = 398; + const unsigned int parser::yyuser_token_number_max_ = 403; const parser::token_number_type parser::yyundef_token_ = 2; } // namespace yy -#line 1177 "DynareBison.yy" +#line 1210 "DynareBison.yy" void diff --git a/parser.src/DynareBison.yy b/parser.src/DynareBison.yy index 58d3fca04..9527de975 100644 --- a/parser.src/DynareBison.yy +++ b/parser.src/DynareBison.yy @@ -40,19 +40,19 @@ typedef pair ExpObj; %token AR AUTOCORR %token BAYESIAN_IRF BETA_PDF -%token CALIB CALIB_VAR CHECK CONF_SIG CONSTANT CORR COVAR +%token CALIB CALIB_VAR CHECK CONF_SIG CONSTANT CORR COVAR CUTOFF %token DATAFILE DR_ALGO DROP DSAMPLE DYNASAVE DYNATYPE %token END ENDVAL EQUAL ESTIMATION ESTIMATED_PARAMS ESTIMATED_PARAMS_BOUNDS ESTIMATED_PARAMS_INIT -%token FILTER_STEP_AHEAD FILTERED_VARS FIRST_OBS +%token FILENAME FILTER_STEP_AHEAD FILTERED_VARS FIRST_OBS %token FLOAT_NUMBER %token FORECAST -%token GAMMA_PDF GRAPH +%token GAMMA_PDF GCC_COMPILER GRAPH %token HISTVAL HP_FILTER HP_NGRID %token INITVAL %token INT_NUMBER %token INV_GAMMA_PDF IRF %token KALMAN_ALGO KALMAN_TOL -%token LAPLACE LIK_ALGO LIK_INIT LINEAR LOAD_MH_FILE LOGLINEAR +%token LAPLACE LCC_COMPILER LIK_ALGO LIK_INIT LINEAR LOAD_MH_FILE LOGLINEAR %token MH_DROP MH_INIT_SCALE MH_JSCALE MH_MODE MH_NBLOCKS MH_REPLIC MH_RECOVER %token MODE_CHECK MODE_COMPUTE MODE_FILE MODEL MODEL_COMPARISON MSHOCKS %token MODEL_COMPARISON_APPROXIMATION MODIFIEDHARMONICMEAN MOMENTS_VARENDO @@ -62,7 +62,7 @@ typedef pair ExpObj; %token PARAMETERS PERIODS PLANNER_OBJECTIVE PREFILTER PRESAMPLE PRINT PRIOR_TRUNC PRIOR_ANALYSIS POSTERIOR_ANALYSIS %token QZ_CRITERIUM %token RELATIVE_IRF REPLIC RPLOT -%token SHOCKS SIGMA_E SIMUL SIMUL_ALGO SIMUL_SEED SMOOTHER SOLVE_ALGO STDERR STEADY STOCH_SIMUL +%token SHOCKS SIGMA_E SIMUL SIMUL_ALGO SIMUL_SEED SMOOTHER SOLVE_ALGO SPARSE_DLL STDERR STEADY STOCH_SIMUL %token TEX RAMSEY_POLICY PLANNER_DISCOUNT %token TEX_NAME %token UNIFORM_PDF UNIT_ROOT_VARS USE_DLL @@ -93,6 +93,7 @@ typedef pair ExpObj; statement : declaration | periods + | cutoff | model | initval | endval @@ -232,6 +233,16 @@ typedef pair ExpObj; } ; +cutoff + : CUTOFF FLOAT_NUMBER ';' + { + driver.cutoff($2); + } + | CUTOFF EQUAL FLOAT_NUMBER ';' + { + driver.cutoff($3); + } + ; init_param : NAME EQUAL expression ';' @@ -296,7 +307,13 @@ typedef pair ExpObj; initval : INITVAL ';' initval_list END {driver.end_initval();} + | INITVAL '(' initval_option ')' ';' initval_list END + {driver.end_initval();} ; + + initval_option + : FILENAME EQUAL NAME {driver.init_val_filename($3);} + ; endval : ENDVAL ';' initval_list END @@ -327,6 +344,16 @@ typedef pair ExpObj; : NAME '(' signed_integer ')' EQUAL expression ';' {driver.hist_val($1, $3, $6);} ; + + model_sparse_options_list : model_sparse_options_list COMMA model_sparse_options + | model_sparse_options + ; + + model_sparse_options : + LCC_COMPILER { driver.init_compiler(0); } + | GCC_COMPILER { driver.init_compiler(1); } + | o_cutoff + ; model : MODEL ';' { driver.begin_model(); } equation_list END @@ -334,6 +361,10 @@ typedef pair ExpObj; equation_list END | MODEL '(' USE_DLL ')' ';' { driver.begin_model(); driver.use_dll(); } equation_list END + | MODEL '(' SPARSE_DLL COMMA model_sparse_options_list ')' { driver.sparse_dll(); driver.begin_model(); } ';' + equation_list END + | MODEL '(' SPARSE_DLL ')' { driver.sparse_dll(); driver.begin_model(); } ';' + equation_list END ; equation_list @@ -529,9 +560,9 @@ typedef pair ExpObj; simul : SIMUL ';' - {driver.simul();} + {driver.simulate();} | SIMUL '(' simul_options_list ')' ';' - {driver.simul();} + {driver.simulate();} ; simul_options_list: simul_options_list COMMA simul_options @@ -572,6 +603,7 @@ typedef pair ExpObj; | o_hp_filter | o_hp_ngrid | o_periods + | o_cutoff | o_simul | o_simul_seed | o_qz_criterium @@ -1091,6 +1123,7 @@ typedef pair ExpObj; o_hp_filter: HP_FILTER EQUAL INT_NUMBER {driver.option_num("hp_filter", $3);}; o_hp_ngrid: HP_NGRID EQUAL INT_NUMBER {driver.option_num("hp_ngrid", $3);}; o_periods: PERIODS EQUAL INT_NUMBER {driver.option_num("periods", $3); driver.option_num("simul", "1");}; + o_cutoff: CUTOFF EQUAL FLOAT_NUMBER {driver.option_num("cutoff", $3);} o_simul: SIMUL {driver.option_num("simul", "1");}; o_simul_seed: SIMUL_SEED EQUAL INT_NUMBER { driver.option_num("simul_seed", $3)}; o_qz_criterium: QZ_CRITERIUM EQUAL INT_NUMBER { driver.option_num("qz_criterium", $3)} diff --git a/parser.src/DynareFlex.ll b/parser.src/DynareFlex.ll index 6883563c4..5218d277b 100644 --- a/parser.src/DynareFlex.ll +++ b/parser.src/DynareFlex.ll @@ -57,6 +57,7 @@ int sigma_e = 0; varexo_det {BEGIN DYNARE_STATEMENT; return token::VAREXO_DET;} parameters {BEGIN DYNARE_STATEMENT; return token::PARAMETERS;} periods {BEGIN DYNARE_STATEMENT; return token::PERIODS;} +cutoff {BEGIN DYNARE_STATEMENT; return token::CUTOFF;} estimation {BEGIN DYNARE_STATEMENT; return token::ESTIMATION;} prior_analysis {BEGIN DYNARE_STATEMENT; return token::PRIOR_ANALYSIS;} posterior_analysis {BEGIN DYNARE_STATEMENT; return token::POSTERIOR_ANALYSIS;} @@ -148,6 +149,7 @@ int sigma_e = 0; nocorr {return token::NOCORR;} optim {return token::OPTIM;} periods {return token::PERIODS;} +cutoff {return token::CUTOFF;} model_comparison_approximation {return token::MODEL_COMPARISON;} laplace {return token::LAPLACE;} modifiedharmonicmean {return token::MODIFIEDHARMONICMEAN;} @@ -167,7 +169,7 @@ int sigma_e = 0; values {return token::VALUES;} corr {return token::CORR;} periods {return token::PERIODS;} - +filename {return token::FILENAME;} gamma_pdf {return token::GAMMA_PDF;} beta_pdf {return token::BETA_PDF;} normal_pdf {return token::NORMAL_PDF;} @@ -208,6 +210,9 @@ int sigma_e = 0; [\'] {return yy::parser::token_type (yytext[0]);} use_dll {return token::USE_DLL;} +sparse_dll {return token::SPARSE_DLL;} +gcc_compiler {return token::GCC_COMPILER;} +lcc_compiler {return token::LCC_COMPILER;} linear {return token::LINEAR;} [,] {return token::COMMA;} [:] {return yy::parser::token_type (yytext[0]);} diff --git a/parser.src/ExprNode.cc b/parser.src/ExprNode.cc index 4ec5e96ff..191930562 100644 --- a/parser.src/ExprNode.cc +++ b/parser.src/ExprNode.cc @@ -2,6 +2,8 @@ #include #include +#include + #include "ExprNode.hh" #include "DataTree.hh" @@ -52,6 +54,18 @@ ExprNode::cost(const temporary_terms_type &temporary_terms) const return 0; } +int +ExprNode::present_endogenous_size() const +{ + return(present_endogenous.size()); +} + +int +ExprNode::present_endogenous_find(int var, int lag) const +{ + return(present_endogenous.find(make_pair(var,lag))!=present_endogenous.end()); +} + void ExprNode::computeTemporaryTerms(map &reference_count, temporary_terms_type &temporary_terms) const @@ -59,6 +73,16 @@ ExprNode::computeTemporaryTerms(map &reference_count, // Nothing to do for a terminal node } +void +ExprNode::computeTemporaryTerms(map &reference_count, + temporary_terms_type &temporary_terms, + map &first_occurence, + int Curr_block, + Model_Block *ModelBlock) const +{ + // Nothing to do for a terminal node +} + NumConstNode::NumConstNode(DataTree &datatree_arg, int id_arg) : ExprNode(datatree_arg), id(id_arg) @@ -77,15 +101,29 @@ NumConstNode::computeDerivative(int varID) void NumConstNode::writeOutput(ostream &output, bool is_dynamic, - const temporary_terms_type &temporary_terms) const + const temporary_terms_type &temporary_terms, int offset) const { temporary_terms_type::const_iterator it = temporary_terms.find(const_cast(this)); if (it != temporary_terms.end()) - output << "T" << idx; + if (offset != 2) + output << "T" << idx; + else + output << "T" << idx << "[it_]"; else output << datatree.num_constants.get(id); } +void +NumConstNode::Evaluate() const +{ + datatree.interprete_.Stack.push(atof(datatree.num_constants.get(id).c_str())); +} + +void +NumConstNode::collectEndogenous(NodeID &Id) +{ +} + VariableNode::VariableNode(DataTree &datatree_arg, int id_arg, Type type_arg) : ExprNode(datatree_arg), id(id_arg), @@ -150,13 +188,16 @@ VariableNode::computeDerivative(int varID) void VariableNode::writeOutput(ostream &output, bool is_dynamic, - const temporary_terms_type &temporary_terms) const + const temporary_terms_type &temporary_terms, int offset) const { // If node is a temporary term temporary_terms_type::const_iterator it = temporary_terms.find(const_cast(this)); if (it != temporary_terms.end()) { - output << "T" << idx; + if (offset != 2) + output << "T" << idx; + else + output << "T" << idx << "[it_]"; return; } @@ -167,7 +208,10 @@ VariableNode::writeOutput(ostream &output, bool is_dynamic, switch(type) { case eParameter: - output << "params" << lpar << id + datatree.offset << rpar; + if (datatree.offset < 2) + output << "params" << lpar << id + datatree.offset << rpar; + else + output << "params" << lpar << id << rpar; break; case eLocalParameter: output << datatree.symbol_table.getNameByID(eLocalParameter, id); @@ -175,17 +219,39 @@ VariableNode::writeOutput(ostream &output, bool is_dynamic, case eEndogenous: if (is_dynamic) { - idx = datatree.variable_table.getPrintIndex(id) + datatree.offset; - output << "y" << lpar << idx << rpar; + if (datatree.offset < 2) + idx = datatree.variable_table.getPrintIndex(id) + datatree.offset; + else + idx = datatree.variable_table.getSymbolID(id); + + if (datatree.offset == 2) + { + int l = datatree.variable_table.getLag((long int) id); + if (l > 0) + output << "y" << lpar << "(it_+" << l << ")*y_size+" << idx << rpar; + else if (l < 0) + output << "y" << lpar << "(it_" << l << ")*y_size+" << idx << rpar; + else + output << "y" << lpar << "Per_y_+" << idx << rpar; + } + else + output << "y" << lpar << idx << rpar; } else { - idx = datatree.variable_table.getSymbolID(id) + datatree.offset; + if (datatree.offset < 2) + idx = datatree.variable_table.getSymbolID(id) + datatree.offset; + else + idx = datatree.variable_table.getSymbolID(id); output << "y" << lpar << idx << rpar; } break; case eExogenous: - idx = datatree.variable_table.getSymbolID(id) + datatree.offset; + if (datatree.offset < 2) + idx = datatree.variable_table.getSymbolID(id) + datatree.offset; + else + idx = datatree.variable_table.getSymbolID(id); + if (is_dynamic) { int lag = datatree.variable_table.getLag(id); @@ -195,30 +261,40 @@ VariableNode::writeOutput(ostream &output, bool is_dynamic, else output << "x" << lpar << "it_, " << idx << rpar; else - if (lag != 0) + if (lag == 0) + output << "x" << lpar << "it_+" << idx << "*nb_row_x" << rpar; + else if (lag > 0) output << "x" << lpar << "it_+" << lag << "+" << idx << "*nb_row_x" << rpar; else - output << "x" << lpar << "it_+" << idx << "*nb_row_x" << rpar; + output << "x" << lpar << "it_" << lag << "+" << idx << "*nb_row_x" << rpar; } else output << "x" << lpar << idx << rpar; break; case eExogenousDet: - idx = datatree.variable_table.getSymbolID(id) + datatree.symbol_table.exo_nbr - + datatree.offset; + if (datatree.offset < 2) + idx = datatree.variable_table.getSymbolID(id) + datatree.symbol_table.exo_nbr + + datatree.offset; + else + idx = datatree.variable_table.getSymbolID(id) + datatree.symbol_table.exo_nbr; + if (is_dynamic) { int lag = datatree.variable_table.getLag(id); if (datatree.offset == 1) - if (lag != 0) - output << "x" << lpar << "it_ + " << lag << ", " << idx << rpar; + if (lag > 0) + output << "x" << lpar << "it_ +" << lag << ", " << idx << rpar; + else if (lag < 0) + output << "x" << lpar << "it_ " << lag << ", " << idx << rpar; else output << "x" << lpar << "it_, " << idx << rpar; else - if (lag != 0) - output << "x" << lpar << "it_ + " << lag << "+" << idx << "*nb_row_xd" << rpar; - else + if (lag == 0) output << "x" << lpar << "it_+" << idx << "*nb_row_xd" << rpar; + else if (lag < 0) + output << "x" << lpar << "it_ " << lag << "+" << idx << "*nb_row_xd" << rpar; + else + output << "x" << lpar << "it_ +" << lag << "+" << idx << "*nb_row_xd" << rpar; } else output << "x" << lpar << idx << rpar; @@ -235,6 +311,26 @@ VariableNode::writeOutput(ostream &output, bool is_dynamic, } } +void +VariableNode::Evaluate() const +{ + if (type == eParameter) + datatree.interprete_.Stack.push(datatree.interprete_.GetDataValue(id, type)); + else + datatree.interprete_.Stack.push(datatree.interprete_.GetDataValue(datatree.variable_table.getSymbolID(id), type)); +} + +void +VariableNode::collectEndogenous(NodeID &Id) +{ + int idx; + if (type == eEndogenous) + { + idx = datatree.variable_table.getSymbolID(id); + Id->present_endogenous.insert(make_pair(idx, datatree.variable_table.getLag((long int) id))); + } +} + UnaryOpNode::UnaryOpNode(DataTree &datatree_arg, UnaryOpcode op_code_arg, const NodeID arg_arg) : ExprNode(datatree_arg), arg(arg_arg), @@ -327,7 +423,7 @@ UnaryOpNode::cost(const temporary_terms_type &temporary_terms) const int cost = arg->cost(temporary_terms); - if (datatree.offset) + if (datatree.offset == 1) // Cost for Matlab files switch(op_code) { @@ -422,15 +518,44 @@ UnaryOpNode::computeTemporaryTerms(map &reference_count, } } +void +UnaryOpNode::computeTemporaryTerms(map &reference_count, + temporary_terms_type &temporary_terms, + map &first_occurence, + int Curr_block, + Model_Block *ModelBlock) const +{ + NodeID this2 = const_cast(this); + map::iterator it = reference_count.find(this2); + if (it == reference_count.end()) + { + reference_count[this2] = 1; + first_occurence[this2] = Curr_block; + arg->computeTemporaryTerms(reference_count, temporary_terms, first_occurence, Curr_block, ModelBlock); + } + else + { + reference_count[this2]++; + if (reference_count[this2] * cost(temporary_terms) > datatree.min_cost) + { + temporary_terms.insert(this2); + ModelBlock->Block_List[first_occurence[this2]].Temporary_terms->insert(this2); + } + } +} + void UnaryOpNode::writeOutput(ostream &output, bool is_dynamic, - const temporary_terms_type &temporary_terms) const + const temporary_terms_type &temporary_terms, int offset) const { // If node is a temporary term temporary_terms_type::const_iterator it = temporary_terms.find(const_cast(this)); if (it != temporary_terms.end()) { - output << "T" << idx; + if (offset != 2) + output << "T" << idx; + else + output << "T" << idx << "[it_]"; return; } @@ -507,7 +632,7 @@ UnaryOpNode::writeOutput(ostream &output, bool is_dynamic, } // Write argument - arg->writeOutput(output, is_dynamic, temporary_terms); + arg->writeOutput(output, is_dynamic, temporary_terms, offset); if (close_parenthesis) output << ")"; @@ -517,6 +642,75 @@ UnaryOpNode::writeOutput(ostream &output, bool is_dynamic, output << ")"; } +void +UnaryOpNode::Evaluate() const +{ + this->arg->Evaluate(); + datatree.interprete_.u2 = datatree.interprete_.Stack.top(); + datatree.interprete_.Stack.pop(); + switch(op_code) + { + case oUminus: + datatree.interprete_.u1=-datatree.interprete_.u2; + break; + case oExp: + datatree.interprete_.u1=exp(datatree.interprete_.u2); + break; + case oLog: + datatree.interprete_.u1=log(datatree.interprete_.u2); + break; + case oLog10: + datatree.interprete_.u1=log10(datatree.interprete_.u2); + break; + case oCos: + datatree.interprete_.u1=cos(datatree.interprete_.u2); + break; + case oSin: + datatree.interprete_.u1=sin(datatree.interprete_.u2); + break; + case oTan: + datatree.interprete_.u1=tan(datatree.interprete_.u2); + break; + case oAcos: + datatree.interprete_.u1=acos(datatree.interprete_.u2); + break; + case oAsin: + datatree.interprete_.u1=asin(datatree.interprete_.u2); + break; + case oAtan: + datatree.interprete_.u1=atan(datatree.interprete_.u2); + break; + case oCosh: + datatree.interprete_.u1=cosh(datatree.interprete_.u2); + break; + case oSinh: + datatree.interprete_.u1=sinh(datatree.interprete_.u2); + break; + case oTanh: + datatree.interprete_.u1=tanh(datatree.interprete_.u2); + break; + case oAcosh: + datatree.interprete_.u1=acosh(datatree.interprete_.u2); + break; + case oAsinh: + datatree.interprete_.u1=asinh(datatree.interprete_.u2); + break; + case oAtanh: + datatree.interprete_.u1=atanh(datatree.interprete_.u2); + break; + case oSqrt: + datatree.interprete_.u1=sqrt(datatree.interprete_.u2); + break; + } + datatree.interprete_.Stack.push(datatree.interprete_.u1); +} + +void +UnaryOpNode::collectEndogenous(NodeID &Id) +{ + arg->collectEndogenous(Id); +} + BinaryOpNode::BinaryOpNode(DataTree &datatree_arg, const NodeID arg1_arg, BinaryOpcode op_code_arg, const NodeID arg2_arg) : ExprNode(datatree_arg), @@ -606,7 +800,7 @@ BinaryOpNode::precedence(const temporary_terms_type &temporary_terms) const case oDivide: return 1; case oPower: - if (datatree.offset) + if (datatree.offset == 1) // In C, power operator is of the form pow(a, b) return 100; else @@ -627,7 +821,7 @@ BinaryOpNode::cost(const temporary_terms_type &temporary_terms) const int cost = arg1->cost(temporary_terms); cost += arg2->cost(temporary_terms); - if (datatree.offset) + if (datatree.offset == 1) // Cost for Matlab files switch(op_code) { @@ -685,25 +879,88 @@ BinaryOpNode::computeTemporaryTerms(map &reference_count, } } +void +BinaryOpNode::computeTemporaryTerms(map &reference_count, + temporary_terms_type &temporary_terms, + map &first_occurence, + int Curr_block, + Model_Block *ModelBlock) const +{ + NodeID this2 = const_cast(this); + map::iterator it = reference_count.find(this2); + if (it == reference_count.end()) + { + reference_count[this2] = 1; + first_occurence[this2] = Curr_block; + arg1->computeTemporaryTerms(reference_count, temporary_terms, first_occurence, Curr_block, ModelBlock); + arg2->computeTemporaryTerms(reference_count, temporary_terms, first_occurence, Curr_block, ModelBlock); + } + else + { + reference_count[this2]++; + if (reference_count[this2] * cost(temporary_terms) > datatree.min_cost) + { + temporary_terms.insert(this2); + ModelBlock->Block_List[first_occurence[this2]].Temporary_terms->insert(this2); + } + } +} + +void +BinaryOpNode::Evaluate() const +{ + // Write current operator symbol + this->arg1->Evaluate(); + this->arg2->Evaluate(); + datatree.interprete_.u2 = datatree.interprete_.Stack.top(); + datatree.interprete_.Stack.pop(); + datatree.interprete_.u1 = datatree.interprete_.Stack.top(); + datatree.interprete_.Stack.pop(); + switch(op_code) + { + case oPlus: + datatree.interprete_.u1+=datatree.interprete_.u2; + break; + case oMinus: + datatree.interprete_.u1-=datatree.interprete_.u2; + break; + case oTimes: + datatree.interprete_.u1*=datatree.interprete_.u2; + break; + case oDivide: + datatree.interprete_.u1/=datatree.interprete_.u2; + break; + case oPower: + datatree.interprete_.u1=pow(datatree.interprete_.u1,datatree.interprete_.u2); + break; + case oEqual: + break; + } + datatree.interprete_.Stack.push(datatree.interprete_.u1); +} + void BinaryOpNode::writeOutput(ostream &output, bool is_dynamic, - const temporary_terms_type &temporary_terms) const + const temporary_terms_type &temporary_terms, int offset) const { // If current node is a temporary term temporary_terms_type::const_iterator it = temporary_terms.find(const_cast(this)); if (it != temporary_terms.end()) { - output << "T" << idx; + if (offset != 2) + output << "T" << idx; + else + output << "T" << idx << "[it_]"; return; } // Treat special case of power operator in C - if (op_code == oPower && datatree.offset == 0) + if (op_code == oPower && (datatree.offset == 0 || datatree.offset == 2)) { output << "pow("; - arg1->writeOutput(output, is_dynamic, temporary_terms); + arg1->writeOutput(output, is_dynamic, temporary_terms, offset); output << ","; - arg2->writeOutput(output, is_dynamic, temporary_terms); + arg2->writeOutput(output, is_dynamic, temporary_terms, offset); output << ")"; return; } @@ -722,7 +979,7 @@ BinaryOpNode::writeOutput(ostream &output, bool is_dynamic, } // Write left argument - arg1->writeOutput(output, is_dynamic, temporary_terms); + arg1->writeOutput(output, is_dynamic, temporary_terms, offset); if (close_parenthesis) output << ")"; @@ -769,8 +1026,15 @@ BinaryOpNode::writeOutput(ostream &output, bool is_dynamic, } // Write right argument - arg2->writeOutput(output, is_dynamic, temporary_terms); + arg2->writeOutput(output, is_dynamic, temporary_terms, offset); if (close_parenthesis) output << ")"; } + +void +BinaryOpNode::collectEndogenous(NodeID &Id) +{ + arg1->collectEndogenous(Id); + arg2->collectEndogenous(Id); +} diff --git a/parser.src/Makefile b/parser.src/Makefile index 7ad72c5e5..58be55227 100644 --- a/parser.src/Makefile +++ b/parser.src/Makefile @@ -51,7 +51,13 @@ COMMON_OBJ=\ DataTree.o \ ModFile.o \ Statement.o \ - ExprNode.o + ExprNode.o \ + ModelNormalization.o \ + ModelBlocks.o \ + BlockTriangular.o \ + Model_Graph.o \ + interprete.o \ + SymbolGaussElim.o MATLAB_OBJ = InterfaceMatlab.o diff --git a/parser.src/ModFile.cc b/parser.src/ModFile.cc index 50eaddffb..82c89f8d6 100644 --- a/parser.src/ModFile.cc +++ b/parser.src/ModFile.cc @@ -67,7 +67,7 @@ ModFile::computingPass() } void -ModFile::writeOutputFiles(const string &basename, bool clear_all) const +ModFile::writeOutputFiles(const string &basename, bool clear_all) { ofstream mOutputFile; @@ -142,7 +142,24 @@ ModFile::writeOutputFiles(const string &basename, bool clear_all) const cout << "Processing outputs ..." << endl; + model_tree.block_triangular.file_name = basename; + int true_offset = model_tree.offset; + if (model_tree.offset == 2) + { + model_tree.offset = 1; + model_tree.lpar = '('; + model_tree.rpar = ')'; + } + model_tree.writeStaticFile(basename); + + if (true_offset == 2) + { + model_tree.offset = 2; + model_tree.lpar = '['; + model_tree.rpar = ']'; + } + model_tree.writeDynamicFile(basename); // Print statements diff --git a/parser.src/ModelBlocks.cc b/parser.src/ModelBlocks.cc new file mode 100644 index 000000000..217c715c7 --- /dev/null +++ b/parser.src/ModelBlocks.cc @@ -0,0 +1,332 @@ +#include +#include +#include +#include +#include +#include "ModelBlocks.hh" + +using namespace std; + +#define UNDEFINED -1 + +Blocks::Blocks() +{ + //Empty +} + +Blocks::~Blocks() +{ + //Empty +} + +int n_sc_set=0; + +void +Blocks::block_depth_search(int v) +// block_depth_search() +// find the strong components of the graph using a recursive depth first search +// The results are stored in the global variables block_vertices, sets_s, sets_f. +{ + Edge *edge_ptr; + int w; + // Add the vertex v to the visited vertex and store it in the result (low_link_nos) + // and increase the number of visited vertex + low_link_nos[v] = visit_nos[v] = n_visited; + n_visited++; + // Put v in the stack. + block_stack[tos] = v; + sp[v] = tos; + tos++; + // Going to visite the edges from vertex v starting + // from the First edge of vetexe v + edge_ptr = vertices[v].First_Edge; + // While there is edge + while(edge_ptr) + { + w = edge_ptr->Vertex_Index; + // if the vertex w hasen't been visited + if(visit_nos[w] == UNDEFINED) + { + // visits the vertex w + block_depth_search(w); + // Update low_link no. + if(low_link_nos[w] < low_link_nos[v]) + low_link_nos[v] = low_link_nos[w]; + } + else if(visit_nos[w] < visit_nos[v] && sp[w] != UNDEFINED) + { + // Update low_link no. */ + if(visit_nos[w] < low_link_nos[v]) + if(visit_nos[w]>=0) + low_link_nos[v] = visit_nos[w]; + else + { + // Check for hierarchic structure accross strong connex components + if(pos_sc[-(visit_nos[w]+2)]next; + } + // If all vertices in v's SC component have been found. + if(low_link_nos[v] == visit_nos[v]) + { + int vpos = sp[v]; + int i; + sets_s[n_sets] = n_written; + // The SC component vertices are stored from the top of the stack, down + // to v. Write these to the result structure. + for(i = vpos; i < tos; i++) + { + block_vertices[n_written] = block_stack[i]; + n_written++; + } + if(n_sc_set>0) + for(i=0;isize; + // accessed by block_depth_search() + vertices = g->Number; + // Allocate space for arrays to represent the search result. + result = (block_result*)malloc(sizeof(block_result_t)); + block_vertices = result->vertices = (int*)malloc(n * sizeof(int)); + sets_s = result->sets_s = (int*)malloc(n *sizeof(int)); + sets_f = result->sets_f = (int*)malloc(n *sizeof(int)); + pos_sc = result->order = (int*)malloc(n * sizeof(int)); + result->ordered = (int*)malloc(n * sizeof(int)); + // Allocate space for arrays used while generating the result. + block_stack = (int*)malloc(n * sizeof(int)); + sp = (int*)malloc(n * sizeof(int)); + visit_nos = (int*)malloc(n * sizeof(int)); + low_link_nos = (int*)malloc(n * sizeof(int)); + // Initialise necessary array entries to UNDEFINED. + // - sets_s[] and sets_f[] array entries are UNDEFINED, until data is + // written into them. + // - visit_nos[] array entries are UNDEFINED, until a vertex has been + // visited, + // - sp[v] is UNDEFINED unless v is in the stack. + for(i = 0; i < n; i++) + { + sets_s[i] = sets_f[i] = visit_nos[i] = sp[i] = UNDEFINED; + pos_sc[i] = i; + } + + // Array sizes in the result structure. + result->size = n; + // Tarjan's algorithm proceeds as a recursive depth first search. Note + // that the block_depth_search() function accesses the current graph through the + // global variable `vertices'. If parts of the graph were not reached + // block_depth_search() will be called again, until all vertices have been + // reached. + tos = 0; + n_written = n_visited = 0; + n_sets = 0; + for(v = 0; v < n; v++) + { + n_sc_set=0; + if(visit_nos[v] == UNDEFINED) + block_depth_search(v); + } + result->n_sets = n_sets; + for(i = 0; i < n_sets; i++) + result->ordered[result->order[i]]=i; + // free space taken up by arrays used while generating the result. + free(block_stack); + free(sp); + free(visit_nos); + free(low_link_nos); + return result; +} + + + +void +Blocks::block_result_free(block_result_t *r) +{ + free(r->vertices); + free(r->sets_s); + free(r->sets_f); + free(r->order); + free(r->ordered); + free(r); +} + + +void +Blocks::block_result_print(block_result_t *r) +{ + int i, j, n_sets; + + n_sets = r->n_sets; + + cout << n_sets << " SC components:\n\n"; + for(i = 0; i < n_sets; i++) + { + cout << "SC" << r->order[i] << " = "; + for(j = r->sets_s[i]; j <= r->sets_f[i]; j++) + { + cout << r->vertices[j] << " "; + } + cout << "\n"; + } + for(i = 0; i < n_sets; i++) + { + cout << "SC" << i << " = "; + for(j = r->sets_s[r->ordered[i]]; j <= r->sets_f[r->ordered[i]]; j++) + { + cout << r->vertices[j] << " "; + } + cout << "\n"; + } +} + + +void +Blocks::block_result_to_IM(block_result_t *r,bool* IM,int prologue, int n,simple* Index_Equ_IM,simple* Index_Var_IM) +{ + int i, j, k, l; + bool* SIM=(bool*)malloc(n*n*sizeof(*SIM)); + simple* Index_Equ_IM_tmp=(simple*)malloc(n*sizeof(*Index_Equ_IM_tmp)); + simple* Index_Var_IM_tmp=(simple*)malloc(n*sizeof(*Index_Var_IM_tmp)); + for(i=0;in_sets; i++) + { + for(j = r->sets_s[r->ordered[i]]; j <= r->sets_f[r->ordered[i]]; j++) + { + Index_Equ_IM[l].index=Index_Equ_IM_tmp[r->vertices[j]+prologue].index; + for(k=0;kvertices[j]+prologue)*n+k]; + l++; + } + } + for(i=0;in_sets; i++) + { + for(j = r->sets_s[r->ordered[i]]; j <= r->sets_f[r->ordered[i]]; j++) + { + Index_Var_IM[l].index=Index_Var_IM_tmp[r->vertices[j]+prologue].index; + for(k=0;kvertices[j]+prologue)]; + l++; + } + } + free(Index_Equ_IM_tmp); + free(Index_Var_IM_tmp); + free(SIM); +} + + +Equation_set* +Blocks::Equation_gr_IM( int n , bool* IM) +{ + Equation_set *g; + Equation_vertex *vertices; + Edge *edge_ptr; + int i,j; + g = (Equation_set*)malloc(sizeof(Equation_set)); + vertices = g->Number = (Equation_vertex*)malloc(n*sizeof(Equation_vertex)); + g->size = n; + for(i = 0; i < n; i++) + { + vertices[i].First_Edge = NULL; + for(j=0; jVertex_Index=j; + edge_ptr->next= NULL; + } + else + { + edge_ptr=(Edge*)malloc(sizeof(Edge)); + edge_ptr->Vertex_Index=j; + edge_ptr->next= NULL; + } + + } + } + } + return g; +} + +void +Blocks::Print_Equation_gr(Equation_set* Equation) +{ + int i; + Edge *e1, *e2; + cout << "The oriented graph of the model (earth blocks only) \n"; + cout << "equation | links\n"; + for(i=0;isize;i++) + { + cout << " " << i << " "; + e1=Equation->Number[i].First_Edge; + while(e1!=NULL) + { + e2=e1->next; + cout << e1->Vertex_Index << " "; + e1=e2; + } + cout << "\n"; + } +} diff --git a/parser.src/ModelNormalization.cc b/parser.src/ModelNormalization.cc new file mode 100644 index 000000000..52c4b004f --- /dev/null +++ b/parser.src/ModelNormalization.cc @@ -0,0 +1,524 @@ +//#define DEBUG +#include +#include +#include +#include +#include +#include "ModelNormalization.hh" + + +using namespace std; + + +Normalization::Normalization() +{ + //Empty +}; + +Normalization::~Normalization() +{ + //Empty +}; + +void +Normalization::IM_to_Gr(int n0, int prologue, int epilogue, bool* IM, Equation_set *Equation, Variable_set *Variable ) +// Create a non-oriented graph of the model from the incidence matrix +{ + int i, j, edges, n; + Edge *e1; +#ifdef DEBUG + cout << "in IM_to_Gr\n"; +#endif + //Normalize only the earth block (the prologue and the epilogue are still normalized) + n = n0 - prologue - epilogue; + Equation->size = n; + Variable->size = n; + Equation->Number = (Equation_vertex*)malloc(n * sizeof(Equation_vertex)); + Variable->Number = (Variable_vertex*)malloc(n * sizeof(Variable_vertex)); + edges = 0; + for(i = 0;i < n;i++) + { + Equation->Number[i].First_Edge = NULL; + Equation->Number[i].matched = -1; + Variable->Number[i].matched = -1; + for(j = 0;j < n;j++) + { + if(IM[(j + prologue)*n0 + (i + prologue)]) + { + edges++; + e1 = (Edge *) malloc(sizeof(Edge)); + e1->next = Equation->Number[i].First_Edge; + Equation->Number[i].First_Edge = e1; + e1->Vertex_Index = j; + } + } + } + //The maximum number of vertex in each equation is set to the total amount of edges in the model + Equation->edges = edges; +#ifdef DEBUG + cout << "end of IM_to_Gr\n"; +#endif +} + +void +Normalization::Inits(Equation_set *Equation) +{ + int i; +#ifdef DEBUG + cout << "in Inits\n"; +#endif + eq = eex = 0; + IndexUnmatched = Equation->edges * 2; + Local_Heap = (t_Heap*)malloc(IndexUnmatched * sizeof(t_Heap)); + for(i = 0; i < Equation->size; i++) + { + Equation->Number[i].Next_Edge = Equation->Number[i].First_Edge; + visited[i] = 0; + // we put all unmatched vertices from Equation at the other end of the Local_Heap + if(Equation->Number[i].matched == -1) + { + Local_Heap[--IndexUnmatched].u = i; +#ifdef DEBUG + cout << i << " is unmatched\n"; +#endif + } + } +#ifdef DEBUG + cout << "end of Inits\n"; +#endif +} + +void +Normalization::UpdatePath(Equation_set *Equation, Variable_set *Variable, int i1, int i2) +{ + int i, j; +#ifdef DEBUG + cout << "in UpdatePath \n"; +#endif + while(i2 >= 0) + { + i = Local_Heap[i2].u; + j = Local_Heap[i1].v; + Variable->Number[j].matched = i; + Equation->Number[i].matched = j; + i1 = i2; + i2 = Local_Heap[i2].i_parent; + eex++; + } +#ifdef DEBUG + cout << "end of UpdatePath \n"; +#endif +} + +void +Normalization::FindAugmentingPaths(Equation_set *Equation, Variable_set *Variable) +{ + // augmenting paths using breadth-first search. + int Bottom; + int Top; + int u, i; + Edge *e, *e2; +#ifdef DEBUG + cout << "in FindAugmentingPaths\n"; +#endif + // external loop gets unmatched u vertices from far end of array Local_Heap + while(IndexUnmatched < Equation->edges*2) + { + Top = Bottom = 0; + Local_Heap[Top].u = Local_Heap[IndexUnmatched++].u; + Local_Heap[Top].i_parent = -1; /* root of BFS tree */ +#ifdef DEBUG + cout << "unmatched u" << Local_Heap[Top].u << " will be processed\n"; +#endif + // Local_Heap processing + while(Bottom >= Top) + { + u = Local_Heap[Top++].u; + e = Equation->Number[u].First_Edge; + eq++; + // adjacency list scanning + while(e != NULL) + { + if (!visited[Variable->Number[e->Vertex_Index].matched]) + { + // extend tree + Local_Heap[++Bottom].u = u = Variable->Number[e->Vertex_Index].matched; + Local_Heap[Bottom].i_parent = Top - 1; + Local_Heap[Bottom].v = e->Vertex_Index; + visited[u] = 1; + e2 = Equation->Number[u].Next_Edge; + eq++; + while ((e2 != NULL) && (Variable->Number[e2->Vertex_Index].matched != -1)) + { + e2 = e2->next; + eq++; + } + Equation->Number[u].Next_Edge = e2; + if(e2 != NULL) + { +#ifdef DEBUG + cout << "augmenting path found\n"; +#endif + // u in the Local_Heap but not the edge to v + Variable->Number[e2->Vertex_Index].matched = u; + Equation->Number[u].matched = e2->Vertex_Index; + // now for the rest of the path + UpdatePath(Equation, Variable, Bottom, Top - 1); + // temporary cut is emptied + for(i = 0; i <= Bottom; i++) + visited[Local_Heap[i].u] = 0; + Bottom = Top - 1; + // to get off from Local_Heap loop + // to get off from adj list scan loop + break; + } + } + e = e->next; + eq++; + } + } + } +#ifdef DEBUG + cout << "end of FindAugmentingPaths\n"; +#endif +} + + +void +Normalization::CheapMatching(Equation_set *Equation, Variable_set *Variable) +{ + int i; + Edge *e; + int count = 0; +#ifdef DEBUG + cout << "in CheapMatching Equation->size : " << Equation->size << "\n"; +#endif + for(i = 0; i < Equation->size; i++) + { + e = Equation->Number[i].First_Edge; + while(e != (Edge *) NULL) + { + if(Variable->Number[e->Vertex_Index].matched == -1) + { + Variable->Number[e->Vertex_Index].matched = i; + Equation->Number[i].matched = e->Vertex_Index; +#ifdef DEBUG + cout << i << " matched to " << e->Vertex_Index << "\n"; +#endif + count++; + break; + } + e = e->next; + } + } + if(fp_verbose) + cout << count << " vertices in Equation were initially matched (" << (float) 100*count / Equation->size << "%)\n"; +#ifdef DEBUG + cout << "end of CheapMatching\n"; +#endif +} + + +void +Normalization::MaximumMatching(Equation_set *Equation, Variable_set *Variable) +{ +#ifdef DEBUG + cout << "in MaximumMatching\n"; +#endif + CheapMatching(Equation, Variable); + Inits(Equation); + FindAugmentingPaths(Equation, Variable); +#ifdef DEBUG + cout << "end of MaximumMatching\n"; +#endif +} + +int +Normalization::MeasureMatching(Equation_set *Equation) +{ + int size = 0, i; + for(i = 0; i < Equation->size; i++) + if(Equation->Number[i].matched != -1) + size++; + return size; +} + +void +Normalization::OutputMatching(Equation_set* Equation) +{ + int i; + Edge* e1; + cout << "Maximum Matching Results for |Equation|=" << Equation->size << " |Edges|=" << Equation->edges << "\n"; + for(i = 0; i < Equation->size; i++) + { + if(Equation->Number[i].matched != -1) + cout << "equation " << i << " matched to variable " << Equation->Number[i].matched; + else + cout << "equation " << i << " not matched \n"; + e1 = Equation->Number[i].First_Edge; + while(e1 != NULL) + { + cout << " " << e1->Vertex_Index; + e1 = e1->next; + } + cout << "\n"; + } +} + +void +Normalization::Gr_to_IM_basic(int n0, int prologue, int epilogue, bool* IM, Equation_set *Equation, bool transpose) +{ + int i, j, edges, n; + Edge *e1; + n = n0 - prologue - epilogue; + Equation->size = n; + Equation->Number = (Equation_vertex*)malloc(n * sizeof(Equation_vertex)); + edges = 0; + if(transpose) + { + for(i = 0;i < n;i++) + { + Equation->Number[i].First_Edge = NULL; + Equation->Number[i].matched = -1; + for(j = 0;j < n;j++) + { + if ((IM[(j + prologue)*n0 + (i + prologue)]) && (i != j)) + { + edges++; + e1 = (Edge *) malloc(sizeof(Edge)); + e1->next = Equation->Number[i].First_Edge; + Equation->Number[i].First_Edge = e1; + e1->Vertex_Index = j; + } + } + } + } + else + { + for(i = 0;i < n;i++) + { + Equation->Number[i].First_Edge = NULL; + Equation->Number[i].matched = -1; + for(j = 0;j < n;j++) + { + if ((IM[(i + prologue)*n0 + (j + prologue)]) && (i != j)) + { + edges++; + e1 = (Edge *) malloc(sizeof(Edge)); + e1->next = Equation->Number[i].First_Edge; + Equation->Number[i].First_Edge = e1; + e1->Vertex_Index = j; + } + } + } + } + //The maximum number of vertex in each equation is set to the total amount of edges in the model + Equation->edges = edges; +#ifdef DEBUG + cout << "end of IM_to_Gr\n"; +#endif +} + +void +Normalization::Gr_to_IM(int n0, int prologue, int epilogue, bool* IM, simple* Index_Equ_IM, Equation_set *Equation, bool mixing, bool* IM_s) +{ + int i, j, n, l; + Edge *e1, *e2; + Equation_set* Equation_p; + simple* Index_Equ_IM_tmp = (simple*)malloc(n0 * sizeof(*Index_Equ_IM_tmp)); + bool* SIM = (bool*)malloc(n0 * n0 * sizeof(bool)); +#ifdef DEBUG + cout << "in Gr_to_IM\n"; +#endif + n = n0 - prologue - epilogue; + if(mixing) + { + for(i = 0;i < n0*n0;i++) + SIM[i] = IM_s[i]; + for(i = 0;i < n0;i++) + Index_Equ_IM_tmp[i].index = Index_Equ_IM[i].index; + for(i = 0;i < n;i++) + { + /*Index_Var_IM[j+prologue].index=Index_Var_IM_tmp[Equation->Number[j].matched+prologue].index;*/ + if(fp_verbose) + cout << "Equation->Number[" << i << "].matched=" << Equation->Number[i].matched << "\n"; + Index_Equ_IM[i + prologue].index = Index_Equ_IM_tmp[Equation->Number[i].matched + prologue].index; + for(j = 0;j < n0;j++) + SIM[(i + prologue)*n0 + j] = IM_s[(Equation->Number[i].matched + prologue) * n0 + j]; + } + for(i = 0;i < n0*n0;i++) + IM[i] = SIM[i]; + } + else + { + for(i = 0;i < n0*n0;i++) + SIM[i] = IM[i]; + for(i = 0;i < n0;i++) + Index_Equ_IM_tmp[i].index = Index_Equ_IM[i].index; + for(j = 0;j < n;j++) + { + if(fp_verbose) + cout << "Equation->Number[" << j << "].matched=" << Equation->Number[j].matched << "\n"; + Index_Equ_IM[j + prologue].index = Index_Equ_IM_tmp[Equation->Number[j].matched + prologue].index; + for(i = 0;i < n0;i++) + SIM[(i)*n0 + j + prologue] = IM[(i) * n0 + Equation->Number[j].matched + prologue]; + } + for(i = 0;i < n0*n0;i++) + IM[i] = SIM[i]; + } + free(SIM); + free(Index_Equ_IM_tmp); + if(mixing) + Gr_to_IM_basic(n0, prologue, epilogue, IM, Equation, true); + else + { + // In this step we : + // 1) get ride of the edge from the equation to its explain variable + // 2) resort the equation in the order of the matched variable + // 3) transpose the graph + // in order to get the oriented graph needed to find strong connex components + Equation_p = (Equation_set*)malloc(sizeof(Equation_set)); + Equation_p->size = Equation->size; + Equation_p->edges = Equation->edges; + Equation_p->Number = (Equation_vertex*)malloc(n * sizeof(Equation_vertex)); + for(i = 0;i < n;i++) + { + Equation_p->Number[i].First_Edge = NULL; + Equation_p->Number[i].Next_Edge = NULL; + } + for(i = 0;i < n;i++) + { + l = Equation->Number[i].matched; + e1 = Equation->Number[l].First_Edge; + while(e1 != NULL) + { + if(e1->Vertex_Index != i) + { + j = e1->Vertex_Index; + if(Equation_p->Number[j].First_Edge != NULL) + { + Equation_p->Number[j].Next_Edge->next = (Edge*)malloc(sizeof(Edge*)); + Equation_p->Number[j].Next_Edge = Equation_p->Number[j].Next_Edge->next; + } + else + { + Equation_p->Number[j].First_Edge = (Edge*)malloc(sizeof(Edge*)); + Equation_p->Number[j].Next_Edge = Equation_p->Number[j].First_Edge; + } + Equation_p->Number[j].Next_Edge->next = NULL; + Equation_p->Number[j].Next_Edge->Vertex_Index = i; + } + e2 = e1->next; + free(e1); + e1 = e2; + } + } + for(i = 0;i < n;i++) + { + Equation->Number[i].matched = Equation_p->Number[i].matched; + Equation->Number[i].First_Edge = Equation_p->Number[i].First_Edge; + Equation->Number[i].Next_Edge = Equation_p->Number[i].Next_Edge; + } + free(Equation_p->Number); + free(Equation_p); + } +#ifdef DEBUG + cout << "end of Gr_to_IM\n"; +#endif +} + +void +Normalization::Free_Equation(int n, Equation_set* Equation) +{ + //free unused space + Edge *e1, *e2; + int i; + for(i = 0;i < n;i++) + { + e1 = Equation->Number[i].First_Edge; + while(e1 != NULL) + { + e2 = e1->next; + e1 = e2; + } + } + free(Equation->Number); + free(Equation); +} + +void +Normalization::Free_Other(Variable_set* Variable) +{ + //free unused space + free(Local_Heap); + free(Variable->Number); + free(Variable); + free(visited); +} + +void +Normalization::Free_All(int n, Equation_set* Equation, Variable_set* Variable) +{ + Free_Equation(n, Equation); + Free_Other(Variable); +} + +void +Normalization::ErrorHandling(int n, bool* IM, simple* Index_Equ_IM) +{ + int i, j, k, k1, k2; + for(i = 0;i < n;i++) + { + k = 0; + for(j = 0;j < n;j++) + k += (int)IM[j * n + Index_Equ_IM[i].index]; + if(k == 0) + cout << " the variable " << getnamebyID(eEndogenous, Index_Equ_IM[i].index) << " does not appear in any equation \n"; + for(j = i + 1;j < n;j++) + { + k1 = k2 = 0; + for(k = 0;k < n;k++) + { + k1 = k1 + (int)(IM[Index_Equ_IM[i].index * n + k] != IM[Index_Equ_IM[j].index * n + k]); + k2 = k2 + (int)IM[Index_Equ_IM[i].index * n + k]; + } + if ((k1 == 0)&(k2 == 1)) + cout << " the variable " << getnamebyID(eEndogenous, Index_Equ_IM[i].index) << " is the only endogenous variable in equations " << Index_Equ_IM[i].index + 1 << " and " << Index_Equ_IM[j].index + 1 << "\n"; + } + } +} + +void +Normalization::Normalize(int n, int prologue, int epilogue, bool* IM, simple* Index_Equ_IM, Equation_set* Equation, bool mixing, bool* IM_s) +{ + int matchingSize, effective_n; + fp_verbose = 0; + Variable_set* Variable = (Variable_set*) malloc(sizeof(Variable_set)); +#ifdef DEBUG + cout << "in Normalize\n"; +#endif + visited = (bool*)malloc(n * sizeof(*visited)); + IM_to_Gr(n, prologue, epilogue, IM, Equation, Variable); + MaximumMatching(Equation, Variable); + matchingSize = MeasureMatching(Equation); + effective_n = n - prologue - epilogue; + if(matchingSize < effective_n) + { + cout << "Error: dynare could not normalize the model\n"; + ErrorHandling(n, IM, Index_Equ_IM); + system("PAUSE"); + exit( -1); + } + Gr_to_IM(n, prologue, epilogue, IM, Index_Equ_IM, Equation, mixing, IM_s); + if(fp_verbose) + { + OutputMatching(Equation); + for(int i = 0;i < n;i++) + cout << "Index_Equ_IM[" << i << "]=" << Index_Equ_IM[i].index /*<< " == " "Index_Var_IM[" << i << "]=" << Index_Var_IM[i].index*/ << "\n"; + } + Free_Other(Variable); +#ifdef DEBUG + cout << "end of Normalize\n"; +#endif +} + diff --git a/parser.src/ModelTree.cc b/parser.src/ModelTree.cc index d340717ea..1943a0ca6 100644 --- a/parser.src/ModelTree.cc +++ b/parser.src/ModelTree.cc @@ -2,9 +2,14 @@ #include #include +#include + #include "ModelTree.hh" #include "Interface.hh" +#include "Model_Graph.hh" +#include "SymbolGaussElim.hh" + ModelTree::ModelTree(SymbolTable &symbol_table_arg, NumericalConstants &num_constants_arg) : DataTree(symbol_table_arg, num_constants_arg), @@ -12,10 +17,28 @@ ModelTree::ModelTree(SymbolTable &symbol_table_arg, computeJacobianExo(false), computeHessian(false), computeStaticHessian(false), - computeThirdDerivatives(false) + computeThirdDerivatives(false), + block_triangular(symbol_table_arg) { } +int +ModelTree::equation_number() const +{ + return(equations.size()); +} + +void +ModelTree::GetDerivatives(ostream &output, int eq, int var, int lag, bool is_dynamic, + const temporary_terms_type &temporary_terms) const +{ + first_derivatives_type::const_iterator it=first_derivatives.find(make_pair(eq,variable_table.getmVariableSelector(var,lag))); + if (it != first_derivatives.end()) + (it->second)->writeOutput(output, is_dynamic, temporary_terms, offset); + else + output << 0; +} + void ModelTree::derive(int order) { @@ -112,19 +135,32 @@ ModelTree::writeTemporaryTerms(ostream &output, bool is_dynamic) const // A copy of temporary terms temporary_terms_type tt2; + bool offs = false; + + if (temporary_terms.size() > 0 && offset == 2) + { + output << "double\n"; + offs = true; + } + for(temporary_terms_type::const_iterator it = temporary_terms.begin(); it != temporary_terms.end(); it++) { - (*it)->writeOutput(output, is_dynamic, temporary_terms); + (*it)->writeOutput(output, is_dynamic, temporary_terms, offset); output << " = "; - (*it)->writeOutput(output, is_dynamic, tt2); + (*it)->writeOutput(output, is_dynamic, tt2, offset); // Insert current node into tt2 tt2.insert(*it); - output << ";" << endl; + if (offs) + output << ",\n"; + else + output << ";" << endl; } + if (offs) + output << ";\n"; } void @@ -136,7 +172,7 @@ ModelTree::writeLocalParameters(ostream &output, bool is_dynamic) const int id = it->first; NodeID value = it->second; output << symbol_table.getNameByID(eLocalParameter, id) << " = "; - value->writeOutput(output, is_dynamic, temporary_terms); + value->writeOutput(output, is_dynamic, temporary_terms, offset); output << ";" << endl; } } @@ -150,18 +186,293 @@ ModelTree::writeModelEquations(ostream &output, bool is_dynamic) const NodeID lhs = eq_node->arg1; output << "lhs ="; - lhs->writeOutput(output, is_dynamic, temporary_terms); + lhs->writeOutput(output, is_dynamic, temporary_terms, offset); output << ";" << endl; NodeID rhs = eq_node->arg2; output << "rhs ="; - rhs->writeOutput(output, is_dynamic, temporary_terms); + rhs->writeOutput(output, is_dynamic, temporary_terms, offset); output << ";" << endl; output << "residual" << lpar << eq + 1 << rpar << "= lhs-rhs;" << endl; } } +void +ModelTree::computeTemporaryTermsOrdered(int order, Model_Block *ModelBlock) +{ + map reference_count, first_occurence; + int i, j, m, eq, var, lag/*, prev_size=0*/; + temporary_terms_type vect; + ostringstream tmp_output; + BinaryOpNode *eq_node; + NodeID lhs, rhs; + first_derivatives_type::const_iterator it; + ostringstream tmp_s; + + temporary_terms.clear(); + for(j = 0;j < ModelBlock->Size;j++) + { + if (ModelBlock->Block_List[j].Size==1) + { + eq_node = equations[ModelBlock->Block_List[j].Equation[0]]; + lhs = eq_node->arg1; + rhs = eq_node->arg2; + tmp_output.str(""); + lhs->writeOutput(tmp_output, true, temporary_terms, offset); + tmp_s << "y[Per_y_+" << ModelBlock->Block_List[j].Variable[0] << "]"; + if (tmp_output.str()==tmp_s.str()) + { + if (ModelBlock->Block_List[j].Simulation_Type==SOLVE_BACKWARD_SIMPLE) + ModelBlock->Block_List[j].Simulation_Type=EVALUATE_BACKWARD; + else if (ModelBlock->Block_List[j].Simulation_Type==SOLVE_FOREWARD_SIMPLE) + ModelBlock->Block_List[j].Simulation_Type=EVALUATE_FOREWARD; + } + } + for(i = 0;i < ModelBlock->Block_List[j].Size;i++) + { + eq_node = equations[ModelBlock->Block_List[j].Equation[i]]; + eq_node->computeTemporaryTerms(reference_count, temporary_terms, first_occurence, j, ModelBlock); + } + if (ModelBlock->Block_List[j].Simulation_Type!=EVALUATE_BACKWARD + && ModelBlock->Block_List[j].Simulation_Type!=EVALUATE_FOREWARD) + { + if (ModelBlock->Block_List[j].Simulation_Type==SOLVE_TWO_BOUNDARIES_COMPLETE || + ModelBlock->Block_List[j].Simulation_Type==SOLVE_TWO_BOUNDARIES_SIMPLE) + { + for(m=0;m<=ModelBlock->Block_List[j].Max_Lead+ModelBlock->Block_List[j].Max_Lag;m++) + { + lag=m-ModelBlock->Block_List[j].Max_Lag; + for(i=0;iBlock_List[j].IM_lead_lag[m].size;i++) + { + eq=ModelBlock->Block_List[j].IM_lead_lag[m].Equ_Index[i]; + var=ModelBlock->Block_List[j].IM_lead_lag[m].Var_Index[i]; + it=first_derivatives.find(make_pair(eq,variable_table.getmVariableSelector(var,lag))); + it->second->computeTemporaryTerms(reference_count, temporary_terms, first_occurence, j, ModelBlock); + } + } + } + else if (ModelBlock->Block_List[j].Simulation_Type!=SOLVE_BACKWARD_SIMPLE + && ModelBlock->Block_List[j].Simulation_Type!=SOLVE_FOREWARD_SIMPLE) + { + m=ModelBlock->Block_List[j].Max_Lag; + for(i=0;iBlock_List[j].IM_lead_lag[m].size;i++) + { + eq=ModelBlock->Block_List[j].IM_lead_lag[m].Equ_Index[i]; + var=ModelBlock->Block_List[j].IM_lead_lag[m].Var_Index[i]; + it=first_derivatives.find(make_pair(eq,variable_table.getmVariableSelector(var,0))); + it->second->computeTemporaryTerms(reference_count, temporary_terms, first_occurence, j, ModelBlock); + } + } + else + { + eq=ModelBlock->Block_List[j].Equation[0]; + var=ModelBlock->Block_List[j].Variable[0]; + it=first_derivatives.find(make_pair(eq,variable_table.getmVariableSelector(var,0))); + it->second->computeTemporaryTerms(reference_count, temporary_terms, first_occurence, j, ModelBlock); + } + } + } + if (order == 2) + for(second_derivatives_type::iterator it = second_derivatives.begin(); + it != second_derivatives.end(); it++) + it->second->computeTemporaryTerms(reference_count, temporary_terms); +} + + +void +ModelTree::writeModelEquationsOrdered(ostream &output, bool is_dynamic, Model_Block *ModelBlock) const +{ + int i,j,k,m; + string sModel, tmp_s; + ostringstream tmp_output; + NodeID lhs, rhs; + BinaryOpNode *eq_node; + bool OK, lhs_rhs_done, skip_the_head; + ostringstream Uf[symbol_table.endo_nbr]; + map reference_count; + int prev_Simulation_Type=-1; + temporary_terms_type::const_iterator it_temp=temporary_terms.begin(); + //---------------------------------------------------------------------- + //Temporary variables dĆ©calaration + OK=true; + for(temporary_terms_type::const_iterator it = temporary_terms.begin(); + it != temporary_terms.end(); it++) + { + if (OK) + OK=false; + else + tmp_output << ", "; + + (*it)->writeOutput(tmp_output, is_dynamic, temporary_terms, 0); + + tmp_output << "[" << block_triangular.periods + variable_table.max_lag+variable_table.max_lead << "]"; + } + if (tmp_output.str().length()>0) + { + output << "double " << tmp_output.str() << ";\n\n"; + } + //For each block + for(j = 0;j < ModelBlock->Size;j++) + { + //For a block composed of a single equation determines wether we have to evaluate or to solve the equation + if (ModelBlock->Block_List[j].Size==1) + { + lhs_rhs_done=true; + eq_node = equations[ModelBlock->Block_List[j].Equation[0]]; + lhs = eq_node->arg1; + rhs = eq_node->arg2; + tmp_output.str(""); + lhs->writeOutput(tmp_output, is_dynamic, temporary_terms, offset); + } + else + lhs_rhs_done=false; + if (prev_Simulation_Type==ModelBlock->Block_List[j].Simulation_Type + && (ModelBlock->Block_List[j].Simulation_Type==EVALUATE_BACKWARD + ||ModelBlock->Block_List[j].Simulation_Type==EVALUATE_FOREWARD )) + skip_the_head=true; + else + skip_the_head=false; + if (!skip_the_head) + { + if (j>0) + output << "}\n\n"; + output << "void Dynamic" << j+1 << "(double *y, double *x, double *residual, double *g1, double *g2)\n"; + output << "{\n"; + output << " ////////////////////////////////////////////////////////////////////////\n" << + " //" << string(" Block ").substr(int(log10(j + 1))) << j + 1 << " " << BlockTriangular::BlockType0(ModelBlock->Block_List[j].Type) << + " //\n" << + " // Simulation type "; + output << BlockTriangular::BlockSim(ModelBlock->Block_List[j].Simulation_Type) << " //\n" << + " ////////////////////////////////////////////////////////////////////////\n"; + } + //The Temporary terms + temporary_terms_type tt2; + if (ModelBlock->Block_List[j].Temporary_terms->size()) + output << " //Temporary variables\n"; + i=0; + for(temporary_terms_type::const_iterator it = ModelBlock->Block_List[j].Temporary_terms->begin(); + it != ModelBlock->Block_List[j].Temporary_terms->end(); it++) + { + output << " "; + (*it)->writeOutput(output, is_dynamic, temporary_terms, offset); + output << " = "; + (*it)->writeOutput(output, is_dynamic, tt2, offset); + // Insert current node into tt2 + tt2.insert(*it); + output << ";" << endl; + i++; + } + // The equations + for(i = 0;i < ModelBlock->Block_List[j].Size;i++) + { + sModel = symbol_table.getNameByID(eEndogenous, ModelBlock->Block_List[j].Variable[i]) ; + ModelBlock->Block_List[j].Variable_Sorted[i] = variable_table.getID(sModel, 0); + output << " //equation " << ModelBlock->Block_List[j].Equation[i] << " variable : " << + sModel << " (" << ModelBlock->Block_List[j].Variable[i] << ")\n"; + if (!lhs_rhs_done) + { + eq_node = equations[ModelBlock->Block_List[j].Equation[i]]; + lhs = eq_node->arg1; + rhs = eq_node->arg2; + tmp_output.str(""); + lhs->writeOutput(tmp_output, is_dynamic, temporary_terms, offset); + } + output << " "; + switch(ModelBlock->Block_List[j].Simulation_Type) + { + case EVALUATE_BACKWARD: + case EVALUATE_FOREWARD: + output << tmp_output.str(); + output << " = "; + rhs->writeOutput(output, is_dynamic, temporary_terms, offset); + output << ";\n"; + break; + case SOLVE_BACKWARD_COMPLETE: + case SOLVE_FOREWARD_COMPLETE: + Uf[ModelBlock->Block_List[j].Equation[i]] << " u[" << i << "] = residual[" << i << "]"; + goto end; + case SOLVE_TWO_BOUNDARIES_COMPLETE: + Uf[ModelBlock->Block_List[j].Equation[i]] << " u[" << i << "+Per_u_] = residual[" << i << "]"; + goto end; + default: + end: + output << "residual[" << i << "] = ("; + output << tmp_output.str(); + output << ") - ("; + rhs->writeOutput(output, is_dynamic, temporary_terms, offset); + output << ");\n"; + } + } + // The Jacobian if we have to solve the block + if (ModelBlock->Block_List[j].Simulation_Type!=EVALUATE_BACKWARD + && ModelBlock->Block_List[j].Simulation_Type!=EVALUATE_FOREWARD) + { + output << " /* Jacobian */\n"; + switch(ModelBlock->Block_List[j].Simulation_Type) + { + case SOLVE_BACKWARD_SIMPLE: + case SOLVE_FOREWARD_SIMPLE: + output << " g1[0]="; + GetDerivatives(output, ModelBlock->Block_List[j].Equation[0], ModelBlock->Block_List[j].Variable[0], 0, true, temporary_terms); + output << "; /* variable=" << symbol_table.getNameByID(eEndogenous, ModelBlock->Block_List[j].Variable[0]) + <<"(" << variable_table.getLag(variable_table.getSymbolID(ModelBlock->Block_List[j].Variable[0])) << ") " << ModelBlock->Block_List[j].Variable[0] + << ", equation=" << ModelBlock->Block_List[j].Equation[0] << "*/\n"; + break; + case SOLVE_BACKWARD_COMPLETE: + case SOLVE_FOREWARD_COMPLETE: + m=ModelBlock->Block_List[j].Max_Lag; + for(i=0;iBlock_List[j].IM_lead_lag[m].size;i++) + { + int eq=ModelBlock->Block_List[j].IM_lead_lag[m].Equ_Index[i]; + int var=ModelBlock->Block_List[j].IM_lead_lag[m].Var_Index[i]; + int u=ModelBlock->Block_List[j].IM_lead_lag[m].u[i]; + int eqr=ModelBlock->Block_List[j].IM_lead_lag[m].Equ[i]; + int varr=ModelBlock->Block_List[j].IM_lead_lag[m].Var[i]; + Uf[ModelBlock->Block_List[j].Equation[eqr]] << "-u[" << u << "]*y[Per_y_+" << var << "]"; + output << " u[" << u << "] = g1[" << eqr << "*" << ModelBlock->Block_List[j].Size << "+" << varr << "] = "; + GetDerivatives(output, eq, var, 0,true, temporary_terms); + output << "; // variable=" << symbol_table.getNameByID(eEndogenous, var) + <<"(" << variable_table.getLag(variable_table.getSymbolID(var))<< ") " << var + << ", equation=" << eq << "\n"; + } + for(i = 0;i < ModelBlock->Block_List[j].Size;i++) + output << Uf[ModelBlock->Block_List[j].Equation[i]].str() << ";\n"; + break; + case SOLVE_TWO_BOUNDARIES_COMPLETE: + for(m=0;m<=ModelBlock->Block_List[j].Max_Lead+ModelBlock->Block_List[j].Max_Lag;m++) + { + k=m-ModelBlock->Block_List[j].Max_Lag; + for(i=0;iBlock_List[j].IM_lead_lag[m].size;i++) + { + int eq=ModelBlock->Block_List[j].IM_lead_lag[m].Equ_Index[i]; + int var=ModelBlock->Block_List[j].IM_lead_lag[m].Var_Index[i]; + int u=ModelBlock->Block_List[j].IM_lead_lag[m].u[i]; + int eqr=ModelBlock->Block_List[j].IM_lead_lag[m].Equ[i]; + if (k==0) + Uf[ModelBlock->Block_List[j].Equation[eqr]] << "-u[" << u << "+Per_u_]*y[Per_y_+" << var << "]"; + else if (k>0) + Uf[ModelBlock->Block_List[j].Equation[eqr]] << "-u[" << u << "+Per_u_]*y[(it_+" << k << ")*y_size+" << var << "]"; + else if (k<0) + Uf[ModelBlock->Block_List[j].Equation[eqr]] << "-u[" << u << "+Per_u_]*y[(it_" << k << ")*y_size+" << var << "]"; + output << " u[" << u << "+Per_u_] = "; + GetDerivatives(output, eq, var, k,true,temporary_terms); + output << "; // variable=" << symbol_table.getNameByID(eEndogenous, var) + <<"(" << k << ") " << var + << ", equation=" << eq << "\n"; + } + } + for(i = 0;i < ModelBlock->Block_List[j].Size;i++) + output << Uf[ModelBlock->Block_List[j].Equation[i]].str() << ";\n"; + break; + } + } + prev_Simulation_Type=ModelBlock->Block_List[j].Simulation_Type; + } + output << "}\n\n"; +} + + void ModelTree::writeStaticMFile(const string &static_basename) const { @@ -210,7 +521,7 @@ ModelTree::writeDynamicMFile(const string &dynamic_basename) const mDynamicModelFile << interfaces::comment(); mDynamicModelFile << " from model file (.mod)\n\n"; - writeDynamicModel(mDynamicModelFile); + writeDynamicModel(mDynamicModelFile, block_triangular.ModelBlock); interfaces::function_close(); mDynamicModelFile.close(); @@ -275,8 +586,8 @@ ModelTree::writeStaticCFile(const string &static_basename) const mStaticModelFile << " /* Gets model parameters from global workspace of Matlab */\n"; mStaticModelFile << " M_ = mexGetVariable(\"global\",\"M_\");\n"; mStaticModelFile << " if (M_ == NULL ){\n"; - mStaticModelFile << " mexPrintf(\"Global variable not found : \");\n"; - mStaticModelFile << " mexErrMsgTxt(\"M_ \\n\");\n"; + mStaticModelFile << " mexPrintf(\"Global variable not found : \");\n"; + mStaticModelFile << " mexErrMsgTxt(\"M_ \\n\");\n"; mStaticModelFile << " }\n"; mStaticModelFile << " params = mxGetPr(mxGetFieldByNumber(M_, 0, mxGetFieldNumber(M_,\"params\")));\n"; mStaticModelFile << " /* Call the C Static. */\n"; @@ -289,9 +600,107 @@ ModelTree::writeStaticCFile(const string &static_basename) const void ModelTree::writeDynamicCFile(const string &dynamic_basename) const { - string filename = dynamic_basename + ".c"; - + string filename; ofstream mDynamicModelFile; + string tmp_s; + int i, j; + if (offset == 2) + { + if (compiler==GCC_COMPILE) + filename = dynamic_basename + ".hh"; + else + filename = dynamic_basename + ".h"; + mDynamicModelFile.open(filename.c_str(), ios::out | ios::binary); + if (!mDynamicModelFile.is_open()) + { + cout << "ModelTree::Open : Error : Can't open file " << filename + << ".h for writing\n"; + exit(-1); + } + filename.erase(filename.end() - 2, filename.end()); + tmp_s = filename; + 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"; + if (compiler==GCC_COMPILE) + { + mDynamicModelFile << "typedef struct IM_compact\n"; + mDynamicModelFile << "{\n"; + mDynamicModelFile << " int size, u_init, u_finish, nb_endo;\n"; + mDynamicModelFile << " int *u, *Var, *Equ, *Var_Index, *Equ_Index, *Var_dyn_Index;\n"; + mDynamicModelFile << "};\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,*/ Nb_Lead_Lag_Endo;\n"; + mDynamicModelFile << " int *Variable, *dVariable, *Equation/*, *icc1, *ics*/;\n"; + mDynamicModelFile << " int *variable_dyn_index, *variable_dyn_leadlag;\n"; + mDynamicModelFile << " IM_compact *IM_lead_lag;\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"; + } + else + { + mDynamicModelFile << "typedef struct IM_compact\n"; + mDynamicModelFile << "{\n"; + mDynamicModelFile << " int size, u_init, u_finish, nb_endo;\n"; + mDynamicModelFile << " int *u, *Var, *Equ, *Var_Index, *Equ_Index, *Var_dyn_Index;\n"; + mDynamicModelFile << "} IM_compact;\n"; + mDynamicModelFile << "typedef struct Variable_l\n"; + mDynamicModelFile << "{\n"; + mDynamicModelFile << " int* Index;\n"; + mDynamicModelFile << "} Variable_l;\n"; + mDynamicModelFile << "typedef struct tBlock\n"; + mDynamicModelFile << "{\n"; + mDynamicModelFile << " int Size, Sized, Type, Max_Lead, Max_Lag, Simulation_Type, /*icc1_size,*/ Nb_Lead_Lag_Endo;\n"; + mDynamicModelFile << " int *Variable, *dVariable, *Equation/*, *icc1, *ics*/;\n"; + mDynamicModelFile << " int *variable_dyn_index, *variable_dyn_leadlag;\n"; + mDynamicModelFile << " IM_compact *IM_lead_lag;\n"; + mDynamicModelFile << "} tBlock;\n"; + mDynamicModelFile << "\n"; + mDynamicModelFile << "typedef struct tModel_Block\n"; + mDynamicModelFile << "{\n"; + mDynamicModelFile << " int Size;\n"; + mDynamicModelFile << " tBlock * List;\n"; + mDynamicModelFile << "} tModel_Block;\n"; + mDynamicModelFile << "\n"; + mDynamicModelFile << "double *u, slowc, max_res, res2, res1;\n"; + mDynamicModelFile << "double *params;\n"; + mDynamicModelFile << "int it_,Per_u_;\n"; + mDynamicModelFile << "bool cvg;\n"; + mDynamicModelFile << "int nb_row_x;\n"; + mDynamicModelFile << "int y_kmin, y_kmax,periods, x_size, y_size, u_size, maxit_;\n"; + mDynamicModelFile << "double *y=NULL, *x=NULL, *r=NULL, *g1=NULL, *g2=NULL, solve_tolf, dynaretol;\n"; + mDynamicModelFile << "pctimer_t t0, t1;\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(); + } + if (offset == 1||(offset==2 && compiler==LCC_COMPILE)) + filename = dynamic_basename + ".c"; + else + filename = dynamic_basename + ".cc"; mDynamicModelFile.open(filename.c_str(), ios::out | ios::binary); if (!mDynamicModelFile.is_open()) { @@ -300,20 +709,53 @@ ModelTree::writeDynamicCFile(const string &dynamic_basename) const } mDynamicModelFile << "/*\n"; mDynamicModelFile << " * " << filename << " : Computes dynamic model for Dynare\n"; - mDynamicModelFile << " *\n"; + mDynamicModelFile << " *\n"; mDynamicModelFile << " * Warning : this file is generated automatically by Dynare\n"; mDynamicModelFile << " * from model file (.mod)\n\n"; mDynamicModelFile << " */\n"; - mDynamicModelFile << "#include \n"; - mDynamicModelFile << "#include \"mex.h\"\n"; - // A flobal variable for model parameters - mDynamicModelFile << "double *params;\n"; - // A global variable for it_ - mDynamicModelFile << "int it_;\n"; - mDynamicModelFile << "int nb_row_x;\n"; - + if (offset == 2) + { + if (compiler==GCC_COMPILE) + { + mDynamicModelFile << "#include \"" << dynamic_basename.c_str() << ".hh\"\n"; + mDynamicModelFile << "#include \"simulate.cc\"\n"; + } + else + { + mDynamicModelFile << "#include \n"; + mDynamicModelFile << "#include \n"; + mDynamicModelFile << "#include \n"; + mDynamicModelFile << "#include \"pctimer_h.h\"\n"; + mDynamicModelFile << "#include \"mex.h\" /* The Last include file*/\n"; + mDynamicModelFile << "#include \"" << dynamic_basename.c_str() << ".h\"\n"; + mDynamicModelFile << "#include \"simulate.h\"\n"; + } + } + if (offset == 2) + mDynamicModelFile << "//#define DEBUG\n"; + if (offset == 0) + { + // A flobal variable for model parameters + mDynamicModelFile << "double *params;\n"; + // A global variable for it_ + mDynamicModelFile << "int it_;\n"; + mDynamicModelFile << "int nb_row_x;\n"; + } + else + { + if (compiler==GCC_COMPILE) + { + mDynamicModelFile << "\n"; + } + } // Writing the function body - writeDynamicModel(mDynamicModelFile); + if (offset == 2) + { + writeDynamicModel(mDynamicModelFile, block_triangular.ModelBlock); + SaveCFiles(block_triangular.ModelBlock, block_triangular.file_name, mDynamicModelFile); + } + else + writeDynamicModel(mDynamicModelFile,block_triangular.ModelBlock); // Writing the gateway routine mDynamicModelFile << "/* The gateway routine */\n"; @@ -362,8 +804,8 @@ ModelTree::writeDynamicCFile(const string &dynamic_basename) const mDynamicModelFile << " M_ = mexGetVariable(\"global\",\"M_\");\n"; mDynamicModelFile << " if (M_ == NULL )\n"; mDynamicModelFile << " {\n"; - mDynamicModelFile << " mexPrintf(\"Global variable not found : \");\n"; - mDynamicModelFile << " mexErrMsgTxt(\"M_ \\n\");\n"; + mDynamicModelFile << " mexPrintf(\"Global variable not found : \");\n"; + mDynamicModelFile << " mexErrMsgTxt(\"M_ \\n\");\n"; mDynamicModelFile << " }\n"; mDynamicModelFile << " params = mxGetPr(mxGetFieldByNumber(M_, 0, mxGetFieldNumber(M_,\"params\")));\n"; mDynamicModelFile << " /* Gets it_ from global workspace of Matlab */\n"; @@ -402,7 +844,7 @@ ModelTree::writeStaticModel(ostream &StaticOutput) const g1 << " g1" << lpar << eq + 1 << ", " << variable_table.getSymbolID(var) + 1 << rpar; jacobian_output << g1.str() << "=" << g1.str() << "+"; - d1->writeOutput(jacobian_output, false, temporary_terms); + d1->writeOutput(jacobian_output, false, temporary_terms, offset); jacobian_output << ";" << endl; } } @@ -428,7 +870,7 @@ ModelTree::writeStaticModel(ostream &StaticOutput) const int col_nb_sym = id2*symbol_table.endo_nbr+id1+1; hessian_output << " g2" << lpar << eq+1 << ", " << col_nb << rpar << " = "; - d2->writeOutput(hessian_output, false, temporary_terms); + d2->writeOutput(hessian_output, false, temporary_terms, offset); hessian_output << ";" << endl; // Treating symetric elements @@ -501,8 +943,567 @@ ModelTree::writeStaticModel(ostream &StaticOutput) const } } +string +ModelTree::reform(const string name1) const +{ + string name=name1; + int pos = name.find("\\", 0); + while(pos >= 0) + { + if (name.substr(pos + 1, 1) != "\\") + { + name = name.insert(pos, "\\"); + pos++; + } + pos++; + pos = name.find("\\", pos); + } + return (name); +} + void -ModelTree::writeDynamicModel(ostream &DynamicOutput) const +ModelTree::SaveCFiles(Model_Block* ModelBlock, string Model_file_name, ofstream &mDynamicModelFile) const +{ + int i, j, k, Nb_SGE=0; + bool printed = false, skip_head, open_par=false; + SymbolicGaussElimination SGE; + + if (mDynamicModelFile.is_open() && (computeJacobian || computeJacobianExo || computeHessian)) + { + if (offset == 2) + { + mDynamicModelFile << "void Dynamic_Init(tModel_Block *Model_Block)\n"; + mDynamicModelFile << " {\n"; + mDynamicModelFile << " int i;\n"; + int prev_Simulation_Type=-1; + for(i = 0;i < block_triangular.ModelBlock->Size;i++) + { + k = block_triangular.ModelBlock->Block_List[i].Simulation_Type; + if (prev_Simulation_Type==k && + (k==EVALUATE_FOREWARD || k==EVALUATE_BACKWARD)) + skip_head=true; + else + skip_head=false; + if ((k == EVALUATE_FOREWARD) && (block_triangular.ModelBlock->Block_List[i].Size)) + { + if (!skip_head) + { + if (open_par) + { + mDynamicModelFile << "#endif\n"; + mDynamicModelFile << " }\n"; + } + mDynamicModelFile << " for(it_=y_kmin;it_Block_List[i].Size;j++) + mDynamicModelFile << " mexPrintf(\"y[%d, %d]=%f \\n\",it_," << block_triangular.ModelBlock->Block_List[i].Variable[j] << ",y[it_," << block_triangular.ModelBlock->Block_List[i].Variable[j] << "]);\n"; + open_par=true; + } + else if ((k == EVALUATE_BACKWARD) && (block_triangular.ModelBlock->Block_List[i].Size)) + { + if (!skip_head) + { + if (open_par) + { + mDynamicModelFile << "#endif\n"; + mDynamicModelFile << " }\n"; + } + mDynamicModelFile << " for(it_=periods+y_kmin;it_>y_kmin;it_--)\n"; + mDynamicModelFile << " {\n"; + mDynamicModelFile << " Per_y_=it_*y_size;\n"; + mDynamicModelFile << " Dynamic" << i + 1 << "(y, x, r, g1, g2);\n"; + mDynamicModelFile << "#ifdef DEBUG\n"; + } + for(j = 0;j < block_triangular.ModelBlock->Block_List[i].Size;j++) + mDynamicModelFile << " mexPrintf(\"y[%d, %d]=%f \\n\",it_," << block_triangular.ModelBlock->Block_List[i].Variable[j] << ",y[it_," << block_triangular.ModelBlock->Block_List[i].Variable[j] << "]);\n"; + open_par=true; + } + else if ((k == SOLVE_FOREWARD_SIMPLE) && (block_triangular.ModelBlock->Block_List[i].Size)) + { + if (open_par) + { + mDynamicModelFile << "#endif\n"; + mDynamicModelFile << " }\n"; + } + open_par=false; + mDynamicModelFile << " g1=(double*)mxMalloc(" << block_triangular.ModelBlock->Block_List[i].Size*block_triangular.ModelBlock->Block_List[i].Size << "*sizeof(double));\n"; + mDynamicModelFile << " r=(double*)mxMalloc(" << block_triangular.ModelBlock->Block_List[i].Size << "*sizeof(double));\n"; + mDynamicModelFile << " for(it_=y_kmin;it_maxit_)))\n"; + mDynamicModelFile << " {\n"; + mDynamicModelFile << " Dynamic" << i + 1 << "(y, x, r, g1, g2);\n"; + mDynamicModelFile << " y[Per_y_+" << block_triangular.ModelBlock->Block_List[i].Variable[0] << "] += -r[0]/g1[0];\n"; + mDynamicModelFile << " cvg=((r[0]*r[0])Block_List[i].Variable[0] << ",y[it_," << block_triangular.ModelBlock->Block_List[i].Variable[0] << "]);\n"; + mDynamicModelFile << "#endif\n"; + mDynamicModelFile << " }\n"; + mDynamicModelFile << " mxFree(g1);\n"; + mDynamicModelFile << " mxFree(r);\n"; + } + else if ((k == SOLVE_BACKWARD_SIMPLE) && (block_triangular.ModelBlock->Block_List[i].Size)) + { + if (open_par) + { + mDynamicModelFile << "#endif\n"; + mDynamicModelFile << " }\n"; + } + open_par=false; + mDynamicModelFile << " g1=(double*)mxMalloc(" << block_triangular.ModelBlock->Block_List[i].Size*block_triangular.ModelBlock->Block_List[i].Size << "*sizeof(double));\n"; + mDynamicModelFile << " r=(double*)mxMalloc(" << block_triangular.ModelBlock->Block_List[i].Size << "*sizeof(double));\n"; + mDynamicModelFile << " for(it_=periods+y_kmin;it_>y_kmin;it_--)\n"; + mDynamicModelFile << " {\n"; + mDynamicModelFile << " cvg=false;\n"; + mDynamicModelFile << " iter=0;\n"; + mDynamicModelFile << " Per_y_=it_*y_size;\n"; + mDynamicModelFile << " while(!((cvg)||(iter>maxit_)))\n"; + mDynamicModelFile << " {\n"; + mDynamicModelFile << " Dynamic" << i + 1 << "(y, x, r, g1, g2);\n"; + mDynamicModelFile << " y[Per_y_+" << block_triangular.ModelBlock->Block_List[i].Variable[0] << "] += -r[0]/g1[0];\n"; + mDynamicModelFile << " cvg=((r[0]*r[0])Block_List[i].Variable[0] << ",y[it_," << block_triangular.ModelBlock->Block_List[i].Variable[0] << "]);\n"; + mDynamicModelFile << "#endif\n"; + mDynamicModelFile << " }\n"; + mDynamicModelFile << " mxFree(g1);\n"; + mDynamicModelFile << " mxFree(r);\n"; + } + else if ((k == SOLVE_TWO_BOUNDARIES_SIMPLE) && (block_triangular.ModelBlock->Block_List[i].Size)) + { + if (open_par) + { + mDynamicModelFile << "#endif\n"; + mDynamicModelFile << " }\n"; + } + open_par=false; + if (!printed) + { + printed = true; + } + SGE.SGE_compute(block_triangular.ModelBlock, i, true, Model_file_name, /*mod_param.endo_nbr*/symbol_table.endo_nbr); + Nb_SGE++; +#ifdef PRINT_OUT + cout << "end of Gaussian elimination\n"; +#endif + mDynamicModelFile << " Read_file(\"" << reform(Model_file_name) << "\",periods," << + block_triangular.ModelBlock->Block_List[i].IM_lead_lag[block_triangular.ModelBlock->Block_List[i].Max_Lag + block_triangular.ModelBlock->Block_List[i].Max_Lead].u_finish + 1 << ", " << /*mod_param.endo_nbr*/symbol_table.endo_nbr << + ", " << block_triangular.ModelBlock->Block_List[i].Max_Lag << ", " << block_triangular.ModelBlock->Block_List[i].Max_Lead << ");\n"; + mDynamicModelFile << " g1=(double*)mxMalloc(" << block_triangular.ModelBlock->Block_List[i].Size*block_triangular.ModelBlock->Block_List[i].Size << "*sizeof(double));\n"; + mDynamicModelFile << " r=(double*)mxMalloc(" << block_triangular.ModelBlock->Block_List[i].Size << "*sizeof(double));\n"; + if (!block_triangular.ModelBlock->Block_List[i].is_linear) + { + mDynamicModelFile << " cvg=false;\n"; + mDynamicModelFile << " iter=0;\n"; + mDynamicModelFile << " while(!((cvg)||(iter>maxit_)))\n"; + mDynamicModelFile << " {\n"; + mDynamicModelFile << " res2=0;\n"; + mDynamicModelFile << " res1=0;\n"; + mDynamicModelFile << " max_res=0;\n"; + mDynamicModelFile << " for(it_=y_kmin;it_Block_List[i].IM_lead_lag[block_triangular.ModelBlock->Block_List[i].Max_Lag + block_triangular.ModelBlock->Block_List[i].Max_Lead].u_finish + 1 << ";\n"; + mDynamicModelFile << " Per_y_=it_*y_size;\n"; + mDynamicModelFile << " Dynamic" << i + 1 << "(y, x, r, g1, g2);\n"; + mDynamicModelFile << " for(i=0;i<" << block_triangular.ModelBlock->Block_List[i].Size << ";i++)\n"; + mDynamicModelFile << " {\n"; + mDynamicModelFile << " if (max_resBlock_List[i].IM_lead_lag[block_triangular.ModelBlock->Block_List[i].Max_Lag + block_triangular.ModelBlock->Block_List[i].Max_Lead].u_finish + 1 << ";\n"; + mDynamicModelFile << " Per_y_=it_*y_size;\n"; + mDynamicModelFile << " Dynamic" << i + 1 << "(y, x, r, g1, g2);\n"; + mDynamicModelFile << "#ifdef PRINT_OUT\n"; + mDynamicModelFile << " for(j=0;j<" << block_triangular.ModelBlock->Block_List[i].IM_lead_lag[block_triangular.ModelBlock->Block_List[i].Max_Lag + block_triangular.ModelBlock->Block_List[i].Max_Lead].u_finish + 1 << ";j++)\n"; + mDynamicModelFile << " {\n"; + mDynamicModelFile << " mexPrintf(\" %f\",u[Per_u_+j]);\n"; + mDynamicModelFile << " }\n"; + mDynamicModelFile << " mexPrintf(\"\\n\");\n"; + mDynamicModelFile << "#endif\n"; + mDynamicModelFile << " }\n"; + mDynamicModelFile << " simulate(" << i << ", " << /*mod_param.endo_nbr*/symbol_table.endo_nbr << ", it_, y_kmin, y_kmax);\n"; + } + mDynamicModelFile << "#ifdef DEBUG\n"; + mDynamicModelFile << " for(it_=y_kmin;it_List[" << i << "].Size;i++)\n"; + mDynamicModelFile << " {"; + mDynamicModelFile << " Per_y_=it_*y_size;\n"; + mDynamicModelFile << " mexPrintf(\" y[%d, %d]=%f \",it_,Model_Block->List[" << i << "].Variable[i],y[Per_y_+Model_Block->List[" << i << "].Variable[i]]);\n"; + mDynamicModelFile << " }"; + mDynamicModelFile << " mexPrintf(\" \\n \");\n"; + mDynamicModelFile << " }\n"; + mDynamicModelFile << "#endif\n"; + mDynamicModelFile << " mxFree(g1);\n"; + mDynamicModelFile << " mxFree(r);\n"; + mDynamicModelFile << " mxFree(u);\n"; + mDynamicModelFile << " //mexErrMsgTxt(\"Exit from Dynare\");\n"; + } + else if ((k == SOLVE_FOREWARD_COMPLETE) && (block_triangular.ModelBlock->Block_List[i].Size)) + { + if (open_par) + { + mDynamicModelFile << "#endif\n"; + mDynamicModelFile << " }\n"; + } + open_par=false; + if (!printed) + { + printed = true; + } + SGE.SGE_compute(block_triangular.ModelBlock, i, false, Model_file_name, /*mod_param.endo_nbr*/symbol_table.endo_nbr); + Nb_SGE++; + mDynamicModelFile << " Read_file(\"" << reform(Model_file_name) << "\", periods, 0, 0, 0, 0);\n"; + mDynamicModelFile << " g1=(double*)mxMalloc(" << block_triangular.ModelBlock->Block_List[i].Size*block_triangular.ModelBlock->Block_List[i].Size << "*sizeof(double));\n"; + mDynamicModelFile << " r=(double*)mxMalloc(" << block_triangular.ModelBlock->Block_List[i].Size << "*sizeof(double));\n"; + mDynamicModelFile << " for(it_=y_kmin;it_Block_List[i].is_linear) + { + mDynamicModelFile << " cvg=false;\n"; + mDynamicModelFile << " iter=0;\n"; + mDynamicModelFile << " Per_y_=it_*y_size;\n"; + mDynamicModelFile << " while(!((cvg)||(iter>maxit_)))\n"; + mDynamicModelFile << " {\n"; + mDynamicModelFile << " Dynamic" << i + 1 << "(y, x, r, g1, g2);\n"; + mDynamicModelFile << " simulate(" << i << ", " << /*mod_param.endo_nbr*/symbol_table.endo_nbr << ", it_, y_kmin, y_kmax);\n"; + mDynamicModelFile << " res2=0;\n"; + mDynamicModelFile << " res1=0;\n"; + mDynamicModelFile << " max_res=0;\n"; + mDynamicModelFile << " for(i=0;i<" << block_triangular.ModelBlock->Block_List[i].Size << ";i++)\n"; + mDynamicModelFile << " {\n"; + mDynamicModelFile << " if (max_resList[" << i << "].Size;i++)\n"; + mDynamicModelFile << " mexPrintf(\" y[%d, %d]=%f \",it_,Model_Block->List[" << i << "].Variable[i],y[it_*" << /*mod_param.endo_nbr*/symbol_table.endo_nbr << "+Model_Block->List[" << i << "].Variable[i]]);\n"; + mDynamicModelFile << " mexPrintf(\" \\n \");\n"; + mDynamicModelFile << "#endif\n"; + mDynamicModelFile << " }\n"; + mDynamicModelFile << " mxFree(g1);\n"; + mDynamicModelFile << " mxFree(r);\n"; + mDynamicModelFile << " mxFree(u);\n"; + } + else if ((k == SOLVE_BACKWARD_COMPLETE) && (block_triangular.ModelBlock->Block_List[i].Size)) + { + if (open_par) + { + mDynamicModelFile << "#endif\n"; + mDynamicModelFile << " }\n"; + } + open_par=false; + SGE.SGE_compute(block_triangular.ModelBlock, i, false, Model_file_name, /*mod_param.endo_nbr*/symbol_table.endo_nbr); + Nb_SGE++; + mDynamicModelFile << " Read_file(\"" << reform(Model_file_name) << "\", periods, 0, 0, 0, 0);\n"; + mDynamicModelFile << " g1=(double*)mxMalloc(" << block_triangular.ModelBlock->Block_List[i].Size*block_triangular.ModelBlock->Block_List[i].Size << "*sizeof(double));\n"; + mDynamicModelFile << " r=(double*)mxMalloc(" << block_triangular.ModelBlock->Block_List[i].Size << "*sizeof(double));\n"; + mDynamicModelFile << " for(it_=periods+y_kmin;it_>y_kmin;it_--)\n"; + mDynamicModelFile << " {\n"; + if (!block_triangular.ModelBlock->Block_List[i].is_linear) + { + mDynamicModelFile << " cvg=false;\n"; + mDynamicModelFile << " iter=0;\n"; + mDynamicModelFile << " Per_y_=it_*y_size;\n"; + mDynamicModelFile << " while(!((cvg)||(iter>maxit_)))\n"; + mDynamicModelFile << " {\n"; + mDynamicModelFile << " Dynamic" << i + 1 << "(y, x, r, g1, g2);\n"; + mDynamicModelFile << " simulate(" << i << ", " << /*mod_param.endo_nbr*/symbol_table.endo_nbr << ", it_, y_kmin, y_kmax);\n"; + mDynamicModelFile << " res2=0;\n"; + mDynamicModelFile << " for(i=0;i<" << block_triangular.ModelBlock->Block_List[i].Size << ";i++)\n"; + mDynamicModelFile << " res2+=r[i]*r[i];\n"; + mDynamicModelFile << " cvg=(res2List[" << i << "].Size;i++)\n"; + mDynamicModelFile << " mexPrintf(\" y[%d, %d]=%f \",it_,Model_Block->List[" << i << "].Variable[i],y[it_*" << /*mod_param.endo_nbr*/symbol_table.endo_nbr << "+Model_Block->List[" << i << "].Variable[i]]);\n"; + mDynamicModelFile << " mexPrintf(\" \\n \");\n"; + mDynamicModelFile << "#endif\n"; + mDynamicModelFile << " }\n"; + mDynamicModelFile << " mxFree(g1);\n"; + mDynamicModelFile << " mxFree(r);\n"; + mDynamicModelFile << " mxFree(u);\n"; + } + else if ((k == SOLVE_TWO_BOUNDARIES_COMPLETE) && (block_triangular.ModelBlock->Block_List[i].Size)) + { + if (open_par) + { + mDynamicModelFile << "#endif\n"; + mDynamicModelFile << " }\n"; + } + open_par=false; + if (!printed) + { + printed = true; + } + SGE.SGE_compute(block_triangular.ModelBlock, i, true, Model_file_name, /*mod_param.endo_nbr*/symbol_table.endo_nbr); + Nb_SGE++; + mDynamicModelFile << " Read_file(\"" << reform(Model_file_name) << "\",periods," << + block_triangular.ModelBlock->Block_List[i].IM_lead_lag[block_triangular.ModelBlock->Block_List[i].Max_Lag + block_triangular.ModelBlock->Block_List[i].Max_Lead].u_finish + 1 << ", " << /*mod_param.endo_nbr*/symbol_table.endo_nbr << + ", " << block_triangular.ModelBlock->Block_List[i].Max_Lag << ", " << block_triangular.ModelBlock->Block_List[i].Max_Lead << ");\n"; + mDynamicModelFile << " g1=(double*)mxMalloc(" << block_triangular.ModelBlock->Block_List[i].Size*block_triangular.ModelBlock->Block_List[i].Size << "*sizeof(double));\n"; + mDynamicModelFile << " r=(double*)mxMalloc(" << block_triangular.ModelBlock->Block_List[i].Size << "*sizeof(double));\n"; + if (!block_triangular.ModelBlock->Block_List[i].is_linear) + { + mDynamicModelFile << " cvg=false;\n"; + mDynamicModelFile << " iter=0;\n"; + mDynamicModelFile << " while(!((cvg)||(iter>maxit_)))\n"; + mDynamicModelFile << " {\n"; + mDynamicModelFile << " res2=0;\n"; + mDynamicModelFile << " res1=0;\n"; + mDynamicModelFile << " max_res=0;\n"; + mDynamicModelFile << " for(it_=y_kmin;it_Block_List[i].IM_lead_lag[block_triangular.ModelBlock->Block_List[i].Max_Lag + block_triangular.ModelBlock->Block_List[i].Max_Lead].u_finish + 1 << ";\n"; + mDynamicModelFile << " Per_y_=it_*y_size;\n"; + mDynamicModelFile << " Dynamic" << i + 1 << "(y, x, r, g1, g2);\n"; + mDynamicModelFile << " for(i=0;i<" << block_triangular.ModelBlock->Block_List[i].Size << ";i++)\n"; + mDynamicModelFile << " {\n"; + mDynamicModelFile << " if (max_resBlock_List[i].IM_lead_lag[block_triangular.ModelBlock->Block_List[i].Max_Lag + block_triangular.ModelBlock->Block_List[i].Max_Lead].u_finish + 1 << ";\n"; + mDynamicModelFile << " Per_y_=it_*y_size;\n"; + mDynamicModelFile << " Dynamic" << i + 1 << "(y, x, r, g1, g2);\n"; + mDynamicModelFile << "#ifdef PRINT_OUT\n"; + mDynamicModelFile << " for(j=0;j<" << block_triangular.ModelBlock->Block_List[i].IM_lead_lag[block_triangular.ModelBlock->Block_List[i].Max_Lag + block_triangular.ModelBlock->Block_List[i].Max_Lead].u_finish + 1 << ";j++)\n"; + mDynamicModelFile << " {\n"; + mDynamicModelFile << " mexPrintf(\" %f\",u[Per_u_+j]);\n"; + mDynamicModelFile << " }\n"; + mDynamicModelFile << " mexPrintf(\"\\n\");\n"; + mDynamicModelFile << "#endif\n"; + mDynamicModelFile << " }\n"; + mDynamicModelFile << " simulate(" << i << ", " << /*mod_param.endo_nbr*/symbol_table.endo_nbr << ", it_, y_kmin, y_kmax);\n"; + } + mDynamicModelFile << "#ifdef DEBUG\n"; + mDynamicModelFile << " for(it_=y_kmin;it_List[" << i << "].Size;i++)\n"; + mDynamicModelFile << " {\n"; + mDynamicModelFile << " Per_y_=it_*y_size;\n"; + mDynamicModelFile << " mexPrintf(\" y[%d, %d]=%f \",it_,Model_Block->List[" << i << "].Variable[i],y[it_*" << /*mod_param.endo_nbr*/symbol_table.endo_nbr << "+Model_Block->List[" << i << "].Variable[i]]);\n"; + mDynamicModelFile << " }\n"; + mDynamicModelFile << " mexPrintf(\" \\n \");\n"; + mDynamicModelFile << " }\n"; + mDynamicModelFile << "#endif\n"; + mDynamicModelFile << " mxFree(g1);\n"; + mDynamicModelFile << " mxFree(r);\n"; + mDynamicModelFile << " mxFree(u);\n"; + mDynamicModelFile << " //mexErrMsgTxt(\"Exit from Dynare\");\n"; + } + prev_Simulation_Type=k; + } + if (open_par) + { + mDynamicModelFile << "#endif\n"; + mDynamicModelFile << " }\n"; + } + mDynamicModelFile << " }\n"; + } + if (offset == 2) + { + // Writing the gateway routine + mDynamicModelFile << " int max(int a, int b)\n"; + mDynamicModelFile << " {\n"; + mDynamicModelFile << " if (a>b) return(a); else return(b);\n"; + mDynamicModelFile << " }\n\n\n"; + mDynamicModelFile << "/* The gateway routine */\n"; + mDynamicModelFile << "void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])\n"; + mDynamicModelFile << "{\n"; + mDynamicModelFile << " tModel_Block *Model_Block;\n"; + mDynamicModelFile << " mxArray *M_, *oo_, *options_;\n"; + mDynamicModelFile << " int i, j, row_y, col_y, row_x, col_x, x_FieldNumber;\n"; + mDynamicModelFile << " mxArray *x_FieldByNumber;\n"; + mDynamicModelFile << " double * pind ;\n"; + mDynamicModelFile << "\n"; + mDynamicModelFile << " /* Gets model parameters from global workspace of Matlab */\n"; + mDynamicModelFile << " M_ = mexGetVariable(\"global\",\"M_\");\n"; + mDynamicModelFile << " if (M_ == NULL )\n"; + mDynamicModelFile << " {\n"; + mDynamicModelFile << " mexPrintf(\"Global variable not found : \");\n"; + mDynamicModelFile << " mexErrMsgTxt(\"M_ \\n\");\n"; + mDynamicModelFile << " }\n"; + mDynamicModelFile << " /* Gets variables and parameters from global workspace of Matlab */\n"; + mDynamicModelFile << " oo_ = mexGetVariable(\"global\",\"oo_\");\n"; + mDynamicModelFile << " if (oo_ == NULL )\n"; + mDynamicModelFile << " {\n"; + mDynamicModelFile << " mexPrintf(\"Global variable not found : \");\n"; + mDynamicModelFile << " mexErrMsgTxt(\"oo_ \\n\");\n"; + mDynamicModelFile << " }\n"; + mDynamicModelFile << " options_ = mexGetVariable(\"global\",\"options_\");\n"; + mDynamicModelFile << " if (options_ == NULL )\n"; + mDynamicModelFile << " {\n"; + mDynamicModelFile << " mexPrintf(\"Global variable not found : \");\n"; + mDynamicModelFile << " mexErrMsgTxt(\"options_ \\n\");\n"; + mDynamicModelFile << " }\n"; + mDynamicModelFile << " params = mxGetPr(mxGetFieldByNumber(M_, 0, mxGetFieldNumber(M_,\"params\")));\n"; + mDynamicModelFile << " y= mxGetPr(mxGetFieldByNumber(oo_, 0, mxGetFieldNumber(oo_,\"endo_simul\")));\n"; + mDynamicModelFile << " row_y=mxGetM(mxGetFieldByNumber(oo_, 0, mxGetFieldNumber(oo_,\"endo_simul\")));\n"; + mDynamicModelFile << " x= mxGetPr(mxGetFieldByNumber(oo_, 0, mxGetFieldNumber(oo_,\"exo_simul\")));\n"; + mDynamicModelFile << " row_x=mxGetM(mxGetFieldByNumber(oo_, 0, mxGetFieldNumber(oo_,\"exo_simul\")));\n"; + mDynamicModelFile << " col_x=mxGetN(mxGetFieldByNumber(oo_, 0, mxGetFieldNumber(oo_,\"exo_simul\")));\n"; + if (compiler==GCC_COMPILE) + { + mDynamicModelFile << " y_kmin=int(floor(*(mxGetPr(mxGetFieldByNumber(M_, 0, mxGetFieldNumber(M_,\"maximum_lag\"))))));\n"; + mDynamicModelFile << " y_kmax=int(floor(*(mxGetPr(mxGetFieldByNumber(M_, 0, mxGetFieldNumber(M_,\"maximum_lead\"))))));\n"; + mDynamicModelFile << " y_decal=max(0,y_kmin-int(floor(*(mxGetPr(mxGetFieldByNumber(M_, 0, mxGetFieldNumber(M_,\"maximum_endo_lag\")))))));\n"; + mDynamicModelFile << " periods=int(floor(*(mxGetPr(mxGetFieldByNumber(options_, 0, mxGetFieldNumber(options_,\"periods\"))))));\n"; + mDynamicModelFile << " maxit_=int(floor(*(mxGetPr(mxGetFieldByNumber(options_, 0, mxGetFieldNumber(options_,\"maxit_\"))))));\n"; + mDynamicModelFile << " slowc=double(*(mxGetPr(mxGetFieldByNumber(options_, 0, mxGetFieldNumber(options_,\"slowc\")))));\n"; + } + else + { + mDynamicModelFile << " y_kmin=(int)floor(*(mxGetPr(mxGetFieldByNumber(M_, 0, mxGetFieldNumber(M_,\"maximum_lag\")))));\n"; + mDynamicModelFile << " y_kmax=(int)floor(*(mxGetPr(mxGetFieldByNumber(M_, 0, mxGetFieldNumber(M_,\"maximum_lead\")))));\n"; + mDynamicModelFile << " periods=(int)floor(*(mxGetPr(mxGetFieldByNumber(options_, 0, mxGetFieldNumber(options_,\"periods\")))));\n"; + mDynamicModelFile << " maxit_=(int)floor(*(mxGetPr(mxGetFieldByNumber(options_, 0, mxGetFieldNumber(options_,\"maxit_\")))));\n"; + mDynamicModelFile << " slowc=(int)floor(*(mxGetPr(mxGetFieldByNumber(options_, 0, mxGetFieldNumber(options_,\"slowc\")))));\n"; + } + mDynamicModelFile << " col_y=mxGetN(mxGetFieldByNumber(oo_, 0, mxGetFieldNumber(oo_,\"endo_simul\")));;\n"; + mDynamicModelFile << " if (col_y0)\n"; + mDynamicModelFile << " {\n"; + mDynamicModelFile << " plhs[0] = mxCreateDoubleMatrix(row_y, col_y, mxREAL);\n"; + mDynamicModelFile << " pind = mxGetPr(plhs[0]);\n"; + mDynamicModelFile << " for(i=0;iwriteOutput(jacobian_output, true, temporary_terms); + d1->writeOutput(jacobian_output, true, temporary_terms, offset); jacobian_output << ";" << endl; } } @@ -561,7 +1566,7 @@ ModelTree::writeDynamicModel(ostream &DynamicOutput) const int col_nb_sym = id2*nvars+id1+1; hessian_output << " g2" << lpar << eq+1 << ", " << col_nb << rpar << " = "; - d2->writeOutput(hessian_output, true, temporary_terms); + d2->writeOutput(hessian_output, true, temporary_terms, offset); hessian_output << ";" << endl; // Treating symetric elements @@ -589,7 +1594,7 @@ ModelTree::writeDynamicModel(ostream &DynamicOutput) const int ref_col = id1 * nvars_sq + id2 * nvars + id3 + 1; third_derivatives_output << " g3" << lpar << eq+1 << ", " << ref_col << rpar << " = "; - d3->writeOutput(third_derivatives_output, true, temporary_terms); + d3->writeOutput(third_derivatives_output, true, temporary_terms, offset); third_derivatives_output << ";" << endl; // Compute the column numbers for the 5 other permutations of (id1,id2,id3) and store them in a set (to avoid duplicates if two indexes are equal) @@ -656,28 +1661,33 @@ ModelTree::writeDynamicModel(ostream &DynamicOutput) const } else { - DynamicOutput << "void Dynamic(double *y, double *x, double *residual, double *g1, double *g2)\n"; - DynamicOutput << "{\n"; - DynamicOutput << " double lhs, rhs;\n\n"; - DynamicOutput << " /* Residual equations */\n"; - DynamicOutput << model_output.str(); - if (computeJacobian || computeJacobianExo) + if (offset!=2) { - DynamicOutput << " /* Jacobian */\n"; - DynamicOutput << " if (g1 == NULL) return;\n"; - DynamicOutput << " {\n"; - DynamicOutput << jacobian_output.str(); - DynamicOutput << " }\n"; + DynamicOutput << "void Dynamic(double *y, double *x, double *residual, double *g1, double *g2)\n"; + DynamicOutput << "{\n"; + DynamicOutput << " double lhs, rhs;\n\n"; + DynamicOutput << " /* Residual equations */\n"; + DynamicOutput << model_output.str(); + if (computeJacobian || computeJacobianExo) + { + DynamicOutput << " /* Jacobian */\n"; + DynamicOutput << " if (g1 == NULL) return;\n"; + DynamicOutput << " {\n"; + DynamicOutput << jacobian_output.str(); + 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"; } - 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"; + else + DynamicOutput << model_output.str(); } } @@ -770,6 +1780,101 @@ ModelTree::checkPass() const } } +inline void +ModelTree::Evaluate_Jacobian() +{ + int i=0; + bool *IM; + int a_variable_lag=-9999; + for(first_derivatives_type::iterator it = first_derivatives.begin(); + it != first_derivatives.end(); it++) + { + if (variable_table.getType(it->first.second) == eEndogenous) + { + NodeID Id = it->second; + Id->Evaluate(); + interprete_.u1 = interprete_.Stack.top(); + interprete_.Stack.pop(); + int eq=it->first.first; + int var=variable_table.getSymbolID(it->first.second); + int k1=variable_table.getLag(it->first.second); + if (a_variable_lag!=k1) + { + IM=block_triangular.bGet_IM(k1); + a_variable_lag=k1; + } + if (IM[eq*symbol_table.endo_nbr+var] && (fabs(interprete_.u1)0) + cout << i << " elements in the incidence matrices are below the cutoff (" << interprete_.cutoff << ") and are discarded\n"; +} + +inline void +ModelTree::BlockLinear(Model_Block *ModelBlock) +{ + int i,j,l,m; + for(j = 0;j < ModelBlock->Size;j++) + { + if (ModelBlock->Block_List[j].Simulation_Type==SOLVE_BACKWARD_COMPLETE || + ModelBlock->Block_List[j].Simulation_Type==SOLVE_FOREWARD_COMPLETE) + { + for(i=0;iBlock_List[j].IM_lead_lag[0].size;i++) + { + int eq=ModelBlock->Block_List[j].IM_lead_lag[0].Equ_Index[i]; + int var=ModelBlock->Block_List[j].IM_lead_lag[0].Var_Index[i]; + first_derivatives_type::const_iterator it=first_derivatives.find(make_pair(eq,variable_table.getmVariableSelector(var,0))); + NodeID Id = it->second; + Id->collectEndogenous(Id); + if (Id->present_endogenous_size()>0) + { + for(l=0;lBlock_List[j].Size;l++) + { + if (Id->present_endogenous_find(ModelBlock->Block_List[j].Variable[l],0)) + { + ModelBlock->Block_List[j].is_linear=false; + goto follow; + } + } + } + } + } + else if (ModelBlock->Block_List[j].Simulation_Type==SOLVE_TWO_BOUNDARIES_COMPLETE) + { + for(m=0;m<=ModelBlock->Block_List[j].Max_Lead+ModelBlock->Block_List[j].Max_Lag;m++) + { + int k1=m-ModelBlock->Block_List[j].Max_Lag; + for(i=0;iBlock_List[j].IM_lead_lag[m].size;i++) + { + int eq=ModelBlock->Block_List[j].IM_lead_lag[m].Equ_Index[i]; + int var=ModelBlock->Block_List[j].IM_lead_lag[m].Var_Index[i]; + first_derivatives_type::const_iterator it=first_derivatives.find(make_pair(eq,variable_table.getmVariableSelector(var,k1))); + NodeID Id = it->second; + Id->collectEndogenous(Id); + if (Id->present_endogenous_size()>0) + { + for(l=0;lBlock_List[j].Size;l++) + { + if (Id->present_endogenous_find(ModelBlock->Block_List[j].Variable[l],k1)) + { + ModelBlock->Block_List[j].is_linear=false; + goto follow; + } + } + } + } + } + } + follow: + i=0; + } +} + void ModelTree::computingPass() { @@ -778,6 +1883,8 @@ ModelTree::computingPass() // Sorting variable table variable_table.Sort(); + variable_table.setmVariableSelector(); + if (offset == 1) { min_cost = 40 * 90; @@ -800,7 +1907,30 @@ ModelTree::computingPass() // Launch computations derive(order); - computeTemporaryTerms(order); + + if (offset == 2) + { + int Size; + int HSize; + int *Table=variable_table.GetVariableTable(&Size,&HSize); + + interprete_.create_id_map(Table,Size,HSize); + Evaluate_Jacobian(); + + if (block_triangular.bt_verbose) + { + cout << "The gross incidence matrix \n"; + block_triangular.Print_IM( symbol_table.endo_nbr); + } + block_triangular.SetVariableTable(Table, Size, HSize); + block_triangular.Normalize_and_BlockDecompose_Static_0_Model(); + BlockLinear(block_triangular.ModelBlock); + + computeTemporaryTermsOrdered(order, block_triangular.ModelBlock); + } + else + computeTemporaryTerms(order); + } void @@ -815,7 +1945,7 @@ ModelTree::writeStaticFile(const string &basename) const void ModelTree::writeDynamicFile(const string &basename) const { - if (offset) + if (offset == 1) writeDynamicMFile(basename + "_dynamic"); else writeDynamicCFile(basename + "_dynamic"); diff --git a/parser.src/Model_Graph.cc b/parser.src/Model_Graph.cc new file mode 100644 index 000000000..ee874520b --- /dev/null +++ b/parser.src/Model_Graph.cc @@ -0,0 +1,1056 @@ +#include +#include +#include +#include +#include +#include +#include +#include "ModelTree.hh" +#include "Model_Graph.hh" +#include "BlockTriangular.hh" + +using namespace std; + +void +free_model_graph(t_model_graph* model_graph) +{ + int i; + for(i = 0;i < model_graph->nb_vertices;i++) + { + free(model_graph->vertex[i].in_degree_edge); + free(model_graph->vertex[i].out_degree_edge); + } + free(model_graph->vertex); + free(model_graph); +} + +void +print_Graph(t_model_graph* model_graph) +{ + int i, j; + for(i = 0;i < model_graph->nb_vertices;i++) + { + cout << "vertex " << model_graph->vertex[i].index << "(" << i << " ," << model_graph->vertex[i].nb_out_degree_edges << ")\n"; + cout << " -> "; + for(j = 0;j < model_graph->vertex[i].nb_out_degree_edges;j++) + cout << model_graph->vertex[model_graph->vertex[i].out_degree_edge[j].index].index << /*" -" << model_graph->vertex[i].out_degree_edge[j].index << "-*/" (" << model_graph->vertex[i].out_degree_edge[j].u_count << "), "; + cout << "\n"; + cout << " <- "; + for(j = 0;j < model_graph->vertex[i].nb_in_degree_edges;j++) + cout << model_graph->vertex[model_graph->vertex[i].in_degree_edge[j].index].index << /*" -" << model_graph->vertex[i].in_degree_edge[j].index << "-*/" (" << model_graph->vertex[i].in_degree_edge[j].u_count << "), "; + cout << "\n"; + } +} + + + +void Check_Graph(t_model_graph* model_graph) +{ + int i, j, k, i1, i2; + bool OK, OK_u_count; + for(i = 0;i < model_graph->nb_vertices;i++) + { + for(j = 0;j < model_graph->vertex[i].nb_in_degree_edges;j++) + { + i1 = model_graph->vertex[i].in_degree_edge[j].index; + i2 = model_graph->vertex[i].in_degree_edge[j].u_count; + OK = 0; + OK_u_count = 0; + for(k = 0;(k < model_graph->vertex[i1].nb_out_degree_edges) && (!OK);k++) + { + if(model_graph->vertex[i1].out_degree_edge[k].index == i) + { + OK = 1; + if(model_graph->vertex[i1].out_degree_edge[k].u_count == i2) + OK_u_count = 1; + } + } + if(!OK) + { + cout << "not symetric for edge between vertices " << model_graph->vertex[i1].index << " and " << model_graph->vertex[i].index << " (in_degree)\n"; + print_Graph(model_graph); + system("pause"); + exit( -1); + } + if(!OK_u_count) + { + cout << "valeur de u_count non symétrique sur l'arc entre " << model_graph->vertex[i1].index << " et " << model_graph->vertex[i].index << " (in_degree)\n"; + print_Graph(model_graph); + system("pause"); + exit( -1); + } + } + for(j = 0;j < model_graph->vertex[i].nb_out_degree_edges;j++) + { + i1 = model_graph->vertex[i].out_degree_edge[j].index; + i2 = model_graph->vertex[i].out_degree_edge[j].u_count; + OK = 0; + OK_u_count = 0; + for(k = 0;(k < model_graph->vertex[i1].nb_in_degree_edges) && (!OK);k++) + { + if(model_graph->vertex[i1].in_degree_edge[k].index == i) + { + OK = 1; + if(model_graph->vertex[i1].in_degree_edge[k].u_count == i2) + OK_u_count = 1; + } + } + if(!OK) + { + cout << "pas symétrique sur l'arc entre " << model_graph->vertex[i1].index << " et " << model_graph->vertex[i].index << " (out_degree)\n"; + print_Graph(model_graph); + system("pause"); + exit( -1); + } + if(!OK_u_count) + { + cout << "valeur de u_count non symétrique sur l'arc entre " << model_graph->vertex[i1].index << " et " << model_graph->vertex[i].index << " (out_degree)\n"; + print_Graph(model_graph); + system("pause"); + exit( -1); + } + } + } +} + + + +void +copy_model_graph(t_model_graph* model_graph, t_model_graph* saved_model_graph, int nb_endo, int y_kmax) +{ + int i, j; + saved_model_graph->nb_vertices = model_graph->nb_vertices; + saved_model_graph->vertex = (t_vertex*)malloc(model_graph->nb_vertices * sizeof(*model_graph->vertex)); + for(i = 0;i < model_graph->nb_vertices;i++) + { + saved_model_graph->vertex[i].index = model_graph->vertex[i].index; + saved_model_graph->vertex[i].nb_in_degree_edges = model_graph->vertex[i].nb_in_degree_edges; + saved_model_graph->vertex[i].in_degree_edge = (t_edge*)malloc((y_kmax + 2) * nb_endo * sizeof(t_edge)); + for(j = 0;j < model_graph->vertex[i].nb_in_degree_edges;j++) + { + saved_model_graph->vertex[i].in_degree_edge[j].index = model_graph->vertex[i].in_degree_edge[j].index; + saved_model_graph->vertex[i].in_degree_edge[j].u_count = model_graph->vertex[i].in_degree_edge[j].u_count; + } + saved_model_graph->vertex[i].nb_out_degree_edges = model_graph->vertex[i].nb_out_degree_edges; + saved_model_graph->vertex[i].out_degree_edge = (t_edge*)malloc((y_kmax + 2) * nb_endo * sizeof(t_edge)); + for(j = 0;j < model_graph->vertex[i].nb_out_degree_edges;j++) + { + saved_model_graph->vertex[i].out_degree_edge[j].index = model_graph->vertex[i].out_degree_edge[j].index; + saved_model_graph->vertex[i].out_degree_edge[j].u_count = model_graph->vertex[i].out_degree_edge[j].u_count; + } + } +} + +int +ModelBlock_Graph(Model_Block *ModelBlock, int Blck_num, bool dynamic, t_model_graph* model_graph, int nb_endo, int* block_u_count, int *starting_vertex, int *periods, int *nb_table_y, int *mean_var_in_equ) +{ + int i, j, k, l, m, lag, per, lag1, k2, complete_size = 0, u_count; + int max_lead, max_lag, size, Lead, Lag; + int *Used, *todo_lag, *todo_lead, *vertex_ref, *vertex_index, *todo_lag1, *todo_lead1 ; + max_lag = ModelBlock->Block_List[Blck_num].Max_Lag; + max_lead = ModelBlock->Block_List[Blck_num].Max_Lead; + if(!dynamic) + { + /*It's a static model that have to be solved at each period*/ + /*size=ModelBlock->Block_List[Blck_num].IM_lead_lag[max_lag].size;*/ + size = ModelBlock->Block_List[Blck_num].Size; + /*We add an extra vertex to take into account of the f(x0) constant term in f(x)=0 approximated by f(x0) + (x-x0) f'(x0) = 0*/ + //cout << "Static, Blck_num= " << Blck_num << "size= " << size << "\n"; + model_graph->nb_vertices = size + 1; + *starting_vertex = 0; + model_graph->vertex = (t_vertex*)malloc(model_graph->nb_vertices * sizeof(*model_graph->vertex)); + for(i = 0;i < size;i++) + { + /*It's not f(x0) vertex*/ + model_graph->vertex[i].in_degree_edge = (t_edge*)malloc((size + 1) * sizeof(t_edge)); + model_graph->vertex[i].out_degree_edge = (t_edge*)malloc((size + 1) * sizeof(t_edge)); + model_graph->vertex[i].nb_in_degree_edges = 0; + model_graph->vertex[i].nb_out_degree_edges = 0; + model_graph->vertex[i].index = ModelBlock->Block_List[Blck_num].Variable[i]; + model_graph->vertex[i].lag_lead = 0; + } + /*It's f(x0) vertex*/ + model_graph->vertex[size].in_degree_edge = (t_edge*)malloc(0 * sizeof(t_edge)); + model_graph->vertex[size].out_degree_edge = (t_edge*)malloc((size) * sizeof(t_edge)); + model_graph->vertex[size].nb_in_degree_edges = 0; + model_graph->vertex[size].index = -1; + model_graph->vertex[size].lag_lead = 0; + for(i = 0;i < ModelBlock->Block_List[Blck_num].IM_lead_lag[max_lag].size;i++) + { + k = ModelBlock->Block_List[Blck_num].IM_lead_lag[max_lag].Equ[i]; + m = ModelBlock->Block_List[Blck_num].IM_lead_lag[max_lag].Var[i]; + j = model_graph->vertex[k].nb_in_degree_edges++; + l = model_graph->vertex[m].nb_out_degree_edges++; + model_graph->vertex[k].in_degree_edge[j].index = m; + model_graph->vertex[m].out_degree_edge[l].index = k; + model_graph->vertex[k].in_degree_edge[j].u_count = ModelBlock->Block_List[Blck_num].IM_lead_lag[max_lag].us[i]; + model_graph->vertex[m].out_degree_edge[l].u_count = ModelBlock->Block_List[Blck_num].IM_lead_lag[max_lag].us[i]; + } + model_graph->vertex[size].nb_out_degree_edges = size; + for(i = 0;i < size;i++) + { + j = model_graph->vertex[i].nb_in_degree_edges++; + model_graph->vertex[i].in_degree_edge[j].index = size; + model_graph->vertex[i].in_degree_edge[j].u_count = i; + model_graph->vertex[size].out_degree_edge[i].index = i; + model_graph->vertex[size].out_degree_edge[i].u_count = i; + } + u_count = ModelBlock->Block_List[Blck_num].IM_lead_lag[max_lag].u_finish - ModelBlock->Block_List[Blck_num].IM_lead_lag[max_lag].u_init + 1 + + ModelBlock->Block_List[Blck_num].Size; + *block_u_count = u_count; + *nb_table_y = size; + return (u_count); + } + else + { + Lead = ModelBlock->Block_List[Blck_num].Max_Lead; + Lag = ModelBlock->Block_List[Blck_num].Max_Lag; + int sup = Lead + Lag +3; + *periods = Lead + Lag + sup; +#ifdef PRINT_OUT + cout << "Lag=" << Lag << " Lead=" << Lead << "\n"; + cout << "periods=Lead+2*Lag+2= " << *periods << "\n"; +#endif + size = ModelBlock->Block_List[Blck_num].Size; + /*It's a dynamic model that have to be solved for all periods. + So we consider the incidence matrice for all lead and lags plus the current value*/ + model_graph->nb_vertices = 0; + vertex_ref = (int*)malloc(size * (Lag + Lead + *periods) * sizeof(int)); + memset(vertex_ref, -1, size*(Lag + Lead + *periods)*sizeof(int)); + vertex_index = (int*)malloc(size * (Lag + Lead + *periods) * sizeof(int)); + complete_size = ModelBlock->Block_List[Blck_num].IM_lead_lag[Lag].size * (*periods); + if(Lag > 0) + { + todo_lag = (int*)malloc(size * Lag * sizeof(int)); + todo_lag1 = (int*)malloc(size * Lag * sizeof(int)); + memset(todo_lag, -1, size*Lag*sizeof(int)); + memset(todo_lag1, -1, size*Lag*sizeof(int)); + Used = (int*)malloc(size * Lag * sizeof(int)); + for(lag = 0;lag < Lag;lag++) + { + memset(Used, -1, size*Lag*sizeof(int)); + complete_size += ModelBlock->Block_List[Blck_num].IM_lead_lag[lag].size; + for(i = 0;i < ModelBlock->Block_List[Blck_num].IM_lead_lag[lag].size;i++) + { + if(Used[ModelBlock->Block_List[Blck_num].IM_lead_lag[lag].Var[i]] < 0) + { + k = ModelBlock->Block_List[Blck_num].IM_lead_lag[lag].Var[i]; + todo_lag[lag*size + k] = k; + vertex_ref[lag*size + k] = model_graph->nb_vertices; + vertex_index[model_graph->nb_vertices] = lag * nb_endo + ModelBlock->Block_List[Blck_num].IM_lead_lag[lag].Var_Index[i]; + todo_lag1[lag*size + k] = i; + model_graph->nb_vertices++; + Used[k] = i; + } + } + if(lag > 0) + { + for(lag1 = 0;lag1 < lag;lag1++) + for(i = 0;i < size;i++) + if(todo_lag[(lag1)*size + i] >= 0) + { + if(Used[i] < 0) + { + todo_lag[lag*size + i] = i; + k = todo_lag[(lag1) * size + i]; + vertex_ref[lag*size + k] = model_graph->nb_vertices; + j = todo_lag1[(lag1) * size + i]; + vertex_index[model_graph->nb_vertices] = lag * nb_endo + ModelBlock->Block_List[Blck_num].IM_lead_lag[lag1].Var_Index[k]; + model_graph->nb_vertices++; + } + } + } + } + *starting_vertex = model_graph->nb_vertices; + free(Used); + free(todo_lag); + free(todo_lag1); + } + int nb_vertices_1=model_graph->nb_vertices; +#ifdef PRINT_OUT + cout << "nb_vertices in the first part: " << nb_vertices_1 << "\n"; +#endif + for(per = Lag;per < Lag + *periods;per++) + for(i = 0;i < size;i++) + { + vertex_ref[per*size + i] = model_graph->nb_vertices; + vertex_index[model_graph->nb_vertices] = (per) * nb_endo + ModelBlock->Block_List[Blck_num].Variable[i]; + model_graph->nb_vertices++; + } + int nb_vertices_2=model_graph->nb_vertices-nb_vertices_1; +#ifdef PRINT_OUT + cout << "nb_vertices in the second part: " << nb_vertices_2 << "\n"; +#endif + if(Lead > 0) + { + todo_lead = (int*)malloc(size * Lead * sizeof(int)); + todo_lead1 = (int*)malloc(size * Lead * sizeof(int)); + memset(todo_lead, -1, size*Lead*sizeof(int)); + memset(todo_lead1, -1, size*Lead*sizeof(int)); + Used = (int*)malloc(size * Lead * sizeof(int)); + k2 = model_graph->nb_vertices; + for(lag = Lag + Lead;lag > Lag;lag--) + { + complete_size += ModelBlock->Block_List[Blck_num].IM_lead_lag[lag].size; + memset(Used, -1, size*Lead*sizeof(int)); + for(i = 0;i < ModelBlock->Block_List[Blck_num].IM_lead_lag[lag].size;i++) + { + if(Used[ModelBlock->Block_List[Blck_num].IM_lead_lag[lag].Var[i]] < 0) + { + k = ModelBlock->Block_List[Blck_num].IM_lead_lag[lag].Var[i]; + todo_lead[(lag - Lag - 1)*size + k] = k; + todo_lead1[(lag - Lag - 1)*size + k] = i; + Used[k] = i; + model_graph->nb_vertices++; + } + } + if(lag < Lag + Lead) + { + for(lag1 = Lag + Lead;lag1 > lag;lag1--) + for(i = 0;i < size;i++) + { + if(todo_lead[(lag1 - Lag - 1)*size + i] >= 0) + { + if(Used[i] < 0) + { + k = todo_lead[(lag1 - Lag - 1) * size + i]; + model_graph->nb_vertices++; + } + } + } + } + } + k2 = model_graph->nb_vertices; + memset(todo_lead, -1, size*Lead*sizeof(int)); + for(lag = Lag + Lead;lag > Lag;lag--) + { + complete_size += ModelBlock->Block_List[Blck_num].IM_lead_lag[lag].size; + memset(Used, -1, size*Lead*sizeof(int)); + for(i = ModelBlock->Block_List[Blck_num].IM_lead_lag[lag].size - 1;i >= 0;i--) + { + if(Used[ModelBlock->Block_List[Blck_num].IM_lead_lag[lag].Var[i]] < 0) + { + k2--; + k = ModelBlock->Block_List[Blck_num].IM_lead_lag[lag].Var[i]; + todo_lead[(lag - Lag - 1)*size + k] = k; + todo_lead1[(lag - Lag - 1)*size + k] = i; + vertex_ref[(lag + *periods - 1)*size + k] = k2; + vertex_index[k2] = (lag + *periods - 1) * nb_endo + ModelBlock->Block_List[Blck_num].IM_lead_lag[lag].Var_Index[i]; + Used[k] = i; + } + } + if(lag < Lag + Lead) + { + for(lag1 = Lag + Lead;lag1 > lag;lag1--) + { + for(i = size - 1;i >= 0;i--) + { + if(todo_lead[(lag1 - Lag - 1)*size + i] >= 0) + { + if(Used[i] < 0) + { + k2--; + todo_lead[(lag - Lag - 1)*size + i] = i; + todo_lead1[(lag - Lag - 1)*size + i] = todo_lead1[(lag1 - Lag - 1)*size + i]; + k = todo_lead[(lag1 - Lag - 1) * size + i]; + vertex_ref[(lag + *periods - 1)*size + k] = k2; + //#ifdef PRINT_OUT + + //#endif + + j = todo_lead1[(lag1 - Lag - 1) * size + i]; + //#ifdef PRINT_OUT + if(j>ModelBlock->Block_List[Blck_num].IM_lead_lag[lag1].size||j==-1) + { + cout << "Error in model graph construction (lead part): j (" << j << ")>size (" << ModelBlock->Block_List[Blck_num].IM_lead_lag[lag1].size << ")\n"; + system("pause"); + exit(-1); + } + //#endif + vertex_index[k2] = (lag + *periods - 1) * nb_endo + ModelBlock->Block_List[Blck_num].IM_lead_lag[lag1].Var_Index[j]; + } + } + } + } + } + } + free(Used); + free(todo_lead); + free(todo_lead1); + } + int nb_vertices_3=model_graph->nb_vertices-nb_vertices_2-nb_vertices_1; +#ifdef PRINT_OUT + cout << "nb_vertices in the last part: " << nb_vertices_3 << "\n"; +#endif + /*We add an extra vertex to take into account of the f(x0) constant term in f(x)=0 approx f(x0) + (x-x0) f'(x0) = 0*/ + model_graph->nb_vertices++; + model_graph->vertex = (t_vertex*)malloc(model_graph->nb_vertices * sizeof(*model_graph->vertex)); + vertex_index[model_graph->nb_vertices - 1] = -1; +#ifdef PRINT_OUT + cout << "ok0\n"; + cout << "model_graph->nb_vertices=" << model_graph->nb_vertices << " Lag=" << Lag << " Lead=" << Lead << "\n"; + cout << "*periods=" << *periods << " size=" << size << "\n"; + cout << "allocated / vertex = " << (size + nb_vertices_1 + nb_vertices_3+ 1) << "\n"; +#endif + int nb_table_u= size+nb_vertices_1+nb_vertices_3+2; + for(k = 0;k < model_graph->nb_vertices-1;k++) + { + model_graph->vertex[k].index = vertex_index[k]; + model_graph->vertex[k].in_degree_edge = (t_edge*)malloc(nb_table_u * sizeof(t_edge)); + model_graph->vertex[k].out_degree_edge = (t_edge*)malloc(nb_table_u * sizeof(t_edge)); + model_graph->vertex[k].nb_in_degree_edges = 0; + model_graph->vertex[k].nb_out_degree_edges = 0; + model_graph->vertex[k].max_nb_in_degree_edges = nb_table_u; + model_graph->vertex[k].max_nb_out_degree_edges = nb_table_u; +#ifdef PRINT_OUT + //if(k==8) + { + cout << " model_graph->vertex[" << k << "].in_degree_edge=" << model_graph->vertex[k].in_degree_edge << "\n"; + } +#endif + } + model_graph->vertex[model_graph->nb_vertices-1].index = vertex_index[model_graph->nb_vertices-1]; + model_graph->vertex[model_graph->nb_vertices-1].in_degree_edge = (t_edge*)malloc(/*model_graph->nb_vertices **/ sizeof(t_edge)); + model_graph->vertex[model_graph->nb_vertices-1].out_degree_edge = (t_edge*)malloc(model_graph->nb_vertices * sizeof(t_edge)); + model_graph->vertex[model_graph->nb_vertices-1].nb_in_degree_edges = 0; + model_graph->vertex[model_graph->nb_vertices-1].nb_out_degree_edges = 0; + model_graph->vertex[model_graph->nb_vertices-1].max_nb_in_degree_edges = 0; + model_graph->vertex[model_graph->nb_vertices-1].max_nb_out_degree_edges = model_graph->nb_vertices; +#ifdef PRINT_OUT + cout << "ok1\n"; + system("pause"); +#endif + u_count = 0; + *mean_var_in_equ = 0; + for(per = 0;per < *periods;per++) + { + j = model_graph->nb_vertices - 1; + for(i = 0;i < size;i++) + { + k = vertex_ref[(Lag + per) * size + i]; + model_graph->vertex[k].in_degree_edge[model_graph->vertex[k].nb_in_degree_edges].index = j; + model_graph->vertex[j].out_degree_edge[model_graph->vertex[j].nb_out_degree_edges].index = k; + model_graph->vertex[k].in_degree_edge[model_graph->vertex[k].nb_in_degree_edges].u_count = u_count; + model_graph->vertex[j].out_degree_edge[model_graph->vertex[j].nb_out_degree_edges].u_count = u_count; + model_graph->vertex[k].nb_in_degree_edges++; + model_graph->vertex[j].nb_out_degree_edges++; + u_count++; + } + for(lag = 0;lag < Lag + Lead + 1;lag++) + { +#ifdef PRINT_OUT + cout << "ModelBlock->Block_List[" << Blck_num << "].IM_lead_lag[" << lag << "].size = " << ModelBlock->Block_List[Blck_num].IM_lead_lag[lag].size << "\n"; +#endif + + for(i = 0;i < ModelBlock->Block_List[Blck_num].IM_lead_lag[lag].size;i++) + { + j = vertex_ref[(lag + per) * size + ModelBlock->Block_List[Blck_num].IM_lead_lag[lag].Var[i]]; + k = vertex_ref[(Lag + per) * size + ModelBlock->Block_List[Blck_num].IM_lead_lag[lag].Equ[i]]; +#ifdef PRINT_OUT + + cout << "per=" << per << " lag=" << lag << " i=" << i << " j=" << j << " k=" << k << "\n"; +#endif + + model_graph->vertex[k].in_degree_edge[model_graph->vertex[k].nb_in_degree_edges].index = j; + model_graph->vertex[j].out_degree_edge[model_graph->vertex[j].nb_out_degree_edges].index = k; + model_graph->vertex[k].in_degree_edge[model_graph->vertex[k].nb_in_degree_edges].u_count = u_count; + model_graph->vertex[j].out_degree_edge[model_graph->vertex[j].nb_out_degree_edges].u_count = u_count; + if(per==(Lag+2))/*&&(lag==(Lag+1))*/ + (*mean_var_in_equ)++; + model_graph->vertex[k].nb_in_degree_edges++; + model_graph->vertex[j].nb_out_degree_edges++; + u_count++; + } + } + } + (*mean_var_in_equ) += size; + //cout << "Total variables=" << *mean_var_in_equ << " nb_endo=" << size << "\n"; + i=*mean_var_in_equ ; + i =int(ceil(double(i)/size)); + *mean_var_in_equ = i; + + //cout << "Mean var in equation=" << *mean_var_in_equ << "\n"; + *block_u_count = u_count / (*periods); + free(vertex_index); + free(vertex_ref); + if(nb_vertices_1+nb_vertices_3+1>size) + *nb_table_y = nb_vertices_1+nb_vertices_3+1; + else + *nb_table_y = size; + return (u_count); + } +} + + + + +void +IM_to_model_graph(List_IM* First_IM, int Time, int endo, int *y_kmin, int *y_kmax, t_model_graph* model_graph, int *nb_endo, int *stacked_time, double** u1, int *u_count +#ifdef VERIF + , Matrix *B, Matrix *D +#endif + ) +{ + int i, j, t, n, k, l=0, k_k_in = 0, m; + t_pList* Endo; + List_IM* Curr_IM; + int nb_IM = 0; + int Max_edge = 0; +#ifdef STACKED + + int k_block = 0; +#endif + + bool OK; + *nb_endo = endo; + Curr_IM = First_IM; + while(Curr_IM) + { + if(Curr_IM->lead_lag > *y_kmax) + *y_kmax = Curr_IM->lead_lag; + if( -Curr_IM->lead_lag > *y_kmin) + *y_kmin = -Curr_IM->lead_lag; + Curr_IM = Curr_IM->pNext; + nb_IM++; + } + Endo = (t_pList*)malloc(endo * sizeof(t_pList)); + for(i = 0;i < endo;i++) + { + Endo[i].Lag_in = (int*)malloc((*y_kmin + *y_kmax + 1) * sizeof(int)); + Endo[i].Lag_out = (int*)malloc((*y_kmin + *y_kmax + 1) * sizeof(int)); + memset(Endo[i].Lag_in, 0, (*y_kmin + *y_kmax + 1)*sizeof(int)); + memset(Endo[i].Lag_out, 0, (*y_kmin + *y_kmax + 1)*sizeof(int)); + Endo[i].CurrNb_in = Endo[i].CurrNb_out = 0; + } + Curr_IM = First_IM; + while(Curr_IM) + { + k = Curr_IM->lead_lag + *y_kmin; + for(i = 0;i < endo;i++) + for(j = 0;j < endo;j++) + if(Curr_IM->IM[i*endo + j]) + { + Endo[i].Lag_in[k]++; + Endo[j].Lag_out[k]++; + } + Curr_IM = Curr_IM->pNext; + } + for(i = 0;i < endo;i++) + { + for(j = 0;j < *y_kmax + *y_kmin + 1;j++) + { + Endo[i].CurrNb_in += Endo[i].Lag_in[j]; + Endo[i].CurrNb_out += Endo[i].Lag_out[j]; + } + if(Endo[i].CurrNb_in + 2 > Max_edge) + Max_edge = Endo[i].CurrNb_in + 2; + if(Endo[i].CurrNb_out + 2 > Max_edge) + Max_edge = Endo[i].CurrNb_out + 2; + } + *stacked_time = Time; + Max_edge = Max_edge * Max_edge; +#ifdef VERIF + + B->resize(Time*endo, Time*endo); + D->resize(Time*endo, 1); + *B = B->zeros(); + *D = D->zeros(); +#endif + + int size_c_in, size_c_out, total_edge = 0; + model_graph->nb_vertices = endo * (*stacked_time) + 1; + model_graph->vertex = (t_vertex*)malloc(model_graph->nb_vertices * sizeof(*model_graph->vertex)); + for(t = 0;t < *stacked_time;t++) + { + if(t > 0) + { + if(t <= *y_kmin) + for(i = 0;i < endo;i++) + Endo[i].CurrNb_in += Endo[i].Lag_in[*y_kmin - t]; + if(t <= *y_kmax) + for(i = 0;i < endo;i++) + Endo[i].CurrNb_out += Endo[i].Lag_out[*y_kmin + t]; + } + if(t >= (*stacked_time - *y_kmax)) + { + for(i = 0;i < endo;i++) + Endo[i].CurrNb_in -= Endo[i].Lag_in[*y_kmin + (*stacked_time - t)]; + } + if(t >= (*stacked_time - *y_kmin)) + { + for(i = 0;i < endo;i++) + Endo[i].CurrNb_out -= Endo[i].Lag_out[*y_kmin - (*stacked_time - t)]; + } + for(j = 0;j < endo;j++) + { + size_c_in = endo * (*y_kmin + *y_kmax + 1) + 2; + size_c_out = endo * (*y_kmin + *y_kmax + 1) + 2; + total_edge += size_c_out - 1; + l = t * endo + j; +#ifdef STACKED + + if(t - *y_kmax - *y_kmin - 2 > 0) + model_graph->vertex[l].index = l + (Time - *y_kmax - *y_kmin - 2) * endo; + else + model_graph->vertex[l].index = l; +#else + + model_graph->vertex[l].index = l; +#endif + + model_graph->vertex[l].in_degree_edge = (t_edge*)malloc(size_c_in * sizeof(t_edge)); + model_graph->vertex[l].out_degree_edge = (t_edge*)malloc(size_c_out * sizeof(t_edge)); + model_graph->vertex[l].nb_in_degree_edges = 0; + model_graph->vertex[l].nb_out_degree_edges = 0; + } + } + total_edge += *stacked_time * endo; + for(i = 0;i < endo;i++) + { + free(Endo[i].Lag_in); + free(Endo[i].Lag_out); + } + free(Endo); + *u1 = (double*)malloc((total_edge) * sizeof(double)); + model_graph->vertex[l + 1].in_degree_edge = (t_edge*)malloc(0 * sizeof(t_edge)); + model_graph->vertex[l + 1].out_degree_edge = (t_edge*)malloc((*stacked_time * endo) * sizeof(t_edge)); + model_graph->vertex[l + 1].index = l + 1; + model_graph->vertex[l + 1].nb_in_degree_edges = 0; + model_graph->vertex[l + 1].nb_out_degree_edges = 0; + for(t = 0;t < *stacked_time;t++) + { + Curr_IM = First_IM; + while(Curr_IM) + { + if(Curr_IM->lead_lag < 0) + { + if(t >= abs(Curr_IM->lead_lag)) + OK = 1; + else + OK = 0; + } + else + { + if(*stacked_time - t > Curr_IM->lead_lag) + OK = 1; + else + OK = 0; + } + if(OK) + { + l = (t + Curr_IM->lead_lag) * endo; + for(j = 0;j < endo;j++) + { + n = t * endo + j; + for(k = 0;k < endo;k++) + { + if(Curr_IM->IM[j*endo + k]) + { + model_graph->vertex[n].in_degree_edge[model_graph->vertex[n].nb_in_degree_edges].index = l + k; + model_graph->vertex[n].in_degree_edge[model_graph->vertex[n].nb_in_degree_edges].u_count = + *u_count; + (*u1)[*u_count] = (double)rand() / RAND_MAX; +#ifdef VERIF + + (*B)[n][l + k] = -(*u1)[*u_count]; +#endif + + (*u_count)++; + model_graph->vertex[n].nb_in_degree_edges++; + } + } + if(Curr_IM->lead_lag == 0) + { + model_graph->vertex[n].in_degree_edge[model_graph->vertex[n].nb_in_degree_edges].index = + endo * (*stacked_time); + model_graph->vertex[n].in_degree_edge[model_graph->vertex[n].nb_in_degree_edges].u_count = + *u_count; + (*u1)[*u_count] = (double)rand() / RAND_MAX; +#ifdef VERIF + + (*D)[n][0] = (*u1)[*u_count]; +#endif + + (*u_count)++; + model_graph->vertex[n].nb_in_degree_edges++; + } + k_k_in += model_graph->vertex[n].nb_in_degree_edges; + } + n = t * endo; + for(j = 0;j < endo;j++) + { + l = (t + Curr_IM->lead_lag) * endo + j; + for(k = 0;k < endo;k++) + { + if(Curr_IM->IM[k*endo + j]) + { + model_graph->vertex[l].out_degree_edge[model_graph->vertex[l].nb_out_degree_edges].index = n + k; + for(m = 0;m < model_graph->vertex[n + k].nb_in_degree_edges;m++) + if(model_graph->vertex[n + k].in_degree_edge[m].index == l) + { + model_graph->vertex[l].out_degree_edge[model_graph->vertex[l].nb_out_degree_edges].u_count = + model_graph->vertex[n + k].in_degree_edge[m].u_count; + } + model_graph->vertex[l].nb_out_degree_edges++; + } + } + } + } + Curr_IM = Curr_IM->pNext; + } + } + l = endo * (*stacked_time); + for(j = 0;j < l;j++) + { + model_graph->vertex[l].out_degree_edge[model_graph->vertex[l].nb_out_degree_edges].index = j; + for(m = 0;m < model_graph->vertex[j].nb_in_degree_edges;m++) + if(model_graph->vertex[j].in_degree_edge[m].index == l) + { + model_graph->vertex[l].out_degree_edge[model_graph->vertex[l].nb_out_degree_edges].u_count = + model_graph->vertex[j].in_degree_edge[m].u_count; + } + model_graph->vertex[l].nb_out_degree_edges++; + } + cout << "mean element by equation : " << (double)(k_k_in) / ((*stacked_time)*endo) << "\n"; +} + + +void +IM_to_model_graph_new(List_IM* First_IM, int Time, int endo, int *y_kmin, int *y_kmax, t_model_graph* model_graph, int * nb_endo, int *stacked_time, double** u1, int* u_count +#ifdef VERIF + , Matrix* B, Matrix* D +#endif + ) +{ + int i, j, t, n, k, l=0, k_k_in = 0, m, u_count_per_period, s_u_count, bi; + t_pList* Endo; + List_IM* Curr_IM; + int nb_IM = 0; + int Max_edge = 0; +#ifdef STACKED + int k_block = 0; +#endif + bool OK; + *nb_endo = endo; + Curr_IM = First_IM; + while(Curr_IM) + { + if(Curr_IM->lead_lag > *y_kmax) + *y_kmax = Curr_IM->lead_lag; + if( -Curr_IM->lead_lag > *y_kmin) + *y_kmin = -Curr_IM->lead_lag; + Curr_IM = Curr_IM->pNext; + nb_IM++; + } + Endo = (t_pList*)malloc(endo * sizeof(t_pList)); + for(i = 0;i < endo;i++) + { + Endo[i].Lag_in = (int*)malloc((*y_kmin + *y_kmax + 1) * sizeof(int)); + Endo[i].Lag_out = (int*)malloc((*y_kmin + *y_kmax + 1) * sizeof(int)); + memset(Endo[i].Lag_in, 0, (*y_kmin + *y_kmax + 1)*sizeof(int)); + memset(Endo[i].Lag_out, 0, (*y_kmin + *y_kmax + 1)*sizeof(int)); + Endo[i].CurrNb_in = Endo[i].CurrNb_out = 0; + } + Curr_IM = First_IM; + while(Curr_IM) + { + k = Curr_IM->lead_lag + *y_kmin; + for(i = 0;i < endo;i++) + for(j = 0;j < endo;j++) + if(Curr_IM->IM[i*endo + j]) + { + Endo[i].Lag_in[k]++; + Endo[j].Lag_out[k]++; + } + Curr_IM = Curr_IM->pNext; + } + for(i = 0;i < endo;i++) + { + for(j = 0;j < *y_kmax + *y_kmin + 1;j++) + { + Endo[i].CurrNb_in += Endo[i].Lag_in[j]; + Endo[i].CurrNb_out += Endo[i].Lag_out[j]; + } + if(Endo[i].CurrNb_in + 2 > Max_edge) + Max_edge = Endo[i].CurrNb_in + 2; + if(Endo[i].CurrNb_out + 2 > Max_edge) + Max_edge = Endo[i].CurrNb_out + 2; + } + *stacked_time = Time; + Max_edge = Max_edge * Max_edge; + cout << "Max_edge=" << Max_edge << "\n"; +#ifdef VERIF + B->resize(Time*endo, Time*endo); + D->resize(Time*endo, 1); + *B = B->zeros(); + *D = D->zeros(); +#endif + int size_c_in, size_c_out, total_edge = 0; + model_graph->nb_vertices = endo * (*stacked_time) + 1; + model_graph->vertex = (t_vertex*)malloc(model_graph->nb_vertices * sizeof(*model_graph->vertex)); + bi = (*y_kmin) + /*6*/20; + for(t = 0;t < *stacked_time;t++) + { + if(t > 0) + { + if(t <= *y_kmin) + for(i = 0;i < endo;i++) + Endo[i].CurrNb_in += Endo[i].Lag_in[*y_kmin - t]; + if(t <= *y_kmax) + for(i = 0;i < endo;i++) + Endo[i].CurrNb_out += Endo[i].Lag_out[*y_kmin + t]; + } + if(t >= (*stacked_time - *y_kmax)) + { + for(i = 0;i < endo;i++) + Endo[i].CurrNb_in -= Endo[i].Lag_in[*y_kmin + (*stacked_time - t)]; + } + if(t >= (*stacked_time - *y_kmin)) + { + for(i = 0;i < endo;i++) + Endo[i].CurrNb_out -= Endo[i].Lag_out[*y_kmin - (*stacked_time - t)]; + } + for(j = 0;j < endo;j++) + { + size_c_in = endo * (*y_kmin + *y_kmax + 1) + 2; + size_c_out = endo * (*y_kmin + *y_kmax + 1) + 2; + total_edge += size_c_out - 1; + l = t * endo + j; +#ifdef STACKED + if(t - *y_kmax - *y_kmin - 2 > 0) + model_graph->vertex[l].index = l + (Time - *y_kmax - *y_kmin - 2) * endo; + else + model_graph->vertex[l].index = l; +#else + model_graph->vertex[l].index = l; +#endif + if((t < bi + 1 ) || (t > *stacked_time - *y_kmax - 5)) + { + model_graph->vertex[l].in_degree_edge = (t_edge*)malloc(size_c_in * sizeof(t_edge)); + model_graph->vertex[l].out_degree_edge = (t_edge*)malloc(size_c_out * sizeof(t_edge)); + } + else + { +#ifdef PRINT_OUT + cout << "nothing allocated for l=" << l << "\n"; +#endif + model_graph->vertex[l].in_degree_edge = (t_edge*)malloc(0 * sizeof(t_edge)); + model_graph->vertex[l].out_degree_edge = (t_edge*)malloc(0 * sizeof(t_edge)); + } + model_graph->vertex[l].nb_in_degree_edges = 0; + model_graph->vertex[l].nb_out_degree_edges = 0; + } + } + total_edge += *stacked_time * endo; + for(i = 0;i < endo;i++) + { + free(Endo[i].Lag_in); + free(Endo[i].Lag_out); + } + free(Endo); + *u1 = (double*)malloc((total_edge) * sizeof(double)); + model_graph->vertex[l + 1].in_degree_edge = (t_edge*)malloc(0 * sizeof(t_edge)); + model_graph->vertex[l + 1].out_degree_edge = (t_edge*)malloc((*stacked_time * endo) * sizeof(t_edge)); + model_graph->vertex[l + 1].index = l + 1; + model_graph->vertex[l + 1].nb_in_degree_edges = 0; + model_graph->vertex[l + 1].nb_out_degree_edges = 0; + s_u_count = *u_count; + for(t = 0;t < *stacked_time;t++) + { + if((t < bi) || (t > *stacked_time - *y_kmax - 4)) + { + u_count_per_period = *u_count; + Curr_IM = First_IM; + while(Curr_IM) + { + if(Curr_IM->lead_lag < 0) + { + if(t >= abs(Curr_IM->lead_lag)) + OK = 1; + else + OK = 0; + } + else + { + if(*stacked_time - t > Curr_IM->lead_lag) + OK = 1; + else + OK = 0; + } + if(OK) + { + l = (t + Curr_IM->lead_lag) * endo; + for(j = 0;j < endo;j++) + { + n = t * endo + j; + for(k = 0;k < endo;k++) + { + if(Curr_IM->IM[j*endo + k]) + { + model_graph->vertex[n].in_degree_edge[model_graph->vertex[n].nb_in_degree_edges].index = l + k; + model_graph->vertex[n].in_degree_edge[model_graph->vertex[n].nb_in_degree_edges].u_count = + *u_count; + (*u1)[*u_count] = (double)rand() / RAND_MAX; +#ifdef VERIF + (*B)[n][l + k] = -(*u1)[*u_count]; +#endif + (*u_count)++; + model_graph->vertex[n].nb_in_degree_edges++; + } + } + if(Curr_IM->lead_lag == 0) + { + model_graph->vertex[n].in_degree_edge[model_graph->vertex[n].nb_in_degree_edges].index = + endo * (*stacked_time); + model_graph->vertex[n].in_degree_edge[model_graph->vertex[n].nb_in_degree_edges].u_count = + *u_count; + (*u1)[*u_count] = (double)rand() / RAND_MAX; +#ifdef VERIF + (*D)[n][0] = (*u1)[*u_count]; +#endif + (*u_count)++; + model_graph->vertex[n].nb_in_degree_edges++; + } + k_k_in += model_graph->vertex[n].nb_in_degree_edges; + } + n = t * endo; + for(j = 0;j < endo;j++) + { + l = (t + Curr_IM->lead_lag) * endo + j; + for(k = 0;k < endo;k++) + { + if(Curr_IM->IM[k*endo + j]) + { + cout << "l=" << l << " (*stacked_time*endo)=" << (*stacked_time*endo) << " model_graph->vertex[l].nb_out_degree_edges= " << model_graph->vertex[l].nb_out_degree_edges << "\n"; + model_graph->vertex[l].out_degree_edge[model_graph->vertex[l].nb_out_degree_edges].index = n + k; + for(m = 0;m < model_graph->vertex[n + k].nb_in_degree_edges;m++) + if(model_graph->vertex[n + k].in_degree_edge[m].index == l) + { + model_graph->vertex[l].out_degree_edge[model_graph->vertex[l].nb_out_degree_edges].u_count = + model_graph->vertex[n + k].in_degree_edge[m].u_count; + } + model_graph->vertex[l].nb_out_degree_edges++; + } + } + } + } + Curr_IM = Curr_IM->pNext; + } + u_count_per_period = *u_count - u_count_per_period; + } + else + { + for(j = 0;j < u_count_per_period;j++) + (*u1)[*u_count + j] = (double)rand() / RAND_MAX; + *u_count += u_count_per_period; + } + } +#ifdef VERIF + *u_count = s_u_count; + for(t = 0;t < *stacked_time;t++) + { + Curr_IM = First_IM; + while(Curr_IM) + { + if(Curr_IM->lead_lag < 0) + { + if(t >= abs(Curr_IM->lead_lag)) + OK = 1; + else + OK = 0; + } + else + { + if(*stacked_time - t > Curr_IM->lead_lag) + OK = 1; + else + OK = 0; + } + if(OK) + { + l = (t + Curr_IM->lead_lag) * endo; + for(j = 0;j < endo;j++) + { + n = t * endo + j; + for(k = 0;k < endo;k++) + { + if(Curr_IM->IM[j*endo + k]) + { + (*B)[n][l + k] = -(*u1)[*u_count]; + (*u_count)++; + } + } + if(Curr_IM->lead_lag == 0) + { + (*D)[n][0] = (*u1)[*u_count]; + (*u_count)++; + } + } + } + Curr_IM = Curr_IM->pNext; + } + } +#endif + l = endo * (*stacked_time); + for(j = 0;j < l;j++) + { + model_graph->vertex[l].out_degree_edge[model_graph->vertex[l].nb_out_degree_edges].index = j; + model_graph->vertex[l].out_degree_edge[model_graph->vertex[l].nb_out_degree_edges].u_count = -1; + for(m = 0;m < model_graph->vertex[j].nb_in_degree_edges;m++) + if(model_graph->vertex[j].in_degree_edge[m].index == l) + { + model_graph->vertex[l].out_degree_edge[model_graph->vertex[l].nb_out_degree_edges].u_count = + model_graph->vertex[j].in_degree_edge[m].u_count; + } + model_graph->vertex[l].nb_out_degree_edges++; + } +} + + +void +reduce_model_graph(t_model_graph* model_graph, int pos) +{ + int i, j, k; + if(pos > 0) + { + for(i = 0;i < pos;i++) + { + free(model_graph->vertex[i].in_degree_edge); + free(model_graph->vertex[i].out_degree_edge); + } + for(i = pos;i < model_graph->nb_vertices;i++) + model_graph->vertex[i - pos] = model_graph->vertex[i]; + model_graph->nb_vertices -= pos; + for(i = 0;i < model_graph->nb_vertices;i++) + { + for(j = 0;j < model_graph->vertex[i].nb_in_degree_edges;j++) + if(model_graph->vertex[i].in_degree_edge[j].index < pos) + { + for(k = j + 1;k < model_graph->vertex[i].nb_in_degree_edges;k++) + { + model_graph->vertex[i].in_degree_edge[k - 1].index = model_graph->vertex[i].in_degree_edge[k].index; + model_graph->vertex[i].in_degree_edge[k - 1].u_count = model_graph->vertex[i].in_degree_edge[k].u_count; + } + j--; + model_graph->vertex[i].nb_in_degree_edges--; + } + else + model_graph->vertex[i].in_degree_edge[j].index -= pos; + for(j = 0;j < model_graph->vertex[i].nb_out_degree_edges;j++) + if(model_graph->vertex[i].out_degree_edge[j].index < pos) + { + for(k = j + 1;k < model_graph->vertex[i].nb_out_degree_edges;k++) + { + model_graph->vertex[i].out_degree_edge[k - 1].index = model_graph->vertex[i].out_degree_edge[k].index; + model_graph->vertex[i].out_degree_edge[k - 1].u_count = model_graph->vertex[i].out_degree_edge[k].u_count; + } + j--; + model_graph->vertex[i].nb_out_degree_edges--; + } + else + model_graph->vertex[i].out_degree_edge[j].index -= pos; + } + } +} + + diff --git a/parser.src/ParsingDriver.cc b/parser.src/ParsingDriver.cc index ed288f02b..933966489 100644 --- a/parser.src/ParsingDriver.cc +++ b/parser.src/ParsingDriver.cc @@ -110,6 +110,10 @@ ExpObj * ParsingDriver::add_expression_constant(string *constant) { int id = mod_file->num_constants.AddConstant(*constant); + + if(mod_file->model_tree.interprete_.eval) + mod_file->model_tree.interprete_.Stack.push(mod_file->model_tree.interprete_.S_to_Val(constant)); + delete constant; return new ExpObj(id, eNumericalConstant); } @@ -127,6 +131,14 @@ ParsingDriver::add_model_variable(string *name) { check_symbol_existence(*name); NodeID id = model_tree->AddVariable(*name); + + Type type = mod_file->symbol_table.getType(*name); + if ((type == eEndogenous) && (mod_file->model_tree.offset == 2)) + { + int ID = mod_file->symbol_table.getID(*name); + mod_file->model_tree.block_triangular.fill_IM(model_tree->equation_number(), ID, 0); + } + delete name; return id; } @@ -145,6 +157,10 @@ ParsingDriver::add_model_variable(string *name, string *olag) << " has lag " << lag << endl; } NodeID id = model_tree->AddVariable(*name, lag); + + if ((type == eEndogenous) && (mod_file->model_tree.offset == 2)) + mod_file->model_tree.block_triangular.fill_IM(model_tree->equation_number(), mod_file->symbol_table.getID(*name), lag); + delete name; delete olag; return id; @@ -156,6 +172,10 @@ ParsingDriver::add_expression_variable(string *name) check_symbol_existence(*name); int id = mod_file->symbol_table.getID(*name); Type type = mod_file->symbol_table.getType(*name); + + if(mod_file->model_tree.interprete_.eval) + mod_file->model_tree.interprete_.Stack.push(mod_file->model_tree.interprete_.get_value(name,0)); + delete name; return new ExpObj(id, type); } @@ -166,6 +186,26 @@ ParsingDriver::add_expression_token(ExpObj *arg1, ExpObj *arg2, int op) int id = expression.AddToken(arg1->first, arg1->second, arg2->first, arg2->second, op); + + if (mod_file->model_tree.interprete_.eval) + { + mod_file->model_tree.interprete_.u2 = mod_file->model_tree.interprete_.Stack.top(); + mod_file->model_tree.interprete_.Stack.pop(); + mod_file->model_tree.interprete_.u1 = mod_file->model_tree.interprete_.Stack.top(); + mod_file->model_tree.interprete_.Stack.pop(); + if (op == token::PLUS) + mod_file->model_tree.interprete_.u1+=mod_file->model_tree.interprete_.u2; + else if (op == token::MINUS) + mod_file->model_tree.interprete_.u1-=mod_file->model_tree.interprete_.u2; + else if (op == token::DIVIDE) + mod_file->model_tree.interprete_.u1/=mod_file->model_tree.interprete_.u2; + else if (op == token::TIMES) + mod_file->model_tree.interprete_.u1*=mod_file->model_tree.interprete_.u2; + else if (op == token::POWER) + mod_file->model_tree.interprete_.u1=pow(mod_file->model_tree.interprete_.u1,mod_file->model_tree.interprete_.u2); + mod_file->model_tree.interprete_.Stack.push(mod_file->model_tree.interprete_.u1); + } + delete arg1; delete arg2; return new ExpObj(id, eTempResult); @@ -175,6 +215,36 @@ ExpObj * ParsingDriver::add_expression_token(ExpObj *arg1, int op) { int id = expression.AddToken(arg1->first, arg1->second, op); + + if (mod_file->model_tree.interprete_.eval) + { + mod_file->model_tree.interprete_.u2 = mod_file->model_tree.interprete_.Stack.top(); + mod_file->model_tree.interprete_.Stack.pop(); + if (op == token::UMINUS) + mod_file->model_tree.interprete_.u1=-mod_file->model_tree.interprete_.u2; + else if (op == token::EXP) + mod_file->model_tree.interprete_.u1=exp(mod_file->model_tree.interprete_.u2); + else if (op == token::LOG) + mod_file->model_tree.interprete_.u1=log(mod_file->model_tree.interprete_.u2); + else if (op == token::LOG10) + mod_file->model_tree.interprete_.u1=log10(mod_file->model_tree.interprete_.u2); + else if (op == token::SIN) + mod_file->model_tree.interprete_.u1=sin(mod_file->model_tree.interprete_.u2); + else if (op == token::COS) + mod_file->model_tree.interprete_.u1=cos(mod_file->model_tree.interprete_.u2); + else if (op == token::TAN) + mod_file->model_tree.interprete_.u1=tan(mod_file->model_tree.interprete_.u2); + else if (op == token::ASIN) + mod_file->model_tree.interprete_.u1=asin(mod_file->model_tree.interprete_.u2); + else if (op == token::ACOS) + mod_file->model_tree.interprete_.u1=acos(mod_file->model_tree.interprete_.u2); + else if (op == token::ATAN) + mod_file->model_tree.interprete_.u1=atan(mod_file->model_tree.interprete_.u2); + else if (op == token::SQRT) + mod_file->model_tree.interprete_.u1=sqrt(mod_file->model_tree.interprete_.u2); + mod_file->model_tree.interprete_.Stack.push(mod_file->model_tree.interprete_.u1); + } + delete arg1; return new ExpObj(id, eTempResult); } @@ -183,6 +253,15 @@ ExpObj * ParsingDriver::add_expression_token(ExpObj *arg1, string *op_name) { int id = expression.AddToken(arg1->first, arg1->second, *op_name); + + if (mod_file->model_tree.interprete_.eval) + { + mod_file->model_tree.interprete_.u2 = mod_file->model_tree.interprete_.Stack.top(); + mod_file->model_tree.interprete_.Stack.pop(); + mod_file->model_tree.interprete_.Stack.push(mod_file->model_tree.interprete_.get_value(op_name,mod_file->model_tree.interprete_.u2)); + mod_file->model_tree.interprete_.Stack.push(mod_file->model_tree.interprete_.u1); + } + delete arg1; delete op_name; return new ExpObj(id, eTempResult); @@ -196,6 +275,14 @@ ParsingDriver::periods(string *periods) delete periods; } +void +ParsingDriver::cutoff(string *cutoff) +{ + int cutoff_val = atoi(cutoff->c_str()); + mod_file->addStatement(new CutoffStatement(cutoff_val)); + delete cutoff; +} + void ParsingDriver::dsample(string *arg1) { @@ -222,6 +309,11 @@ ParsingDriver::init_param(string *name, ExpObj *rhs) error(*name + " is not a parameter"); mod_file->addStatement(new InitParamStatement(*name, get_expression(rhs), mod_file->symbol_table)); + + mod_file->model_tree.interprete_.u2 = mod_file->model_tree.interprete_.Stack.top(); + mod_file->model_tree.interprete_.Stack.pop(); + mod_file->model_tree.interprete_.put_value(name,mod_file->symbol_table.getID(*name), eParameter, mod_file->model_tree.interprete_.u2); + delete name; delete rhs; } @@ -239,10 +331,25 @@ ParsingDriver::init_val(string *name, ExpObj *rhs) init_values.push_back(make_pair(*name, get_expression(rhs))); + if(mod_file->model_tree.interprete_.eval) + { + mod_file->model_tree.interprete_.u2 = mod_file->model_tree.interprete_.Stack.top(); + mod_file->model_tree.interprete_.Stack.pop(); + mod_file->model_tree.interprete_.put_value(name, mod_file->symbol_table.getID(*name), type, mod_file->model_tree.interprete_.u2); + } + delete name; delete rhs; } +void +ParsingDriver::init_val_filename(string *filename) +{ + options_list.num_options["INITVAL_FILE"] = 1; + options_list.string_options["INITVAL_FILENAME"] = *filename; + delete filename; +} + void ParsingDriver::hist_val(string *name, string *lag, ExpObj *rhs) { @@ -267,6 +374,14 @@ ParsingDriver::hist_val(string *name, string *lag, ExpObj *rhs) delete rhs; } +void +ParsingDriver::initialize_model(void) +{ + //Initialize the incidence matrix + //cout << "mod_file->symbol_table.endo_nbr=" << mod_file->symbol_table.endo_nbr << "\n"; + mod_file->model_tree.block_triangular.init_incidence_matrix(mod_file->symbol_table.endo_nbr); +} + void ParsingDriver::use_dll() { @@ -274,6 +389,13 @@ ParsingDriver::use_dll() mod_file->model_tree.offset = 0; } +void +ParsingDriver::sparse_dll() +{ + // Seetting variable momber offset to use C outputs + mod_file->model_tree.offset = 2; +} + void ParsingDriver::end_initval() { @@ -299,6 +421,8 @@ void ParsingDriver::begin_model() { model_tree = &mod_file->model_tree; + if (mod_file->model_tree.offset == 2) + initialize_model(); } void @@ -529,6 +653,11 @@ ParsingDriver::option_num(const string &name_option, const string &opt) != options_list.num_options.end()) error("option " + name_option + " declared twice"); + if ((name_option == "periods") && (mod_file->model_tree.offset == 2)) + mod_file->model_tree.block_triangular.periods = atoi(opt.c_str()); + else if (name_option == "cutoff") + mod_file->model_tree.interprete_.set_cutoff(atof(opt.c_str())); + options_list.num_options[name_option] = opt; } @@ -587,6 +716,33 @@ void ParsingDriver::stoch_simul() options_list.clear(); } +void ParsingDriver::simulate() +{ + if(mod_file->model_tree.offset==2) + simul_sparse(); + else + simul(); +} + +void +ParsingDriver::simul_sparse() +{ + SimulSparseStatement *st=new SimulSparseStatement(options_list); + st->filename=file; + string tmp=st->filename.substr(st->filename.length()-4); + if(tmp==".mod"||tmp==".dyn") + st->filename.erase(st->filename.length()-4); + st->compiler=mod_file->model_tree.compiler; + mod_file->addStatement(st); + options_list.clear(); +} + +void +ParsingDriver::init_compiler(int compiler_type) +{ + mod_file->model_tree.compiler=compiler_type; +} + void ParsingDriver::simul() { diff --git a/parser.src/SymbolGaussElim.cc b/parser.src/SymbolGaussElim.cc new file mode 100644 index 000000000..699d0f20e --- /dev/null +++ b/parser.src/SymbolGaussElim.cc @@ -0,0 +1,1907 @@ +#include +#include +#include +#include +#include +#include +#include +#include + +#include "ModelTree.hh" +//#include "pctimer_h.hh" +#include "Model_Graph.hh" +#include "SymbolGaussElim.hh" + +using namespace std; +int max_nb_table_y, max_nb_in_degree_edges=0, max_nb_out_degree_edges=0; + +SymbolicGaussElimination::SymbolicGaussElimination() +{ +#ifdef SAVE + file_open = false; +#endif +} + +#ifdef SIMPLIFY +void +SymbolicGaussElimination::list_table_u(int pos) +{ + int i; + t_table_u *table_u; + table_u = First_table_u->pNext; + i = 0; + while(table_u) + { + if((table_u->type > 7) || (table_u->type < 1)) + { + cout << "Error : table_u->type=" << int(table_u->type) << " i=" << i << " pos=" << pos << "\n"; + system("pause"); + exit( -1); + } + i++; + table_u = table_u->pNext; + } +} + +//================================================================================== +void +SymbolicGaussElimination::print_free_u_list() +{ + int i; + cout << "nb_free_u_list : " << nb_free_u_list << " \n"; + cout << "-----------------------------------------------\n"; + for(i = 0;i < nb_free_u_list;i++) + cout << i << " " << free_u_list[i] << "\n"; +} + +//================================================================================== +void +SymbolicGaussElimination::set_free_u_list(int index) +{ +#ifndef UNSORTED + int i = 0, j; + if(nb_free_u_list > 0) + { + while((free_u_list[i] > index) && (i < nb_free_u_list)) + i++; + for(j = nb_free_u_list;j > i;j--) + { + free_u_list[j] = free_u_list[j - 1]; + if(j >= MAX_FREE_U_LIST) + { + cout << "Error to much j=" << j << " Maximum allowed=" << MAX_FREE_U_LIST << "\n"; + system("pause"); + exit( -1); + } + } + } + if(i >= MAX_FREE_U_LIST) + { + cout << "Error to much i=" << i << " Maximum allowed=" << MAX_FREE_U_LIST << "\n"; + system("pause"); + exit( -1); + } + free_u_list[i] = index; + nb_free_u_list++; + if(nb_free_u_list >= MAX_FREE_U_LIST) + { + cout << "Error to much free_u_list=" << nb_free_u_list << " Maximum allowed=" << MAX_FREE_U_LIST << "\n"; + system("pause"); + exit( -1); + } + if(nb_free_u_list > max_nb_free_u_list) + max_nb_free_u_list = nb_free_u_list; +#else + free_u_list[nb_free_u_list++] = index; +#endif +} + +int +SymbolicGaussElimination::get_free_u_list(bool dynamic) +{ + int i; + if((nb_free_u_list > 0) && (simplification_allowed)) + { + i = free_u_list[--nb_free_u_list]; + return (i); + } + else + if(dynamic) + return (u_count++); + else + return (u_count++); +} +#endif /**SIMPLIFY**/ + +//================================================================================== +void +SymbolicGaussElimination::init_glb() +{ + tol = TOL; + vertex_count = 0; + nb_table_u = 0; + nb_prologue_save_table_y = 0; + nb_first_save_table_y = 0; + nb_middle_save_table_y = 0; + nb_last_save_table_y = 0; + nb_prologue_save_table_u = 0; + nb_first_save_table_u = 0; + nb_middle_save_table_u = 0; + nb_last_save_table_u = 0; + middle_count_loop = 0; + u_count = 0; + y_kmin = y_kmax = 0; + prologue_save_table_u = NULL; + first_save_table_u = NULL; + first_save_i_table_u = NULL; + middle_save_table_u = NULL; + middle_save_i_table_u = NULL; + last_save_table_u = NULL; + prologue_save_table_y = NULL; + first_save_table_y = NULL; + first_save_i_table_y = NULL; + middle_save_table_y = NULL; + middle_save_i_table_y = NULL; + last_save_table_y = NULL; + pos_nb_first_save_table_u = 0; +#ifdef SIMPLIFY + nb_free_u_list = 0; + max_nb_free_u_list1 = 0; + max_nb_free_u_list = 0; +#endif + save_direct=true; +} + + +void +SymbolicGaussElimination::write_to_file_table_y( t_table_y *save_table_y, t_table_y *save_i_table_y, int nb_save_table_y, int nb_save_i_table_y) +{ + int i, k; +#ifdef PRINT_OUT + cout << "nb_save_table_y=" << nb_save_table_y << "\n"; +#endif + SaveCode.write(reinterpret_cast (&nb_save_table_y), sizeof(nb_save_table_y)); + for(i = 0;i < nb_save_table_y;i++) + { + SaveCode.write(reinterpret_cast(&save_table_y[i].index), sizeof(save_table_y[i].index)); +#ifdef PRINT_OUT + cout << "+y[" << save_table_y[i].index << "]="; +#endif + SaveCode.write(reinterpret_cast(&save_table_y[i].nb), sizeof(save_table_y[i].nb)); + for(k = 0;k < save_table_y[i].nb;k++) + { + SaveCode.write(reinterpret_cast(&save_table_y[i].u_index[k]), sizeof(save_table_y[i].u_index[k])); + SaveCode.write(reinterpret_cast(&save_table_y[i].y_index[k]), sizeof(save_table_y[i].y_index[k])); +#ifdef PRINT_OUT + cout << "u[" << save_table_y[i].u_index[k] << "]*y[" << save_table_y[i].y_index[k] << "]"; + if(k + 1 < save_table_y[i].nb) + cout << "+"; + else + cout << "\n"; +#endif + } + } + for(i = 0;i < nb_save_i_table_y;i++) + { + SaveCode.write(reinterpret_cast(&save_i_table_y[i].index), sizeof(save_i_table_y[i].index)); +#ifdef PRINT_OUT + cout << "+i y[" << save_i_table_y[i].index << "]="; +#endif + SaveCode.write(reinterpret_cast(&save_i_table_y[i].nb), sizeof(save_i_table_y[i].nb)); + for(k = 0;k < save_i_table_y[i].nb;k++) + { + SaveCode.write(reinterpret_cast(&save_i_table_y[i].u_index[k]), sizeof(save_i_table_y[i].u_index[k])); + SaveCode.write(reinterpret_cast(&save_i_table_y[i].y_index[k]), sizeof(save_i_table_y[i].y_index[k])); +#ifdef PRINT_OUT + cout << "u[" << save_i_table_y[i].u_index[k] << "]*y[" << save_i_table_y[i].y_index[k] << "]"; + if(k + 1 < save_i_table_y[i].nb) + cout << "+"; + else + cout << "\n"; +#endif + } + } +} + +void +SymbolicGaussElimination::write_to_file_table_u(t_table_u *save_table_u, t_table_u *save_i_table_u, int nb_save_table_u) +{ + t_table_u *table_u; + SaveCode.write(reinterpret_cast(&nb_save_table_u), sizeof(nb_save_table_u)); +#ifdef PRINT_OUT + cout << "**nb_save_table_u=" << nb_save_table_u << "\n"; +#endif +#ifdef PRINT_OUT + cout << "**save_table_u=" << save_table_u << "\n"; +#endif + while(save_table_u) + { +#ifdef PRINT_OUT + cout << "**save_table_u->type=" << int(save_table_u->type) << "\n"; +#endif + switch (save_table_u->type) + { + case 3: + case 7: + SaveCode.write(reinterpret_cast(&save_table_u->type), sizeof(save_table_u->type)); + SaveCode.write(reinterpret_cast(&save_table_u->index), sizeof(save_table_u->index)); + SaveCode.write(reinterpret_cast(&save_table_u->op1), sizeof(save_table_u->op1)); +#ifdef PRINT_OUT + if(save_table_u->type == 3) + cout << "+u[" << save_table_u->index << "]=1/(1-u[" << save_table_u->op1 << "])\n"; + else + cout << "+u[" << save_table_u->index << "]*=u[" << save_table_u->op1 << "]\n"; +#endif /**PRINT_OUT**/ + break; + case 1: + case 2: + case 6: + SaveCode.write(reinterpret_cast(&save_table_u->type), sizeof(save_table_u->type)); + SaveCode.write(reinterpret_cast(&save_table_u->index), sizeof(save_table_u->index)); + SaveCode.write(reinterpret_cast(&save_table_u->op1), sizeof(save_table_u->op1)); + SaveCode.write(reinterpret_cast(&save_table_u->op2), sizeof(save_table_u->op2)); +#ifdef PRINT_OUT + if(save_table_u->type == 1) + cout << "+u[" << save_table_u->index << "]=" << "u[" << save_table_u->op1 << "]*u[" << save_table_u->op2 << "]\n"; + else if(save_table_u->type == 2) + cout << "+u[" << save_table_u->index << "]+=u[" << save_table_u->op1 << "]*u[" << save_table_u->op2 << "]\n"; + else + cout << "+u[" << save_table_u->index << "]=1/(1-u[" << save_table_u->op1 << "]*u[" << save_table_u->op2 << "])\n"; +#endif /**PRINT_OUT**/ + break; + case 5: + SaveCode.write(reinterpret_cast(&save_table_u->type), sizeof(save_table_u->type)); + SaveCode.write(reinterpret_cast(&save_table_u->index), sizeof(save_table_u->index)); +#ifdef PRINT_OUT + cout << "+push(u[" << save_table_u->index << "])\n"; +#endif /**PRINT_OUT**/ + break; + } + table_u = save_table_u->pNext; + free(save_table_u); + save_table_u = table_u; + } +#ifdef PRINT_OUT + cout << "save_i_table_u=" << save_i_table_u << "\n"; +#endif + while(save_i_table_u) + { + switch (save_i_table_u->type) + { + case 3: + case 7: + SaveCode.write(reinterpret_cast(&save_i_table_u->type), sizeof(save_i_table_u->type)); + SaveCode.write(reinterpret_cast(&save_i_table_u->index), sizeof(save_i_table_u->index)); + SaveCode.write(reinterpret_cast(&save_i_table_u->op1), sizeof(save_i_table_u->op1)); + break; + case 1: + case 2: + case 6: + SaveCode.write(reinterpret_cast(&save_i_table_u->type), sizeof(save_i_table_u->type)); + SaveCode.write(reinterpret_cast(&save_i_table_u->index), sizeof(save_i_table_u->index)); + SaveCode.write(reinterpret_cast(&save_i_table_u->op1), sizeof(save_i_table_u->op1)); + SaveCode.write(reinterpret_cast(&save_i_table_u->op2), sizeof(save_i_table_u->op2)); + break; + case 5: + SaveCode.write(reinterpret_cast(&save_i_table_u->type), sizeof(save_i_table_u->type)); + SaveCode.write(reinterpret_cast(&save_i_table_u->index), sizeof(save_i_table_u->index)); + break; + } + table_u = save_i_table_u->pNext; + free(save_i_table_u); + save_i_table_u = table_u; + } +#ifdef PRINT_OUT + cout << "nb_save_table_u=" << nb_save_table_u << "\n"; +#endif +} + +void +SymbolicGaussElimination::write_to_file_table_u_b(t_table_u *save_table_u, t_table_u *last_table_u, int *nb_save_table_u) +{ + t_table_u *table_u; + while(save_table_u!=last_table_u) + { +#ifdef PRINT_OUT + cout << "**save_table_u->type=" << int(save_table_u->type) << "\n"; +#endif + switch (save_table_u->type) + { + case 3: + case 7: + (*nb_save_table_u)++; + //SaveCode << save_table_u->type << save_table_u->index << save_table_u->op1; + SaveCode.write(reinterpret_cast(&save_table_u->type), sizeof(save_table_u->type)); + SaveCode.write(reinterpret_cast(&save_table_u->index), sizeof(save_table_u->index)); + SaveCode.write(reinterpret_cast(&save_table_u->op1), sizeof(save_table_u->op1)); +#ifdef PRINT_OUT + if(save_table_u->type == 3) + cout << "+u[" << save_table_u->index << "]=1/(1-u[" << save_table_u->op1 << "])\n"; + else + cout << "+u[" << save_table_u->index << "]*=u[" << save_table_u->op1 << "]\n"; +#endif /**PRINT_OUT**/ + break; + case 1: + case 2: + case 6: + (*nb_save_table_u)++; + //SaveCode << save_table_u->type << save_table_u->index << save_table_u->op1 << save_table_u->op2; + SaveCode.write(reinterpret_cast(&save_table_u->type), sizeof(save_table_u->type)); + SaveCode.write(reinterpret_cast(&save_table_u->index), sizeof(save_table_u->index)); + SaveCode.write(reinterpret_cast(&save_table_u->op1), sizeof(save_table_u->op1)); + SaveCode.write(reinterpret_cast(&save_table_u->op2), sizeof(save_table_u->op2)); +#ifdef PRINT_OUT + if(save_table_u->type == 1) + cout << "+u[" << save_table_u->index << "]=" << "u[" << save_table_u->op1 << "]*u[" << save_table_u->op2 << "]\n"; + else if(save_table_u->type == 2) + cout << "+u[" << save_table_u->index << "]+=u[" << save_table_u->op1 << "]*u[" << save_table_u->op2 << "]\n"; + else + cout << "+u[" << save_table_u->index << "]=1/(1-u[" << save_table_u->op1 << "]*u[" << save_table_u->op2 << "])\n"; +#endif /**PRINT_OUT**/ + break; + case 5: + (*nb_save_table_u)++; + //SaveCode << save_table_u->type << save_table_u->index; + SaveCode.write(reinterpret_cast(&save_table_u->type), sizeof(save_table_u->type)); + SaveCode.write(reinterpret_cast(&save_table_u->index), sizeof(save_table_u->index)); +#ifdef PRINT_OUT + cout << "+push(u[" << save_table_u->index << "])\n"; +#endif /**PRINT_OUT**/ + break; + } + table_u = save_table_u->pNext; + free(save_table_u); + save_table_u = table_u; + } +} + + +void +store_code(t_table_u **save_table_u, t_table_u *First_table_u, t_table_u *stop_table_u, t_table_y *table_y, t_table_y **s_table_y, int *nb_save_table_u, int *nb_save_table_y, int vertex_count) +{ + int i, k; + t_table_u *s_table_u, *table_u; + table_u = First_table_u->pNext; + s_table_u = (t_table_u*)malloc(sizeof(t_table_u) - 3 * sizeof(int)); + (*save_table_u) = s_table_u; + (*nb_save_table_u) = 0; + while(table_u != stop_table_u) + { + if((table_u->type > 7) || (table_u->type < 1)) + { + cout << "Error : table_u->type=" << int(table_u->type) << " *nb_save_table_u=" << *nb_save_table_u << "\n"; + exit( -1); + } + else + { + (*nb_save_table_u)++; +#ifdef PRINT_OUT + cout << "--table_u->type=" << int(table_u->type) << "\n"; +#endif + switch (table_u->type) + { + case 3: + case 7: + s_table_u->pNext = (t_table_u*)malloc(sizeof(t_table_u) - sizeof(int)); + s_table_u = s_table_u->pNext; + s_table_u->type = table_u->type; + s_table_u->index = table_u->index; + s_table_u->op1 = table_u->op1; +#ifdef PRINT_OUT + if(s_table_u->type == 3) + cout << "st u[" << s_table_u->index << "]=-1/u[" << s_table_u->op1 << "]\n"; + else + cout << "st u[" << s_table_u->index << "]*=u[" << s_table_u->op1 << "]\n"; +#endif + break; + case 1: + case 2: + case 6: + s_table_u->pNext = (t_table_u*)malloc(sizeof(t_table_u) ); + s_table_u = s_table_u->pNext; + s_table_u->type = table_u->type; + s_table_u->index = table_u->index; + s_table_u->op1 = table_u->op1; + s_table_u->op2 = table_u->op2; +#ifdef PRINT_OUT + if(s_table_u->type == 1) + cout << "st u[" << s_table_u->index << "]=" << "u[" << s_table_u->op1 << "]*u[" << s_table_u->op2 << "]\n"; + else if(s_table_u->type == 2) + cout << "st u[" << s_table_u->index << "]+=u[" << s_table_u->op1 << "]*u[" << s_table_u->op2 << "]\n"; + else + cout << "st u[" << s_table_u->index << "]=1/(1-u[" << s_table_u->op1 << "]*u[" << s_table_u->op2 << "])\n"; +#endif /**PRINT_OUT**/ + break; + case 5: + s_table_u->pNext = (t_table_u*)malloc(sizeof(t_table_u) - 2 * sizeof(int)); + s_table_u = s_table_u->pNext; + s_table_u->type = table_u->type; + s_table_u->index = table_u->index; +#ifdef PRINT_OUT + cout << "st push(u[" << s_table_u->index << "])\n"; +#endif /**PRINT_OUT**/ + break; + } + } + table_u = table_u->pNext; + } + s_table_u->pNext = NULL; +#ifdef PRINT_OUT + cout << "*nb_save_table_u=" << *nb_save_table_u << "\n"; + cout << "vertex_count=" << vertex_count << " nb_save_table_y=" << nb_save_table_y << "\n"; +#endif + (*s_table_y) = (t_table_y*)malloc((vertex_count - *nb_save_table_y) * sizeof(t_table_y)); + for(i = 0;i < vertex_count - *nb_save_table_y;i++) + { + (*s_table_y)[i].u_index = (int*)malloc(table_y[i + *nb_save_table_y].nb * sizeof(int)); + (*s_table_y)[i].y_index = (int*)malloc(table_y[i + *nb_save_table_y].nb * sizeof(int)); + /*(*s_table_y)[i].y_lead_lag = (int*)malloc(table_y[i + *nb_save_table_y].nb * sizeof(int));*/ + (*s_table_y)[i].index = table_y[i + *nb_save_table_y].index; + (*s_table_y)[i].nb = table_y[i + *nb_save_table_y].nb; + for(k = 0;k < table_y[i + *nb_save_table_y].nb;k++) + { + (*s_table_y)[i].u_index[k] = table_y[i + *nb_save_table_y].u_index[k]; + (*s_table_y)[i].y_index[k] = table_y[i + *nb_save_table_y].y_index[k]; + } + } + *nb_save_table_y = vertex_count - *nb_save_table_y; +} + + + +bool +SymbolicGaussElimination::Check_Regularity(t_table_u *first_u_blck, t_table_u *second_u_blck, t_table_u *third_u_blck) +{ + t_table_u *c_first_table_u, *c_second_table_u, *c_third_table_u; + bool OK, Regular; + int i=0; + c_first_table_u = first_u_blck->pNext; + c_second_table_u = second_u_blck->pNext; + c_third_table_u = third_u_blck->pNext; + OK = true; + Regular = true; + while(OK) + { + i++; +#ifdef PRINT_OUT + cout << "c_first_table_u=" << c_first_table_u << " c_second_table_u=" << c_second_table_u << " c_third_table_u=" << c_third_table_u << "\n"; +#endif /**PRINT_OUT**/ + if((c_first_table_u->type != c_second_table_u->type) || + (c_second_table_u->index + (c_second_table_u->index - c_first_table_u->index) != c_third_table_u->index)) + { + Regular = false; +#ifdef PRINT_OUT + cout << "c_first_table_u->type=" << (int)c_first_table_u->type << "?=c_second_table_u->type=" << (int)c_second_table_u->type << "\n"; + cout << "c_second_table_u->index+(c_second_table_u->index-c_first_table_u->index)=" << c_second_table_u->index + (c_second_table_u->index - c_first_table_u->index) + << "?=c_third_table_u->index=" << c_third_table_u->index << "\n"; +#endif + break; + } + if(c_first_table_u->type != 5) + { + if(c_second_table_u->op1 + (c_second_table_u->op1 - c_first_table_u->op1) != c_third_table_u->op1) + { +#ifdef PRINT_OUT + cout << "c_second_table_u->op1+(c_second_table_u->op1-c_first_table_u->op1)=" << c_second_table_u->op1 + (c_second_table_u->op1 - c_first_table_u->op1) + << "?=c_third_table_u->op1=" << c_third_table_u->op1 << "\n"; +#endif + Regular = false; + break; + } + if((c_first_table_u->type != 3) && (c_first_table_u->type != 7)) + { + if(c_second_table_u->op2 + (c_second_table_u->op2 - c_first_table_u->op2) != c_third_table_u->op2) + { +#ifdef PRINT_OUT + cout << "c_second_table_u->op2+(c_second_table_u->op2-c_first_table_u->op2)=" << c_second_table_u->op2 + (c_second_table_u->op2 - c_first_table_u->op2) + << "?=c_third_table_u->op2=" << c_third_table_u->op2 << "\n"; +#endif + Regular = false; + break; + } + } + } + if(c_first_table_u->pNext != second_u_blck->pNext) + { + c_second_table_u = c_second_table_u->pNext; + c_first_table_u = c_first_table_u->pNext; + c_third_table_u = c_third_table_u->pNext; + } + else + OK = 0; + } +#ifdef PRINT_OUT + cout << "Regular=" << Regular << " OK=" << OK << " i=" << i << "\n"; + cout << "Check_Regularity Regular=" << Regular << "\n"; +#endif + return (Regular); +} + + +//================================================================================== +t_table_u* +SymbolicGaussElimination::interpolation(t_model_graph* model_graph, t_table_y* table_y, int to_add, bool middle, int per) +{ + t_table_u *tmp_table_u, *old_table_u; + t_table_u *c_first_table_u, *c_second_table_u, *c_third_table_u; + int c_first_y_blck, c_second_y_blck; + int i, j, k, up_to, op_count, k1, k2; + bool OK, modify_u_count; + int cur_pos, nb_table_u=0; +#ifdef PRINT_OUT + cout << "in interpolation\n"; + cout << "--- u_count=" << u_count << "\n"; + print_Graph(model_graph); +#endif /**PRINT_OUT**/ + cur_pos=SaveCode.tellp(); + SaveCode.write(reinterpret_cast(&up_to), sizeof(up_to)); + if(middle) + { + up_to = 2; + middle_count_loop = 1 + per; + //middle_count_loop = 4; + } + else + up_to = 2; +#ifdef SAVE + if(middle) + { + middle_save_table_u = NULL; +#ifdef PRINT_OUT + cout << "up_to=" << up_to << " middle_count_loop=" << middle_count_loop << "\n"; +#endif + } +#endif /**SAVE**/ + /*Adding the Gaussian Elimination coefficients for the uncomputed periods*/ + /*table_u = tmp_table_u = (t_table_u*)malloc(sizeof(t_table_u) - 3 * sizeof(int));*/ + c_third_table_u = third_u_blck; + c_first_y_blck = first_y_blck; + c_second_y_blck = second_y_blck; + modify_u_count = true; + for(i = 1;i < up_to;i++) + { + c_first_table_u = first_u_blck->pNext; + c_second_table_u = second_u_blck->pNext; +#ifdef PRINT_OUT + cout << "c_first_table_u=" << c_first_table_u << " c_second_table_u=" << c_second_table_u << "\n"; +#endif + old_table_u = tmp_table_u; + op_count = 0; + OK = true; + while(OK) + { + if(c_first_table_u->type != c_second_table_u->type) + { + cout << "Error : Interpolation the two lists are not synchronized (middle=" << middle << ", op_count=" << op_count << ")\n"; + cout << "c_first_table_u=" << c_first_table_u << " c_second_table_u=" << c_second_table_u << "\n"; + cout << "y_kmin=" << y_kmin << " y_kmax=" << y_kmax << "\n"; + cout << "first_u_blck=" << first_u_blck << " second_u_blck=" << second_u_blck << "\n"; + cout << "c_first_table_u->type=" << int(c_first_table_u->type) << " c_second_table_u->type=" << int(c_second_table_u->type) << "\n"; + system("pause"); + exit( -1); + } + switch (c_first_table_u->type) + { + case 3: + case 7: + nb_table_u++; +#ifdef SAVE + if(i == 1) + { + if(middle) + { + nb_middle_save_table_u++; + } + else + { +#ifdef PRINT_OUT + cout << "!!!!!nb_first_save_table_u=" << nb_first_save_table_u << "\n"; +#endif + nb_first_save_table_u++; + } + SaveCode.write(reinterpret_cast(&c_first_table_u->type), sizeof(c_first_table_u->type)); + SaveCode.write(reinterpret_cast(&c_first_table_u->index), sizeof(c_first_table_u->index)); + SaveCode.write(reinterpret_cast(&c_first_table_u->op1), sizeof(c_first_table_u->op1)); +#ifdef PRINT_OUT + if(c_first_table_u->type == 3) + cout << ">u[" << c_first_table_u->index << "]=1/(1-u[" << c_first_table_u->op1 << "])\n"; //"]) (" << tmp_table_u << ", " << tmp_table_u->pNext << ")\n"; + else + cout << ">u[" << c_first_table_u->index << "]*=u[" << c_first_table_u->op1 << "]\n"; //"] (" << tmp_table_u << ", " << tmp_table_u->pNext << ")\n"; +#endif + k=c_second_table_u->index - c_first_table_u->index; + SaveCode.write(reinterpret_cast(&k), sizeof(k)); + k1=c_second_table_u->op1- c_first_table_u->op1; + SaveCode.write(reinterpret_cast(&k1), sizeof(k1)); +#ifdef PRINT_OUT + if(c_first_table_u->type == 3) + cout << ">i u[" << k << "]=1/(1-u[" << k1 << "])\n"; //"]) (" << tmp_table_u << ", " << tmp_table_u->pNext << ")\n"; + else + cout << ">i u[" << k << "]*=u[" << k1 << "]\n"; //"] (" << tmp_table_u << ", " << tmp_table_u->pNext << ")\n"; +#endif + } +#endif /**SAVE**/ + break; + case 1: + case 2: + case 6: + nb_table_u++; +#ifdef SAVE + if((i == 1) && (middle)) + { + nb_middle_save_table_u++; + SaveCode.write(reinterpret_cast(&c_first_table_u->type), sizeof(c_first_table_u->type)); + SaveCode.write(reinterpret_cast(&c_first_table_u->index), sizeof(c_first_table_u->index)); + SaveCode.write(reinterpret_cast(&c_first_table_u->op1), sizeof(c_first_table_u->op1)); + SaveCode.write(reinterpret_cast(&c_first_table_u->op2), sizeof(c_first_table_u->op2)); +#ifdef PRINT_OUT + if((c_first_table_u->type == 1) && (middle)) + cout << ">u[" << c_first_table_u->index << "]=u[" << c_first_table_u->op1 << "]*u[" << c_first_table_u->op2 << "]\n"; //"] (" << tmp_table_u << ", " << tmp_table_u->pNext << ")\n"; + else if(c_first_table_u->type == 2) + cout << ">u[" << c_first_table_u->index << "]+=u[" << c_first_table_u->op1 << "]*u[" << c_first_table_u->op2 << "]\n"; //"] (" << tmp_table_u << ", " << tmp_table_u->pNext << ")\n"; + else + cout << ">u[" << c_first_table_u->index << "]=1/(1-u[" << c_first_table_u->op1 << "]*u[" << c_first_table_u->op2 << "])\n"; //"]) (" << tmp_table_u << ", " << tmp_table_u->pNext << ")\n"; +#endif //PRINT_OUT + + k=c_second_table_u->index - c_first_table_u->index; + SaveCode.write(reinterpret_cast(&k), sizeof(c_first_table_u->index)); + k1=c_second_table_u->op1- c_first_table_u->op1; + SaveCode.write(reinterpret_cast(&k1), sizeof(c_first_table_u->op1)); + k2=c_second_table_u->op2- c_first_table_u->op2; + SaveCode.write(reinterpret_cast(&k2), sizeof(c_first_table_u->op2)); +#ifdef PRINT_OUT + if((c_first_table_u->type == 1) && (middle)) + cout << ">u[" << k << "]=u[" << k1 << "]*u[" << k2 << "]\n"; //"] (" << tmp_table_u << ", " << tmp_table_u->pNext << ")\n"; + else if(c_first_table_u->type == 2) + cout << ">u[" << k << "]+=u[" << k1 << "]*u[" << k2 << "]\n"; //"] (" << tmp_table_u << ", " << tmp_table_u->pNext << ")\n"; + else + cout << ">u[" << k << "]=1/(1-u[" << k1 << "]*u[" << k2 << "])\n"; //"]) (" << tmp_table_u << ", " << tmp_table_u->pNext << ")\n"; +#endif //PRINT_OUT + } +#endif /**SAVE**/ + break; + case 5: + nb_table_u++; +#ifdef SAVE + if((i == 1) && (middle)) + { + nb_middle_save_table_u++; + SaveCode.write(reinterpret_cast(&c_first_table_u->type), sizeof(c_first_table_u->type)); + SaveCode.write(reinterpret_cast(&c_first_table_u->index), sizeof(c_first_table_u->index)); +#ifdef PRINT_OUT + cout << ">push(u[" << c_first_table_u->index << "])\n"; // "]) (" << tmp_table_u << ", " << tmp_table_u->pNext << ")\n"; +#endif //PRINT_OUT + k=c_second_table_u->index - c_first_table_u->index; + SaveCode.write(reinterpret_cast(&k), sizeof(c_first_table_u->index)); +#ifdef PRINT_OUT + cout << ">push(u[" << k << "])\n"; // "]) (" << tmp_table_u << ", " << tmp_table_u->pNext << ")\n"; +#endif //PRINT_OUT + + } +#endif /**SAVE**/ + break; + } + if((c_first_table_u->pNext != second_u_blck->pNext) && (c_first_table_u->pNext != NULL) && (c_second_table_u->pNext != NULL)) + { + tmp_table_u=c_first_table_u ; + c_first_table_u = c_first_table_u->pNext; + free(tmp_table_u); + tmp_table_u=c_second_table_u ; + c_second_table_u = c_second_table_u->pNext; + free(tmp_table_u); + } + else + { + if(c_first_table_u->pNext != second_u_blck->pNext) /*||(second_u_blck->pNext!=NULL))*/ + { + cout << "c_first_table_u->pNext=" << c_first_table_u->pNext << " second_u_blck->pNext=" << second_u_blck->pNext << "\n"; + cout << "Error not synchronize graph interpolation\n"; + exit( -1); + } + OK = 0; + } + op_count++; + } + k=SaveCode.tellp(); + SaveCode.seekp(cur_pos); + SaveCode.write(reinterpret_cast(&nb_table_u), sizeof(nb_table_u)); + SaveCode.seekp(k); + if(middle) + { + first_y_blck = c_first_y_blck; + second_y_blck = c_second_y_blck; +#ifdef SAVE + if((i == 1) && (middle)) + { + middle_save_table_y = (t_table_y*)malloc((nb_endo) * sizeof(t_table_y)); + middle_save_i_table_y = (t_table_y*)malloc((nb_endo) * sizeof(t_table_y)); + nb_middle_save_table_y = nb_endo; + } +#endif /**SAVE**/ + for(j = 0;j < nb_endo;j++) + { +#ifdef SAVE + if(i == 1) + { + if(middle) + { + middle_save_i_table_y[j].u_index = (int*)malloc(table_y[first_y_blck].nb * sizeof(int)); + middle_save_i_table_y[j].y_index = (int*)malloc(table_y[first_y_blck].nb * sizeof(int)); + middle_save_i_table_y[j].index = table_y[second_y_blck].index - table_y[first_y_blck].index; + middle_save_i_table_y[j].nb = table_y[first_y_blck].nb; + for(k = 0;k < table_y[first_y_blck].nb;k++) + { + middle_save_i_table_y[j].u_index[k] = table_y[second_y_blck].u_index[k] - table_y[first_y_blck].u_index[k]; + middle_save_i_table_y[j].y_index[k] = table_y[second_y_blck].y_index[k] - table_y[first_y_blck].y_index[k]; + } + middle_save_table_y[j].u_index = (int*)malloc(table_y[first_y_blck].nb * sizeof(int)); + middle_save_table_y[j].y_index = (int*)malloc(table_y[first_y_blck].nb * sizeof(int)); + /*middle_save_table_y[j].y_lead_lag = (int*)malloc(table_y[first_y_blck].nb * sizeof(int));*/ + middle_save_table_y[j].index = table_y[first_y_blck].index; + middle_save_table_y[j].nb = table_y[first_y_blck].nb; + for(k = 0;k < table_y[first_y_blck].nb;k++) + { + middle_save_table_y[j].u_index[k] = table_y[first_y_blck].u_index[k]; + middle_save_table_y[j].y_index[k] = table_y[first_y_blck].y_index[k]; + } + } + else + { + first_save_i_table_y[j].u_index = (int*)malloc(table_y[first_y_blck].nb * sizeof(int)); + first_save_i_table_y[j].y_index = (int*)malloc(table_y[first_y_blck].nb * sizeof(int)); + first_save_i_table_y[j].index = table_y[second_y_blck].index - table_y[first_y_blck].index; + first_save_i_table_y[j].nb = table_y[first_y_blck].nb; + for(k = 0;k < table_y[first_y_blck].nb;k++) + { + first_save_i_table_y[j].u_index[k] = table_y[second_y_blck].u_index[k] - table_y[first_y_blck].u_index[k]; + first_save_i_table_y[j].y_index[k] = table_y[second_y_blck].y_index[k] - table_y[first_y_blck].y_index[k]; + } + first_save_table_y[j].u_index = (int*)malloc(table_y[first_y_blck].nb * sizeof(int)); + first_save_table_y[j].y_index = (int*)malloc(table_y[first_y_blck].nb * sizeof(int)); + first_save_table_y[j].index = table_y[first_y_blck].index; + first_save_table_y[j].nb = table_y[first_y_blck].nb; + for(k = 0;k < table_y[first_y_blck].nb;k++) + { + first_save_table_y[j].u_index[k] = table_y[first_y_blck].u_index[k]; + first_save_table_y[j].y_index[k] = table_y[first_y_blck].y_index[k]; + } + } + } +#endif /**SAVE**/ + table_y[vertex_count].nb = table_y[first_y_blck].nb; + table_y[vertex_count].index = table_y[first_y_blck].index + (i - 1) * (table_y[second_y_blck].index - table_y[first_y_blck].index); +#ifdef PRINT_OUT + cout << ">y[" << table_y[vertex_count].index << "]="; +#endif /**PRINT_OUT**/ + for(k = 0;k < table_y[vertex_count].nb;k++) + { + table_y[vertex_count].u_index[k] = table_y[first_y_blck].u_index[k] + (i - 1) * (table_y[second_y_blck].u_index[k] - table_y[first_y_blck].u_index[k]); + table_y[vertex_count].y_index[k] = table_y[first_y_blck].y_index[k] + (i - 1) * (table_y[second_y_blck].y_index[k] - table_y[first_y_blck].y_index[k]); +#ifdef PRINT_OUT + cout << "u[" << table_y[vertex_count].u_index[k] << "]*y[" << table_y[vertex_count].y_index[k] << "]"; + if(k + 1 == table_y[vertex_count].nb) + cout << "\n"; + else + cout << "+"; +#endif /**PRINT_OUT**/ + } + vertex_count++; + first_y_blck++; + second_y_blck++; + } + } + } +#ifdef PRINT_OUT + cout << "+++ u_count=" << u_count << "\n"; + cout << "out interpolation\n"; +#endif + + return (old_table_u); +} + + +//================================================================================== +bool +SymbolicGaussElimination::Loop_Elimination(t_model_graph* model_graph) +{ + int i, j, pos, i1, i_per; + bool there_is_a_loop, go_on = true; + /* destroy the loop*/ + int per = 0; + there_is_a_loop = 0; + i_per = 0; + for(i = 0;i < model_graph->nb_vertices;i++) + { + if(nstacked) + { + if(model_graph->vertex[i].nb_in_degree_edges > 0) + { + if(!(i_per % nb_endo)) + { + per++; + if(per == 1) + { + first_u_blck = table_u; +#ifdef PRINT_OUT + cout << "first_u_blck=" << first_u_blck << "\n"; +#endif + } + if(per == 2) + { + pos_nb_first_save_table_u = nb_table_u; + second_u_blck = table_u; +#ifdef PRINT_OUT + cout << "second_u_blck=" << second_u_blck << "\n"; +#endif + } + if(per == 3) + { + go_on = false; + third_u_blck = table_u; +#ifdef PRINT_OUT + cout << "third_u_blck\n"; +#endif + } + } + i_per++; + } + } + pos = -1; + for(j = 0;((j < model_graph->vertex[i].nb_in_degree_edges) && (pos < 0));j++) + if(model_graph->vertex[i].in_degree_edge[j].index == i) + { + // at least one loop + pos = j; + } + if(pos >= 0) + { + there_is_a_loop = 1; +#ifdef DEBUGR + cout << "--------------------------------------------------------------- \n"; + cout << "Loop elimination on vertex " << model_graph->vertex[i].index << "\n"; +#endif /**DEBUGR**/ + if(nstacked) + { + /*Store the u_count associated to the loop to re-use it in case of + loop creation during vertex supression step*/ + loop_table_u_count[i] = model_graph->vertex[i].in_degree_edge[pos].u_count; + loop_table_vertex_index[i] = model_graph->vertex[i].index; + } + if(go_on) + { + nb_table_u++; + table_u->pNext = (t_table_u*)malloc(sizeof(t_table_u) - sizeof(int)); + table_u = table_u->pNext; + table_u->pNext = NULL; + table_u->type = 3; + table_u->index = model_graph->vertex[i].in_degree_edge[pos].u_count; + table_u->op1 = model_graph->vertex[i].in_degree_edge[pos].u_count; +#ifdef PRINT_OUT + cout << "u[" << table_u->op1 << "]=1/(-u[" << table_u->op1 << "]) " << table_u << "\n"; // "]) (nb_free_u_list : " << nb_free_u_list << " u_count=" << u_count << ")\n"; +#endif /**PRINT_OUT**/ + for(j = 0;j < model_graph->vertex[i].nb_in_degree_edges;j++) + { + if(j != pos) + { + i1 = model_graph->vertex[i].in_degree_edge[j].index; +#ifdef DIRECT_COMPUTE + nb_table_u++; + table_u->pNext = (t_table_u*)malloc(sizeof(t_table_u) - sizeof(int)); + table_u = table_u->pNext; + table_u->pNext = NULL; + table_u->type = 7; + table_u->index = model_graph->vertex[i].in_degree_edge[j].u_count; + table_u->op1 = model_graph->vertex[i].in_degree_edge[pos].u_count; +#ifdef PRINT_OUT + cout << "u[" << model_graph->vertex[i].in_degree_edge[j].u_count << "]*=u[" << table_u->op1 << "] " << table_u << "\n"; // "] (nb_free_u_list : " << nb_free_u_list << " u_count=" << u_count << ")\n"; +#endif /**PRINT_OUT**/ +#endif /**DIRECT_COMPUTE**/ + } + } + } + /*elimination of the loop*/ + /*in the out_degree*/ + pos = -1; + for(j = 0;((j < model_graph->vertex[i].nb_out_degree_edges) && (pos < 0));j++) + if(model_graph->vertex[i].out_degree_edge[j].index == i) + pos = j; + if(pos < 0) + { + cout << "Error: not symetric on a loop on vertex " << model_graph->vertex[i].index << "\n"; + print_Graph(model_graph); + system("pause"); + exit( -1); + } + for(j = pos + 1;j < model_graph->vertex[i].nb_out_degree_edges;j++) + { + model_graph->vertex[i].out_degree_edge[j - 1].index = model_graph->vertex[i].out_degree_edge[j].index; + model_graph->vertex[i].out_degree_edge[j - 1].u_count = model_graph->vertex[i].out_degree_edge[j].u_count; + } + model_graph->vertex[i].nb_out_degree_edges--; + /*in the in_degree*/ + pos = -1; + for(j = 0;((j < model_graph->vertex[i].nb_in_degree_edges) && (pos < 0));j++) + if(model_graph->vertex[i].in_degree_edge[j].index == i) + pos = j; + if(pos < 0) + { + cout << "Error: not symetric on a loop on vertex " << model_graph->vertex[i].index << "\n"; + print_Graph(model_graph); + system("pause"); + exit( -1); + } + for(j = pos + 1;j < model_graph->vertex[i].nb_in_degree_edges;j++) + { + model_graph->vertex[i].in_degree_edge[j - 1].index = model_graph->vertex[i].in_degree_edge[j].index; + model_graph->vertex[i].in_degree_edge[j - 1].u_count = model_graph->vertex[i].in_degree_edge[j].u_count; + } + model_graph->vertex[i].nb_in_degree_edges--; + } + } + return (there_is_a_loop); +} + +//================================================================================== +bool +SymbolicGaussElimination::Vertex_Elimination(t_model_graph* model_graph, int pos, bool* interpolate, int length_markowitz, bool dynamic) +{ + int i, j, k, min_edge, vertex_to_eliminate = -1, to_add, to_add_index, curr_u_count; + int i1, i2, j1, j2, i3, i4, i5, size; + int i_max, j_max; + bool OK; + t_vertex* lvertex = model_graph->vertex; + t_vertex* ilvertex; + int nb_new = 0, nb_free = 0; + int a_loop = 0; + char usi; +#ifdef DIRECT_COMPUTE + int in_y = 0; +#endif /**DIRECT_COMPUTE**/ + size = model_graph->nb_vertices; + min_edge = size * size + 1; + vertex_to_eliminate = -1; + // minimize the product of in and out degree of the remaining vertices (Markowitz criteria) + for(i = starting_vertex;i < starting_vertex + length_markowitz;i++) + if(((lvertex[i].nb_out_degree_edges*lvertex[i].nb_in_degree_edges) < min_edge) && (lvertex[i].nb_in_degree_edges > 0)) + { + min_edge = lvertex[i].nb_out_degree_edges * lvertex[i].nb_in_degree_edges; + vertex_to_eliminate = i; + } + OK = 0; + //cout << "save_direct=" << save_direct << "\n"; + if(vertex_to_eliminate >= 0) + { +#ifdef PRINT_OUT_1 + cout << "--------------------------------------------------------------- \n"; + cout << "Elimination of vertex " << lvertex[vertex_to_eliminate].index << " interpolate=" << *interpolate << "\n"; + cout << "min_edge=" << min_edge << " length_markowitz=" << length_markowitz << "\n"; +#endif /**PRINT_OUT**/ +#ifdef DIRECT_COMPUTE + table_y[vertex_count].index = lvertex[vertex_to_eliminate].index; +#ifdef PRINT_OUT + cout << "vertex_count=" << vertex_count << " size=" << size << " vertex_to_eliminate=" << vertex_to_eliminate << "\n"; +#endif +#endif /**DIRECT_COMPUTE**/ + ilvertex = &(lvertex[vertex_to_eliminate]); + i_max = ilvertex->nb_in_degree_edges; + j_max = ilvertex->nb_out_degree_edges; + for(i = 0;i < i_max;i++) + { + i1 = ilvertex->in_degree_edge[i].index; + i2 = ilvertex->in_degree_edge[i].u_count; +#ifdef DIRECT_COMPUTE + table_y[vertex_count].u_index[in_y] = i2; + table_y[vertex_count].y_index[in_y] = lvertex[i1].index; + in_y++; + nb_table_u++; + if(save_direct) + { + usi=5; + //SaveCode << (&usi) << i2; + SaveCode.write(reinterpret_cast(&usi), sizeof(usi)); + SaveCode.write(reinterpret_cast(&i2), sizeof(i2)); +#ifdef PRINT_OUT_1 + cout << "push(u[" << i2 << "]) \n"; +#endif + } + else + { + table_u->pNext = (t_table_u*)malloc(sizeof(t_table_u) - 2 * sizeof(int)); + table_u = table_u->pNext; + table_u->pNext = NULL; + table_u->type = 5; + table_u->index = i2; + } + //cout << "ok0\n"; +#ifdef PRINT_OUT_1 + cout << "push(u[" << i2 << "]) (" << table_u << ")\n"; +#endif /**PRINT_OUT**/ +#endif /**DIRECT_COMPUTE**/ + for(j = 0;j < j_max;j++) + { + to_add = -9999999; + j1 = ilvertex->out_degree_edge[j].index; + j2 = ilvertex->out_degree_edge[j].u_count; + //cout << "ok1\n"; + /* Is there already an edge from vertex i1 to vertex j1? */ + for(k = 0;((k < lvertex[i1].nb_out_degree_edges) && (to_add < 0));k++) + if(lvertex[i1].out_degree_edge[k].index == j1) + { + /*yes*/ + to_add = lvertex[i1].out_degree_edge[k].u_count; + to_add_index = k; + } + if(to_add != -9999999) + { +#ifdef DEBUGR + cout << " modification of edge between vertices " << lvertex[i1].index << " and " << lvertex[j1].index << "\n"; +#endif /**DEBUGR**/ +#ifdef DIRECT_COMPUTE + if(save_direct) + { + nb_table_u++; + usi=2; + SaveCode.write(reinterpret_cast(&usi), sizeof(usi)); + SaveCode.write(reinterpret_cast(&to_add), sizeof(to_add)); + SaveCode.write(reinterpret_cast(&j2), sizeof(j2)); + SaveCode.write(reinterpret_cast(&i2), sizeof(i2)); + //SaveCode << (unsigned short int)(2) << to_add << j2 << i2; +#ifdef PRINT_OUT_1 + cout << "u[" << to_add << "]+=u[" << j2 << "]*u[" << i2 << "]; \n"; +#endif + } + else + { + nb_table_u++; + table_u->pNext = (t_table_u*)malloc(sizeof(t_table_u)); + table_u = table_u->pNext; + table_u->pNext = NULL; + table_u->type = 2; + table_u->index = to_add; + table_u->op1 = j2; + table_u->op2 = i2; + } +#ifdef PRINT_OUT_1 + cout << "u[" << to_add << "]+=u[" << j2 << "]*u[" << i2 << "]; (" << table_u << ")\n"; +#endif /**PRINT_OUT**/ +#endif /**DIRECT_COMPUTE**/ + } + else + { + /*now modifie the in_degree edge from vertex_to_elminate to j1 */ + if(j1 == i1) + { + /* its a loop */ + /*Store it to operate after*/ + if(a_loop >= size) + { + cout << "Error : a_loop (" << a_loop << ") >= " << size << "\n"; + exit( -1); + } + s_j2[a_loop] = j2; + s_i2[a_loop] = i2; + s_i1[a_loop] = i1; + a_loop++; + } + else + { +#ifdef DEBUGR + cout << " creation of edge between vertices " << lvertex[i1].index << " and " << lvertex[j1].index << "\n"; +#endif /**DEBUGR**/ +#ifdef SYMPLIFY + curr_u_count = get_free_u_list(dynamic); +#else + curr_u_count = u_count; + u_count++; +#endif +#ifdef DIRECT_COMPUTE + nb_table_u++; + nb_new++; + if(save_direct) + { + usi=1; + SaveCode.write(reinterpret_cast(&usi), sizeof(usi)); + SaveCode.write(reinterpret_cast(&curr_u_count), sizeof(curr_u_count)); + SaveCode.write(reinterpret_cast(&j2), sizeof(j2)); + SaveCode.write(reinterpret_cast(&i2), sizeof(i2)); +#ifdef PRINT_OUT_1 + cout << "u[" << curr_u_count << "]=u[" << j2 << "]*u[" << i2 << "]; \n"; +#endif + } + else + { + table_u->pNext = (t_table_u*)malloc(sizeof(t_table_u)); + table_u = table_u->pNext; + table_u->pNext = NULL; + table_u->type = 1; + table_u->index = curr_u_count; + table_u->op1 = j2; + table_u->op2 = i2; + } +#ifdef PRINT_OUT_1 + cout << "u[" << curr_u_count << "]=u[" << j2 << "]*u[" << i2 << "]; (" << table_u << ")\n"; +#endif /**PRINT_OUT**/ +#endif /**DIRECT_COMPUTE**/ + /*its not a loop so adding a new adge*/ + /*modify the in_degree edge from vertex_to_elminate to j1*/ +#ifdef SORTED + k = lvertex[j1].nb_in_degree_edges; + while((i1 < lvertex[j1].in_degree_edge[k - 1].index) && (k > 0)) + { + lvertex[j1].in_degree_edge[k].index = lvertex[j1].in_degree_edge[k - 1].index; + lvertex[j1].in_degree_edge[k].u_count = lvertex[j1].in_degree_edge[k - 1].u_count; + k--; + } + lvertex[j1].in_degree_edge[k].index = i1; + lvertex[j1].in_degree_edge[k].u_count = curr_u_count; + (lvertex[j1].nb_in_degree_edges)++; + /*Tested*/ + if(lvertex[j1].max_nb_in_degree_edges<=lvertex[j1].nb_in_degree_edges) + { + lvertex[j1].max_nb_in_degree_edges=lvertex[j1].nb_in_degree_edges; + t_edge *tmp_edge; + tmp_edge=lvertex[j1].in_degree_edge; + int taille=lvertex[j1].nb_in_degree_edges*sizeof(t_edge); + tmp_edge = (t_edge*)realloc(tmp_edge, taille); + lvertex[j1].in_degree_edge=tmp_edge; + } + /*EndTested*/ +#else + k = lvertex[j1].nb_in_degree_edges; + lvertex[j1].in_degree_edge[k].index = i1; + lvertex[j1].in_degree_edge[k].u_count = curr_u_count; + (lvertex[j1].nb_in_degree_edges)++; +#endif + /*now modify the out_degree edge from i1 to vertex_to_elminate */ +#ifdef SORTED + k = lvertex[i1].nb_out_degree_edges; + while((j1 < lvertex[i1].out_degree_edge[k - 1].index) && (k > 0)) + { + lvertex[i1].out_degree_edge[k].index = lvertex[i1].out_degree_edge[k - 1].index; + lvertex[i1].out_degree_edge[k].u_count = lvertex[i1].out_degree_edge[k - 1].u_count; + k--; + } + lvertex[i1].out_degree_edge[k].index = j1; + lvertex[i1].out_degree_edge[k].u_count = curr_u_count; + (lvertex[i1].nb_out_degree_edges)++; + /*Tested*/ + if(lvertex[j1].max_nb_out_degree_edgesin_degree_edge[i].index; +#ifdef DEBUGR + cout << " supress the out_degree edge from " << lvertex[i1].index << " to " << ilvertex->index << "\n"; +#endif /**DEBUGR**/ + to_add = -1; + for(k = 0;((k < lvertex[i1].nb_out_degree_edges) && (to_add < 0));k++) + if(lvertex[i1].out_degree_edge[k].index == vertex_to_eliminate) + to_add = k; + if(to_add < 0) + { + cout << "error: Model_Graph not correctly filled in out_degree (edge from " << lvertex[i1].index << " to " << lvertex[vertex_to_eliminate].index << ")\n"; + print_Graph(model_graph); + system("pause"); + exit( -1); + } +#ifdef SIMPLIFYS + nb_free++; + set_free_u_list(lvertex[i1].out_degree_edge[to_add].u_count); +#endif /**SIMPLIFY**/ +#ifdef SIMPLIFYT + if(simplification_allowed) + { + free_u_list1[nb_free_u_list1] = lvertex[i1].out_degree_edge[to_add].u_count; + if(nb_free_u_list1 > max_nb_free_u_list1) + max_nb_free_u_list1 = nb_free_u_list1; + nb_free_u_list1++; + } +#endif /**SIMPLIFY**/ + for(k = to_add + 1;k < lvertex[i1].nb_out_degree_edges;k++) + { + lvertex[i1].out_degree_edge[k - 1].index = lvertex[i1].out_degree_edge[k].index; + lvertex[i1].out_degree_edge[k - 1].u_count = lvertex[i1].out_degree_edge[k].u_count; + } + (lvertex[i1].nb_out_degree_edges)--; + } + for(j = 0;j < j_max;j++) + { + /*now supress the in_degree edge from vertex_to_elminate to j1 */ + j1 = ilvertex->out_degree_edge[j].index; +#ifdef DEBUGR + cout << " supress the in_degree edge from " << ilvertex->index << " to " << lvertex[j1].index << "\n"; +#endif /**DEBUGR**/ + to_add = -1; + for(k = 0;((k < lvertex[j1].nb_in_degree_edges) && (to_add < 0));k++) + if(lvertex[j1].in_degree_edge[k].index == vertex_to_eliminate) + to_add = k; + if(to_add < 0) + { + cout << "error: Model_Graph not correctly filled in in_degree (edge from " << lvertex[vertex_to_eliminate].index << " to " << lvertex[j1].index << ")\n"; + print_Graph(model_graph); + system("pause"); + exit( -1); + } +#ifdef SIMPLIFYS + set_free_u_list(lvertex[j1].in_degree_edge[to_add].u_count); + nb_free++; +#endif /**SIMPLIFY**/ +#ifdef SIMPLIFYT + if(simplification_allowed) + { + free_u_list1[nb_free_u_list1] = lvertex[j1].in_degree_edge[to_add].u_count; + if(nb_free_u_list1 > max_nb_free_u_list1) + max_nb_free_u_list1 = nb_free_u_list1; + nb_free_u_list1++; + } +#endif /**SIMPLIFY**/ + for(k = to_add + 1;k < lvertex[j1].nb_in_degree_edges;k++) + { + lvertex[j1].in_degree_edge[k - 1].index = lvertex[j1].in_degree_edge[k].index; + lvertex[j1].in_degree_edge[k - 1].u_count = lvertex[j1].in_degree_edge[k].u_count; + } + (lvertex[j1].nb_in_degree_edges)--; + } + if(a_loop) + { + for(i = 0;i < a_loop;i++) + { + i1 = s_i1[i]; + if(nstacked) + { + /*re-use the u_count index eliminated during the loop elmination*/ + k = 0; + while((k <= nb_loop_table) && (loop_table_vertex_index[k] != model_graph->vertex[i1].index)) + k++; + if(loop_table_vertex_index[k] != model_graph->vertex[i1].index) + { + cout << "Error can't find the loop associated to vertex " << model_graph->vertex[i1].index << "\n"; + k = 0; + while((k <= nb_loop_table) && (loop_table_vertex_index[k] != model_graph->vertex[i1].index)) + { + cout << "loop_table_vertex_index[" << k << "]=" << loop_table_vertex_index[k] << " =? model_graph->vertex[" << i1 << "].index=" << model_graph->vertex[i1].index << "\n"; + k++; + } + exit( -1); + } + curr_u_count = loop_table_u_count[k] ; + } + else + { +#ifdef SIMPLIFY + curr_u_count = get_free_u_list(dynamic); +#else /**SIMPLIFY**/ + curr_u_count = u_count; + u_count++; +#endif /**SIMPLIFY**/ + } + nb_table_u++; + if(save_direct) + { + usi=6; + SaveCode.write(reinterpret_cast(&usi), sizeof(usi)); + SaveCode.write(reinterpret_cast(&curr_u_count), sizeof(curr_u_count)); + SaveCode.write(reinterpret_cast(&s_i2[i]), sizeof(s_i2[i])); + SaveCode.write(reinterpret_cast(&s_j2[i]), sizeof(s_j2[i])); +#ifdef PRINT_OUT_1 + cout << "u[" << curr_u_count << "]=1/(1-u[" << s_i2[i] << "]*u[" << s_j2[i] << "]) ;\n"; +#endif + } + else + { + table_u->pNext = (t_table_u*)malloc(sizeof(t_table_u) ); + table_u = table_u->pNext; + table_u->pNext = NULL; + table_u->type = 6; + table_u->index = curr_u_count; + table_u->op1 = s_i2[i]; + table_u->op2 = s_j2[i]; + } + nb_new++; +#ifdef PRINT_OUT_1 + cout << "u[" << curr_u_count << "]=1/(1-u[" << s_i2[i] << "]*u[" << s_j2[i] << "]) (" << table_u << ");\n"; +#endif /**PRINT_OUT**/ + i5 = curr_u_count; + OK = 0; + for(k = 0;k < lvertex[i1].nb_in_degree_edges;k++) + { + i3 = lvertex[i1].in_degree_edge[k].index; + if(i3 != i1) + { + i4 = lvertex[i1].in_degree_edge[k].u_count; +#ifdef DIRECT_COMPUTE + nb_table_u++; + if(save_direct) + { + usi=7; + SaveCode.write(reinterpret_cast(&usi), sizeof(usi)); + SaveCode.write(reinterpret_cast(&i4), sizeof(i4)); + SaveCode.write(reinterpret_cast(&i5), sizeof(i5)); +#ifdef PRINT_OUT_1 + cout << "u[" << i4 << "]*=u[" << i5 << "]; \n"; +#endif + } + else + { + table_u->pNext = (t_table_u*)malloc(sizeof(t_table_u) - sizeof(int)); + table_u = table_u->pNext; + table_u->pNext = NULL; + table_u->type = 7; + table_u->index = i4; + table_u->op1 = i5; + } +#ifdef PRINT_OUT_1 + cout << "u[" << i4 << "]*=u[" << i5 << "]; (" << table_u << ")\n"; +#endif /**PRINT_OUT**/ +#endif /**DIRECT_COMPUTE**/ + } + } +#ifdef SIMPLIFY + if(simplification_allowed) + { + set_free_u_list(i5); + nb_free++; + } +#endif /**SIMPLIFY**/ + } + } +#ifdef SIMPLIFYS + if(simplification_allowed) + for(i = 0;i < nb_free_u_list1;i++) + { + set_free_u_list(free_u_list1[i]); + nb_free++; + } +#endif /**SIMPLIFY**/ + /*Change all indexes*/ + free(ilvertex->in_degree_edge); + free(ilvertex->out_degree_edge); + for(i = vertex_to_eliminate + 1;i < size;i++) + lvertex[i - 1] = lvertex[i]; + (model_graph->nb_vertices)--; + OK = 0; + for(i = 0;i < model_graph->nb_vertices;i++) + { + for(j = 0;j < lvertex[i].nb_in_degree_edges;j++) + { + OK = 1; + if(lvertex[i].in_degree_edge[j].index > vertex_to_eliminate) + (lvertex[i].in_degree_edge[j].index)--; + } + for(j = 0;j < lvertex[i].nb_out_degree_edges;j++) + { + if(lvertex[i].out_degree_edge[j].index > vertex_to_eliminate) + (lvertex[i].out_degree_edge[j].index)--; + } + } + if(in_y>max_nb_table_y) + max_nb_table_y=in_y; +#ifdef DIRECT_COMPUTE + table_y[vertex_count].nb = in_y; +#ifdef PRINT_OUT_1 + cout << "y[" << table_y[vertex_count].index << "]="; + for(i = 0;i < table_y[vertex_count].nb;i++) + { + cout << "u[" << table_y[vertex_count].u_index[i] << "]*y[" << table_y[vertex_count].y_index[i] << "]"; + if(i + 1 < table_y[vertex_count].nb) + cout << "+"; + else + cout << "\n"; + } +#endif /**PRINT_OUT**/ + vertex_count++; +#endif /**DIRECT_COMPUTE**/ + } +#ifdef PRINT_OUT + cout << "nb_new=" << nb_new << " nb_free=" << nb_free << "\n"; + cout <<"end of vertex elimination\n"; +#endif + return (OK); +} + + +//================================================================================== +void +SymbolicGaussElimination::Gaussian_Elimination(t_model_graph* model_graph +#ifdef SAVE + , string file_name +#endif + , bool dynamic) +{ + int i, size, j, k, per; + bool OK, interpolate = false; + t_table_u *First_prologue_table_u; + int length_markowitz, per_next = 3; + bool try_to_interpolate; + int cur_pos; + int prologue_nb_table_u, first_nb_prologue_save_table_y; + int nb_first_u_blck, nb_second_u_blck, nb_third_u_blck; + int nb_first_y_blck, nb_second_y_blck, nb_third_y_blck; + + size = model_graph->nb_vertices; +#ifdef PRINT_OUT + cout << "going to open file file_open=" << file_open << " file_name={" << file_name << "}\n"; +#endif + if(file_open) + SaveCode.open((file_name + ".bin").c_str(), ios::app | ios::binary); + else + SaveCode.open((file_name + ".bin").c_str(), ios::out | ios::binary); + file_open = true; + if(!SaveCode.is_open()) + { + cout << "Error : Can't open file \"CurrentModel.bin\" for writing\n"; + exit( -1); + } +#ifdef PRINT_OUT + print_Graph(model_graph); +#endif /**PRINT_OUT**/ + s_i1 = (int*)malloc(size * sizeof(int)); + s_i2 = (int*)malloc(size * sizeof(int)); + s_j2 = (int*)malloc(size * sizeof(int)); +#ifdef SIMPLIFY + simplification_allowed = 1; + MAX_FREE_U_LIST = size * /*size *//*12*/50; + free_u_list = (int*)malloc(MAX_FREE_U_LIST* sizeof(int)); +#ifdef PRINT_OUT + cout << "free_u_list=" << free_u_list << " length=" << ceil((double)4 / (double)2*(double)u_count)*sizeof(int) << "\n"; + cout << "free_u_list length0=" << (*((short int*)&(*(((char*)free_u_list) - 4))) & ~(3)) << "\n"; + cout << "free_u_list1=(int*)malloc(" << u_count << ");\n"; +#endif + free_u_list1 = (int*)malloc(u_count * sizeof(int)); +#ifdef PRINT_OUT + cout << "after free alloc u_count=" << u_count << "\n"; +#endif +#endif /**SIMPLIFY**/ +#ifdef PRINT_OUT + cout << "periods=" << periods << "\n"; +#endif + if(dynamic) + u_count = (periods + y_kmin + y_kmax) * u_count / (y_kmin + y_kmax + 2); + if(nstacked) + { + nb_loop_table = model_graph->nb_vertices; + loop_table_u_count = (int*)malloc(nb_loop_table * sizeof(int)); + loop_table_vertex_index = (int*)malloc(nb_loop_table * sizeof(int)); + } +#ifdef PRINT_OUT + cout << "after nb_loop_table=" << nb_loop_table << "\n"; + system("pause"); +#endif + + SaveCode.write(reinterpret_cast(&nb_endo), sizeof(nb_endo)); + SaveCode.write(reinterpret_cast(&u_count), sizeof(u_count)); + SaveCode.write(reinterpret_cast(&u_count_init), sizeof(u_count_init)); + + +#ifdef PRINT_OUT + cout << "u_count=" << u_count << "\n"; + //We start with the elimination of all loops in the graph + cout << "going to loop elminate\n"; +#endif + save_direct=false; + if(nstacked) + save_direct=false; + else + { + i=0; + SaveCode.write(reinterpret_cast(&i), sizeof(i)); + SaveCode.write(reinterpret_cast(&i), sizeof(i)); + SaveCode.write(reinterpret_cast(&i), sizeof(i)); + SaveCode.write(reinterpret_cast(&i), sizeof(i)); + } + if(Loop_Elimination(model_graph)) + { +#ifdef PRINT_OUT + cout << "->table_u=" << table_u << "\n"; +#endif + if(nstacked) + { + //if there are some loops eliminated, we have to update it for the next blocks + // So we call the interpolation procedure + //cout << "nb_first_table_u="; + interpolation(model_graph, table_y, 1, false, 0); + } +#ifdef PRINT_OUT + else + { + cout << "nb_first_save_table_u=" << nb_first_save_table_u << " nb_table_u=" << nb_table_u << "\n"; + } +#endif +#ifdef PRINT_OUT + cout << "->table_u=" << table_u << "\n"; +#endif + } + if(nstacked) + { + first_nb_prologue_save_table_y = vertex_count; + nb_prologue_save_table_y=0; + First_prologue_table_u = table_u; + cur_pos=SaveCode.tellp(); + prologue_nb_table_u=nb_table_u; + i=0; + SaveCode.write(reinterpret_cast(&i), sizeof(i)); +#ifdef PRINT_OUT + cout << "--> fixe prologue\n"; +#endif + } +#ifdef PRINT_OUT +#ifdef SIMPLIFY + cout << "1 free_u_list length0=" << (*((short int*)&(*(((char*)free_u_list) - 4))) & ~(3)) << "\n"; +#endif /**SIMPLIFY**/ +#endif +#ifdef DEBUGR + //Check the graph +#ifdef PRINT_OUT + cout << "going to Check Graph\n"; +#endif + Check_Graph(model_graph); +#endif + per = 0; + OK = true; +#ifdef PRINT_OUT + cout << "nb_endo=" << nb_endo << " y_kmin=" << y_kmin << " y_kmax=" << y_kmax << " size=" << size << "\n"; +#endif + int pos = 0; + j = 0; + if(nstacked) + try_to_interpolate = 1; +#ifdef PRINT_OUT + cout << "try_to_interpolate=" << try_to_interpolate << "\n"; + cout << "y_kmin=" << y_kmin << " y_kmax=" << y_kmax << "\n"; + cout << "(0) nb_table_u=" << nb_table_u << "\n"; +#endif + if(nstacked) + save_direct=true; + while(OK) + { +#ifdef DEBUGR + Check_Graph(model_graph); +#endif /**DEBUGR**/ + if(!(j % nb_endo)) + length_markowitz = nb_endo; + else + length_markowitz--; + if(nstacked) + { +#ifdef PRINT_OUT + cout << "try_to_interpolate=" << try_to_interpolate << "\n"; +#endif + if(try_to_interpolate) + { +#ifdef PRINT_OUT + cout << j << " % " << nb_endo << " = " << (j % nb_endo) << "\n"; +#endif + if(!(j % nb_endo)) + { + per++; + if(per == y_kmin + 1) + { + nb_prologue_save_table_y=vertex_count-first_nb_prologue_save_table_y; + prologue_save_table_y=(t_table_y*)malloc(nb_prologue_save_table_y*sizeof(*prologue_save_table_y)); + for(i=first_nb_prologue_save_table_y;i(&i), sizeof(i)); + SaveCode.seekp(k); + if(nstacked) + save_direct=false; + first_u_blck = table_u; + nb_first_u_blck= nb_table_u; + nb_first_y_blck= vertex_count; + first_y_blck = vertex_count; +#ifdef PRINT_OUT + cout << "(1) nb_table_u=" << nb_table_u << "\n"; + cout << "first_u_blck=" << first_u_blck << "\n"; + system("pause"); +#endif + } + else if(per == y_kmin + 2) + { + second_u_blck = table_u; + nb_second_u_blck= nb_table_u; + second_y_blck = vertex_count; + nb_second_y_blck= vertex_count; +#ifdef PRINT_OUT + cout << "(2) nb_table_u=" << nb_table_u << "\n"; + cout << "second_u_blck=" << second_u_blck << "\n"; + system("pause"); +#endif + } + else if(per >= y_kmin + 3) + { + third_u_blck = table_u; + nb_third_u_blck= nb_table_u; + third_y_blck = vertex_count; + nb_third_y_blck= vertex_count; +#ifdef PRINT_OUT + cout << "(3) nb_table_u=" << nb_table_u << "\n"; + cout << "third_u_blck=" << third_u_blck << "\n"; + system("pause"); +#endif + } + } + } + OK = Vertex_Elimination(model_graph, pos, &interpolate, length_markowitz, dynamic); + } + else + { +#ifdef PRINT_OUT + cout << "j=" << j << "\n"; +#endif + OK = Vertex_Elimination(model_graph, pos, &interpolate, length_markowitz, dynamic); + } +#ifdef SIMPLIFY +#endif /**SIMPLIFY**/ + j++; +#ifdef SIMPLIFY + if(!(j % nb_endo)) + nb_free_u_list = 0; +#endif /**SIMPLIFY**/ + if(nstacked) + { +#ifdef PRINT_OUT + cout << "try_to_interpolate=" << try_to_interpolate << "\n"; +#endif + if(try_to_interpolate) + { +#ifdef PRINT_OUT + cout << j << " % " << nb_endo << " = " << (j % nb_endo) << "\n"; +#endif + if(!((j) % nb_endo)) + { +#ifdef PRINT_OUT + cout << "per (" << per << ") >= y_kmin (" << y_kmin << ")+3\n"; +#endif + if( per >= y_kmin + 3) + { + // pctimer_t t1, t2; +#ifdef PRINT_OUT + cout << "bef check regularity\n"; + system("pause"); +#endif + if(Check_Regularity(first_u_blck, second_u_blck, third_u_blck)) + { +#ifdef PRINT_OUT + cout << "af check regularity OK \n"; + system("pause"); + cout << "nb_first_save_table_u=" << nb_first_save_table_u << "\n"; +#endif +#ifdef PRINT_OUT + cout << "table_u=" << table_u << " table_u->pNext=" << table_u->pNext << "\n"; + cout << "(3) nb_table_u=" << nb_table_u << "\n"; +#endif + // t1 = pctimer(); + + k=SaveCode.tellp(); +#ifdef PRINT_OUT + cout << "middle_count_loop= " << middle_count_loop << "\n"; +#endif + i=0; + SaveCode.write(reinterpret_cast(&i), sizeof(i)); + table_u = interpolation(model_graph, table_y, per_next /*+1*/ + 2, true, per - y_kmin - 3); +#ifdef PRINT_OUT + cout << "middle_count_loop= " << middle_count_loop << "\n"; +#endif + i=SaveCode.tellp(); + SaveCode.seekp(k); + SaveCode.write(reinterpret_cast(&middle_count_loop), sizeof(middle_count_loop)); + SaveCode.seekp(i); + i=0; + SaveCode.write(reinterpret_cast(&i), sizeof(i)); //last_u + OK = false; + vertex_count -= nb_endo; + // t2 = pctimer(); +#ifdef PRINT_OUT + // cout << "interpolate=" << 1000*(t2 - t1) << "\n"; + cout << "table_u=" << table_u << " table_u->pNext=" << table_u->pNext << "\n"; +#endif +#ifdef SAVE + last_save_table_u = table_u; + nb_last_save_table_y = vertex_count; +#endif /**SAVE**/ + } + else + { + nb_prologue_save_table_y=nb_second_y_blck-first_nb_prologue_save_table_y; + prologue_save_table_y=(t_table_y*)malloc(nb_prologue_save_table_y*sizeof(*prologue_save_table_y)); + for(i=first_nb_prologue_save_table_y;i(&i), sizeof(i)); + SaveCode.seekp(k); + write_to_file_table_u_b(first_u_blck,second_u_blck, &nb_prologue_save_table_u); + //cout << "nb_prologue_save_table_u(1)=" << nb_prologue_save_table_u << "\n"; + nb_first_u_blck=nb_second_u_blck; + nb_second_u_blck=nb_third_u_blck; + nb_first_y_blck=nb_second_y_blck; + nb_second_y_blck=nb_third_y_blck; + first_u_blck = second_u_blck; + second_u_blck = third_u_blck; + first_y_blck = second_y_blck; + second_y_blck = third_y_blck; + } + } + } +#ifdef DEBUGR + cout << 100*j / size << "%\n"; +#endif /**DEBUGR**/ + } + } + } +#ifdef PRINT_OUT + cout << "nstacked=" << nstacked << "\n"; + cout << "nb_first_save_table_y=" << nb_first_save_table_y << "\n"; + cout << "nb_prologue_save_table_y=" << nb_prologue_save_table_y << "\n"; + cout << "nb_middle_save_table_y=" << nb_middle_save_table_y << "\n"; + cout << "nb_last_save_table_y=" << nb_last_save_table_y << "\n"; +#endif + if((nstacked)&&(!nb_last_save_table_y)) + { + cout << "not synchronized per=" << per << "\n"; + exit(-1); + } + +#ifdef PRINT_OUT + cout << "end vertex supress\n"; +#endif +#ifdef SAVE + if(!nstacked) + table_u->pNext = NULL; + if(nstacked) + { + table_u = NULL; + last_save_table_u = NULL; + nb_last_save_table_y = 0; + OK = true; + } + else + { + SaveCode.write(reinterpret_cast(&nb_table_u), sizeof(nb_table_u)); + write_to_file_table_u_b(First_table_u->pNext, table_u->pNext, &nb_last_save_table_u ); + nb_last_save_table_y = vertex_count; + last_save_table_y=(t_table_y*)malloc(nb_last_save_table_y*sizeof(*last_save_table_y)); + for(i=0;iwrite prologue\n"; +#endif +#ifdef PRINT_OUT + cout << "-->write first\n"; +#endif +#ifdef PRINT_OUT + cout << "middle_count_loop=" << middle_count_loop << "\n"; + cout << "-->write middle\n"; +#endif +#ifdef PRINT_OUT + cout << "-->write last\n"; +#endif + nb_last_save_table_u = i; +#ifdef PRINT_OUT + cout << "nb_prologue_save_table_y=" << nb_prologue_save_table_y << "\n"; +#endif + write_to_file_table_y( prologue_save_table_y, NULL, nb_prologue_save_table_y, 0); +#ifdef PRINT_OUT + cout << "nb_first_save_table_y=" << nb_first_save_table_y << "\n"; +#endif + write_to_file_table_y( first_save_table_y, NULL, nb_first_save_table_y, 0); +#ifdef PRINT_OUT + cout << "nb_middle_save_table_y=" << nb_first_save_table_y << "\n"; +#endif + write_to_file_table_y( middle_save_table_y, middle_save_i_table_y, nb_middle_save_table_y, nb_middle_save_table_y); +#ifdef PRINT_OUT + cout << "//// last_save_table_y ===\n"; + cout << "nb_last_save_table_y=" << nb_last_save_table_y << "\n"; +#endif + write_to_file_table_y( last_save_table_y, NULL, nb_last_save_table_y, 0); + SaveCode.close(); +#endif /**SAVE**/ +#ifdef SIMPLIFY +#ifdef PRINT_OUT + cout << "try_to_interpolate=" << try_to_interpolate << "\n"; +#endif + free(free_u_list); + free(free_u_list1); +#endif /**SIMPLIFY**/ + free(s_i1); + free(s_i2); + free(s_j2); +} + + +void +SymbolicGaussElimination::SGE_compute(Model_Block *ModelBlock, int blck, bool dynamic, string file_name, int endo_nbr) +{ + t_model_graph *model_graph; + int block_u_count, nb_table_y; + // pctimer_t t1, t2; + int i; + int mean_var_in_equation; +#ifdef PRINT_OUT + cout << "sizeof(i)=" << sizeof(i) << " sizeof(ttt)=" << sizeof(ttt) << " sizeof(short int)=" << sizeof(tti) << "\n" ; + system("pause"); +#endif + init_glb(); + model_graph = (t_model_graph*)malloc(sizeof(*model_graph)); + nstacked = dynamic; +#ifdef PRINT_OUT + cout << "nstacked=" << nstacked << "\n"; + // t1 = pctimer(); + cout << "periods=" << periods << "\n"; +#endif + + u_count = ModelBlock_Graph(ModelBlock, blck, dynamic, model_graph, endo_nbr, &block_u_count, &starting_vertex, &periods, &nb_table_y, &mean_var_in_equation); + if(dynamic) + { + cout << "Mean endogenous variable per equation: " << mean_var_in_equation << ", density indicator=" << double(mean_var_in_equation)/endo_nbr*100 << "%\n"; + cout << "Coding the model..."; + } + Time = periods; +#ifdef PRINT_OUT + // t2 = pctimer(); + // cout << "/* ModelBlock_Graph : " << 1000*(t2 - t1) << " milliseconds u_count : " << u_count << "*/\n"; +#endif + int size = model_graph->nb_vertices; + nb_endo = ModelBlock->Block_List[blck].Size; + y_kmin = ModelBlock->Block_List[blck].Max_Lag; + y_kmax = ModelBlock->Block_List[blck].Max_Lead; + periods = ModelBlock->Periods; + u_count_init = u_count; +#ifdef PRINT_OUT + cout << "size : " << size << "\n"; +#endif + table_y = (t_table_y*)malloc((size + 1) * sizeof(t_table_y)); + for(i = 0;i <= size;i++) + { + table_y[i].u_index = (int*)malloc(nb_table_y * sizeof(int)); + table_y[i].y_index = (int*)malloc(nb_table_y * sizeof(int)); + table_y[i].index = i; + table_y[i].nb = 0; + } + table_u = (t_table_u*)malloc(sizeof(*table_u)-3*sizeof(int)); + table_u->pNext = NULL; + First_table_u = table_u; +#ifdef PRINT_OUT + cout << "oł en est-on ? nb_table_y=" << nb_table_y << "\n"; + system("pause"); + cout << "u_count_init=" << u_count_init << "\n"; + cout << "table_u=" << table_u << "\n"; + t1 = pctimer(); +#endif + Gaussian_Elimination(model_graph, file_name, dynamic); + free_model_graph(model_graph); +#ifdef PRINT_OUT + cout << "max_nb_table_y=" << max_nb_table_y << "\n"; + cout << "max_nb_in_degree_edges=" << max_nb_in_degree_edges << "\n"; + cout << "max_nb_out_degree_edges=" << max_nb_out_degree_edges << "\n"; + t2 = pctimer(); + cout << "/* Gaussian Elimination : " << 1000*(t2 - t1) << " milliseconds u_count : " << u_count << "*/\n"; +#endif +} + diff --git a/parser.src/VariableTable.cc b/parser.src/VariableTable.cc index 63e45e033..6dc55e0ad 100644 --- a/parser.src/VariableTable.cc +++ b/parser.src/VariableTable.cc @@ -132,3 +132,45 @@ VariableTable::Sort() } } } + +int* +VariableTable::GetVariableTable(int* Size, int* HSize) +{ + int* Table; + varKey key; + int variable,id, ind; + (*Size)=0; + for (id=0; id < (int) mVariableIndex.size(); id++) + { + key = mVariableIndex[id]; + variable = mVariableTable[key]; + if(getType(variable)==eEndogenous) + (*Size)++; + } + (*HSize)=4; + Table=(int*)malloc((*Size)*(*HSize)*sizeof(*Table)); + ind=0; + for (id=0; id < (int) mVariableIndex.size(); id++) + { + key = mVariableIndex[id]; + variable = mVariableTable[key]; + if (getType(variable)==eEndogenous) + { + Table[ind*(*HSize)]= getSymbolID(id); + Table[ind*(*HSize)+1]= key.second; + Table[ind*(*HSize)+2]= mPrintFormatIndex[id]; + Table[ind*(*HSize)+3]= mSortedVariableID[id]; + ind++; + } + } + return(Table); +} + +int +VariableTable::getIDS(int id, int lead_lag) const +{ + varKey key; + key=mVariableIndex[id]; + map::const_iterator it = mVariableTable.find(key); + return(it->second); +} diff --git a/parser.src/include/BlockTriangular.hh b/parser.src/include/BlockTriangular.hh new file mode 100644 index 000000000..1bf745726 --- /dev/null +++ b/parser.src/include/BlockTriangular.hh @@ -0,0 +1,173 @@ +#ifndef BLOCKTRIANGULAR_H +#define BLOCKTRIANGULAR_H +//------------------------------------------------------------------------------ +/*! \file + \version 1.0 + \date 16/07/2006 + \par This file defines the BlockTriangular class. +*/ +//------------------------------------------------------------------------------ +#include +#include "ExprNode.hh" +#include "SymbolTable.hh" +#include "ModelNormalization.hh" +#include "ModelBlocks.hh" +//------------------------------------------------------------------------------ +/*! + \class BlockTriangular + \brief Creat the incidence matrice and reorder the model's equations. +*/ + +#include "ExprNode.hh" + +typedef struct List_IM +{ + List_IM* pNext; + int lead_lag; + bool* IM; +}; + + +typedef struct vari +{ + int Size; + int* arc; + int used_arc; + int available; +}; + + +class BlockTriangular +{ +public: + Normalization normalization; + BlockTriangular(const SymbolTable &symbol_table_arg); + ~BlockTriangular(); + /*! The incidence matrix for each lead and lags */ + Blocks blocks; + SymbolTable symbol_table; + List_IM* Build_IM(int lead_lag); + List_IM* Get_IM(int lead_lag); + bool* bGet_IM(int lead_lag); + void fill_IM(int equation, int variable_endo, int lead_lag); + void unfill_IM(int equation, int variable_endo, int lead_lag); + void incidence_matrix() const; + void init_incidence_matrix(int nb_endo); + void Print_IM(int n); + void Free_IM(List_IM* First_IM); + void Print_SIM(bool* IM, int n); + void Normalize_and_BlockDecompose_Static_Model(); + void Normalize_and_BlockDecompose_Static_0_Model(); + bool Normalize_and_BlockDecompose(bool* IM, Model_Block* ModelBlock, int n, int* prologue, int* epilogue, simple* Index_Var_IM, simple* Index_Equ_IM, bool Do_Normalization, bool mixing, bool* IM_0 ); + void Normalize_and_BlockDecompose_0(); + void Normalize_and_BlockDecompose_Inside_Earth(); + void Prologue_Epilogue(bool* IM, int* prologue, int* epilogue, int n, simple* Index_Var_IM, simple* Index_Equ_IM); + void Sort_By_Cols(bool* IM, int d, int f); + void getMax_Lead_Lag(int var, int equ, int *lead, int *lag); + void getMax_Lead_Lag_B(int size, int* Equation, int *Variable, int *lead, int *lag); + void swap_IM_c(bool *SIM, int pos1, int pos2, int pos3, simple* Index_Var_IM, simple* Index_Equ_IM, int n); + void Allocate_Block(int size, int *count_Equ, int *count_Block, int type, Model_Block * ModelBlock, int* Table, int TableSize); + void Free_Block(Model_Block* ModelBlock); + void SetVariableTable(int *Table,int Size,int HSize); + List_IM *First_IM ; + List_IM *Last_IM ; + simple *Index_Equ_IM; + simple *Index_Var_IM; + int prologue, epilogue; + int Model_Max_Lead, Model_Max_Lag, periods; + bool bt_verbose; + int endo_nbr, TableSize; + int* Table; + Model_Block* ModelBlock; + string file_name; + inline static std::string BlockType0(int type) + { + switch (type) + { + case 0: + return ("SIMULTANEOUS TIME SEPARABLE "); + break; + case 1: + return ("PROLOGUE "); + break; + case 2: + return ("EPILOGUE "); + break; + case 3: + return ("SIMULTANEOUS TIME UNSEPARABLE"); + break; + default: + return ("UNKNOWN "); + break; + } + }; + inline static std::string BlockSim(int type) + { + switch (type) + { + case 0: + return ("EVALUATE FOREWARD "); + break; + case 1: + return ("EVALUATE BACKWARD "); + break; + case 2: + return ("SOLVE FOREWARD SIMPLE "); + break; + case 3: + return ("SOLVE BACKWARD SIMPLE "); + break; + case 4: + return ("SOLVE TWO BOUNDARIES SIMPLE "); + break; + case 5: + return ("SOLVE FOREWARD COMPLETE "); + break; + case 6: + return ("SOLVE BACKWARD COMPLETE "); + break; + case 7: + return ("SOLVE TWO BOUNDARIES COMPLETE"); + break; + default: + return ("UNKNOWN "); + break; + } + }; + inline static std::string BlockSim_d(int type) + { + switch (type) + { + case 0: + return ("EVALUATE_FOREWARD "); + break; + case 1: + return ("EVALUATE_BACKWARD "); + break; + case 2: + return ("SOLVE_FOREWARD_SIMPLE "); + break; + case 3: + return ("SOLVE_BACKWARD_SIMPLE "); + break; + case 4: + return ("SOLVE_TWO_BOUNDARIES_SIMPLE "); + break; + case 5: + return ("SOLVE_FOREWARD_COMPLETE "); + break; + case 6: + return ("SOLVE_BACKWARD_COMPLETE "); + break; + case 7: + return ("SOLVE_TWO_BOUNDARIES_COMPLETE"); + break; + default: + return ("UNKNOWN "); + break; + } + }; + +}; +//------------------------------------------------------------------------------ +#endif diff --git a/parser.src/include/ComputingTasks.hh b/parser.src/include/ComputingTasks.hh index 5df3cae1e..c2b0d2535 100644 --- a/parser.src/include/ComputingTasks.hh +++ b/parser.src/include/ComputingTasks.hh @@ -37,6 +37,18 @@ public: virtual void writeOutput(ostream &output, const string &basename) const; }; +class SimulSparseStatement : public Statement +{ +private: + const OptionsList options_list; +public: + string filename; + int compiler; + SimulSparseStatement(const OptionsList &options_list_arg); + virtual void checkPass(ModFileStructure &mod_file_struct); + virtual void writeOutput(ostream &output, const string &basename) const; +}; + class StochSimulStatement : public Statement { private: @@ -90,6 +102,15 @@ public: virtual void writeOutput(ostream &output, const string &basename) const; }; +class CutoffStatement : public Statement +{ +private: + const int cutoff; +public: + CutoffStatement(int cutoff_arg); + virtual void writeOutput(ostream &output, const string &basename) const; +}; + class DsampleStatement : public Statement { private: diff --git a/parser.src/include/DataTree.hh b/parser.src/include/DataTree.hh index 50d19e786..834f7327b 100644 --- a/parser.src/include/DataTree.hh +++ b/parser.src/include/DataTree.hh @@ -12,6 +12,11 @@ using namespace std; #include "VariableTable.hh" #include "ExprNode.hh" +#include "interprete.hh" + +#define LCC_COMPILE 0 +#define GCC_COMPILE 1 + class DataTree { friend class ExprNode; @@ -24,8 +29,6 @@ protected: SymbolTable &symbol_table; //! Reference to numerical constants table NumericalConstants &num_constants; - //! The variable table - VariableTable variable_table; typedef list node_list_type; //! The list of nodes @@ -39,11 +42,6 @@ protected: //! Computing cost above which a node can be declared a temporary term int min_cost; - //! Left indexing parenthesis - char lpar; - //! Right indexing parenthesis - char rpar; - typedef map num_const_node_map_type; num_const_node_map_type num_const_node_map; typedef map, NodeID> variable_node_map_type; @@ -58,9 +56,20 @@ protected: public: DataTree(SymbolTable &symbol_table_arg, NumericalConstants &num_constants_arg); virtual ~DataTree(); + //! The variable table + VariableTable variable_table; NodeID Zero, One, MinusOne; //! Type of output 0 for C and 1 for Matlab (default), also used as matrix index offset int offset; + //! Complete set to interpret the model parameters and variables + interprete interprete_; + + //! Left indexing parenthesis + char lpar; + //! Right indexing parenthesis + char rpar; + //! Type of compiler used in matlab : 0 = LCC or 1 = GCC + int compiler; //! Raised when a local parameter is declared twice class LocalParameterException diff --git a/parser.src/include/DynareBison.hh b/parser.src/include/DynareBison.hh index 36f606703..faad70757 100644 --- a/parser.src/include/DynareBison.hh +++ b/parser.src/include/DynareBison.hh @@ -61,7 +61,7 @@ class ParsingDriver; typedef pair ExpObj; -/* Line 303 of lalr1.cc. */ +/* Line 35 of lalr1.cc. */ #line 66 "DynareBison.hh" #include "location.hh" @@ -119,7 +119,7 @@ namespace yy ExpObj *exp_val; NodeID model_val; } -/* Line 303 of lalr1.cc. */ +/* Line 35 of lalr1.cc. */ #line 124 "DynareBison.hh" ; #else @@ -143,136 +143,141 @@ namespace yy CONSTANT = 266, CORR = 267, COVAR = 268, - DATAFILE = 269, - DR_ALGO = 270, - DROP = 271, - DSAMPLE = 272, - DYNASAVE = 273, - DYNATYPE = 274, - END = 275, - ENDVAL = 276, - EQUAL = 277, - ESTIMATION = 278, - ESTIMATED_PARAMS = 279, - ESTIMATED_PARAMS_BOUNDS = 280, - ESTIMATED_PARAMS_INIT = 281, - FILTER_STEP_AHEAD = 282, - FILTERED_VARS = 283, - FIRST_OBS = 284, - FLOAT_NUMBER = 285, - FORECAST = 286, - GAMMA_PDF = 287, - GRAPH = 288, - HISTVAL = 289, - HP_FILTER = 290, - HP_NGRID = 291, - INITVAL = 292, - INT_NUMBER = 293, - INV_GAMMA_PDF = 294, - IRF = 295, - KALMAN_ALGO = 296, - KALMAN_TOL = 297, - LAPLACE = 298, - LIK_ALGO = 299, - LIK_INIT = 300, - LINEAR = 301, - LOAD_MH_FILE = 302, - LOGLINEAR = 303, - MH_DROP = 304, - MH_INIT_SCALE = 305, - MH_JSCALE = 306, - MH_MODE = 307, - MH_NBLOCKS = 308, - MH_REPLIC = 309, - MH_RECOVER = 310, - MODE_CHECK = 311, - MODE_COMPUTE = 312, - MODE_FILE = 313, - MODEL = 314, - MODEL_COMPARISON = 315, - MSHOCKS = 316, - MODEL_COMPARISON_APPROXIMATION = 317, - MODIFIEDHARMONICMEAN = 318, - MOMENTS_VARENDO = 319, - NAME = 320, - NOBS = 321, - NOCONSTANT = 322, - NOCORR = 323, - NODIAGNOSTIC = 324, - NOFUNCTIONS = 325, - NOGRAPH = 326, - NOMOMENTS = 327, - NOPRINT = 328, - NORMAL_PDF = 329, - OBSERVATION_TRENDS = 330, - OLR = 331, - OLR_INST = 332, - OLR_BETA = 333, - OPTIM = 334, - OPTIM_WEIGHTS = 335, - ORDER = 336, - OSR = 337, - OSR_PARAMS = 338, - PARAMETERS = 339, - PERIODS = 340, - PLANNER_OBJECTIVE = 341, - PREFILTER = 342, - PRESAMPLE = 343, - PRINT = 344, - PRIOR_TRUNC = 345, - PRIOR_ANALYSIS = 346, - POSTERIOR_ANALYSIS = 347, - QZ_CRITERIUM = 348, - RELATIVE_IRF = 349, - REPLIC = 350, - RPLOT = 351, - SHOCKS = 352, - SIGMA_E = 353, - SIMUL = 354, - SIMUL_ALGO = 355, - SIMUL_SEED = 356, - SMOOTHER = 357, - SOLVE_ALGO = 358, - STDERR = 359, - STEADY = 360, - STOCH_SIMUL = 361, - TEX = 362, - RAMSEY_POLICY = 363, - PLANNER_DISCOUNT = 364, - TEX_NAME = 365, - UNIFORM_PDF = 366, - UNIT_ROOT_VARS = 367, - USE_DLL = 368, - VALUES = 369, - VAR = 370, - VAREXO = 371, - VAREXO_DET = 372, - VAROBS = 373, - XLS_SHEET = 374, - XLS_RANGE = 375, - COMMA = 376, - MINUS = 377, - PLUS = 378, - DIVIDE = 379, - TIMES = 380, - UMINUS = 381, - POWER = 382, - EXP = 383, - LOG = 384, - LOG10 = 385, - SIN = 386, - COS = 387, - TAN = 388, - ASIN = 389, - ACOS = 390, - ATAN = 391, - SINH = 392, - COSH = 393, - TANH = 394, - ASINH = 395, - ACOSH = 396, - ATANH = 397, - SQRT = 398 + CUTOFF = 269, + DATAFILE = 270, + DR_ALGO = 271, + DROP = 272, + DSAMPLE = 273, + DYNASAVE = 274, + DYNATYPE = 275, + END = 276, + ENDVAL = 277, + EQUAL = 278, + ESTIMATION = 279, + ESTIMATED_PARAMS = 280, + ESTIMATED_PARAMS_BOUNDS = 281, + ESTIMATED_PARAMS_INIT = 282, + FILENAME = 283, + FILTER_STEP_AHEAD = 284, + FILTERED_VARS = 285, + FIRST_OBS = 286, + FLOAT_NUMBER = 287, + FORECAST = 288, + GAMMA_PDF = 289, + GCC_COMPILER = 290, + GRAPH = 291, + HISTVAL = 292, + HP_FILTER = 293, + HP_NGRID = 294, + INITVAL = 295, + INT_NUMBER = 296, + INV_GAMMA_PDF = 297, + IRF = 298, + KALMAN_ALGO = 299, + KALMAN_TOL = 300, + LAPLACE = 301, + LCC_COMPILER = 302, + LIK_ALGO = 303, + LIK_INIT = 304, + LINEAR = 305, + LOAD_MH_FILE = 306, + LOGLINEAR = 307, + MH_DROP = 308, + MH_INIT_SCALE = 309, + MH_JSCALE = 310, + MH_MODE = 311, + MH_NBLOCKS = 312, + MH_REPLIC = 313, + MH_RECOVER = 314, + MODE_CHECK = 315, + MODE_COMPUTE = 316, + MODE_FILE = 317, + MODEL = 318, + MODEL_COMPARISON = 319, + MSHOCKS = 320, + MODEL_COMPARISON_APPROXIMATION = 321, + MODIFIEDHARMONICMEAN = 322, + MOMENTS_VARENDO = 323, + NAME = 324, + NOBS = 325, + NOCONSTANT = 326, + NOCORR = 327, + NODIAGNOSTIC = 328, + NOFUNCTIONS = 329, + NOGRAPH = 330, + NOMOMENTS = 331, + NOPRINT = 332, + NORMAL_PDF = 333, + OBSERVATION_TRENDS = 334, + OLR = 335, + OLR_INST = 336, + OLR_BETA = 337, + OPTIM = 338, + OPTIM_WEIGHTS = 339, + ORDER = 340, + OSR = 341, + OSR_PARAMS = 342, + PARAMETERS = 343, + PERIODS = 344, + PLANNER_OBJECTIVE = 345, + PREFILTER = 346, + PRESAMPLE = 347, + PRINT = 348, + PRIOR_TRUNC = 349, + PRIOR_ANALYSIS = 350, + POSTERIOR_ANALYSIS = 351, + QZ_CRITERIUM = 352, + RELATIVE_IRF = 353, + REPLIC = 354, + RPLOT = 355, + SHOCKS = 356, + SIGMA_E = 357, + SIMUL = 358, + SIMUL_ALGO = 359, + SIMUL_SEED = 360, + SMOOTHER = 361, + SOLVE_ALGO = 362, + SPARSE_DLL = 363, + STDERR = 364, + STEADY = 365, + STOCH_SIMUL = 366, + TEX = 367, + RAMSEY_POLICY = 368, + PLANNER_DISCOUNT = 369, + TEX_NAME = 370, + UNIFORM_PDF = 371, + UNIT_ROOT_VARS = 372, + USE_DLL = 373, + VALUES = 374, + VAR = 375, + VAREXO = 376, + VAREXO_DET = 377, + VAROBS = 378, + XLS_SHEET = 379, + XLS_RANGE = 380, + COMMA = 381, + MINUS = 382, + PLUS = 383, + DIVIDE = 384, + TIMES = 385, + UMINUS = 386, + POWER = 387, + EXP = 388, + LOG = 389, + LOG10 = 390, + SIN = 391, + COS = 392, + TAN = 393, + ASIN = 394, + ACOS = 395, + ATAN = 396, + SINH = 397, + COSH = 398, + TANH = 399, + ASINH = 400, + ACOSH = 401, + ATANH = 402, + SQRT = 403 }; }; diff --git a/parser.src/include/ExprNode.hh b/parser.src/include/ExprNode.hh index dd607cc75..8423c4ee9 100644 --- a/parser.src/include/ExprNode.hh +++ b/parser.src/include/ExprNode.hh @@ -12,6 +12,8 @@ class DataTree; typedef class ExprNode *NodeID; +typedef struct Model_Block; + struct ExprNodeLess; //! Type for set of temporary terms @@ -51,6 +53,9 @@ protected: /*! Nodes included in temporary_terms are considered having a null cost */ virtual int cost(const temporary_terms_type &temporary_terms) const; + //! set of endogenous variables in the current expression + //! + set< pair > present_endogenous; public: ExprNode(DataTree &datatree_arg); virtual ~ExprNode(); @@ -69,7 +74,18 @@ public: virtual void computeTemporaryTerms(map &reference_count, temporary_terms_type &temporary_terms) const; //! Writes output of node, using a Txxx notation for nodes in temporary_terms - virtual void writeOutput(ostream &output, bool is_dynamic, const temporary_terms_type &temporary_terms) const = 0; + virtual void writeOutput(ostream &output, bool is_dynamic, const temporary_terms_type &temporary_terms, int offset) const = 0; + + //! Collects the Endogenous in a expression + virtual void collectEndogenous(NodeID &Id) = 0; + virtual void computeTemporaryTerms(map &reference_count, + temporary_terms_type &temporary_terms, + map &first_occurence, + int Curr_block, + Model_Block *ModelBlock) const; + int present_endogenous_size() const; + int present_endogenous_find(int var, int lag) const; + virtual void Evaluate() const = 0; }; //! Object used to compare two nodes (using their indexes) @@ -90,7 +106,9 @@ private: virtual NodeID computeDerivative(int varID); public: NumConstNode(DataTree &datatree_arg, int id_arg); - virtual void writeOutput(ostream &output, bool is_dynamic, const temporary_terms_type &temporary_terms) const; + virtual void writeOutput(ostream &output, bool is_dynamic, const temporary_terms_type &temporary_terms, int offset) const; + virtual void collectEndogenous(NodeID &Id); + virtual void Evaluate() const; }; //! Symbol or variable node @@ -104,7 +122,9 @@ private: virtual NodeID computeDerivative(int varID); public: VariableNode(DataTree &datatree_arg, int id_arg, Type type_arg); - virtual void writeOutput(ostream &output, bool is_dynamic, const temporary_terms_type &temporary_terms) const; + virtual void writeOutput(ostream &output, bool is_dynamic, const temporary_terms_type &temporary_terms, int offset) const; + virtual void collectEndogenous(NodeID &Id); + virtual void Evaluate() const; }; enum UnaryOpcode @@ -141,7 +161,14 @@ private: public: UnaryOpNode(DataTree &datatree_arg, UnaryOpcode op_code_arg, const NodeID arg_arg); virtual void computeTemporaryTerms(map &reference_count, temporary_terms_type &temporary_terms) const; - virtual void writeOutput(ostream &output, bool is_dynamic, const temporary_terms_type &temporary_terms) const; + virtual void writeOutput(ostream &output, bool is_dynamic, const temporary_terms_type &temporary_terms, int offset) const; + virtual void computeTemporaryTerms(map &reference_count, + temporary_terms_type &temporary_terms, + map &first_occurence, + int Curr_block, + Model_Block *ModelBlock) const; + virtual void collectEndogenous(NodeID &Id); + virtual void Evaluate() const; }; enum BinaryOpcode @@ -168,7 +195,38 @@ public: BinaryOpcode op_code_arg, const NodeID arg2_arg); virtual int precedence(const temporary_terms_type &temporary_terms) const; virtual void computeTemporaryTerms(map &reference_count, temporary_terms_type &temporary_terms) const; - virtual void writeOutput(ostream &output, bool is_dynamic, const temporary_terms_type &temporary_terms) const; + virtual void writeOutput(ostream &output, bool is_dynamic, const temporary_terms_type &temporary_terms, int offset) const; + virtual void computeTemporaryTerms(map &reference_count, + temporary_terms_type &temporary_terms, + map &first_occurence, + int Curr_block, + Model_Block *ModelBlock) const; + virtual void collectEndogenous(NodeID &Id); + virtual void Evaluate() const; +}; + +typedef struct IM_compact +{ + int size, u_init, u_finish, nb_endo; + int *u, *us, *Var, *Equ, *Var_Index, *Equ_Index, *Var_dyn_Index; +}; + +typedef struct Block +{ + int Size, Sized, Type, Simulation_Type, Max_Lead, Max_Lag, Nb_Lead_Lag_Endo; + bool is_linear; + int* Equation; + int *Variable, *Variable_Sorted, *dVariable; + int *variable_dyn_index, *variable_dyn_leadlag; + temporary_terms_type *Temporary_terms; + IM_compact *IM_lead_lag; +}; + +typedef struct Model_Block +{ + int Size, Periods; + Block* Block_List; + int *in_Block_Equ, *in_Block_Var, *in_Equ_of_Block, *in_Var_of_Block; }; #endif diff --git a/parser.src/include/ModFile.hh b/parser.src/include/ModFile.hh index 180cd216c..e9d8e3d2d 100644 --- a/parser.src/include/ModFile.hh +++ b/parser.src/include/ModFile.hh @@ -43,8 +43,9 @@ public: /*! \param basename The base name used for writing output files. Should be the name of the mod file without its extension \param clear_all Should a "clear all" instruction be written to output ? + \todo make this method "const" again! */ - void writeOutputFiles(const string &basename, bool clear_all) const; + void writeOutputFiles(const string &basename, bool clear_all); }; #endif // ! MOD_FILE_HH diff --git a/parser.src/include/ModelBlocks.hh b/parser.src/include/ModelBlocks.hh new file mode 100644 index 000000000..78e3ef725 --- /dev/null +++ b/parser.src/include/ModelBlocks.hh @@ -0,0 +1,37 @@ +#ifndef MODELBLOCKS +#define MODELBLOCKS +#include "ModelNormalization.hh" + + +typedef struct block_result +{ + int size, n_sets; + int *vertices; + int *sets_s, *sets_f; + int *order, *ordered; +} + block_result_t; + + + +class Blocks +{ +public: + Blocks(); + ~Blocks(); + void block_depth_search(int v); + block_result_t* sc(Equation_set *g); + void block_result_free(block_result_t *r); + void block_result_print(block_result_t *r); + Equation_set* Equation_gr_IM( int n , bool* IM); + void Print_Equation_gr(Equation_set* Equation); + void block_result_to_IM(block_result_t *r,bool* IM,int prologue, int n,simple* Index_Equ_IM,simple* Index_Var_IM); + Equation_vertex *vertices; + int *block_vertices, *sets_s, *sets_f; + int *block_stack, *sp, tos; + int *visit_nos, *low_link_nos; + int n_visited, n_written, n_sets; + int *pos_sc; +}; +#endif + diff --git a/parser.src/include/ModelNormalization.hh b/parser.src/include/ModelNormalization.hh new file mode 100644 index 000000000..ad9c5fd71 --- /dev/null +++ b/parser.src/include/ModelNormalization.hh @@ -0,0 +1,90 @@ +#ifndef MODELNORMALIZATION +#define MODELNORMALIZATION +#include "SymbolTableTypes.hh" +const int SIMULTANS=0; +const int PROLOGUE=1; +const int EPILOGUE=2; +const int SIMULTAN=3; +const int UNKNOWN=-1; +const int EVALUATE_FOREWARD=0; +const int EVALUATE_BACKWARD=1; +const int SOLVE_FOREWARD_SIMPLE=2; +const int SOLVE_BACKWARD_SIMPLE=3; +const int SOLVE_TWO_BOUNDARIES_SIMPLE=4; +const int SOLVE_FOREWARD_COMPLETE=5; +const int SOLVE_BACKWARD_COMPLETE=6; +const int SOLVE_TWO_BOUNDARIES_COMPLETE=7; + +typedef struct Edge +{ + Edge *next; + int Vertex_Index; +}; + +typedef struct Equation_vertex +{ + Edge *First_Edge; + Edge *Next_Edge; + int matched,index; +}; + +typedef struct Equation_set +{ + Equation_vertex *Number; + int size; + int edges; +}; + +typedef struct simple +{ + int index, block; + bool available; +}; + +typedef std::string (*t_getNameByID)(Type type, int id); + +class Normalization +{ +private: + typedef struct Variable_vertex + { + int matched; + }; + typedef struct Variable_set + { + Variable_vertex *Number; + int size; + }; + typedef struct t_Heap + { + int u; /* vertex */ + int i_parent; /* index in t_Heap of parent vertex in tree of u */ + int v; /* current matched of u */ + }; +public: + Normalization(/*t_getNameByID gdi*/); + ~Normalization(); + void Normalize(int n, int prologue, int epilogue, bool* IM, simple* Index_Var_IM, Equation_set* Equation,bool mixing, bool* IM_s); + void Gr_to_IM_basic(int n0, int prologue, int epilogue, bool* IM, Equation_set *Equation,bool transpose); + t_getNameByID getnamebyID; +private: + void IM_to_Gr(int n0, int prologue, int epilogue, bool* IM, Equation_set *Equation, Variable_set *Variable ); + void Inits(Equation_set *Equation); + void UpdatePath(Equation_set *Equation, Variable_set *Variable, int i1, int i2); + void FindAugmentingPaths(Equation_set *Equation, Variable_set *Variable); + void CheapMatching(Equation_set *Equation, Variable_set *Variable); + void MaximumMatching(Equation_set *Equation, Variable_set *Variable); + int MeasureMatching(Equation_set *Equation); + void OutputMatching(Equation_set* Equation); + void Gr_to_IM(int n0, int prologue, int epilogue, bool* IM, simple* Index_Var_IM, Equation_set *Equation,bool mixing, bool* IM_s); + void Free_Equation(int n, Equation_set* Equation); + void Free_Other(Variable_set* Variable); + void Free_All(int n, Equation_set* Equation, Variable_set* Variable); + void ErrorHandling(int n, bool* IM, simple* Index_Equ_IM); + int eq, eex; + int IndexUnmatched; + bool fp_verbose; + bool* visited; + t_Heap* Local_Heap; +}; +#endif diff --git a/parser.src/include/ModelTree.hh b/parser.src/include/ModelTree.hh index 1940850ed..622f4586d 100644 --- a/parser.src/include/ModelTree.hh +++ b/parser.src/include/ModelTree.hh @@ -11,6 +11,8 @@ using namespace std; #include "SymbolTable.hh" #include "NumericalConstants.hh" #include "DataTree.hh" +#include "OperatorTable.hh" +#include "BlockTriangular.hh" //! Stores a model's equations and derivatives class ModelTree : public DataTree @@ -50,9 +52,10 @@ private: //! Computes derivatives of ModelTree void derive(int order); + void GetDerivatives(ostream &output, int eq, int var, int lag, bool is_dynamic, const temporary_terms_type &temporary_terms) const; //! Computes temporary terms void computeTemporaryTerms(int order); - + void computeTemporaryTermsOrdered(int order, Model_Block *ModelBlock); //! Writes temporary terms void writeTemporaryTerms(ostream &output, bool is_dynamic) const; //! Writes local parameters @@ -64,7 +67,8 @@ private: void writeStaticModel(ostream &StaticOutput) const; //! Writes the dynamic model equations and its derivatives /*! \todo add third derivatives handling in C output */ - void writeDynamicModel(ostream &DynamicOutput) const; + void writeDynamicModel(ostream &DynamicOutput, Model_Block *ModelBlock) const; + void writeModelEquationsOrdered(ostream &output, bool is_dynamic, Model_Block *ModelBlock) const; //! Writes static model file (Matlab version) void writeStaticMFile(const string &static_basename) const; //! Writes static model file (C version) @@ -74,6 +78,10 @@ private: //! Writes dynamic model file (C version) /*! \todo add third derivatives handling */ void writeDynamicCFile(const string &dynamic_basename) const; + //! Evaluates part of a model tree + inline double Evaluate_Expression(NodeID StartID); + inline void Evaluate_Jacobian(); + inline void BlockLinear(Model_Block *ModelBlock); public: ModelTree(SymbolTable &symbol_table_arg, NumericalConstants &num_constants); @@ -100,6 +108,12 @@ public: void writeStaticFile(const string &basename) const; //! Writes dynamic model file void writeDynamicFile(const string &basename) const; + void SaveCFiles(Model_Block* ModelBlock, std::string Model_file_name, std::ofstream &mDynamicModelFile) const; + void writeDynamicInitCFile(ostream &mDynamicModelFile); + string reform(string name) const; + //! Complete set to block decompose the model + BlockTriangular block_triangular; + int equation_number() const; }; #endif diff --git a/parser.src/include/Model_Graph.hh b/parser.src/include/Model_Graph.hh new file mode 100644 index 000000000..3effc1079 --- /dev/null +++ b/parser.src/include/Model_Graph.hh @@ -0,0 +1,63 @@ +#ifndef MODEL_GRAPH +#define MODEL_GRAPH +#define DIRECT_COMPUTE +#define SORTED +#define SIMPLIFY +#define SIMPLIFYS +#define SAVE +#define COMPUTE +#define PRINT_OUT_OUT +#define DIRECT_SAVE +#include "ModelTree.hh" +#include "BlockTriangular.hh" + +typedef struct t_edge +{ + int index, u_count; +}; + +typedef struct t_vertex +{ + t_edge *out_degree_edge, *in_degree_edge; + int nb_out_degree_edges, nb_in_degree_edges; + int max_nb_out_degree_edges, max_nb_in_degree_edges; + int index, lag_lead; +}; + +typedef struct t_model_graph +{ + int nb_vertices; + t_vertex* vertex; +}; + +typedef struct t_pList +{ + int* Lag_in, * Lag_out; + int CurrNb_in, CurrNb_out; +}; + + + + +void free_model_graph(t_model_graph* model_graph); +void print_Graph(t_model_graph* model_graph); +void Check_Graph(t_model_graph* model_graph); +void copy_model_graph(t_model_graph* model_graph, t_model_graph* saved_model_graph, int nb_endo, int y_kmax); +int ModelBlock_Graph(Model_Block *ModelBlock, int Blck_num,bool dynamic, t_model_graph* model_graph, int nb_endo, int *block_u_count, int *starting_vertex, int* periods, int *nb_table_y, int *mean_var_in_equ); +void IM_to_model_graph(List_IM* First_IM,int Time, int endo, int* y_kmin, int* y_kmax, t_model_graph* model_graph, int* nb_endo, int *stacked_time, double** u1, int* u_count +#ifdef VERIF + , Matrix *B, Matrix *D +#endif + ); +void IM_to_model_graph_new(List_IM* First_IM,int Time, int endo, int* y_kmin, int* y_kmax, t_model_graph* model_graph, int* nb_endo, int *stacked_time, double** u1, int* u_count +#ifdef VERIF + , Matrix *B, Matrix *D +#endif + ); +void IM_to_model_graph_new_new(List_IM* First_IM,int Time, int endo, int* y_kmin, int* y_kmax, t_model_graph* model_graph, int* nb_endo, int *stacked_time, double** u1, int* u_count +#ifdef VERIF + , Matrix *B, Matrix *D +#endif + ); +void reduce_model_graph(t_model_graph* model_graph,int pos); +#endif diff --git a/parser.src/include/ParsingDriver.hh b/parser.src/include/ParsingDriver.hh index 9ce2b0f38..3cd0e7ee8 100644 --- a/parser.src/include/ParsingDriver.hh +++ b/parser.src/include/ParsingDriver.hh @@ -3,6 +3,8 @@ #include +#include + #include "ModFile.hh" #include "Expression.hh" #include "TmpSymbolTable.hh" @@ -144,6 +146,14 @@ public: bool exists_symbol(const char *s); //! Sets variable offset of ModelTree class to use C output void use_dll(); + //! Sets variable offset of ModelTree class to block decompose the model and to use C output + void sparse_dll(); + //! Initialize the model => creation of the incidence matrix + void initialize_model(); + //! Sets the compiler type used in conjunction with SPARCE_DLL + void init_compiler(int compiler_type); + //! Sets the FILENAME for the initial value in initval + void init_val_filename(string *filename); //! Declares an endogenous variable by adding it to SymbolTable void declare_endogenous(string *name, string *tex_name = new string); //! Declares an exogenous variable by adding it to SymbolTable @@ -172,6 +182,8 @@ public: ExpObj *add_expression_token(ExpObj *arg1, string *op_name); //! Adds a "periods" statement void periods(string *periods); + //! Adds a "cutoff" statement + void cutoff(string *cutoff); //! Adds a "dsample" statement void dsample(string *arg1); //! Adds a "dsample" statement @@ -242,6 +254,10 @@ public: void rplot(); //! Writes a stock_simul command void stoch_simul(); + //! Determine whether to write simul command or simul_sparse command + void simulate(); + //! Writes a simul_sparse command + void simul_sparse(); //! Writes a simul command void simul(); //! Writes check command diff --git a/parser.src/include/SymbolGaussElim.hh b/parser.src/include/SymbolGaussElim.hh new file mode 100644 index 000000000..c730fab04 --- /dev/null +++ b/parser.src/include/SymbolGaussElim.hh @@ -0,0 +1,92 @@ +#ifndef SYMBGAUSSELIM +#define SYMBGAUSSELIM +//------------------------------------------------------------------------------ +/*! \file + \version 1.0 + \date 28/10/2006 + \par This file defines the BlockTriangular class. +*/ +//------------------------------------------------------------------------------ +#include +#include +#include "Model_Graph.hh" +//------------------------------------------------------------------------------ +using namespace std; +#define TOL 1e-9 + +typedef struct t_table_y +{ + int index,nb; + int *u_index, *y_index; +}; + +typedef struct t_table_u +{ + t_table_u* pNext; + unsigned char type; + int index; + int op1,op2; + +}; + +class SymbolicGaussElimination +{ +public: + int y_kmin, y_kmax, nb_endo, Time, stacked_time, u_count, periods; + double* u1; + int *s_i1, *s_i2, *s_j2; + bool nstacked, save_direct; + int nb_loop_table; + int *loop_table_u_count, *loop_table_vertex_index; +#ifdef DIRECT_COMPUTE + int u_count_init; + double tol; + t_table_y *table_y; + int vertex_count; + t_table_u* table_u; + int nb_table_u; + t_table_u *get_table_u; + t_table_u* First_table_u; +#endif /**DIRECT_COMPUTE**/ + int starting_vertex; + t_table_u *first_u_blck, *second_u_blck, *third_u_blck, *stop_table_u, *forth_u_blck; + int first_y_blck, second_y_blck, third_y_blck; +#ifdef SAVE + t_table_u *prologue_save_table_u, *first_save_table_u, *first_save_i_table_u, *middle_save_table_u, *middle_save_i_table_u, *last_save_table_u, *save_table_u, *save_i_table_u; + t_table_y *prologue_save_table_y, *first_save_table_y, *first_save_i_table_y, *middle_save_table_y, *middle_save_i_table_y, *last_save_table_y; + int nb_prologue_save_table_y, nb_first_save_table_y, nb_middle_save_table_y, nb_last_save_table_y; + int nb_prologue_save_table_u, nb_first_save_table_u, nb_middle_save_table_u, nb_last_save_table_u, middle_count_loop; + int pos_nb_first_save_table_u; + std::ofstream SaveCode; + bool file_open; +#endif /**SAVE**/ +#ifdef SIMPLIFY + int* free_u_list; + int* free_u_list1; + int MAX_FREE_U_LIST; + int nb_free_u_list,nb_free_u_list1,max_nb_free_u_list1,max_nb_free_u_list; + bool simplification_allowed; + void print_free_u_list(); + void set_free_u_list(int index); + int get_free_u_list(bool dynamic); +#endif /**SIMPLIFY**/ + SymbolicGaussElimination(); + void list_table_u(int pos); + void init_glb(); + void write_to_file_table_y( t_table_y *save_table_y, t_table_y *save_i_table_y, int nb_save_table_y, int nb_save_i_table_y); + void write_to_file_table_u(t_table_u *save_table_u,t_table_u *save_i_table_u, int nb_save_table_u); + void write_to_file_table_u_b(t_table_u *save_table_u, t_table_u *last_table_u, int *nb_save_table_u); + bool Check_Regularity(t_table_u *first_u_blck, t_table_u *second_u_blck, t_table_u *third_u_blck); + t_table_u* interpolation(t_model_graph* model_graph,t_table_y* table_y, int to_add, bool middle,int per); + bool Loop_Elimination(t_model_graph* model_graph); + bool Vertex_Elimination(t_model_graph* model_graph, int pos,bool* interpolate, int length_markowitz, bool dynamic); + void Gaussian_Elimination(t_model_graph* model_graph +#ifdef SAVE + , string file_name +#endif + , bool dynamic); + int SGE_all(int endo,int Time, List_IM *First_IM); + void SGE_compute(Model_Block *ModelBlock, int blck, bool dynamic, string file_name, int endo_nbr); +}; +//------------------------------------------------------------------------------ +#endif diff --git a/parser.src/include/VariableTable.hh b/parser.src/include/VariableTable.hh index 3f43106d4..4ca19d310 100644 --- a/parser.src/include/VariableTable.hh +++ b/parser.src/include/VariableTable.hh @@ -27,10 +27,11 @@ private: vector mSortedVariableID; //! For each variable, gives its index number among variables of the same type /*! It is the index used in the output file: - - in the lead/lag matrix - - in the right hand side of equations (such as y(index)) + - in the lead/lag matrix + - in the right hand side of equations (such as y(index)) */ vector mPrintFormatIndex; + map, int> mVariableSelector; public: VariableTable(const SymbolTable &symbol_table_arg); //! Number of dynamic endogenous variables inside the model block @@ -81,8 +82,28 @@ public: void Sort(); //! Get the number of dynamic variables inline int get_dyn_var_nbr(void) const; + int* GetVariableTable(int* Size, int* HSize); + int getIDS(int id, int lead_lag) const; + void setmVariableSelector(); + int getmVariableSelector(int var, int lag) const; }; +inline void +VariableTable::setmVariableSelector() +{ + for(int var = 0; var < (int) mVariableTable.size(); var++) + { + if(getType(var)==eEndogenous) + mVariableSelector[make_pair(getSymbolID(var),mVariableIndex[var].second)]=var; + } +} + +inline int +VariableTable::getmVariableSelector(int var, int lag) const +{ + return(mVariableSelector.find(make_pair(var,lag))->second); +} + inline int VariableTable::getSortID(int iVarID) const { diff --git a/parser.src/include/interprete.hh b/parser.src/include/interprete.hh new file mode 100644 index 000000000..511170dde --- /dev/null +++ b/parser.src/include/interprete.hh @@ -0,0 +1,51 @@ +#ifndef _INTERPRETE_HH +#define _INTERPRETE_HH +#include +#include +#include +#include +#include "SymbolTable.hh" +#include "VariableTable.hh" +#include "ExprNode.hh" +//#define PRINT_IT + + +using namespace std; +typedef struct t_val_index +{ + int index,type,indexed; + double value; +}; + +typedef struct t_val1_index +{ + string name; + double value; +}; + + +typedef stack STACK_SIMPLE00; +typedef map > t_map_to_val_index; +typedef map t_map_int; + +class interprete +{ +public: + double cutoff; + bool eval; + double u1, u2; + STACK_SIMPLE00 Stack; + interprete(); + double S_to_Val(string *str); + double get_value(string *str, double ll); + void put_value(string *str, int num,int Type, double val); + void print_all(); + void create_id_map(int* Table, int Size, int HSize); + double GetDataValue(/*NodeID*/int id, Type type); + void set_cutoff(double r); +private: + string tmp_put_value_name; + t_map_to_val_index variable; + t_map_int i_endo_variable, i_exo_variable, i_param_variable; +}; +#endif diff --git a/parser.src/interprete.cc b/parser.src/interprete.cc new file mode 100644 index 000000000..99bf9bb8d --- /dev/null +++ b/parser.src/interprete.cc @@ -0,0 +1,95 @@ +#include "interprete.hh" + +interprete::interprete() +{ + eval=true; + cutoff=1.0e-6; +} + +void +interprete::set_cutoff(double r) +{ + cutoff=r; +} + +double +interprete::S_to_Val(string *str) +{ + double v=atof((*str).c_str()); +#ifdef PRINT_IT + cout << "v=" << v << "\n"; +#endif + return(v); +} + +double +interprete::get_value(string *str, double ll) +{ +#ifdef PRINT_IT + cout << "value[" << *str << "]=" << variable[(*str)].value << "\n"; +#endif + return(variable[(*str)].value); +} + +void +interprete::put_value(string *str, int num,int Type, double val) +{ +#ifdef PRINT_IT + cout << "*str=" << *str << " val=" << val << "\n"; +#endif + tmp_put_value_name=*str; + variable[(*str)].value=val; + variable[(*str)].index=num; + variable[(*str)].type=Type; +} + +void +interprete::print_all() +{ + map::iterator iter; + for( iter = variable.begin(); iter != variable.end(); iter++ ) + { + cout << "Name= " << iter->first << ", Value= " << iter->second.value << ", Index= " << iter->second.index << ", Type= " << iter->second.type << ", Indexed=" << iter->second.index << endl; + } +} + +void +interprete::create_id_map(int *Table, int Size, int HSize) +{ + map::iterator iter; + for( iter = variable.begin(); iter != variable.end(); iter++ ) + { + if(iter->second.type==0) + { + i_endo_variable[iter->second.index].name=iter->first; + i_endo_variable[iter->second.index].value=iter->second.value; + } + else if(iter->second.type==1) + { + i_exo_variable[iter->second.index].name=iter->first; + i_exo_variable[iter->second.index].value=iter->second.value; + } + else if(iter->second.type==4) + { + i_param_variable[iter->second.index].name=iter->first; + i_param_variable[iter->second.index].value=iter->second.value; + } + } +} + +double +interprete::GetDataValue(int id, Type type) +{ + switch(type) + { + case eParameter: + return(i_param_variable[(long int) id].value); + case eEndogenous: + return(i_endo_variable[(long int) id].value); + case eExogenous: + return(i_exo_variable[(long int) id].value); + default: + cerr << "interprete::GetDataValue: unhandled type!!"; + exit(-1); + } +}