Commit Graph

324 Commits (master)

Author SHA1 Message Date
Houtan Bastani bf56d6fb82
fix LaTeX output for sqrt, exp, sin, cos, tan 2019-12-04 11:26:30 +01:00
Houtan Bastani 2db2133796
fix bugs with cbrt
- it was not handled in the model block
- output was incorrect for MATLAB/Octave and LaTeX
2019-12-04 11:10:19 +01:00
Houtan Bastani 0ff7a9d2ab
introduce command line options: `exclude_eqs` and `include_eqs`
Allows for the inclusion/exclusion of a set of equations, specified either on the command line or in a text file.

If the equation has a single endogenous variable on the LHS, then the equation is moved. If not, if the equation has an `endogenous` tag then that variable is removed along with this equation. If not, then an error is thrown.

As a command line argument, `exclude_eqs` can take the form (same syntax for `include_eqs`):
* `exclude_eqs=eq1 to remove all equations declared as `[name=eq1]`
* `exclude_eqs=[eq 1, eq 2]` to remove all equations declared as `[name=eq 1]` or `[name=eq 2]`
* `exclude_eqs=[tagname=X]` to remove all equations declared as `[tagname=X]`
* `exclude_eqs=[tagname=(X, Y)]` to remove all equations declared as `[tagname=X]` or `[tagname=Y]`

When declared in a file, the file should be of the form:
```
eq 1
eq 2
```
to remove all equations declared as `[name=eq 1]` or `[name=eq 2]`.

It should be of the form:
```
tagname=
X
Y
```
to remove all equations declared as `[tagname=X]` or `[tagname=Y]`.
2019-11-26 14:16:00 +01:00
Houtan Bastani 217dadabbd
Use `if` statements with initializers allowed by C++17 2019-10-29 11:20:13 +01:00
Houtan Bastani 361e99bee5
simplify code 2019-10-28 17:25:40 +01:00
Sébastien Villemot ecdca502aa
Modernization: stop using make_pair() and make_tuple()
In many cases, they can be replaced by the curly braces syntax.

Otherwise, we can now use the pair() and tuple() constructors, without the need
to specify template parameters, thanks to class template argument
deduction (new in C++17).
2019-10-24 10:49:13 +02:00
Sébastien Villemot 2a127b1f23
VAR/TCM models: use lag-equivalence relationship to compute maximum lags
This is made possible by the getLagEquivalenceClass() method introduced in the
previous commit.

Previously, the static version of the LHS expressions was used.

As a consequence, drop ModFile::diff_static_model, now useless.
2019-10-22 16:04:24 +02:00
Sébastien Villemot 8a83e08e79
Fix bug with diff or unary ops that have same static representation
Previously, for testing whether two diff() expressions or two unary ops were
the lead/lag of each other, the preprocessor would test whether they have the
same static representation. This is ok for simple expressions (e.g.
diff(x(-1))), but not for more complex ones (e.g. diff(x-y) and diff(x(-1)-y)
should not be given the same auxiliary variable).

This commit fixes this by properly constructing the equivalence relationship
and choosing a representative within each equivalence class. See the comments
above lag_equivalence_table_t in ExprNode.hh for more details.

Closes #27
2019-10-22 15:01:06 +02:00
Sébastien Villemot c5d223a79b
Fix semantics of ExprNode::maxLag(), maxLead() and maxLagWithDiffsExpanded() with constants
Those methods can return a negative value in some cases. For example,
maxLead(x₋₁) = −1.

But constants were always returning a value of zero, which means that we had
inconsistent behaviour like maxLead(x₋₁ + 2) = 0.

This commits fixes the behaviour by making these methods return the smallest
possible integer when called on constants.
2019-10-22 11:35:11 +02:00
Houtan Bastani 0b3cd3ec90
pac: fix parsing of linear combination for growth option 2019-10-03 18:26:09 +02:00
Houtan Bastani 5e54761201
clarify error message in bfcfbac66d. #29 2019-09-30 14:27:58 +02:00
Houtan Bastani bfcfbac66d
change error message when trying to write unused endogenous variable. #29 2019-09-30 14:21:37 +02:00
Houtan Bastani e3c23df9b8
fix spacing and typos 2019-09-30 14:21:36 +02:00
Sébastien Villemot 2c6fa34a1f
C++17: use structured bindings instead of std::tie whenever possible 2019-09-11 16:40:19 +02:00
Sébastien Villemot 4594fdd0fd
More comment improvements in relation to diff operator expansion/substitution 2019-08-20 18:22:02 +02:00
Sébastien Villemot 9b9c5beb5c
Ensure that unary ops aux vars are never created when there is a lead
The transformation would be incorrect because of the expectation operator.

There was already a safety check, but it was not entirely correct. For example,
if “exp(y)” was appearing before “exp(y(+1))”, the check would not catch the
problem, because it happened after the substitution table had been filled. So
we now do the check before filling that table.
2019-08-19 18:27:57 +02:00
Sébastien Villemot 3941278832
Add more comments in routines for aux vars for unary ops / diff operators
By the way, do some small code simplifications.
2019-08-19 18:27:57 +02:00
Houtan Bastani 2c8d0471a4
normalizeEquation not implemented for PacExpectationNodes 2019-07-15 16:34:54 -04:00
Houtan Bastani ae0a91256a
add cubic root to dynare language 2019-07-15 12:18:26 -04:00
Sébastien Villemot 17c4104275
ExprNode::removeTrendLeadLag(): pass map argument by const-reference rather than by value 2019-07-05 18:22:24 +02:00
Sébastien Villemot 69f2f1ca88
UnaryOpCode::eval(): add missing error cases 2019-06-19 17:31:33 +02:00
Houtan Bastani 7fb591645f
fix bug in pac equation: match terms of param*linear_expression 2019-05-03 11:54:45 +02:00
Sébastien Villemot 82cd95a653
Remove some unnecessary headers 2019-05-02 15:30:33 +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 39926133b8
More automatic modernizations with clang-tidy 2019-04-03 16:46:20 +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 8dad93964d
Allow linear combination of targets in error correction term of trend component models 2019-03-29 17:06:24 +01:00
Sébastien Villemot 9bc6c57a5c
Factorization: create new utility SymbolTable::getUltimateOrigSymbID() 2019-03-29 17:06:24 +01:00
Sébastien Villemot 9b98da424a
Simplification in BinaryOpNode::getPacAREC() 2019-03-29 17:06:24 +01:00
Sébastien Villemot 4114b8a9e1
Simplification in BinaryOpNode::fillAutoregressiveRow
By the way, fix bug in detection of duplicate elements.
2019-03-29 17:06:23 +01:00
Houtan Bastani 92af6ffbe7
pass flag because regex’s on matlab side depend on it 2019-03-15 16:12:54 +01:00
Houtan Bastani da9f5dcffb
Revert "make pac expectation JSON output like that of var expectation"
This reverts commit 21d42e6010.
2019-03-15 16:11:55 +01:00
Houtan Bastani 21d42e6010
make pac expectation JSON output like that of var expectation 2019-03-15 15:47:50 +01:00
Houtan Bastani 50c26f4945
further simplifications related to AR matrices 2019-03-15 14:35:57 +01:00
Houtan Bastani f1d1c1e1c1
trend_component_model: simplify AR 2019-03-15 12:27:32 +01:00
Houtan Bastani a3c08f932e
simplify code to find autoregressive matrix for VARs 2019-03-15 12:26:59 +01:00
Houtan Bastani 0544141545
pac: fix bug when checking for symb_ids 2019-03-15 12:06:10 +01:00
Houtan Bastani 1e21904496
use emplace_back instead of push_back 2019-03-11 15:51:41 +01:00
Houtan Bastani 583c8373d7
pac: add residual to additive part 2019-03-07 12:23:19 +01:00
Houtan Bastani 9b1b4113d9
pac: keep order of variables in ec part of pac equation and add scaling factor to output 2019-03-07 11:31:45 +01:00
Houtan Bastani 14e7c92f14
pac: fix bug in setting of target variable 2019-03-07 11:31:45 +01:00
Sébastien Villemot abfe1a70e7
Fix typo 2019-03-05 18:59:40 +01:00
Houtan Bastani 68850536e6
stop processing if we substitute a unary op with a lead. closes #20 2019-03-05 15:20:32 +01:00
Houtan Bastani a1c79e6a4c
remove code that should have been removed in 9963686e72 2019-03-05 12:33:21 +01:00
Houtan Bastani 9963686e72
handle additive terms when PAC equation does NOT have non/optimizing agents 2019-03-05 12:20:45 +01:00
Houtan Bastani 5f013756f2 find additive parts to pac equation 2019-02-27 23:12:05 +01:00
Houtan Bastani effa40543e
pac: find correct target variable when pac equation accounts for share of optimizing agents 2019-02-25 18:46:44 +01:00
Sébastien Villemot 8ae7f81fd9
Fix bug with var_expectation nodes introduced in 38152c34a4
We must provide a return value for
VarExpectationNode::maxLagWithDiffsExpanded().

Return zero, which will lead to the right overall result even if it is not
strictly the right choice (see the comment in the code).
2019-02-22 17:30:09 +01:00
Houtan Bastani 469a328cfc
replace make_pair and make_tuple 2019-02-21 10:42:10 +01:00
Houtan Bastani 240aba6709
move pac info out of pac expectation node 2019-02-20 15:35:13 +01:00
Houtan Bastani 34756833ae
pac: output info into substructures based on pac model name & equation tag 2019-02-19 18:32:42 +01:00
Houtan Bastani 760eaf6712
fix compilation warning 2019-02-19 18:32:42 +01:00
Houtan Bastani fc6d04b015
create A0 and A0star matrices for trend component models 2019-02-19 12:26:30 +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
Houtan Bastani b3fbb86214
relieve constraint that max lag on EC matrix is 1 2019-02-15 11:12:07 +01:00
Houtan Bastani f4837e6c94
fix AR and EC matrices when `equation = C` results in a simplified equation 2019-02-14 17:09:57 +01:00
Houtan Bastani 6e680c0159
simplify in accordance with 02ae0af3e5 2019-01-29 17:52:19 +01:00
Houtan Bastani 302fec4dec
remove comparisons to nullptr 2019-01-29 17:46:09 +01:00
Houtan Bastani 02ae0af3e5
change map type for readability 2019-01-29 17:43:17 +01:00
Houtan Bastani 90c45b2cd6
remove unused function added in d922ae8ffc 2019-01-28 15:34:38 +01:00
Houtan Bastani f5df7e7567
when an equation is of the form `X` = `constant`, replace all occurrences of `X` in other equations with `constant` 2019-01-28 15:32:12 +01:00
Houtan Bastani d922ae8ffc
pac_model: permit lag on growth option 2019-01-25 14:52:26 +01:00
Sébastien Villemot e7c9c26d2d
More modernizations with clang-tidy 2019-01-15 11:08:47 +01:00
Houtan Bastani bb624ec6a7
epilogue: allow for simulations in epilogue block 2018-12-19 16:09:30 +01:00
Houtan Bastani aad8414f94
allow the use of previously assigned variables in epilogue block in later equations in epilogue block 2018-12-10 16:30:19 +01:00
Houtan Bastani 9d3f104b8c
fix epilogue block 2018-12-10 12:27:27 +01:00
Sébastien Villemot 82b1467074
Improve consistency of ExprNode methods for calculating max lead/lag
- ExprNode::maxLag() and ExprNode::maxLead() now take into account exogenous
  deterministic variables, for consistency with M_.maximum_{lead,lag}

- ExprNode::maxLag() no longer behaves as if diff() operators were
  expanded (i.e. it now returns 1 on diff(x(-1))), for consistency with
  maxEndoLag() and maxExoLag()

- New ExprNode::maxLagWithDiffsExpanded() method, that behaves as maxLag() used
  to behave (except that it also takes exogenous deterministic into account)
2018-12-05 15:30:03 +01:00
Sébastien Villemot fe6d4e9bca
Modify semantics of ExprNode::countDiffs()
Previously, this function was counting the total number of diff() operators in
an expression. But this is not very useful, and is potentially misleading,
because in practice we use this function to compute the maximum lag on
variables in levels.

This function now returns the maximum number of nested diffs.

For example, on diff(x)+diff(diff(y)), this function was returning 3, and it
now returns 2.
2018-12-05 12:41:13 +01:00
Sébastien Villemot a08ce3de2b
Yet more simplifactions using std::tuple 2018-12-03 16:07:13 +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 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
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
Houtan Bastani 9968f5c971 fix bug in JSON output: JSON values that are decimals must be preceded by a 0
e.g. 0.5 is valid but .5 is not.
2018-10-23 14:00:36 +02:00
Houtan Bastani 9eaf39235e write aux_unary_op function to output 2018-10-15 12:04:53 +02:00
Sébastien Villemot 1089a223c4 Clean up default constructors/destructors 2018-10-11 17:08:44 +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 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 3f26933f44 Replace ExternalFunctionSetOrNot enum by integer constants
This was not conceptually an enum, but rather a collection of unrelated
constants:
- two constants for use as placeholder for symbol IDs at different places
- one constant for the default number of arguments
2018-10-02 18:10:12 +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
Houtan Bastani c9f5cef99b write AST in JSON 2018-09-18 17:48:04 +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 8acee8fd54 fix AR and EC matrices for double diff 2018-09-11 16:56:05 +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
Sébastien Villemot c6d4cb88c3 ExprNode and its subclasses are no longer friends of DataTree
This ensures a better isolation between the container and the containees.
2018-09-05 18:28:32 +02:00
Sébastien Villemot 004d909621 Use smart pointers for storage of ExprNode in DataTree class
- BTW, store them in a std::vector rather than std::list

- incidentally, fix issue in VariableNode::removeTrendLeadLag where expression
  sharing was possibly violated when creating a new VariableNode
2018-09-05 18:28:32 +02:00
Houtan Bastani 9f0c30740e introduce epilogue block 2018-09-05 12:31:49 +02:00
Stéphane Adjemian(Charybdis) a35c1785a8 Cosmetic change. 2018-09-04 12:08:05 +02:00
Houtan Bastani 49d8931fc0 fix typo in 8584323563 2018-09-04 10:45:39 +02:00
Houtan Bastani 8584323563 provide information on order of ec.vars 2018-09-04 10:39:05 +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 9e6bdc2334 Revert "fix bug in collection of ec vars of pac equation"
This reverts commit 74dd6a69e9.
2018-08-28 13:32:48 +02:00
Houtan Bastani 74dd6a69e9 fix bug in collection of ec vars of pac equation 2018-08-27 16:41:39 +02:00
Stéphane Adjemian(Charybdis) 74b693a1ec Cosmetic change. 2018-08-14 16:46:43 +02:00
Stéphane Adjemian(Charybdis) adbeb49b29 Do not print non optimizing behaviour field in PAC if empty. 2018-08-14 16:45:01 +02:00
Houtan Bastani ac850f5187 pac: stop processing of PAC equation if optimizing share parameter is hard-coded 2018-08-13 17:22:28 +02:00
Houtan Bastani d3bd6ace90 pac: print optimizing share parameter 2018-08-13 17:00:47 +02:00
Houtan Bastani edc242d471 preprocessor: find optimizing shares of agents in PAC equation 2018-08-13 14:34:57 +02:00
Houtan Bastani c5c61f99ba fix bug with max_lag reported for PAC equation 2018-08-13 12:12:20 +02:00
Sébastien Villemot f3c2a1bf87 New var_expectation_model statement and re-design of var_expectation operator
Given a previously declared var_model, the var_expectation_model statement is
used to declare a way of forming expectations with this VAR (possibly using a
finite or infinite discounted sum). The var_expectation operator now takes a
single argument, the name of the var_expectation_model.

For the moment, this only works when the var_model is using equations
explicitly declared in the model block.
2018-08-02 08:39:09 +02:00
Sébastien Villemot 04b6690d5a C++11: convert ExternalFunctionType to a class enum 2018-07-18 17:28:23 +02:00
Sébastien Villemot 4ad0e500d4 C++11: convert {Unary,Binary,Trinary}Opcode to class enums 2018-07-18 16:18:26 +02:00
Sébastien Villemot d6055c1407 C++11: convert SymbolType to a class enum 2018-07-17 18:55:26 +02:00
Sébastien Villemot 946d105c04 Remove C and C++ preprocessor output types
This code is broken since the temporary terms array changes. It is probably not
worth maintaining it.
2018-07-17 16:52:11 +02:00
Sébastien Villemot b8a5dfdc39 Replace several usages of C macroprocessor with C++ constructs 2018-07-17 16:36:58 +02:00
Houtan Bastani bbb2b067bf prevent compilation warning 2018-06-27 13:45:51 +02:00
Houtan Bastani b8ae9f6935 Fix max lags for var 2018-06-11 15:18:06 +02:00
Houtan Bastani 84c2dc5f36 transform_unary_ops now introduces aux variables/equations for all unary ops specified by UnaryOpNode::createAuxVarForUnaryOpNode()
In the absence of this option, if a var_model statement(s) is present, then aux vars/eqs are created for the same types of unary operators but only for equations specified in the var_model statement

In the absence of both this option and var_model statements, no unary op auxiliary variables are created

diffs continue to be substituted everywhere; for the moment auxiliary variables are created for diffs of expressions. A forthcoming change will allow auxiliary variables created for diffs of expressions to be linked with their lagged expressions as is currently the case for diffs of variables
2018-06-07 17:16:12 +02:00
Houtan Bastani a30f8f365e Only create auxiliary variables for diffs that appear in VAR equations or equations that have pac_expectations in them
Otherwise, substitute the diff (i.e. `diff(x)` -> `x-x(-1)`)
2018-06-05 18:39:13 +02:00
Houtan Bastani 2cd3aa95cc When `transform_unary_ops` is passed, only substitute unary operators that appear in VAR equations 2018-06-05 17:41:15 +02:00
Sébastien Villemot 7e16307382 Simplify DataTree maps using std::tuple 2018-06-04 17:35:02 +02:00
Sébastien Villemot abe44fb063 Replace the use of boost::bind by a lambda 2018-06-04 16:51:36 +02:00
Sébastien Villemot 272d36a37c Remove useless casts of nullptr 2018-06-04 16:39:01 +02:00
Sébastien Villemot 608c43450c Replace most calls to make_pair by braced-initializer lists or emplace()/emplace_back() 2018-06-04 16:36:46 +02:00
Sébastien Villemot 182c53273e Remove useless spaces in type qualifiers
In C++11, it is no longer necessary to put a space between two consecutive ">".
2018-06-04 15:03:31 +02:00
Sébastien Villemot 1e56c73377 Port to C++11 nullptr keyword
Performed using modernize-use-nullptr from clang-tidy.

https://clang.llvm.org/extra/clang-tidy/checks/modernize-use-nullptr.html
2018-06-04 15:03:31 +02:00
Sébastien Villemot e73ebc7033 Port to C++11 noexcept keyword
Performed using modernize-use-noexcept from clang-tidy.

https://clang.llvm.org/extra/clang-tidy/checks/modernize-use-noexcept.html
2018-06-04 15:03:31 +02:00
Sébastien Villemot 64eb494298 Port to C++11 syntax for default constructors
Performed using modernize-use-equals-default from clang-tidy.

https://clang.llvm.org/extra/clang-tidy/checks/modernize-use-equals-default.html
2018-06-04 15:03:31 +02:00
Sébastien Villemot 33b1359905 Port to C++11 emplace_back() method on containers
Performed using modernize-use-emplace from clang-tidy.

Manual intervention was needed to transform a NULL into nullptr in SymbolTable.cc.

https://clang.llvm.org/extra/clang-tidy/checks/modernize-use-emplace.html
2018-06-04 15:03:31 +02:00
Sébastien Villemot c0ed97d247 Port to C++11 auto keyword
Performed using modernize-use-auto from clang-tidy.

https://clang.llvm.org/extra/clang-tidy/checks/modernize-use-auto.html
2018-06-04 15:03:26 +02:00
Sébastien Villemot dcfc598196 Remove redundant void arguments
Performed using modernize-redundant-void-arg from clang-tidy.

https://clang.llvm.org/extra/clang-tidy/checks/modernize-redundant-void-arg.html
2018-06-04 15:02:57 +02:00
Sébastien Villemot 20bbbd46c3 Port some constructors to pass-by-value using C++11 move semantics
Performed using modernize-pass-by-value from clang-tidy.

Manual intervention was needed to fix an issue in MacroValue.hh.
Also replace std::move by move, since we import the std namespace.

https://clang.llvm.org/extra/clang-tidy/checks/modernize-pass-by-value.html
2018-06-04 12:35:28 +02:00
Sébastien Villemot 6cf4e6dc0c Port to C++11 range-based for loops
Performed using modernize-loop-convert from clang-tidy.

Manual intervention was needed in MacroValue.cc because of a variable name
capture issue.

https://clang.llvm.org/extra/clang-tidy/checks/modernize-loop-convert.html
2018-06-04 12:26:16 +02:00
Sébastien Villemot 28582c4a4b Merge branch 'temporary_terms_array' 2018-06-04 11:40:49 +02:00
Houtan Bastani 90cf5bfbb1 fix bug in creation of auxiliary variables for unary ops 2018-06-01 15:52:39 +02:00
Houtan Bastani cc65f82fd8 fix typo in a648dc9e50 2018-06-01 15:06:31 +02:00
Houtan Bastani a648dc9e50 clarify error message 2018-05-31 19:23:44 +02:00
Houtan Bastani 9166cda225 remove code that is no longer used in creation of auxiliary variables for diff operator 2018-05-31 18:44:06 +02:00
Houtan Bastani 1b952a12e6 fix bug in var max lag and simplify code 2018-05-31 15:36:03 +02:00
Sébastien Villemot 59e427cf66 Merge branch 'master' into temporary_terms_array 2018-05-30 17:20:48 +02:00
Houtan Bastani 0aea4f0cc4 introduce dynare command transform_unary_ops to create auxiliary variables for certain unary ops. This will be used for VARs and VECMs but can also be used for OLS, for example 2018-05-30 16:48:08 +02:00
Houtan Bastani 856f6f508a Revert "create aux vars for certain unary ops contained in diff operator"
This reverts commit f600a65c0e.
2018-05-30 15:50:42 +02:00
Houtan Bastani 922d0551a8 Revert "fixes to auxiliary variable creation for unary ops in diff operators"
This reverts commit 48031b99f6.
2018-05-30 15:50:26 +02:00
Houtan Bastani 48031b99f6 fixes to auxiliary variable creation for unary ops in diff operators 2018-05-30 14:42:00 +02:00
Sébastien Villemot 0b617ceb4b Merge branch 'master' into temporary_terms_array 2018-05-29 17:25:11 +02:00
Sébastien Villemot e1f65b3390 Fix bug in external functions with temporary terms array
Given that temporary terms are separated in several functions (residuals,
jacobian, …), we must make sure that all temporary terms derived from a given
external function call are assigned just after that call, and not in an other
function.
2018-05-29 17:07:18 +02:00
Houtan Bastani f600a65c0e create aux vars for certain unary ops contained in diff operator 2018-05-29 17:00:56 +02:00
Sébastien Villemot 08eedcb448 Add const qualifier for tef_terms in writeOutput method and siblings
Consequently, change various function calls where tef_terms was empty, passing
an (empty) rvalue instead of an lvalue.
2018-05-29 14:22:01 +02:00
Sébastien Villemot 33b280b3d5 Remove some ExprNode::writeOutput variants
More precisely, remove those variants where temporary_terms can be specified
without temporary_terms_idxs, in order to make clear that the latter is
expected. For situations where the tt_idxs are not needed (C, block MATLAB), an
empty map has to be explicitly given.
2018-05-29 11:13:55 +02:00
Sébastien Villemot 3f874cfced Remove obsolete function 2018-05-28 16:39:28 +02:00
Sébastien Villemot 8657d4dc98 Fix block decomposition with temporary terms array 2018-05-28 11:58:11 +02:00
Sébastien Villemot 968e411c31 Make indexing in temporary terms array ready for a (hypothetical future) implementation in C 2018-05-25 15:19:50 +02:00
Sébastien Villemot f4b633b199 Factorize code for writing temporary terms identifiers (Tnnn)
Incidentally fix bug when a trinary operator becomes a temporary term with
block decomposition (without bytecode).

Also add a safety check to ensure that, if a temporary term is detected, its
index is indeed present in temporary_terms_idxs.
2018-05-25 14:53:48 +02:00
Sébastien Villemot 467604d428 Simplify ExprNode::writeOutput methods
The version with no temporary_terms_idxs argument needs not be virtual, since
it is the same implementation in all derived classes. Rather move it at the
level of the base ExprNode class.
2018-05-25 12:20:25 +02:00
Sébastien Villemot bb4b5993b0 Simplify code for model local variables 2018-05-24 19:35:35 +02:00
Sébastien Villemot 164a6f303b Fix bug in temporary terms array in the presence of model local variables
In the presence of MLVs, the temporary terms indexing was corrupted. The code
was using the implicit assumption that the ExprNodeLess ordering was giving the
same ordering as the temporary terms indexes ordering. But MLVs can be higher
in ExprNodeLess ordering than some other temporary terms, while they have the
lowest temporary terms index, hence the bug.

Fix this by no longer relying on the ExprNodeLess ordering, and rather use a
full map<ExprNode *, int> for ModelTree::temporary_terms_idxs. By the way,
simplify the code by removing a few useless data structures (e.g.
ModelTree::temporary_terms_idxs_*).
2018-05-24 19:35:21 +02:00
Houtan Bastani 732a317030 Merge branch 'master' into temporary_terms_array 2018-05-18 16:40:12 +02:00
Houtan Bastani 3d946ec8b7 var: check for leaded/contemporaneous variables 2018-05-16 12:17:06 +02:00
Houtan Bastani 3a71215ae1 pac: change auxiliary variable creation, fix VAR max lag 2018-05-15 14:42:36 +02:00
Houtan Bastani 912261e5fc pac: separate params into EC and AR 2018-05-04 15:26:21 +02:00
Houtan Bastani 1310ec3caa update pac output 2018-04-18 15:50:35 +02:00
Houtan Bastani 7ac33099f8 support undiff in pac model 2018-04-17 16:56:27 +02:00
Houtan Bastani 09e73f3bb4 var_model: fix lag info when diff present 2018-04-17 16:55:55 +02:00
Houtan Bastani fb8d9258d0 add pac_model statement 2018-04-04 11:48:59 +02:00
Houtan Bastani ec215e2a44 separate temporary terms: WIP 2018-03-28 16:41:48 +02:00
Houtan Bastani 5d339b69de simplify pac_expectation code 2018-03-07 15:04:07 +01:00
Houtan Bastani 2a2f2799dd fix compilation warnings 2018-03-07 12:58:51 +01:00
Houtan Bastani a69c53b0c8 clean up var_model code 2018-03-06 14:42:11 +01:00
Houtan Bastani de9e897a59 fix bug when the argument of the diff operator is not a variable 2018-03-02 18:39:38 +01:00
Houtan Bastani feb5b93eea create function to calculate aux vars as dseries 2018-03-02 17:50:35 +01:00
Houtan Bastani 9885fbacff diff: substitute auxiliary variables starting from the least lagged 2018-03-02 12:32:01 +01:00
Houtan Bastani 1e20717f58 fix bug in substitution of diff operator 2018-02-28 17:33:00 +01:00
Houtan Bastani 4897ab7d69 clean up adl code 2018-02-28 11:31:08 +01:00
Houtan Bastani f439f86688 fix bug with the collection of dynamic variables for diff operator 2018-02-28 10:44:24 +01:00
Houtan Bastani a1437ac982 Merge remote-tracking branch 'dynare-preprocessor-github/master' into other-master 2018-02-26 12:09:58 +01:00
Houtan Bastani b504f160ca move files to src directory 2018-02-15 11:48:04 +01:00