Commit Graph

76 Commits (4348f4d57f83aa8f96c3ec23899c33971e847428)

Author SHA1 Message Date
Sébastien Villemot 50d5b916e2
Remove constructor and accessors for AuxVarInfo
Rather make all data members public and const, and use aggregate-initialization.
2022-07-20 14:48:30 +02:00
Sébastien Villemot 13dc0a1144
Use operator""s to replace some calls to std::string constructor
By the way, remove other unnecessary calls to that constructor.
2022-06-22 12:47:11 +02:00
Sébastien Villemot c94dfb848c
C++20 modernization: use initialization within range-based for loop
In particular, use this feature in many loops which feature a special treatment
for the first iteration, using a boolean variable (replacing iterator
manipulation). By the way, also use std::exchange() to simultaneously test the
value of this variable and update it.
2022-06-07 14:35:59 +02:00
Sébastien Villemot 0b5c88109f
Various simplifications 2022-06-07 14:34:30 +02:00
Sébastien Villemot c6007aa780
C++17 modernization: use [[fallthrough]] attribute
This disables warnings when -Wimplicit-fallthrough is used (enabled by -Wextra).
2022-05-18 16:33:48 +02:00
Sébastien Villemot 06d05e9a8d
C++17 modernization: use std::optional for SymbolTable::getEquationNumberForMultiplier() 2022-05-16 19:10:16 +02:00
Sébastien Villemot fa7a926143
C++17 modernization: use std::optional for the storage of orig_symb_id and orig_lead_lag in SymbolTable
For the diff and unaryOp auxvar types, these value may be set or unset
depending on the complexity of the expression represented by the auxvar.
2022-05-16 19:10:15 +02:00
Sébastien Villemot b42ee40b55
C++20 modernization: use contains() method on containers 2022-05-04 17:37:57 +02:00
Sébastien Villemot ef02b79486
Various minor simplifications 2022-05-04 17:36:59 +02:00
Sébastien Villemot 71edfd05e4
Add new “log” option to “var” statement
When an endogenous is declared with “var(log)”, say “y”:
– creates an auxiliary named “LOG_y”
– replaces “y(±l)” everywhere by “exp(LOG_y(±l))”
– adds a new auxiliary equation “y=exp(LOG_y)”
– adds a new definition “LOG_y=log(y)” in set_auxiliary_variables.m and
  dynamic_set_auxiliary_series.m files

This option also works in conjunction with “deflator=…”, such as “var(log,
deflator=…)” (the “log” must appear befor “deflator”). There are no provisions
for combining “log” with “log_deflator”, because that would not make much sense
from an economic point of view (amounts to taking the log two times).

Ref. dynare#349
2022-03-30 17:46:07 +02:00
Sébastien Villemot 1e77f7c5a7
SymbolTable::getOrigSymbIdForAuxVar() now also works on unaryOp and diffForward auxvars
This is a more natural semantics.

Incidentally, this fixes a bug in the variable mapping (M_.mapping) where some
endogenous, appearing in a log() in a VAR or TCM, would not be mentioned (e.g.
in the var-expectations/7/example1.mod test, and many others).
2022-01-28 16:30:11 +01:00
Sébastien Villemot 28f89261ab
Minor simplification of SymbolTable::addDiffAuxiliaryVar()
For symmetry with SymbolTable::addUnaryOpAuxiliaryVar().
2022-01-28 16:01:44 +01:00
Sébastien Villemot a93e264c2c
Harmonize “diffForward” auxvar with “diff” auxvar by giving it an orig_lead_lag as well
By the way:
– Fix and improve the explanation of the purpose of the orig_symb_id and
  orig_lead_lag fields for auxvars
– Factorize the code that prints those fields in MATLAB and JSON output
2022-01-28 15:53:41 +01:00
Sébastien Villemot 289b4773d7
Fix matching of diff leads/lags in TCM and PAC models
The logic was flawed in several ways. In particular, the test files
pac/trend-component-{3,10,11}/example1.mod would return A0 and A0star matrices
where the (2,2) element was incorrectly zero.
2022-01-28 15:53:41 +01:00
Sébastien Villemot b709da7f17
Fix SymbolTable’s getOrigSymbIdForAuxVar() and getUltimateOrigSymbID() so that they never return -1
The case of a diff aux var corresponding to a complex expression was not
correctly handled, and could lead to a value -1 being returned by these
methods.
2022-01-28 15:53:39 +01:00
Sébastien Villemot ea6fb40db7
PAC: new “pac_target_info” block and “pac_target_nonstationary” operator
Ref. Madysson/estimation-codes#5
2021-12-16 15:40:47 +01:00
Sébastien Villemot 2282d4773c
PAC: new auxiliary variable type for pac_expectation operator
Also add the new equation to auxiliary equations in the backward case (but not
in the MCE case, since that equation is recursive).
2021-11-23 14:31:03 +01:00
Sébastien Villemot bc827326eb
JSON: fix syntax error in the aux vars table introduced in a7fb198463 2021-10-26 12:31:01 +02:00
MichelJuillard a7fb198463 add field aux_vars to modfile.json 2021-10-08 09:26:49 +02:00
Sébastien Villemot 67f4777ac3
Remove support for obsolete syntax: var_model(order = 2) X Y Z; 2021-07-07 18:26:09 +02:00
Sébastien Villemot 74ef3457b4
Use secure URL for link to GNU licenses 2021-06-09 17:21:00 +02:00
Sébastien Villemot c2d47fb48e
Julia: remove driver file
The Julia code now uses the JSON output for retrieving the information that
previously was in the driver file.
2021-04-19 17:02:41 +02:00
Michel Juillard c9dd241f5b
add varobs statement to JSON output 2021-04-01 17:05:12 +02:00
Sébastien Villemot db3ef925a7
Fix handling of diffLead in SymbolTable::getOrigLeadLagForDiffAuxVar() 2020-10-16 16:31:55 +02:00
Sébastien Villemot 8f31e443d6
SymbolTable::getTypeSpecificID() now throws an exception instead of returning -1 when symbol does not have a type-specific ID
This can potentially avoid some undetected bugs.
2020-09-23 17:09:36 +02:00
Sébastien Villemot 4e2538a2a2
Ensure original tags and line numbers are preserved with ramsey_model
In particular, introduce a method for clearing all equations, so that tags and
line numbers are also cleared.

Ref. dynare#1685
2020-01-06 18:26:35 +01:00
Sébastien Villemot e2d5a83592
Global reindentation 2019-12-20 16:59:30 +01:00
Sébastien Villemot d441ff059a
Fill the “M_.aux_vars(:).orig_expr” field for all auxiliary variables
This field contains a string representation of the expression that the
auxiliary variable replaces.

It is non-empty for all auxiliary variables, except for Lagrange multipliers.

Ref. dynare#773
2019-12-19 16:58:26 +01:00
Sébastien Villemot 031c0cff5f
Various code simplifications and modernizations 2019-12-16 19:42:59 +01:00
Sébastien Villemot d839aea08b
Drop unused functions for writing C and C++ output
These functions should have been deleted in
946d105c04.
2019-10-24 10:54:46 +02:00
Stéphane Adjemian (Charybdis) 84d57393dc Return empty list of names in models without parameters or exogenous variables. 2019-04-29 23:27:26 +02:00
Houtan Bastani 21fe0f4bdc
avoid cast warnings when compiling boost headers 2019-04-23 14:57:03 +02:00
Sébastien Villemot 1907249fac
Ask GCC to warn about C-style casts (-Wold-style-cast)
Adapt the code accordingly.
2019-04-23 12:54:11 +02:00
Sébastien Villemot b73d554ad2
Use Unicode copyright symbol (in UTF-8 encoding) 2019-04-16 11:35:31 +02:00
Sébastien Villemot 8a41a75c85
Apply modernize-raw-string-literal from clang-tidy
Use ReplaceShorterLiterals option to enforce replacement of all strings.

https://clang.llvm.org/extra/clang-tidy/checks/modernize-raw-string-literal.html
2019-04-03 16:45:52 +02:00
Sébastien Villemot 9bc6c57a5c
Factorization: create new utility SymbolTable::getUltimateOrigSymbID() 2019-03-29 17:06:24 +01:00
Houtan Bastani 50c26f4945
further simplifications related to AR matrices 2019-03-15 14:35:57 +01:00
Stéphane Adjemian (Charybdis) 9632b18c24
Add in M_ a list of exogenous variables that needs to be excluded if the model is not used for estimation. 2019-03-14 11:03:02 +01:00
Stéphane Adjemian (Charybdis) e0acc669bd
Append a list of observed exogenous variables in M_ if varexo option status is used. 2019-03-07 16:55:20 +01:00
Houtan Bastani 0ea84fa9a4
pac: allow steady state growth and model consistent expectation substitution in pac equation 2019-02-18 15:11:45 +01:00
Sébastien Villemot e7c9c26d2d
More modernizations with clang-tidy 2019-01-15 11:08:47 +01:00
Houtan Bastani 08caaa0744
backslashes not used in escape sequences are not allowed in strings in Julia v1.0
See: https://github.com/JuliaLang/julia/issues/21284
2018-10-30 12:14:26 +01:00
Houtan Bastani 9eaf39235e write aux_unary_op function to output 2018-10-15 12:04:53 +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
Houtan Bastani 8acee8fd54 fix AR and EC matrices for double diff 2018-09-11 16:56:05 +02:00
Houtan Bastani 46709ada3f output AR matrix in file for trend component models 2018-09-10 14:51:33 +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 fde836d7fe trend_component_model: find trend_vars associated with equation 2018-08-31 14:24:44 +02:00
Sébastien Villemot 7280c92642 Use variant semantic values in the Bison parser
We can therefore manipulate objects by value rather than by pointers, which
saves a lot of memory manipulations (and avoid potential segfaults and memory
leaks).

Note that there is no default action ("$$ = $1") when using the variant type,
so we add them explicitly.
2018-07-31 11:48:08 +02:00
Sébastien Villemot 97868cbd2a Remove unneeded enum keyword 2018-07-18 17:28:26 +02:00