Bytecode: diminish the number of data members in Evaluate class

silicon
Sébastien Villemot 2023-02-17 13:46:41 -05:00
parent aee39d54ef
commit 05ba2970be
No known key found for this signature in database
GPG Key ID: 2CECE9350ECEBE4A
7 changed files with 28 additions and 27 deletions

View File

@ -25,9 +25,8 @@
#include "Evaluate.hh"
#include "CommonEnums.hh"
Evaluate::Evaluate(int y_size_arg, int y_kmin_arg, int y_kmax_arg, bool print_it_arg, bool steady_state_arg, int periods_arg, int minimal_solving_periods_arg, BasicSymbolTable &symbol_table_arg) :
symbol_table {symbol_table_arg},
print_it(print_it_arg), minimal_solving_periods(minimal_solving_periods_arg)
Evaluate::Evaluate(int y_size_arg, int y_kmin_arg, int y_kmax_arg, bool steady_state_arg, int periods_arg, BasicSymbolTable &symbol_table_arg) :
symbol_table {symbol_table_arg}
{
symbol_table_endo_nbr = 0;
u_count_int = 0;

View File

@ -50,11 +50,11 @@ protected:
double *y, *ya;
int y_size;
double *T;
int nb_row_x, col_x, col_y;
int nb_row_x;
int y_kmin, y_kmax, periods;
double *x, *params;
double *u;
double *steady_y, *steady_x;
double *steady_y;
double *g1, *r, *res;
vector<mxArray *> jacobian_block, jacobian_exo_block, jacobian_det_exo_block;
mxArray *GlobalTemporaryTerms;
@ -69,17 +69,12 @@ protected:
void compute_block_time(int Per_u_, bool evaluate, bool no_derivatives);
instructions_list_t code_liste;
it_code_type it_code;
int Block_Count, Per_u_, Per_y_;
int Per_u_, Per_y_;
int it_;
int maxit_, size_of_direction;
int maxit_;
double *direction;
double solve_tolf;
bool GaussSeidel;
int equation, derivative_equation, derivative_variable;
string filename;
int stack_solve_algo, solve_algo;
bool global_temporary_terms;
bool print, print_error;
bool print_error;
double res1, res2, max_res;
int max_res_idx;
vector<Block_contain_type> Block_Contain;
@ -87,12 +82,12 @@ protected:
int size;
int *index_vara;
bool print_it, forward;
int minimal_solving_periods;
BlockSimulationType type;
int block_num, symbol_table_endo_nbr, u_count_int, block;
string file_name, bin_base_name;
bool Gaussian_Elimination, is_linear;
bool is_linear;
bool steady_state;
/* Prints a bytecode expression in human readable form.
If faulty_op is not default constructed, it should point to a tag withing
@ -102,8 +97,7 @@ protected:
pair<string, it_code_type> print_expression(const it_code_type &expr_begin, const optional<it_code_type> &faulty_op = nullopt) const;
public:
bool steady_state;
Evaluate(int y_size_arg, int y_kmin_arg, int y_kmax_arg, bool print_it_arg, bool steady_state_arg, int periods_arg, int minimal_solving_periods_arg, BasicSymbolTable &symbol_table_arg);
Evaluate(int y_size_arg, int y_kmin_arg, int y_kmax_arg, bool steady_state_arg, int periods_arg, BasicSymbolTable &symbol_table_arg);
void set_block(int size_arg, BlockSimulationType type_arg, string file_name_arg, string bin_base_name_arg, int block_num_arg,
bool is_linear_arg, int symbol_table_endo_nbr_arg, int u_count_int_arg, int block_arg);
void evaluate_complete(bool no_derivatives);

View File

@ -26,7 +26,7 @@
constexpr double BIG = 1.0e+8, SMALL = 1.0e-5;
Interpreter::Interpreter(double *params_arg, double *y_arg, double *ya_arg, double *x_arg, double *steady_y_arg, double *steady_x_arg,
Interpreter::Interpreter(double *params_arg, double *y_arg, double *ya_arg, double *x_arg, double *steady_y_arg,
double *direction_arg, size_t y_size_arg,
size_t nb_row_x_arg, int periods_arg, int y_kmin_arg, int y_kmax_arg,
int maxit_arg_, double solve_tolf_arg, size_t size_of_direction_arg, int y_decal_arg, double markowitz_c_arg,
@ -40,7 +40,6 @@ Interpreter::Interpreter(double *params_arg, double *y_arg, double *ya_arg, doub
ya = ya_arg;
x = x_arg;
steady_y = steady_y_arg;
steady_x = steady_x_arg;
direction = direction_arg;
nb_row_x = nb_row_x_arg;
periods = periods_arg;

View File

@ -39,13 +39,18 @@ class Interpreter : public dynSparseMatrix
{
private:
vector<int> previous_block_exogenous;
int size_of_direction;
bool global_temporary_terms;
bool print;
int col_x, col_y;
int Block_Count;
protected:
void evaluate_a_block(bool initialization);
int simulate_a_block(const vector_table_conditional_local_type &vector_table_conditional_local);
void print_a_block();
string elastic(string str, unsigned int len, bool left);
public:
Interpreter(double *params_arg, double *y_arg, double *ya_arg, double *x_arg, double *steady_y_arg, double *steady_x_arg,
Interpreter(double *params_arg, double *y_arg, double *ya_arg, double *x_arg, double *steady_y_arg,
double *direction_arg, size_t y_size_arg,
size_t nb_row_x_arg, int periods_arg, int y_kmin_arg, int y_kmax_arg,
int maxit_arg_, double solve_tolf_arg, size_t size_of_direction_arg, int y_decal_arg, double markowitz_c_arg,

View File

@ -26,8 +26,10 @@
dynSparseMatrix::dynSparseMatrix(int y_size_arg, int y_kmin_arg, int y_kmax_arg, bool print_it_arg, bool steady_state_arg, bool block_decomposed_arg, int periods_arg,
int minimal_solving_periods_arg, BasicSymbolTable &symbol_table_arg) :
Evaluate {y_size_arg, y_kmin_arg, y_kmax_arg, print_it_arg, steady_state_arg, periods_arg, minimal_solving_periods_arg, symbol_table_arg},
block_decomposed {block_decomposed_arg}
Evaluate {y_size_arg, y_kmin_arg, y_kmax_arg, steady_state_arg, periods_arg, symbol_table_arg},
block_decomposed {block_decomposed_arg},
minimal_solving_periods {minimal_solving_periods_arg},
print_it {print_it_arg}
{
pivotva = nullptr;
g_save_op = nullptr;

View File

@ -174,7 +174,6 @@ protected:
double res1a;
long int nop_all, nop1, nop2;
map<tuple<int, int, int>, int> IM_i;
protected:
vector<double> residual;
int u_count_alloc, u_count_alloc_save;
vector<double *> jac;
@ -192,6 +191,10 @@ protected:
SuiteSparse_long *Ap_save, *Ai_save;
double *Ax_save, *b_save;
mxArray *A_m_save, *b_m_save;
int stack_solve_algo, solve_algo;
int minimal_solving_periods;
bool print_it;
};
#endif // _SPARSEMATRIX_HH

View File

@ -216,7 +216,7 @@ mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
int count_array_argument = 0;
bool global_temporary_terms = false;
bool print = false, print_error = true, print_it = false;
double *steady_yd = nullptr, *steady_xd = nullptr;
double *steady_yd = nullptr;
string plan, pfplan;
bool extended_path;
mxArray *extended_path_struct;
@ -584,7 +584,6 @@ mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
steady_row_y = mxGetM(steady_state_arr);
steady_col_y = mxGetN(steady_state_arr);
}
steady_xd = mxGetPr(mxGetFieldByNumber(oo_, 0, field_exo_steady_state));
}
else
{
@ -716,7 +715,7 @@ mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
size_t nb_row_x = row_x;
clock_t t0 = clock();
Interpreter interprete {params, y, ya, x, steady_yd, steady_xd, direction, y_size, nb_row_x,
Interpreter interprete {params, y, ya, x, steady_yd, direction, y_size, nb_row_x,
periods, y_kmin, y_kmax, maxit_, solve_tolf, size_of_direction, y_decal,
markowitz_c, file_name, minimal_solving_periods, stack_solve_algo,
solve_algo, global_temporary_terms, print, print_error, GlobalTemporaryTerms,