Commit 4fe7e3e1 authored by ferhat's avatar ferhat
Browse files

- SymbolGaussElim.cc is discarded from the preprocessor (all simulations are...

- SymbolGaussElim.cc is discarded from the preprocessor (all simulations are now implemented in simulate)
- Correction in model_info.m

git-svn-id: https://www.dynare.org/svn/dynare/trunk@2358 ac1d8469-bf42-47a9-8791-bf33cf982152
parent b1e31855
......@@ -72,17 +72,20 @@ function model_info;
function ret=Sym_type(type);
EVALUATE_FORWARD=0;
EVALUATE_BACKWARD=1;
SOLVE_FORWARD_SIMPLE=2;
SOLVE_BACKWARD_SIMPLE=3;
SOLVE_TWO_BOUNDARIES_SIMPLE=4;
SOLVE_FORWARD_COMPLETE=5;
SOLVE_BACKWARD_COMPLETE=6;
SOLVE_TWO_BOUNDARIES_COMPLETE=7;
EVALUATE_FORWARD_R=8;
EVALUATE_BACKWARD_R=9;
UNKNOWN=0;
EVALUATE_FORWARD=1;
EVALUATE_BACKWARD=2;
SOLVE_FORWARD_SIMPLE=3;
SOLVE_BACKWARD_SIMPLE=4;
SOLVE_TWO_BOUNDARIES_SIMPLE=5;
SOLVE_FORWARD_COMPLETE=6;
SOLVE_BACKWARD_COMPLETE=7;
SOLVE_TWO_BOUNDARIES_COMPLETE=8;
EVALUATE_FORWARD_R=9;
EVALUATE_BACKWARD_R=10;
switch (type)
case (UNKNOWN),
ret='UNKNOWN ';
case {EVALUATE_FORWARD,EVALUATE_FORWARD_R},
ret='EVALUATE FORWARD ';
case {EVALUATE_BACKWARD,EVALUATE_BACKWARD_R},
......
......@@ -62,7 +62,7 @@ Interpreter::pow1(double a, double b)
void
Interpreter::compute_block_time() /*throw(EvalException)*/
Interpreter::compute_block_time(int Per_u_) /*throw(EvalException)*/
{
int var, lag, op;
double v1, v2;
......@@ -586,7 +586,7 @@ Interpreter::simulate_a_block(int size,int type, string file_name, string bin_ba
#endif
//SparseMatrix sparse_matrix;
int nb_endo, u_count_init;
//int nb_endo, u_count_init;
//mexPrintf("simulate_a_block\n");
......@@ -608,12 +608,20 @@ Interpreter::simulate_a_block(int size,int type, string file_name, string bin_ba
{
set_code_pointer(begining);
Per_y_=it_*y_size;
compute_block_time();
compute_block_time(0);
#ifdef PRINT_OUT
for (j = 0; j<size; j++)
mexPrintf("y[%d, %d] = %f\n", Block_Contain[j].Variable, it_, y[Per_y_ + Block_Contain[j].Variable]);
#endif
}
/*mexPrintf("Evaluate Forward\n");
for (it_=y_kmin;it_<periods+y_kmin;it_++)
{
mexPrintf("it_=%d ",it_);
for(i=0; i<y_size; i++)
mexPrintf(" %f",y[i+it_*y_size]);
mexPrintf("\n");
}*/
break;
case EVALUATE_BACKWARD :
case EVALUATE_BACKWARD_R :
......@@ -625,7 +633,7 @@ Interpreter::simulate_a_block(int size,int type, string file_name, string bin_ba
{
set_code_pointer(begining);
Per_y_=it_*y_size;
compute_block_time();
compute_block_time(0);
#ifdef PRINT_OUT
for (j = 0; j<size; j++)
mexPrintf("y[%d, %d] = %f\n", Block_Contain[j].Variable, it_, y[Per_y_ + Block_Contain[j].Variable]);
......@@ -648,7 +656,7 @@ Interpreter::simulate_a_block(int size,int type, string file_name, string bin_ba
{
set_code_pointer(begining);
Per_y_=it_*y_size;
compute_block_time();
compute_block_time(0);
y[Per_y_+Block_Contain[0].Variable] += -r[0]/g1[0];
//mexPrintf("y[%d] += -r[0] (%f) / g1[0] (%f) = %f\n",Per_y_+Block_Contain[0].Variable,r[0],g1[0],y[Per_y_+Block_Contain[0].Variable]);
double rr;
......@@ -685,9 +693,9 @@ Interpreter::simulate_a_block(int size,int type, string file_name, string bin_ba
{
set_code_pointer(begining);
Per_y_=it_*y_size;
compute_block_time();
mexPrintf("Compute_block_time=> in SOLVE_BACKWARD_SIMPLE : OK\n");
mexEvalString("drawnow;");
compute_block_time(0);
/*mexPrintf("Compute_block_time=> in SOLVE_BACKWARD_SIMPLE : OK\n");
mexEvalString("drawnow;");*/
y[Per_y_+Block_Contain[0].Variable] += -r[0]/g1[0];
double rr;
rr=r[0]/(1+y[Per_y_+Block_Contain[0].Variable]);
......@@ -781,19 +789,39 @@ Interpreter::simulate_a_block(int size,int type, string file_name, string bin_ba
}
break;*/
case SOLVE_FORWARD_COMPLETE :
//#ifdef DEBUGC
mexPrintf("SOLVE_FORWARD_COMPLETE\n");
//#endif
#ifdef DEBUGC
mexPrintf("SOLVE FORWARD_COMPLETE\n");
mexPrintf("confirmation!\n");
mexEvalString("drawnow;");
#endif
is_linear=get_code_bool;
//mexPrintf("is_linear=%d\n",is_linear);
//mexEvalString("drawnow;");
max_lag_plus_max_lead_plus_1=get_code_int;
//mexPrintf("max_lag_plus_max_lead_plus_1=%d\n",max_lag_plus_max_lead_plus_1);
//mexEvalString("drawnow;");
symbol_table_endo_nbr=get_code_int;
//mexPrintf("symbol_table_endo_nbr=%d\n",symbol_table_endo_nbr);
//mexEvalString("drawnow;");
Block_List_Max_Lag=get_code_int;
//mexPrintf("Block_List_Max_Lag=%d\n",Block_List_Max_Lag);
//mexEvalString("drawnow;");
Block_List_Max_Lead=get_code_int;
//mexPrintf("Block_List_Max_Lead=%d\n",Block_List_Max_Lead);
//mexEvalString("drawnow;");
u_count_int=get_code_int
//mexPrintf("u_count_int=%d\n",u_count_int);
//mexEvalString("drawnow;");
fixe_u(&u, u_count_int, u_count_int);
//Read_file(file_name, periods, 0, symbol_table_endo_nbr, Block_List_Max_Lag, Block_List_Max_Lead, nb_endo, u_count, u_count_init, u);
//sparse_matrix.initialize(periods, nb_endo, y_kmin, y_kmax, y_size, u_count, u_count_init, u, y, ya, slowc, y_decal, markowitz_c, res1, res2, max_res);
Read_SparseMatrix(bin_basename, size, 1, 0, 0);
//mexPrintf("size=%d\n",size);
g1=(double*)mxMalloc(size*size*sizeof(double));
r=(double*)mxMalloc(size*sizeof(double));
begining=get_code_pointer;
Per_u_ = 0;
if (!is_linear)
{
for (it_=y_kmin;it_<periods+y_kmin;it_++)
......@@ -804,10 +832,11 @@ Interpreter::simulate_a_block(int size,int type, string file_name, string bin_ba
while (!(cvg||(iter>maxit_)))
{
set_code_pointer(begining);
compute_block_time();
mexPrintf("Compute_block_time=> in SOLVE_FORWARD_COMPLETE : OK\n");
mexEvalString("drawnow;");
Direct_Simulate(Block_Count, symbol_table_endo_nbr, it_, y_kmin, y_kmax, size, 0, false, iter);
compute_block_time(0);
/*mexPrintf("Compute_block_time=> in SOLVE_FORWARD_COMPLETE : OK\n");
mexEvalString("drawnow;");*/
//Direct_Simulate(Block_Count, symbol_table_endo_nbr, it_, y_kmin, y_kmax, size, 0, false, iter);
simulate_NG(Block_Count, symbol_table_endo_nbr, it_, y_kmin, y_kmax, size, false, cvg, iter);
res2=0;
res1=0;
max_res=0;
......@@ -841,15 +870,26 @@ Interpreter::simulate_a_block(int size,int type, string file_name, string bin_ba
res1=res2=max_res=0;
/*mexPrintf("Compute_block_time=> in SOLVE_FORWARD_COMPLETE before compute_block_time OK\n");
mexEvalString("drawnow;");*/
compute_block_time();
compute_block_time(0);
//mexPrintf("Compute_block_time=> in SOLVE_FORWARD_COMPLETE : OK\n");
/*mexPrintf("Compute_block_time=> in SOLVE_FORWARD_COMPLETE : %d OK\n",it_);
mexEvalString("drawnow;");*/
//Direct_Simulate(Block_Count, symbol_table_endo_nbr, it_, y_kmin, y_kmax, size, 0, false, iter);
//Direct_Simulate(Block_Count, symbol_table_endo_nbr, it_, y_kmin, y_kmax, size, 0, false, iter);
simulate_NG1(Block_Count, symbol_table_endo_nbr, it_, y_kmin, y_kmax, size, 0, /*true*/false, cvg, iter);
//simulate_NG1(Block_Count, symbol_table_endo_nbr, it_, y_kmin, y_kmax, size, 0, /*true*/false, cvg, iter);
simulate_NG(Block_Count, symbol_table_endo_nbr, it_, y_kmin, y_kmax, size, false, cvg, iter);
//simulate_NG1(Block_Count, symbol_table_endo_nbr, it_, y_kmin, y_kmax, size, periods, true, cvg, iter);
}
/*mexPrintf("solve forward complete simulation\n");
for (it_=y_kmin;it_<periods+y_kmin;it_++)
{
mexPrintf("it_=%d ",it_);
for(i=0; i<y_size; i++)
mexPrintf(" %f",y[i+it_*y_size]);
mexPrintf("\n");
}*/
}
memset(direction,0,size_of_direction);
mxFree(g1);
mxFree(r);
mxFree(u);
......@@ -863,8 +903,13 @@ Interpreter::simulate_a_block(int size,int type, string file_name, string bin_ba
symbol_table_endo_nbr=get_code_int;
Block_List_Max_Lag=get_code_int;
Block_List_Max_Lead=get_code_int;
Read_file(file_name, periods, 0, symbol_table_endo_nbr, Block_List_Max_Lag, Block_List_Max_Lead, nb_endo, u_count, u_count_init, u);
//Read_file(file_name, periods, 0, symbol_table_endo_nbr, Block_List_Max_Lag, Block_List_Max_Lead, nb_endo, u_count, u_count_init, u);
//sparse_matrix.initialize(periods, nb_endo, y_kmin, y_kmax, y_size, u_count, u_count_init, u, y, ya, slowc, y_decal, markowitz_c, res1, res2, max_res);
u_count_int=get_code_int
//mexPrintf("u_count_int=%d\n",u_count_int);
//mexEvalString("drawnow;");
fixe_u(&u, u_count_int, u_count_int);
Read_SparseMatrix(bin_basename, size, 1, 0, 0);
g1=(double*)mxMalloc(size*size*sizeof(double));
r=(double*)mxMalloc(size*sizeof(double));
begining=get_code_pointer;
......@@ -878,10 +923,11 @@ Interpreter::simulate_a_block(int size,int type, string file_name, string bin_ba
while (!(cvg||(iter>maxit_)))
{
set_code_pointer(begining);
compute_block_time();
mexPrintf("Compute_block_time=> in SOLVE_BACKWARD_COMPLETE : OK\n");
mexEvalString("drawnow;");
Direct_Simulate(Block_Count, symbol_table_endo_nbr, it_, y_kmin, y_kmax, size, 0, false, iter);
compute_block_time(0);
/*mexPrintf("Compute_block_time=> in SOLVE_BACKWARD_COMPLETE : OK\n");
mexEvalString("drawnow;");*/
//Direct_Simulate(Block_Count, symbol_table_endo_nbr, it_, y_kmin, y_kmax, size, 0, false, iter);
simulate_NG(Block_Count, symbol_table_endo_nbr, it_, y_kmin, y_kmax, size, false, cvg, iter);
res2=0;
res1=0;
max_res=0;
......@@ -911,16 +957,19 @@ Interpreter::simulate_a_block(int size,int type, string file_name, string bin_ba
{
set_code_pointer(begining);
Per_y_=it_*y_size;
compute_block_time();
Direct_Simulate(Block_Count, symbol_table_endo_nbr, it_, y_kmin, y_kmax, size, 1, false, iter);
compute_block_time(0);
//Direct_Simulate(Block_Count, symbol_table_endo_nbr, it_, y_kmin, y_kmax, size, 1, false, iter);
simulate_NG(Block_Count, symbol_table_endo_nbr, it_, y_kmin, y_kmax, size, false, cvg, iter);
}
}
memset(direction,0,size_of_direction);
mxFree(g1);
mxFree(r);
mxFree(u);
break;
case SOLVE_TWO_BOUNDARIES_SIMPLE :
case SOLVE_TWO_BOUNDARIES_COMPLETE:
mexPrintf("omp_get_max_threads=%d\n",omp_get_max_threads());
#ifdef DEBUGC
mexPrintf("SOLVE_TWO_BOUNDARIES_COMPLETE\n");
mexEvalString("drawnow;");
......@@ -982,7 +1031,7 @@ Interpreter::simulate_a_block(int size,int type, string file_name, string bin_ba
Per_u_=0;
Per_y_=it_*y_size;
set_code_pointer(begining);
compute_block_time();
compute_block_time(0);
linbcg.Initialize(filename, res1, res2, max_res, slowc, ya, direction, iter);
linbcg.Preconditioner(periods, y_kmin, y_kmax, size, IM_i, index_vara, index_equa, y_size, y, true, 0, a, indx);
#endif
......@@ -1012,7 +1061,7 @@ Interpreter::simulate_a_block(int size,int type, string file_name, string bin_ba
//mexPrintf("ok\n");
//mexPrintf("compute_block_time\n");
set_code_pointer(begining);
compute_block_time();
compute_block_time(Per_u_);
//mexPrintf("end of compute_block_time\n");
/*if(Gaussian_Elimination)
initialize(periods, nb_endo, y_kmin, y_kmax, y_size, u_count, u_count_init, u, y, ya, slowc, y_decal, markowitz_c, res1, res2, max_res);*/
......@@ -1084,7 +1133,7 @@ Interpreter::simulate_a_block(int size,int type, string file_name, string bin_ba
Per_u_=(it_-y_kmin)*max_lag_plus_max_lead_plus_1;
Per_y_=it_*y_size;
set_code_pointer(begining);
compute_block_time();
compute_block_time(Per_u_);
#ifdef PRINT_OUT
for (j=0; j<max_lag_plus_max_lead_plus_1; j++)
{
......@@ -1092,6 +1141,10 @@ Interpreter::simulate_a_block(int size,int type, string file_name, string bin_ba
}
mexPrintf("\n");
#endif
/*mexPrintf("it_=%d ",it_);
for(i=0; i<y_size; i++)
mexPrintf(" %f",y[i]);
mexPrintf("\n");*/
}
res1=res2=max_res=0;
if(Gaussian_Elimination)
......@@ -1103,6 +1156,14 @@ Interpreter::simulate_a_block(int size,int type, string file_name, string bin_ba
linbcg.SolveLinear(periods, y_kmin, y_kmax, size, IM_i, index_vara, index_equa, y_size, y, true, cvg, a, indx);
#endif
}
/*mexPrintf("Two boundaries simulation\n");
for (it_=y_kmin;it_<periods+y_kmin;it_++)
{
mexPrintf("it_=%d ",it_);
for(i=0; i<y_size; i++)
mexPrintf(" %f",y[i+it_*y_size]);
mexPrintf("\n");
}*/
}
#ifdef DEBUGC
//mexErrMsgTxt("End of simulate");
......
......@@ -63,7 +63,7 @@ class Interpreter : SparseMatrix
{
protected :
double pow1(double a, double b);
void compute_block_time();
void compute_block_time(int Per_u_);
void simulate_a_block(int size,int type, string file_name, string bin_basename, bool Gaussian_Elimination);
double *T;
vector<Block_contain_type> Block_Contain;
......
......@@ -277,7 +277,7 @@ void
Mem_Mngr::Free_All()
{
int i;
for (int i=0;i<Nb_CHUNK;i++)
for (i=0;i<Nb_CHUNK;i++)
{
mxFree(NZE_Mem_add[i*CHUNK_BLCK_SIZE]);
}
......
This diff is collapsed.
......@@ -26,7 +26,12 @@
#include <map>
#include <ctime>
#include "Mem_Mngr.hh"
//! Openmp is available in GCC since version 4.3.2
//! Test if GCC version is greater then 4.3.2 order to avoid a copilation error
#define GNUVER 100*__GNUC__+10*__GNUC_MINOR__+__GNUC_PATCHLEVEL__
#if GNUVER >= 432
#include <omp.h>
#endif
#define NEW_ALLOC
#define MARKOVITZ
//#define MEMORY_LEAKS
......@@ -71,6 +76,7 @@ class SparseMatrix
public:
SparseMatrix();
int simulate_NG1(int blck, int y_size, int it_, int y_kmin, int y_kmax, int Size, int periods, bool print_it, bool cvg, int &iter);
int simulate_NG(int blck, int y_size, int it_, int y_kmin, int y_kmax, int Size, bool print_it, bool cvg, int &iter);
void Direct_Simulate(int blck, int y_size, int it_, int y_kmin, int y_kmax, int Size, int periods, bool print_it, int iter);
void fixe_u(double **u, int u_count_int, int max_lag_plus_max_lead_plus_1);
//void initialize(int periods_arg, int nb_endo_arg, int y_kmin_arg, int y_kmax_arg, int y_size_arg, int u_count_arg, int u_count_init_arg, double *u_arg, double *y_arg, double *ya_arg, double slowc_arg, int y_decal_arg, double markowitz_c_arg, double res1_arg, double res2_arg, double max_res_arg);
......@@ -80,6 +86,7 @@ class SparseMatrix
private:
void Init(int periods, int y_kmin, int y_kmax, int Size, map<pair<pair<int, int> ,int>, int> IM);
void ShortInit(int periods, int y_kmin, int y_kmax, int Size, map<pair<pair<int, int> ,int>, int> IM);
void Simple_Init(int it_, int y_kmin, int y_kmax, int Size, std::map<std::pair<std::pair<int, int> ,int>, int> IM);
void End(int Size);
bool compare( int *save_op, int *save_opa, int *save_opaa, int beg_t, int periods, long int nop4, int Size
#ifdef PROFILER
......@@ -106,6 +113,7 @@ class SparseMatrix
, long int *nmul
#endif
);
double simple_bksub(int it_, int Size, double slowc_l);
void run_triangular(int nop_all,int *op_all);
void run_it(int nop_all,int *op_all);
void run_u_period1(int periods);
......
......@@ -147,10 +147,11 @@ NumConstNode::eval(const eval_context_type &eval_context) const throw (EvalExcep
}
void
NumConstNode::compile(ofstream &CompileCode, bool lhs_rhs, ExprNodeOutputType output_type, const temporary_terms_type &temporary_terms, map_idx_type map_idx) const
NumConstNode::compile(ofstream &CompileCode, bool lhs_rhs, ExprNodeOutputType output_type, const temporary_terms_type &temporary_terms, map_idx_type &map_idx) const
{
CompileCode.write(&FLDC, sizeof(FLDC));
double vard=atof(datatree.num_constants.get(id).c_str());
//double vard=id;
#ifdef DEBUGC
cout << "FLDC " << vard << "\n";
#endif
......@@ -427,7 +428,7 @@ VariableNode::eval(const eval_context_type &eval_context) const throw (EvalExcep
}
void
VariableNode::compile(ofstream &CompileCode, bool lhs_rhs, ExprNodeOutputType output_type, const temporary_terms_type &temporary_terms, map_idx_type map_idx) const
VariableNode::compile(ofstream &CompileCode, bool lhs_rhs, ExprNodeOutputType output_type, const temporary_terms_type &temporary_terms, map_idx_type &map_idx) const
{
int i, lagl;
#ifdef DEBUGC
......@@ -892,7 +893,7 @@ UnaryOpNode::eval(const eval_context_type &eval_context) const throw (EvalExcept
}
void
UnaryOpNode::compile(ofstream &CompileCode, bool lhs_rhs, ExprNodeOutputType output_type, const temporary_terms_type &temporary_terms, map_idx_type map_idx) const
UnaryOpNode::compile(ofstream &CompileCode, bool lhs_rhs, ExprNodeOutputType output_type, const temporary_terms_type &temporary_terms, map_idx_type &map_idx) const
{
temporary_terms_type::const_iterator it = temporary_terms.find(const_cast<UnaryOpNode *>(this));
if (it != temporary_terms.end())
......@@ -1164,8 +1165,6 @@ BinaryOpNode::computeTemporaryTerms(map<NodeID, int> &reference_count,
reference_count[this2]++;
if (reference_count[this2] * cost(temporary_terms, false) > MIN_COST_C)
{
if(this2->idx==2280)
cout << "==>Curr_block= " << Curr_block << " equation= " << equation << " first_occurence[this2].first=" << first_occurence[this2].first << " first_occurence[this2].second=" << first_occurence[this2].second << "\n";
temporary_terms.insert(this2);
ModelBlock->Block_List[first_occurence[this2].first].Temporary_Terms_in_Equation[first_occurence[this2].second]->insert(this2);
}
......@@ -1226,7 +1225,7 @@ BinaryOpNode::eval(const eval_context_type &eval_context) const throw (EvalExcep
}
void
BinaryOpNode::compile(ofstream &CompileCode, bool lhs_rhs, ExprNodeOutputType output_type, const temporary_terms_type &temporary_terms, map_idx_type map_idx) const
BinaryOpNode::compile(ofstream &CompileCode, bool lhs_rhs, ExprNodeOutputType output_type, const temporary_terms_type &temporary_terms, map_idx_type &map_idx) const
{
// If current node is a temporary term
temporary_terms_type::const_iterator it = temporary_terms.find(const_cast<BinaryOpNode *>(this));
......@@ -1580,8 +1579,6 @@ TrinaryOpNode::computeTemporaryTerms(map<NodeID, int> &reference_count,
reference_count[this2]++;
if (reference_count[this2] * cost(temporary_terms, false) > MIN_COST_C)
{
if(this2->idx==2280)
cout << "==>Curr_block= " << Curr_block << " equation= " << equation << " first_occurence[this2].first=" << first_occurence[this2].first << " first_occurence[this2].second=" << first_occurence[this2].second << "\n";
temporary_terms.insert(this2);
ModelBlock->Block_List[first_occurence[this2].first].Temporary_Terms_in_Equation[first_occurence[this2].second]->insert(this2);
}
......@@ -1613,7 +1610,7 @@ TrinaryOpNode::eval(const eval_context_type &eval_context) const throw (EvalExce
void
TrinaryOpNode::compile(ofstream &CompileCode, bool lhs_rhs, ExprNodeOutputType output_type,
const temporary_terms_type &temporary_terms, map_idx_type map_idx) const
const temporary_terms_type &temporary_terms, map_idx_type &map_idx) const
{
// If current node is a temporary term
temporary_terms_type::const_iterator it = temporary_terms.find(const_cast<TrinaryOpNode *>(this));
......@@ -1788,7 +1785,7 @@ UnknownFunctionNode::eval(const eval_context_type &eval_context) const throw (Ev
}
void
UnknownFunctionNode::compile(ofstream &CompileCode, bool lhs_rhs, ExprNodeOutputType output_type, const temporary_terms_type &temporary_terms, map_idx_type map_idx) const
UnknownFunctionNode::compile(ofstream &CompileCode, bool lhs_rhs, ExprNodeOutputType output_type, const temporary_terms_type &temporary_terms, map_idx_type &map_idx) const
{
cerr << "UnknownFunctionNode::compile: operation impossible!" << endl;
exit(EXIT_FAILURE);
......
......@@ -33,7 +33,6 @@ OBJS = \
IncidenceMatrix.o \
BlockTriangular.o \
Model_Graph.o \
SymbolGaussElim.o \
DynareMain.o \
DynareMain2.o
......
......@@ -125,7 +125,7 @@ ModFile::evalAllExpressions()
cout << "error in evaluation of variable\n";
}
}
if(mod_file_struct.load_params_and_steady_state_present && init_values.size()<symbol_table.endo_nbr+symbol_table.exo_nbr+symbol_table.exo_det_nbr)
if(mod_file_struct.load_params_and_steady_state_present && int(init_values.size())<symbol_table.endo_nbr+symbol_table.exo_nbr+symbol_table.exo_det_nbr)
{
for(j=0;j <symbol_table.endo_nbr; j++)
{
......@@ -200,7 +200,7 @@ ModFile::evalAllExpressions()
}
}
}
if(init_values.size()<symbol_table.endo_nbr+symbol_table.exo_nbr+symbol_table.exo_det_nbr)
if(int(init_values.size())<symbol_table.endo_nbr+symbol_table.exo_nbr+symbol_table.exo_det_nbr)
{
cout << "\nWarning: Uninitialized variable: \n";
cout << "Endogenous\n";
......@@ -246,7 +246,7 @@ ModFile::evalAllExpressions()
cout << "error in evaluation of pound\n";
}
}
if(model_tree.local_variables_table.size()!=symbol_table.model_local_variable_nbr+symbol_table.modfile_local_variable_nbr)
if(int(model_tree.local_variables_table.size())!=symbol_table.model_local_variable_nbr+symbol_table.modfile_local_variable_nbr)
{
cout << "Warning: Unitilialized pound: \n";
cout << "Local variable in a model\n";
......@@ -398,7 +398,7 @@ ModFile::writeOutputFiles(const string &basename, bool clear_all) const
mOutputFile << "logname_ = '" << basename << ".log';" << endl;
mOutputFile << "diary " << basename << ".log" << endl;
mOutputFile << "options_.model_mode = " << model_tree.mode << ";\n";
if (model_tree.mode == eSparseMode)
if (model_tree.mode == eSparseMode || model_tree.mode == eSparseDLLMode)
{
mOutputFile << "addpath " << basename << ";\n";
mOutputFile << "delete('" << basename << "_static.m');\n";
......@@ -408,7 +408,7 @@ ModFile::writeOutputFiles(const string &basename, bool clear_all) const
if (model_tree.equation_number() > 0)
{
if (model_tree.mode == eDLLMode)
if (model_tree.mode == eDLLMode || model_tree.mode == eSparseDLLMode)
{
mOutputFile << "if exist('" << basename << "_static.c')" << endl;
mOutputFile << " clear " << basename << "_static" << endl;
......@@ -425,7 +425,6 @@ ModFile::writeOutputFiles(const string &basename, bool clear_all) const
mOutputFile << "erase_compiled_function('" + basename +"_dynamic');" << endl;
}
}
cout << "Processing outputs ...";
symbol_table.writeOutput(mOutputFile);
......@@ -448,9 +447,10 @@ ModFile::writeOutputFiles(const string &basename, bool clear_all) const
mOutputFile << "save('" << basename << "_results.mat', 'oo_', 'M_', 'options_');" << endl;
mOutputFile << "diary off" << endl;
if (model_tree.mode == eSparseMode)
if (model_tree.mode == eSparseMode || model_tree.mode == eSparseDLLMode)
mOutputFile << "rmpath " << basename << ";\n";
mOutputFile << endl << "disp(['Total computing time : ' dynsec2hms(toc) ]);" << endl;
mOutputFile.close();
cout << "done\n";
}
......@@ -73,7 +73,7 @@ ModelTree::writeDerivative(ostream &output, int eq, int symb_id, int lag,
}
void
ModelTree::compileDerivative(ofstream &code_file, int eq, int symb_id, int lag, ExprNodeOutputType output_type, map_idx_type map_idx) const
ModelTree::compileDerivative(ofstream &code_file, int eq, int symb_id, int lag, ExprNodeOutputType output_type, map_idx_type &map_idx) const
{
first_derivatives_type::const_iterator it = first_derivatives.find(make_pair(eq, variable_table.getID(eEndogenous, symb_id, lag)));
if (it != first_derivatives.end())
......@@ -1082,7 +1082,7 @@ end:
void
ModelTree::writeModelEquationsCodeOrdered(const string file_name, const Model_Block *ModelBlock, const string bin_basename, ExprNodeOutputType output_type) const
ModelTree::writeModelEquationsCodeOrdered(const string file_name, const Model_Block *ModelBlock, const string bin_basename, ExprNodeOutputType output_type, map_idx_type map_idx) const
{
struct Uff_l
{
......@@ -1107,7 +1107,8 @@ ModelTree::writeModelEquationsCodeOrdered(const string file_name, const Model_Bl
map<NodeID, int> reference_count;
map<int,int> ModelBlock_Aggregated_Size, ModelBlock_Aggregated_Number;
int prev_Simulation_Type=-1;
SymbolicGaussElimination SGE;
//SymbolicGaussElimination SGE;
bool file_open=false;
temporary_terms_type::const_iterator it_temp=temporary_terms.begin();
//----------------------------------------------------------------------
string main_name=file_name;
......@@ -1180,14 +1181,15 @@ ModelTree::writeModelEquationsCodeOrdered(const string file_name, const Model_Bl
code_file.write(reinterpret_cast<char *>(&v),sizeof(v));
v=block_triangular.ModelBlock->Block_List[j].Max_Lead;
code_file.write(reinterpret_cast<char *>(&v),sizeof(v));
if (ModelBlock->Block_List[j].Simulation_Type==SOLVE_TWO_BOUNDARIES_COMPLETE || ModelBlock->Block_List[j].Simulation_Type==SOLVE_TWO_BOUNDARIES_SIMPLE)
{
//if (ModelBlock->Block_List[j].Simulation_Type==SOLVE_TWO_BOUNDARIES_COMPLETE || ModelBlock->Block_List[j].Simulation_Type==SOLVE_TWO_BOUNDARIES_SIMPLE)
//{
int u_count_int=0;
Write_Inf_To_Bin_File(file_name, bin_basename, j, u_count_int,SGE.file_open);
Write_Inf_To_Bin_File(file_name, bin_basename, j, u_count_int,file_open,
ModelBlock->Block_List[j].Simulation_Type==SOLVE_TWO_BOUNDARIES_COMPLETE || ModelBlock->Block_List[j].Simulation_Type==SOLVE_TWO_BOUNDARIES_SIMPLE);
v=u_count_int;
code_file.write(reinterpret_cast<char *>(&v),sizeof(v));
SGE.file_is_open();
}
file_open=true;
//}
}
for (k1 = 0; k1 < ModelBlock_Aggregated_Size[k0]; k1++)
{
......@@ -1821,7 +1823,7 @@ ModelTree::reform(const string name1) const
void
ModelTree::Write_Inf_To_Bin_File(const string &dynamic_basename, const string &bin_basename, const int &num,
int &u_count_int, bool &file_open) const
int &u_count_int, bool &file_open, bool is_two_boundaries) const
{
int j;
std::ofstream SaveCode;
......@@ -1850,19 +1852,22 @@ ModelTree::Write_Inf_To_Bin_File(const string &dynamic_basename, const string &b
u_count_int++;
}
}
for (j=0;j<block_triangular.ModelBlock->Block_List[num].Size;j++)
if(is_two_boundaries)
{
int eqr1=j;
int varr=block_triangular.ModelBlock->Block_List[num].Size*(block_triangular.periods
+block_triangular.incidencematrix.Model_Max_Lead_Endo);
int k1=0;
SaveCode.write(reinterpret_cast<char *>(&eqr1), sizeof(eqr1));
SaveCode.write(reinterpret_cast<char *>(&varr), sizeof(varr));
SaveCode.write(reinterpret_cast<char *>(&k1), sizeof(k1));
SaveCode.write(reinterpret_cast<char *>(&eqr1), sizeof(eqr1));
u_count_int++;
for (j=0;j<block_triangular.ModelBlock->Block_List[num].Size;j++)
{
int eqr1=j;
int varr=block_triangular.ModelBlock->Block_List[num].Size*(block_triangular.periods
+block_triangular.incidencematrix.Model_Max_Lead_Endo);
int k1=0;
SaveCode.write(reinterpret_cast<char *>(&eqr1), sizeof(eqr1));
SaveCode.write(reinterpret_cast<char *>(&varr), sizeof(varr));
SaveCode.write(reinterpret_cast<char *>(&k1), sizeof(k1));
SaveCode.write(reinterpret_cast<char *>(&eqr1), sizeof(eqr1));
u_count_int++;
}
}
//cout << "u_count_int=" << u_count_int << "\n";
for (j=0;j<block_triangular.ModelBlock->Block_List[num].Size;j++)
{
int varr=block_triangular.ModelBlock->Block_List[num].Variable[j];
......@@ -2103,7 +2108,7 @@ ModelTree::writeSparseDynamicMFile(const string &dynamic_basename, const string
ofstream mDynamicModelFile;
ostringstream tmp, tmp1, tmp_eq;
int prev_Simulation_Type, tmp_i;
SymbolicGaussElimination SGE;
//SymbolicGaussElimination SGE;
bool OK;
chdir(basename.c_str());
string filename = dynamic_basename + ".m";
......@@ -2121,7 +2126,7 @@ ModelTree::writeSparseDynamicMFile(const string &dynamic_basename, const string
mDynamicModelFile << "%/\n";
int i, k, Nb_SGE=0;
bool printed = false, skip_head, open_par=false;
bool skip_head, open_par=false;