Commit Graph

3002 Commits (pac-components)

Author SHA1 Message Date
Sébastien Villemot a8fce06dc4
PAC: new options “auxname” and “kind” to “pac_model” 2021-12-16 15:40:47 +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 6a31ba4b62
PAC: minor simplification in the matching of the growth expression
Simple variable nodes are already correctly matched by
ExprNode::matchLinearCombinationOfVariables().

Also improve the related documentation.
2021-12-16 15:40:47 +01:00
Sébastien Villemot 7dde09169e
estimated_params: check that no parameter is declared twice across concatenated blocks
The existing check (in AbstractEstimatedParamsStatement::commonCheckPass()) was
only working inside a given estimated_params block, but not across blocks.
2021-12-16 15:22:48 +01:00
Sébastien Villemot ea44aa19d6
New option “overwrite” to “estimated_params” block
This option provides the same behaviour as before the change in
60ef6bbdbd.

It is typically useful when doing several estimations in the same .mod file.
2021-12-16 14:22:31 +01:00
Sébastien Villemot 5ffbc5bad3
New estimated_params_remove statement 2021-12-15 16:02:57 +01:00
Sébastien Villemot 06a436fdf0
Minors simplification in EstimatedParams* classes
Also use a better name for the type-specific ID variable.
2021-12-15 16:02:53 +01:00
Sébastien Villemot 342c4faf8d
New var_remove statement 2021-12-15 12:20:29 +01:00
Sébastien Villemot 60ef6bbdbd
Allow multiple estimated_params statements 2021-12-15 12:20:29 +01:00
Sébastien Villemot 2d07186b8b
New model_options statement
The purpose of this statement is to specify the options that apply to the whole
model, when there are several “model” blocks, so as to restore the symmetry
between those blocks (since otherwise one “model” block would typically bear
the options, while the other ones would typically have no option).

It still remains possible to specify the options on one “model” block, or even
spread accross several ones.

Closes: #19
2021-12-15 12:20:14 +01:00
Sébastien Villemot 1f004584e9
New model_remove statement and model_replace block
Factorize the implementation with the existing code for the include_eqs and
exclude_eqs options (which has been refactored by the way).

Ref. #19
2021-12-15 12:11:25 +01:00
Sébastien Villemot a73b0d911a
Fix logic of include_eqs in the presence of [static]/[dynamic] equations
In a model with [static]/[dynamic] equations, if the user was using include_eqs
with a list of equations that does *not* contain equations marked
[static]/[dynamic], then the call to ModelTree::includeExcludeEquations(…,
static_equations=true) would have an empty list of equation tags (as stored
in tag_eqns).

The right behaviour in this case is to exclude all static equations. However,
the code would exclude none, and this would disrupt the equilibrium between
[static] and [dynamic] equations (since all [dynamic] equations were excluded
by the other call to the same method).

The fix consists in removing the shortcut that returns from the method if
tag_eqns is empty.
2021-12-10 12:50:10 +01:00
Sébastien Villemot a492417a5b
Fix typo 2021-12-10 12:44:42 +01:00
Sébastien Villemot 82c4b567cf Merge branch 'master' into 'master'
Julia specific interface for normcdf and normpdf

See merge request Dynare/preprocessor!56
2021-12-10 09:50:50 +00:00
MichelJuillard d047878333 Julia specific interface for normcdf and normpdf 2021-12-10 10:17:06 +01:00
Sébastien Villemot be316b3dec
Bump version number 2021-12-08 14:21:59 +01:00
Sébastien Villemot c0ea8d7203
Add hyperbolic primitives (cosh, sinh, tanh, acosh, asinh, atanh)
Everything was already in place (since ages!), except that the parser interface
was missing.

Also fix the derivation formula for atanh, which was incorrect.
2021-12-07 18:03:33 +01:00
Sébastien Villemot d15b2110a0
Add erfc() primitive
Closes: #85
2021-12-07 15:19:40 +01:00
Sébastien Villemot a040a7dbde
Merge branch 'write_regimes' of git.dynare.org:JohannesPfeifer/preprocessor
Ref. !55
2021-12-07 12:24:38 +01:00
Sébastien Villemot 81abea042b
Occbin: use element-by-element multiply, divide and power in occbin_difference.m
This file operates on vectors.

Ref. dynare#1826
2021-12-07 12:22:59 +01:00
Sébastien Villemot b356b8d5fa
Substitute out adl() operators in equations marked [static] 2021-12-06 17:17:38 +01:00
Sébastien Villemot dc99d81c45
Explain why expectation() operators need not be substituted in equations marked [static]
By the way, also perform a small code simplification.
2021-12-06 17:17:38 +01:00
Sébastien Villemot 214f0db4db
Add comment about predetermined variables and equations marked [static]
By the way, also perform a small code simplification.
2021-12-06 17:17:38 +01:00
Sébastien Villemot 5fe94ed606
Simplify constant equations also in equations marked [static]
The simplifyEquations() methods had to be moved to DynamicModel, in order to
access the static_only_equations member.
2021-12-06 17:17:37 +01:00
Sébastien Villemot fe974c4c31
When looking for unused endos/exos, also search in equations marked [static] 2021-12-06 17:17:37 +01:00
Sébastien Villemot 8d4cab6fe3
Substitute model-local variables in equations marked [static] 2021-12-06 17:17:27 +01:00
Johannes Pfeifer 164e2debdc occbin_write_regimes: add option to select type 2021-12-06 16:10:58 +01:00
Sébastien Villemot 7b8fc8edb7
Symbolic detrending engine: correctly handle equations marked [static]
Incidentally, this also fixes a detrending bug in the Occbin engine (since the
latter internally generates a [static] equation).

Ref. dynare#1827

By the way, perform a small code simplification.
2021-12-06 12:59:21 +01:00
Sébastien Villemot 607c5aab19 Merge branch 'planner_objective_options' into 'master'
evaluate_planner_objective: add options

See merge request Dynare/preprocessor!54
2021-12-03 16:07:14 +00:00
Johannes Pfeifer befd432be7 evaluate_planner_objective: add options
Related to https://git.dynare.org/Dynare/dynare/-/merge_requests/1967
2021-12-03 14:06:57 +01:00
Sébastien Villemot 3c6d5126b3
PAC: fix comment 2021-12-03 11:07:59 +01:00
Sébastien Villemot a210a8fd59
Add several types of auxiliary variables to M_.mapping
In practice, only those auxiliary variables which do not have an orig_symb_id
will be listed (in addition to unary ops, due to an implementation bug).
2021-11-24 11:27:17 +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 ae242770f9
PAC: in the backward case, unify h0 and h1 parameters vector into a single vector
There is no reason to keep this distinction.

Additionally, since the data structure is now symmetric with the MCE case,
unify this “h” parameter vector with the “α” parameter vector.
2021-11-23 14:31:03 +01:00
Sébastien Villemot 0f89569f7e
PAC: in the backward case, create an aux. var. for the pac_expectation expression
By the way, refactor the MCE case by merging two routines related to the Z₁ aux. var.
This restores the symmetry with the backward case, now that the latter also has
an aux. var. for the pac_expectation operator. Also store the aux. var. IDs in a
structure common to the backward and MCE cases.
2021-11-23 14:31:03 +01:00
Sébastien Villemot 0e62206203
PAC: drop support for multiple PAC equations associated to a given PAC model 2021-11-23 14:31:02 +01:00
Sébastien Villemot 1cc512962c
No longer consider an equation of the form “x(+1) = 0” as defining x to be a constant
Fix this by restricting the detection of constant equations to those where the
variable appears without a lead or lag.

Closes: #83
2021-11-19 18:01:11 +01:00
Sébastien Villemot b51f122e59
With nostrict, really ignore unused endogenous in initval/endval/histval
Closes: #82
2021-11-19 17:49:57 +01:00
Sébastien Villemot 02ee077663
Fix handling of undeclared variables in the planner_objective statement
Closes: #81
2021-11-19 17:32:45 +01:00
Sébastien Villemot 1e4eadb266
Macroprocessor: make the removal of “@#line” directives and extra newlines consistent across LF and CR+LF conventions
Simplify the algorithm using only regexps, and add comments.
2021-11-19 16:49:21 +01:00
Sébastien Villemot 1de3476546
Macroprocessor: fix line counter inside @{} constructs
There were two bugs:
– with the LF convention, newlines were counted twice
– with the CR+LF convention, they were counted four times (because the CR was
  included in yyleng, alongside the LF)

The fix consists in implementing a location_increment() method similar to the
one used for the Dynare parser. This is the most robust solution.

By the way, mark the method DynareFlex::location_increment() method static.
2021-11-19 14:55:14 +01:00
Sébastien Villemot 487c372900
Macroprocessor: fix newlines in output when under Windows and input uses CR+LF convention
If the input .mod file uses CR+LF convention, and if the user is under Windows,
then the output of the macroprocessor (as given by the “savemacro” option) had
incorrect end of lines: those would be CR+CR+LF.

The reason is that some TextNode(s) internally created by the macroprocessor
would themselves contain CR+LF sequences, which would then be transformed into
CR+CR+LF in the output (because MinGW transforms LF into CR+LF in output
streams).

The fix consists in changing the nature of the EOL token: the parsed text is no
longer attached to it, so that the Bison file now systematically turns it into
a LF inside TextNode(s).

Closes: #80
2021-11-19 14:55:12 +01:00
Sébastien Villemot 1041f205ea
PAC: trap a few more cases when an auxiliary param conflicts with a declared one 2021-11-09 15:48:59 +01:00
Sébastien Villemot 6ad3d02ec6
Minor simplification in ExprNode::matchLinearCombinationOfVariables() 2021-10-29 15:39:40 +02:00
Sébastien Villemot c4e9432eef
Remove implementation of various methods of PacExpectationNode
Those implementations are dummy and are normally never used. Rather error out
on those, factorizing them within SubModelNode.
2021-10-29 14:11:30 +02:00
Sébastien Villemot 3e242dd481
New class SubModelNode to factorize between VarExpectationNode and PacExpectationNode 2021-10-29 14:11:30 +02:00
Sébastien Villemot 37a6ed6261
PAC: rethink the relation between PacModelTable and DynamicModel classes 2021-10-29 14:11:30 +02:00
Sébastien Villemot 127361971f
PAC: refactor with new PacModelTable that replaces PacModelStatement(s)
Incidentally, the auxiliary endogenous variable representing Z₁ and created for
PAC MCE models no longer necessarily appear as the first auxiliary variable (so
this is effectively a revert of 64f55e4a5e).
2021-10-29 14:11:30 +02:00
Sébastien Villemot 0123326123
Fix error message when using pac_expectation with occbin_constraints
By the way, also fix the argument name (the model is not a VAR).
2021-10-29 14:11:08 +02: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