2013-03-22 16:34:50 +01:00
|
|
|
/*
|
2022-02-15 16:15:38 +01:00
|
|
|
* Copyright © 2007-2022 Dynare Team
|
2013-03-22 16:34:50 +01:00
|
|
|
*
|
|
|
|
* This file is part of Dynare.
|
|
|
|
*
|
|
|
|
* Dynare is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* Dynare is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2021-06-09 17:33:48 +02:00
|
|
|
* along with Dynare. If not, see <https://www.gnu.org/licenses/>.
|
2013-03-22 16:34:50 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef EVALUATE_HH_INCLUDED
|
|
|
|
#define EVALUATE_HH_INCLUDED
|
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
#include <string>
|
2021-02-09 15:55:36 +01:00
|
|
|
|
|
|
|
#include "dynmex.h"
|
|
|
|
|
2022-06-16 18:05:00 +02:00
|
|
|
#define BYTECODE_MEX
|
|
|
|
#include "Bytecode.hh"
|
2013-03-22 16:34:50 +01:00
|
|
|
#include "ErrorHandling.hh"
|
|
|
|
|
|
|
|
class Evaluate : public ErrorMsg
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
int EQN_lag1, EQN_lag2, EQN_lag3;
|
2022-07-25 16:20:19 +02:00
|
|
|
map<int, double> TEF;
|
|
|
|
map<pair<int, int>, double> TEFD;
|
|
|
|
map<tuple<int, int, int>, double> TEFDD;
|
|
|
|
|
2013-03-22 16:34:50 +01:00
|
|
|
protected:
|
2022-07-25 16:20:19 +02:00
|
|
|
double *y, *ya;
|
|
|
|
int y_size;
|
|
|
|
double *T;
|
|
|
|
int nb_row_x, col_x, col_y;
|
|
|
|
int y_kmin, y_kmax, periods;
|
|
|
|
double *x, *params;
|
|
|
|
double *u;
|
|
|
|
double *steady_y, *steady_x;
|
|
|
|
double *g1, *r, *res;
|
|
|
|
vector<mxArray *> jacobian_block, jacobian_other_endo_block, jacobian_exo_block, jacobian_det_exo_block;
|
2013-03-22 16:34:50 +01:00
|
|
|
mxArray *GlobalTemporaryTerms;
|
|
|
|
it_code_type start_code, end_code;
|
|
|
|
double pow1(double a, double b);
|
|
|
|
double divide(double a, double b);
|
|
|
|
double log1(double a);
|
|
|
|
double log10_1(double a);
|
2021-02-03 18:10:01 +01:00
|
|
|
void evaluate_over_periods(bool forward);
|
2013-03-22 16:34:50 +01:00
|
|
|
void solve_simple_one_periods();
|
2021-02-03 18:10:01 +01:00
|
|
|
void solve_simple_over_periods(bool forward);
|
|
|
|
void compute_block_time(int Per_u_, bool evaluate, bool no_derivatives);
|
2013-03-22 16:34:50 +01:00
|
|
|
code_liste_type code_liste;
|
|
|
|
it_code_type it_code;
|
|
|
|
int Block_Count, Per_u_, Per_y_;
|
|
|
|
int it_;
|
|
|
|
int maxit_, size_of_direction;
|
|
|
|
double *direction;
|
|
|
|
double solve_tolf;
|
|
|
|
bool GaussSeidel;
|
2017-05-16 16:30:27 +02:00
|
|
|
int equation, derivative_equation, derivative_variable;
|
2013-03-22 16:34:50 +01:00
|
|
|
string filename;
|
|
|
|
int stack_solve_algo, solve_algo;
|
|
|
|
bool global_temporary_terms;
|
|
|
|
bool print, print_error;
|
|
|
|
double res1, res2, max_res;
|
2017-05-16 16:30:27 +02:00
|
|
|
int max_res_idx;
|
2013-03-22 16:34:50 +01:00
|
|
|
vector<Block_contain_type> Block_Contain;
|
|
|
|
|
|
|
|
int size;
|
2019-12-20 14:50:19 +01:00
|
|
|
int *index_vara;
|
2013-03-22 16:34:50 +01:00
|
|
|
|
|
|
|
bool print_it, forward;
|
|
|
|
int minimal_solving_periods;
|
2022-06-20 16:26:58 +02:00
|
|
|
BlockSimulationType type;
|
|
|
|
int block_num, symbol_table_endo_nbr, Block_List_Max_Lag, Block_List_Max_Lead, u_count_int, block;
|
2013-03-22 16:34:50 +01:00
|
|
|
string file_name, bin_base_name;
|
|
|
|
bool Gaussian_Elimination, is_linear;
|
|
|
|
public:
|
|
|
|
bool steady_state;
|
2022-03-31 17:39:43 +02:00
|
|
|
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);
|
2022-06-20 16:26:58 +02:00
|
|
|
void set_block(int size_arg, BlockSimulationType type_arg, string file_name_arg, string bin_base_name_arg, int block_num_arg,
|
2021-02-03 18:10:01 +01:00
|
|
|
bool is_linear_arg, int symbol_table_endo_nbr_arg, int Block_List_Max_Lag_arg, int Block_List_Max_Lead_arg, int u_count_int_arg, int block_arg);
|
|
|
|
void evaluate_complete(bool no_derivatives);
|
|
|
|
bool compute_complete(bool no_derivatives, double &res1, double &res2, double &max_res, int &max_res_idx);
|
|
|
|
void compute_complete_2b(bool no_derivatives, double *_res1, double *_res2, double *_max_res, int *_max_res_idx);
|
2013-03-22 16:34:50 +01:00
|
|
|
|
|
|
|
bool compute_complete(double lambda, double *crit);
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|