Commit Graph

139 Commits (aad8414f94b30a3024bdb759897f100036bf3e95)

Author SHA1 Message Date
Sébastien Villemot 66a766b0b7
Small modernization 2018-12-04 18:41:04 +01:00
Sébastien Villemot 571b5d0816
Computation of temporary terms generalized to any derivation order 2018-11-30 12:22:13 +01:00
Sébastien Villemot 67ac4bf8ea
Allow diff() and log() in "expression" option of var_expectation_model 2018-11-29 16:01:49 +01:00
Sébastien Villemot e9341c7153
Implement option "expression" of var_expectation_model
The data structure written in the driver file is changed also in the case of
the "variable" option.
2018-11-28 17:33:59 +01:00
Sébastien Villemot b88e0de53f
Remove useless accessor methods for data members that are const in ExprNode classes
Those const data members are simply made public.
2018-11-28 14:35:30 +01:00
Houtan Bastani 41af0841c3
extend nopreprocessoroutput option to substitution output 2018-11-28 11:53:50 +01:00
Sébastien Villemot 16a97a96fd
Rewrite engine for matching the non-optimizing agents part in PAC
The engine is now more robust and should reject any expression that does not
conform to the expected form. It is also able to deal with more cases, such as
terms appearing with a minus sign, or variables in the middle of a
three-factors product.

BTW, use a std::tuple for storing the result of the matching inside
PacExpectationNode, and change the order of components within the
structure (variable first, scalar last).
2018-11-27 19:03:35 +01:00
Sébastien Villemot fa039b8c41
Fix bug in block decomposition with treatment of varexo_det 2018-11-23 17:39:18 +01:00
Sébastien Villemot d733f3fb5a
Various simplifications and modernizations of the block/bytecode part 2018-11-23 17:19:59 +01:00
Sébastien Villemot fc9cc2dc50
Output symmetric elements in derivatives of hessian w.r.t. parameters
The preprocessor now writes all the symmetric elements in the "hp"
matrix (derivatives of the hessian w.r.t. parameters), for consistency with all
other derivatives output.

Previously it was only writing one of the two symmetric elements, when indices
of endogenous were different.
2018-11-22 17:51:14 +01:00
Sébastien Villemot e3a3992c1c
Derivation engine w.r.t. parameters generalized to any order
Also, no longer compute two times symmetric elements in derivation w.r.t.
parameters at order 2, for consistency with derivation w.r.t. endogenous.
It is therefore now necessary to duplicate them in the output to keep behavior
unchanged.
2018-11-22 17:13:55 +01:00
Sébastien Villemot 6fa115aedd
Derivation engine w.r.t. endogenous generalized to any order 2018-11-22 17:13:55 +01:00
Sébastien Villemot 33994dde03
Optimization for use_dll at 2nd and 3rd order
When creating the sparse matrix (in MATLAB or C mode), since storage is in
column-major order, output the first column, then the second, then the third.
This gives a significant performance boost in use_dll mode (at both compilation
and runtime), because it facilitates memory accesses and expression reusage.
2018-11-19 16:03:47 +01:00
Sébastien Villemot b524e19cde
Remove duplicate storage of temp terms for params derivs in ModelTree 2018-11-16 18:26:36 +01:00
Sébastien Villemot e9b5f239df
Properly deal with model local variables in params derivatives file
Closes #13
2018-11-16 18:26:11 +01:00
Sébastien Villemot 3d2125287a
Temporary terms: various simplifications and added comments 2018-11-16 17:11:06 +01:00
Sébastien Villemot e89dd9cb8b
Make storage of derivatives ready for k-order
This is the first step towards computing k-order derivatives.

Ref Dynare/dynare#217, #10
2018-11-15 17:48:46 +01:00
Sébastien Villemot 4a974bb428
The preprocessor now compiles the MEX when use_dll is specified
New options "mexext" and "matlabroot" are introduced, so that the preprocessor
knows where to find MATLAB and which architecture to compile for.

Only recent gcc is now supported. A set of optimization flags is used so that
compilation goes reasonably fast on large models.

Consequently, options "msvc", "mingw" and "cygwin" have been removed.
2018-10-26 18:09:13 +02:00
Houtan Bastani bef7c2a193 remove need to declare equations nonstationary 2018-10-24 16:04:51 +02:00
Sébastien Villemot ac94ad906e Various fixes for silencing errors and warnings under Clang 6 2018-10-11 11:21:58 +02:00
Sébastien Villemot bcdfb43fd3 Replate DynamicModel::toStatic() by a converting constructor in StaticModel
It is therefore now possible to write:

  static_model = static_cast<StaticModel>(dynamic_model);
2018-10-10 17:08:54 +02:00
Sébastien Villemot 63a5ffb761 Rename ExprNode::cloneDynamic into ExprNode::clone, for clarity 2018-10-10 13:08:11 +02:00
Sébastien Villemot f2cf86b734 Add copy constructors / assignment operators for the DataTree class hierarchy
In particular, it is necessary to turn back DataTree::AddVariable() into a
non-virtual method, because it is called from DataTree's constructor. Enforcing
the absence of leads/lags is now done using a new boolean DataTree::is_static.

Take advantage of the new copy constructor for handling
PlannerObjectiveStatement more elegantly.

Unfortunately it is not possible to implement *move* constructor / assigment
operators, because the reference ExprNode::datatree is not mutable.
2018-10-10 12:53:55 +02:00
Sébastien Villemot 215283005e No longer store symbol type in VariableNode
This facilitates switching variable types on the fly. In particular, this
allows removing the hack in DynamicModel::updateAfterVariableChange() that way
basically recreating all the nodes after the type change.
2018-10-10 12:34:05 +02:00
Sébastien Villemot 7bb5382428 Always use brace-initializer in constructors
The syntax makes clearer the distinction between a function call and an
initialization. Also, it prevents bugs due to implicit type conversions.
2018-10-04 17:19:18 +02:00
Sébastien Villemot 5e6b8f0a6b No longer test for __MINGW32__ macro, testing for _WIN32 is enough
Closes: Dynare/dynare#1315
2018-10-02 16:50:07 +02:00
Sébastien Villemot 15d026e54e C output: split generated function into several smaller subfunctions
This mimicks the structure of M-functions (though the logic for filling the
temporary terms vector is a bit different).

This change implied a modification in the way we compute the checksum in case
of block decomposition (the temporary terms for the C output are not correctly
computed in that case).
2018-10-01 16:04:01 +02:00
Ferhat Mihoubi 139e3efa82 Adds a new model option "linear_decomposition" that creates a block composed of the non-linear equations o the model 2018-09-28 14:54:52 +02:00
Houtan Bastani 63a334cfd3 fix typo 2018-09-27 10:47:13 +02:00
Sébastien Villemot c6cb9aa1b8 Fix bug in option notmpterms with model local variables
Since model local variables are now treated as temporary terms, they must be
marked as such even when option notmpterms is present.
2018-09-25 15:57:56 +02:00
Houtan Bastani 7282b7bf32 fix bug in filling of var AR matrix 2018-09-25 15:47:52 +02:00
Houtan Bastani c9f5cef99b write AST in JSON 2018-09-18 17:48:04 +02:00
Houtan Bastani 9f9c8fdfbf fix typo 2018-09-18 14:50:54 +02:00
Houtan Bastani 85dbb649b7 move trend_component_table and var_model_table to DynamicModel as they are only used there 2018-09-14 17:04:06 +02:00
Houtan Bastani eb74d48393 trend_component_model: replace `trends` option with `targets` 2018-09-13 12:21:23 +02:00
Houtan Bastani dc9ecbb49a fix bug in columns of EC matrix 2018-09-12 17:56:30 +02:00
Houtan Bastani 0376f7f173 fix bugs in creation of AR/EC matrices 2018-09-12 11:57:14 +02:00
Houtan Bastani aa120abd02 simplify code 2018-09-12 11:57:14 +02:00
Houtan Bastani f71c861d5e output EC matrix in file for trend component models 2018-09-10 17:44:04 +02:00
Houtan Bastani 46709ada3f output AR matrix in file for trend component models 2018-09-10 14:51:33 +02:00
Houtan Bastani f5e5dea1be support hard-coded parameters and parameter expressions in AR matrix 2018-09-07 10:14:18 +02:00
Houtan Bastani acc197f539 output AR matrix in file 2018-09-06 18:00:05 +02:00
Sébastien Villemot e19a14869e Convert ExprNodeOutputType into a class enum
Incidentally, replace the IS_* macros by inline functions.
2018-09-05 18:28:32 +02:00
Houtan Bastani 8584323563 provide information on order of ec.vars 2018-09-04 10:39:05 +02:00
Houtan Bastani 27c9a9a5e0 store LHS of trend equation in trend_vars 2018-09-03 17:25:42 +02:00
Houtan Bastani 7a438a3ce7 ensure that trend_variable found is actually a trend variable as declared in the trend_component_model statement 2018-09-03 15:05:30 +02:00
Houtan Bastani fde836d7fe trend_component_model: find trend_vars associated with equation 2018-08-31 14:24:44 +02:00
Houtan Bastani 948e8cb6e4 fix bug in creation of ec vars for pac equation 2018-08-28 16:00:25 +02:00
Houtan Bastani d5d6e8beb0 simplify updating of RHS variables for trend component and var models 2018-08-23 13:57:27 +02:00
Houtan Bastani 16f10d954f don’t rely on scope: clean up iterator names 2018-08-23 13:03:52 +02:00