Commit Graph

1149 Commits (b709da7f17c683ba943159929c8310794112e0f6)

Author SHA1 Message Date
Sébastien Villemot a2c96a9d79
Allow empty quoted strings
Can be useful when resetting a filename option to an empty value, e.g. for the
mh_initialize_from_previous_mcmc_* options.

Ref. dynare!1841
2021-05-11 18:50:18 +02:00
Sébastien Villemot 73e07b78b8
Add mh_initialize_from_previous_mcmc option family to estimation command
Ref. dynare!1841
2021-05-11 18:12:54 +02:00
Sébastien Villemot be7ff255f6
The fast_realtime option now accepts a vector of integers
Ref. dynare!1842
2021-05-10 15:41:36 +02:00
Sébastien Villemot 80e1090257
Add no_init_estimation_check_first_obs option to estimation
Ref. dynare!1839
2021-05-07 17:41:20 +02:00
Sébastien Villemot 337b6f469c
New parallel_use_psexec command-line option
Ref. dynare!1843
2021-05-06 16:25:46 +02:00
Sébastien Villemot 1d188a7444
Add comment
[skip ci]
2021-05-04 17:21:47 +02:00
Sébastien Villemot 3c4d647cc3
Forbid mfs > 0 in a stochastic setup (or even when using check)
The result would be wrong.

Ref. dynare#1726
2021-05-04 17:11:09 +02:00
Sébastien Villemot 7765efe95b
Windows: fix detection of location of MinGW compiler 2021-04-30 15:03:53 +02:00
Sébastien Villemot 12b61e4817
Bugfix in DataTree::writeToFileIfModified()
If the old file and the new contents shared a common prefix, then the output in
the generated file would be truncated at the start.

Ref. DynareJulia/Dynare.jl#1
2021-04-26 14:10:47 +02:00
MichelJuillard 9773bafc5b Julia: write definition of get_power_deriv inside generated static/dynamic files 2021-04-26 10:52:18 +00:00
Sébastien Villemot dca294de3a
Julia: refactor the auxiliary variable/series files
— rename the files with camel case
— encapsulate the functions with modules
— change the signature of function <MODFILE>_dynamic_set_series!, by removing
  the output argument and appending the exclamation mark, since this function
  modifies one of its arguments, and for symmetry with the static version

Ref. DynareJulia/Dynare.jl#1
2021-04-23 17:57:33 +02:00
Sébastien Villemot 4354d8a578
Julia: do not overwrite steady state / auxiliary variables/series files if contents has not changed
Ref. DynareJulia/Dynare.jl#1
2021-04-23 17:56:54 +02:00
Sébastien Villemot 4cfc7a563b
Julia: do not overwrite Static/Dynamic files if contents has not changed
Ref. DynareJulia/Dynare.jl#1
2021-04-22 18:03:47 +02:00
Sébastien Villemot 81b1d02748
Julia: fix typo in StatsFuns package name
Ref. DynareJulia/Dynare.jl#1
2021-04-22 15:48:25 +02:00
Sébastien Villemot 0213c9be73 Merge branch 'ramsey_k_order' into 'master'
Allows to write M_.NNZDerivatives_objective in the driver.m file

See merge request Dynare/preprocessor!36
2021-04-22 13:28:18 +00:00
normann 22fbfb0fba Allows to write M_.NNZDerivatives_objective in the driver.m file
Writes the number of non-zero derivatives of the planner objective function NNZDerivatives_objective in the driver.m file. Useful for the k-order approximations of welfare.
2021-04-22 15:26:25 +02:00
Michel Juillard d511e3ec3a
add deterministic_trends statement (only used by Dynare Julia) 2021-04-22 15:19:21 +02:00
Sébastien Villemot 910649dd28
Fix treatment of “series” option of “initval_file”
This option was treated as a numeric value: it was a hack to ensure that the
name of the dseries object was printed without quotes in the driver file.

However, that would make the JSON output synctically incorrect.

This commits removes the hack, and treats the “series” option as a string
value (in the same way as for the “data” command). A modification of the MATLAB
code will thus be needed to accomodate the change.
2021-04-20 10:39:14 +02:00
Sébastien Villemot 1f17528383
Julia: update dependencies of Static/Dynamic modules
Ref. DynareJulia/Dynare.jl#1
2021-04-19 17:02:46 +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
Sébastien Villemot 7b3df21f11
DataTree::operator=(): fix crash when symbol ID ordering of model local variables does not correspond to the recursive ordering in the model block
Ref. dynare#1782
2021-04-16 17:34:13 +02:00
MichelJuillard c2009e2012
fix set_auxiliary_variables.jl 2021-04-01 17:05:13 +02:00
MichelJuillard 6662d8014e
fix writeJsonOutput for load_params_and_steady_state 2021-04-01 17:05:13 +02:00
Michel Juillard fd979f625a
add maximum lead and lag to modfile.json 2021-04-01 17:05:13 +02:00
Michel Juillard c9dd241f5b
add varobs statement to JSON output 2021-04-01 17:05:12 +02:00
Michel Juillard 50a2e7c44f
Add escape codes in NativeStatement and VerbatimStatement writeJsonOutput() method 2021-04-01 17:05:10 +02:00
Sébastien Villemot 29b3b744ef
Remove spurious space produced when parsing key/value pairs
Introduced in e46168db66.
2021-02-26 12:28:06 +01:00
Stéphane Adjemian (Charybdis) f0d67b01dd
Honour bi-annual dates in mod file. 2021-02-26 09:30:02 +01:00
Sébastien Villemot 5581052451
Add particle_filter_options option to estimation
Ref. #59
2021-02-23 16:54:36 +01:00
Sébastien Villemot e46168db66
Simplify parsing of lists of key/value pairs options 2021-02-23 16:49:11 +01:00
Sébastien Villemot 54365b16ed
Remove unfinished “occbin” option to perfect_foresight_solver and extended_path
Partially reverts f914837aff and
567156aad4.
2021-02-22 16:22:17 +01:00
Sébastien Villemot 825b9ee8ef
Fix bugs introduced in d3e115194b
Ref. #65
2021-02-19 20:29:18 +01:00
Sébastien Villemot 4798a5e2bc
Cosmetic change 2021-02-19 20:09:48 +01:00
Sébastien Villemot ca4b1ba4ed
Remove time subscript in LaTeX output of model-local variables
See https://forum.dynare.org/t/tex-output-unwanted-subscript-t/16072
2021-02-19 17:45:58 +01:00
Sébastien Villemot d3e115194b
Fix output write_latex_original_model for model-local variables
Those variables were substituted out by early substitution methods (which are
also called on the original model, for an unknown reason).

Closes: #65
2021-02-19 17:45:02 +01:00
Willi Mutschler 071a46a798
Add interface to set zero_moments_tolerance
Useful in identification and method_of_moments toolbox to set the tolerance which replaces very small numbers by hard zeros in unconditional second moments (particularly in pruned_state_space_system.m and disp_moments.m)
2021-02-16 16:29:57 +01:00
Sébastien Villemot 2781e3e6f6
A few modernizations using clang-tidy 2021-02-10 16:48:46 +01:00
Sébastien Villemot 9274675efb
Allow booleans in optimization options list
Closes: #63
2021-02-10 16:18:58 +01:00
Willi Mutschler f7cd6dbf0a
🐛 save oo_.time also in _results.mat 2021-02-04 10:48:59 +01:00
Sébastien Villemot 702cf62ee3
Declare some methods as const 2021-02-03 18:09:11 +01:00
Sébastien Villemot 234fcd1d2b
Remove obsolete stuff from bytecode 2021-02-01 14:46:08 +01:00
Sébastien Villemot 754a1a464d
Use default member init
Performed using modernize-use-default-member-init from clang-tidy.

https://clang.llvm.org/extra/clang-tidy/checks/modernize-use-default-member-init.html
2021-02-01 12:44:24 +01:00
Sébastien Villemot 4ee89d6e70
Use more auto keyword
Performed using modernize-use-auto from clang-tidy.

https://clang.llvm.org/extra/clang-tidy/checks/modernize-use-auto.html
2021-02-01 12:42:59 +01:00
Sébastien Villemot 07391e0f9f
Remove unused kludge 2021-02-01 12:07:33 +01:00
Sébastien Villemot 89e2daf7c7
C++17 modernization: convert the remaining enums to enum classes 2021-02-01 12:05:06 +01:00
Willi Mutschler c79ae5d4bd
Save 'Total computing time' into oo_.time 2021-01-28 11:28:41 +01:00
Johannes Pfeifer ad22e62874
filter_initial_state: Port lost preprocessor commits from https://git.dynare.org/JohannesPfeifer/dynare/-/commits/filter_initial_state 2021-01-26 16:03:04 +01:00
Sébastien Villemot 7468b4d8d7
Remove more stuff related to unfinished decomposition in linear and nonlinear blocks
Ref. #39, dynare!1626
2021-01-25 18:13:35 +01:00
Sébastien Villemot af9bd8f109
Remove the unfinished decomposition in linear and nonlinear blocks
Also remove the det_cond_forecast interface, that was related to it.

Ref. dynare!1626
Closes: #39
2021-01-25 18:03:37 +01:00
Sébastien Villemot 1e5de7d71e
Fix typo
Introduced in 4c14dc3fbf.
2021-01-22 14:20:52 +01:00
Sébastien Villemot 4c14dc3fbf
Macro processor: gracefully fail when argument to @#ifdef/@#ifndef is not a variable name
Ref. dynare#1771
2021-01-22 12:20:13 +01:00
Sébastien Villemot ec66768a63
Forbid exogenous deterministic variables with a lead or lag
Ref. dynare#1765
2021-01-22 11:59:44 +01:00
Sébastien Villemot ab656f2d84
macOS/use_dll: upgrade to gcc-10 compiler 2021-01-13 15:42:09 +01:00
Sébastien Villemot a0d12310cb
macOS/use_dll: drop -mmacosx-version-min=10.9 flag
The MEX files are not intended for distribution to other systems.
2021-01-13 15:42:09 +01:00
Sébastien Villemot c91178e3e3
macOS/use_dll: no longer pass -arch x86_64, in preparation for ARM support 2021-01-13 15:42:09 +01:00
Stéphane Adjemian (Charybdis) 7a8446e836
Added call to a routine filling the fields required by some nonlinear solvers.
At some point this task might be delegated to the preprocessor.

(cherry picked from commit ca230d0902eadeb89ab705cf66790ffa2f135192)
2021-01-12 19:50:37 +01:00
Willi Mutschler a87b2753ed
MoM: Add option analytic_jacobian 2021-01-08 18:57:06 +01:00
Sébastien Villemot 8e03f17350
Cleanup the “output” option
— output Julia files as soon as “language=julia” is passed, independently of
  the value of the “output” option
— drop the “dynamic” and “first” values of the “output” option, since they
  actually do nothing
— obey the “output” option even in the deterministic case

Ref. dynare#1600
2021-01-08 18:51:48 +01:00
Sébastien Villemot a9daec1c07
Rename preprocessor binary to dynare-preprocessor
Ref. dynare#1728
2021-01-06 17:08:42 +01:00
Sébastien Villemot cd443a6083
Revert to accepting the “nolog” option, but do nothing about it
This is necessary to avoid an “unknown option” error.

Ref. dynare#1743
2021-01-06 15:50:30 +01:00
Sébastien Villemot 78874a01d3
No longer deal with the log file at the preprocessor level
Ref. dynare#1743
2021-01-06 14:19:33 +01:00
Johannes Pfeifer 1def52a088 Add interface to set schur_vec_tol 2020-12-17 19:55:20 +01:00
Sébastien Villemot 91db87b1cf
Forbid some basenames, since they will cause trouble
Closes: preprocessor#62
2020-12-16 18:21:55 +01:00
Sébastien Villemot 84d79226cd
Lexer: no longer associate a semantic value to GMM and SMM tokens
This was forgotten from commit 78f6d48601.
2020-12-14 19:10:29 +01:00
Johannes Pfeifer 78f6d48601 GMM: introduce option analytic_standard_errors 2020-12-12 09:36:40 +01:00
Sébastien Villemot 7baeda8b8d
Occbin: add equation number in M_.occbin.constraint structure
Ref. #569
2020-12-10 15:57:47 +01:00
Sébastien Villemot f67e9c044b
JSON output: fix “variable_mapping” for Ramsey models
Ref. dynare#1755
2020-12-09 17:32:29 +01:00
Sébastien Villemot bf1da3c6fb
JSON output: fix logic in “variable_mapping” that could lead to invalid JSON formatting
Ref. dynare#1755
2020-12-09 16:47:55 +01:00
Sébastien Villemot ec779235ea
Macro-processor: move environment out of node classes
This completes the separation of parse trees from their evaluation.

Closes: #32
2020-12-07 17:29:05 +01:00
Sébastien Villemot 638b4c7ac5
Ensure that all statements produce an output in JSON mode 2020-11-26 16:25:22 +01:00
Sébastien Villemot a99ca9f450
Remove obsolete “var_estimation” statement 2020-11-26 16:13:52 +01:00
Sébastien Villemot 1b40327639
Remove obsolete “restrictions” block 2020-11-26 16:13:49 +01:00
Sébastien Villemot c697a63119
Fix typo 2020-11-25 18:08:49 +01:00
Sébastien Villemot 9292b0692e
Rename DetCondForecast to DetCondForecastStatement, for naming consistency 2020-11-25 17:40:00 +01:00
Sébastien Villemot 4b8290faa5
Do not crash when unknown symbol is passed to “irf_shocks” option
Closes: #57
2020-11-18 17:47:37 +01:00
Sébastien Villemot b1df9ecc38
Parallel config file: switch back to DynarePath field (instead of ProgramPath)
This is a partial revert of f022f666b7

Ref. dynare#1748
2020-11-13 15:35:01 +01:00
Sébastien Villemot cfb41d291c
Substitute out model-local variables early in the model transform pass
Incidentally, this makes it possible to use model-local variables with either
the “block” or “bytecode” option. (Ref: dynare#1243)
2020-11-10 18:07:57 +01:00
Sébastien Villemot 1e419a48e4
Remove unused function 2020-11-10 18:02:06 +01:00
Sébastien Villemot 9bca65c7e5
Deterministic models: replace exogenous with lead/lags by auxiliary variables
This brings those models in line with stochastic models.

However note that transformation is still not exactly the same on stochastic
and deterministic models, because there is no need to take into account the
Jensen inequality on the latter. In deterministic models, there is a one-to-one
mapping between exogenous with lead/lags and auxiliaries, while in stochastic
models, an auxiliary endo may correspond to a more complex nonlinear expression.
2020-11-09 16:28:32 +01:00
Sébastien Villemot 5d564eed07
Fix the interpretation of @#elseif clauses within an @#ifdef or @#ifndef 2020-11-02 12:47:33 +01:00
Sébastien Villemot df8d8ef116
Fix logic for @#ifndef
Ref. dynare#1747
2020-11-02 12:27:27 +01:00
Stéphane Adjemian (Charybdis) abf5a6553b
Removed useless subfield (only julia output).
TODO: Check that we can do the same in the matlab version…
2020-10-21 18:16:07 +02:00
Stéphane Adjemian (Charybdis) b8f7b5846b
Fixed flags for temporaries (julia output). 2020-10-21 16:37:13 +02:00
Sébastien Villemot 56581b1dd4
PAC model: make detection of non-optimizing part more robust
Introduce a new method for decomposing a product of factors, so that we can
identify expressions of the form (1-optim_share)*A*B.

Also enforce that the optim_share parameter be in a factor of the form
1-optim_share (previously it would accept any expression containing the
parameter).

Note that this fix does not yet allow to actually write non-optimizing parts of
the form (1-optim_share)*A*B, since at a later point the preprocessor imposes
that this part be a linear combination of variables (but in the future we could
think of expanding the A*B product into a linear combination if, for example, A
is a paramater or a constant and B is a linear combination).

Closes: #50
2020-10-19 18:32:30 +02:00
Sébastien Villemot db3ef925a7
Fix handling of diffLead in SymbolTable::getOrigLeadLagForDiffAuxVar() 2020-10-16 16:31:55 +02:00
Sébastien Villemot d2cbe2a19e
PAC model: fixes to M_.pac.MODEL.ar (information about autoregressive part)
– Fix order of items in this structure. Previously, items were ordered
  according to the declaration order of parameters. Now, items are order
  according to lag order (first lag appears first)
– Gracefully handle the case where there is no autoregressive part
  (Closes: #52)
2020-10-16 16:31:51 +02:00
Sébastien Villemot 740ea833f6
Block decomposition: bugfix for solve one boundary blocks with mfs>0
Ref. dynare#1726
2020-10-07 18:55:19 +02:00
Sébastien Villemot e736b9234f
Minor simplification 2020-10-07 17:15:53 +02:00
Sébastien Villemot 4560639eb4
Block decomposition: fix evaluation of recursive variables in solved blocks
Ref. dynare#1726
2020-10-06 18:30:34 +02:00
Sébastien Villemot 5979885714
Block decomposition, chain rule derivation: code improvement 2020-10-02 18:31:55 +02:00
Sébastien Villemot d347a92f14
Drop ExprNode::containsExogenous()
Replace it by calls to ExprNode::collectVariables() at the single place where
it was used.
2020-09-29 18:41:31 +02:00
Sébastien Villemot 063207e71f
ExprNode::collectEndogenous() is not a virtual method 2020-09-29 18:41:31 +02:00
Sébastien Villemot 2424b7358c
Remove unused ExprNode::collectExogenous() 2020-09-29 18:41:31 +02:00
Sébastien Villemot b0bd031a9f
Remove unused ExprNode::containsEndogenous() 2020-09-29 18:41:31 +02:00
Sébastien Villemot 7f05489639
Simplify ExprNode::findConstantEquations() 2020-09-29 18:41:31 +02:00
Sébastien Villemot a377fc8398
Fix various potential bugs with model local variables
Many recursive function on ExprNodes were not correctly recursing into the
definition of model local variables.
2020-09-29 18:41:17 +02:00
Sébastien Villemot e4687bb976
Ensure that negative constants are never marked as temporary terms 2020-09-23 17:28:53 +02:00
Sébastien Villemot 571ea3eb8a
SymbolTable: add some const qualifiers 2020-09-23 17:28:04 +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
Houtan Bastani 7ba77751c3
simplify external function C output 2020-09-18 17:05:54 +02:00
Sébastien Villemot 98d01cbbb6
Provide a meaningful error message when 'use_dll' option is used without 'matlabroot' 2020-09-18 15:00:47 +02:00
Sébastien Villemot 7e1563fdbb
Allow 'use_dll' option to be specified on the command line
Ref. Enteprise/dynare#4
2020-09-18 15:00:00 +02:00
Stéphane Adjemian (Charybdis) 0f268ce70c
Fixed logic.
Value passed to steady_state_growth was not acknowledge.
2020-09-18 11:11:50 +02:00
Sébastien Villemot feee0ffa12
PAC model: better error message when pac_expectation refers to a non-existent pac_model
Closes: #53
2020-09-10 14:24:20 +02:00
Sébastien Villemot de65e74c8f
use_dll: add the “restrict” C99 keyword to all pointers to double in computation functions
This greatly facilitates the job of the compiler during the optimization pass,
since we promise that the various pointers do not overlap each other. It may
now be possible to reenable some of the optimization flags that were disabled
without sacrificing compilation time, but this needs more investigation.

For the gory details, see:
https://en.cppreference.com/w/c/language/restrict
https://cellperformance.beyond3d.com/articles/2006/05/demystifying-the-restrict-keyword.html
2020-09-03 18:09:06 +02:00
Sébastien Villemot 5a9d1c4d87 Merge branch 'MoM' into 'master'
Remove matched_moments_ as input of method_of_moments

See merge request Dynare/preprocessor!27
2020-09-01 13:13:26 +00:00
Sébastien Villemot c6ad212c8a Merge branch 'typo' into 'master'
Fix typo

See merge request Dynare/preprocessor!26
2020-09-01 12:15:44 +00:00
Johannes Pfeifer 9d9a4bd4d1 Remove matched_moments_ as input of method_of_moments
Now a subfield of M_
2020-08-05 13:46:09 +02:00
Johannes Pfeifer d714cac8e1 EquationTags.hh: fix typo 2020-08-04 16:21:50 +02:00
Sébastien Villemot 09054e11dc
Add new “matched_moments” block
Closes: #51
2020-07-28 18:30:24 +02:00
Sébastien Villemot ecf6d67e1c
PAC/MCE model: fix timing of target in PAC expectation term
Also be more strict on the form of the target (must now be X(-1) or log(X(-1))
where X is *not* an auxiliary variable).

By the way, improve some comments in SymbolTable.
2020-07-24 18:26:16 +02:00
Sébastien Villemot 3b3589b958
PAC model: rewrite the algorithm for detecting the target, to make it more robust
Closes: #54
2020-07-23 17:19:16 +02:00
Sébastien Villemot 7bca47385d
Fixes to include_eqs/exclude_eqs
— fix segfault due to bad handling of iterators while erasing elements of a set
— fix logic for excluding endogenous variable when it is present on the LHS
2020-07-23 11:06:57 +02:00
Sébastien Villemot 86ac7d5bbc
PAC/MCE: improve informative message about # of aux. vars/eqs by adding the model name
This makes the output more useful when there are multiple PAC models.
2020-07-22 16:09:12 +02:00
Sébastien Villemot 2b25ab3e85
Fix handling of multiple PAC models 2020-07-22 12:21:05 +02:00
Sébastien Villemot f2f6097777 Merge branch 'tune_jscale' into 'master'
Fix faulty logic in checks for mh_tune_jscale

Closes #46

See merge request Dynare/preprocessor!25
2020-07-21 08:59:20 +00:00
Johannes Pfeifer eb464665ac Fix faulty logic in checks 2020-07-21 10:48:45 +02:00
Johannes Pfeifer 5cc9f216ca Make preprocessor recognize default order=2 of stoch_simul 2020-07-21 10:40:08 +02:00
Sébastien Villemot d4e20c7ec4 Merge branch 'moment_estimation' into 'master'
Method of moments: Preprocessor preparations

See merge request Dynare/preprocessor!23
2020-07-16 08:56:03 +00:00
Stéphane Adjemian (Charybdis) 03f53c1b0d
Allow empty shocks(overwrite) block. 2020-07-15 12:33:02 +02:00
Sébastien Villemot 16f9168fda
PAC MCE: fix incorrect detection of the target variable
The detection of the target EC variable to be used when constructing the
forward-looking expectation variable is rather fragile.

When the PAC model is written with an (non-)optimizing share of agents,
restrict the identification of the target variable to the optimizing
expression, to minimize the risk of wrong identification.

By the way, add a few comments, and a small simplification.
2020-07-13 17:52:42 +02:00
Johannes Pfeifer 98ddbb61ba Method of moments: Preprocessor preparations 2020-07-10 11:18:57 +02:00
Stéphane Adjemian (Charybdis) 51b3d5c68f
Do not print aux. var. for PAC expectation in dynamic_set_auxiliary_series routine.
It is useless in the backward looking version, and it cannot be
evaluated in the MCE case (because of the forward looking recursion).
2020-07-08 22:51:35 +02:00
Sébastien Villemot 3a9b0fc9ce
PAC MCE expectations: add corresponding auxiliary variables in dynamic_set_auxiliary_series.m and set_auxiliary_variables.m 2020-07-08 22:49:51 +02:00
Sébastien Villemot 4b3f010bc6
Simplify DynamicModel::writeAuxVarRecursiveDefinitions() 2020-07-08 18:48:45 +02:00
Sébastien Villemot 5b80a4db59
Unary ops substitution: bugfix, actually restrict the substitution to the chosen equations
By default, the preprocessor is supposed to only do the “unary ops”
transformation in the equations of VAR/PAC/trend component models.

However, the implementation was slightly different so far. It would detect
candidates to this transformation in the chosen equations, but it would then
perform the substitution in *all* equations.

This could lead for crashes, for example if the chosen equation contains
log(X(-1)), but another (non-chosen) equation has log(X(-2)). Then this latter
expression, even though it belongs to the same lag-equivalence class, is not
properly handled, causing a segfault.

Also do a few related cosmetic changes.
2020-07-08 15:13:14 +02:00
Sébastien Villemot 59bda04d8b
Block decomposition + use_dll: fix bug in timing of exogenous variables 2020-06-25 15:19:49 +02:00
Sébastien Villemot c4351166a9
use_dll: remove nb_row_x from static file, it is useless 2020-06-23 18:19:27 +02:00
Sébastien Villemot db8c5439f7
use_dll: higher order derivatives are now returned as sparse matrices by static/dynamic files
Previously they were returned as 3-column matrices. But this was inconsistent
with the M-file mode.
2020-06-23 17:50:50 +02:00
Sébastien Villemot 95bdfcee8c
use_dll: better safeguards on the number of input/output argument to static/dynamic MEX files 2020-06-23 16:30:21 +02:00
Sébastien Villemot 633b89db64
use_dll: remove hack for Microsoft Visual C++
We don’t support that compiler, and in any case it should support C99.
2020-06-23 16:00:55 +02:00
Sébastien Villemot fd13c03401
use_dll: use fmax() and fmin() from C99 to compute max and min operators 2020-06-23 15:59:35 +02:00
Sébastien Villemot ad5e196d30
Block decomposition now compatible with 'use_dll' option 2020-06-23 15:13:04 +02:00
Sébastien Villemot 479c2c029f
Block decomposition: move core of the routine for writing per-block files in separate function
This is a preparatory step to allow use_dll with block decomposition.
2020-06-22 14:18:21 +02:00
Sébastien Villemot 7641c2f7ee
Cosmetics 2020-06-22 11:33:16 +02:00
Sébastien Villemot f098329c74
Block decomposition: static and dynamic files are now pure wrappers around the per-block files 2020-06-19 18:45:42 +02:00
Sébastien Villemot f4d2ce70da
Block decomposition: move logic for Jacobians in stochastic mode outside the dynamic file 2020-06-19 17:44:05 +02:00
Sébastien Villemot 92aff91066
Block decomposition: in per-block files, construct sparse Jacobians more efficiently
Use 3-column format before calling sparse().

Ensure that the 3-column matrix is constructed in column-major order: data
locality will greatly improve performance once we implement use_dll.
2020-06-19 16:42:32 +02:00
Sébastien Villemot 93c18d514b
Block decomposition: in per-block dynamic files, fix nonzero elements for deterministic Jacobians 2020-06-19 15:26:19 +02:00
Sébastien Villemot 8ec43b1fb2
Block decomposition: small simplification in per-block dynamic files 2020-06-19 12:39:54 +02:00
Sébastien Villemot dc28aaa5e9
Block decomposition: fix bug in reduction of block decomposition
Some evaluated blocks could be incorrectly merged, leading to wrong
results (e.g. blocks incorrectly marked as evaluable forward).

Bug introduced in 39407083be
2020-06-17 19:42:13 +02:00
Sébastien Villemot 79763911b2
Block decomposition: in the dynamic file, y and T are now vectors as in non-block mode 2020-06-17 16:49:12 +02:00
Sébastien Villemot 91d5be3b8c
Block decomposition: fix value of M_.block_structure.dyn_tmp_nbr 2020-06-17 16:04:49 +02:00
Sébastien Villemot 257b399a94
Block decomposition: in dynamic files, rename “jacobian_eval” to “stochastic_mode”
This is much more explicit.
2020-06-16 15:54:51 +02:00
Sébastien Villemot 379be6ccef
Block decomposition: for “solve two-boundaries” blocks, move the iteration loop outside the dynamic file 2020-06-16 15:34:45 +02:00
Sébastien Villemot 85b900363d
Block decomposition: for “solve two boundaries” block, no longer compute “b” (-residuals+g1*y) in the dynamic function 2020-06-16 13:49:23 +02:00
Sébastien Villemot 8496979375
Block decomposition: remove useless “y” output for static/dynamic files of solved blocks 2020-06-16 10:38:16 +02:00
Sébastien Villemot ad583adcd4
Block decomposition: for evaluate blocks, move the iteration loop outside the dynamic file 2020-06-15 18:13:17 +02:00
Sébastien Villemot f022c0e16e
Block decomposition: remove duplicate “periods” arg. to dynamic file of complete two-boundaries blocks 2020-06-15 16:54:11 +02:00
Sébastien Villemot d530ccd012
Misc cosmetic improvements 2020-06-05 17:12:15 +02:00
Sébastien Villemot b402e35683
In the driver file, provide mapping between model local variables and indices in the temporary terms vector
The structures are M_.model_local_variables_{dynamic,static}_tt_idxs.

Ref. dynare#1722
2020-06-05 17:12:15 +02:00
Sébastien Villemot 90b9b6a1e4
JSON output: write model local variables in parsed model (modfile.json)
Ref. dynare#1723
2020-06-05 16:10:38 +02:00
Sébastien Villemot 7b9495bb2f
JSON output: when writing the model after computing pass, use TEF terms for (not derived) external functions 2020-06-05 16:10:38 +02:00
Sébastien Villemot f9ab44da56
JSON output: do not append two underscores after model local variable names in their definition
This is inconsistent with the way they are printed in equations (without
underscores).

The practice of appending underscores only makes sense in a MATLAB workspace context.
2020-06-05 16:10:37 +02:00
Sébastien Villemot 931935a942
Bug fix: allow external functions in model local variables 2020-06-05 14:50:06 +02:00
Sébastien Villemot 050f1cdd74
Block decomposition: remove unused 2nd and 3rd derivatives in output of dynamic functions 2020-06-03 16:59:04 +02:00
Sébastien Villemot f0c8a14551
Block decomposition: no longer compute deterministic simulation from dynamic.m file 2020-06-02 17:42:00 +02:00
Sébastien Villemot 2caad3ee84
Block decomposition: simplify DynamicModel::writeDynamicBlockMFile() 2020-05-29 16:48:38 +02:00
Sébastien Villemot 7b11898689
use_dll: merge the two generated C source files into a single one
Also, do various other cosmetic/simplification changes.
2020-05-29 16:12:01 +02:00
Sébastien Villemot 3c5d731500
Fix compilation with GCC 10 2020-05-28 14:21:58 +02:00
Sébastien Villemot 3ca1914e03
Block decomposition: fix simulation of blocks of type "evaluate backward" (without bytecode)
Ref. dynare#1727
2020-05-26 17:00:21 +02:00
Sébastien Villemot faa6666abe
Block decomposition: no longer use global variables for temporary terms in the dynamic M-file
Rather use a single vector as in non-block mode.

By the way, change the order of output arguments in static functions, to be
closer to the dynamic ones.
2020-05-26 16:21:11 +02:00
Sébastien Villemot 04b7d4386d
Block decomposition: no longer use global variables for temporary terms in the static M-file
Rather use a single vector as in non-block mode.
2020-05-25 18:35:36 +02:00
Sébastien Villemot a5abbae46a
use_dll: remove workaround for char16_t type
Should no longer be needed now that the minimal MATLAB version is R2014a.
2020-05-25 16:06:17 +02:00
Sébastien Villemot b9216be277
Block decomposition: fix incorrect check with model local variables
We normally never arrive here, since MLV are not compatible with 'block'
option.
2020-05-25 15:42:16 +02:00
Sébastien Villemot 3033417f5a
Block decomposition: remove ExprNodeOutputType::matlabDynamicSparseSteadyStateOperator
It’s not really needed, since it does the same as
ExprNodeOutputType::matlabDynamicSteadyStateOperator.
2020-05-25 15:35:55 +02:00
Sébastien Villemot 7b1a77ca47
Block decomposition: use logical values for some inputs to solve_{one_boundary,two_boundaries} 2020-05-25 15:12:43 +02:00
Sébastien Villemot a6d9ba6e55
Rename EquationType::evaluate_s to evaluateRenormalized, for clarity 2020-05-20 11:49:32 +02:00
Sébastien Villemot c6a17913b4
Rename {Static,Dynamic}Model::writeOutput() to ::writeDriverOutput() for clarity 2020-05-20 11:44:40 +02:00
Sébastien Villemot becc433d56
Rename byte_code to bytecode for consistency with user option name 2020-05-20 11:39:59 +02:00
Sébastien Villemot c579a45b08
Remove helper now unused because of 1d838e96ff 2020-05-20 11:35:44 +02:00
Sébastien Villemot 96657b4974
Block decomposition: refactor code that writes the block structure to the driver file 2020-05-20 11:35:14 +02:00
Sébastien Villemot 4b28f1fe9c
Bytecode: remove unused data structure 2020-05-20 10:31:31 +02:00
Sébastien Villemot 2944484442
Bytecode: rename output methods for better consistency 2020-05-19 17:45:33 +02:00
Sébastien Villemot 1d838e96ff
Block decomposition: simplify routines for writing output dynamic/static M files 2020-05-19 17:33:58 +02:00
Sébastien Villemot d05ffde63e Merge branch 'hif' into 'master'
histval_file initval_file refactoring

See merge request Dynare/preprocessor!20
2020-05-14 14:36:36 +00:00
MichelJuillard ed4c36a267 add first_simulation_period to the lexer
(cherry picked from commit c8575e11d2f81ad606ab50849c52127653699a93)
2020-05-14 14:36:35 +00:00
Sébastien Villemot a2bea00fee
Block decomposition: another fix related to temporary terms refactoring
Temporary terms need to be computed per equation (as was done previously), and
not simply per block.

It’s necessary to track temporary terms per equation, because some equations
are evaluated instead of solved, and an equation E1 may depend on the value of
an endogenous Y computed by a previously evaluated equation E2; in this case,
if some temporary term TT of equation E2 contains Y, then TT needs to be
computed after E1, but before E2.
2020-05-13 16:58:19 +02:00
Sébastien Villemot c9388da649
Bytecode: still another fix for temporary terms 2020-05-13 15:16:38 +02:00
Sébastien Villemot 2e6bc7ecaa
Bytecode: fix handling of temporary terms
They were broken by 49036f166d
2020-05-13 12:53:47 +02:00
Sébastien Villemot f8796c67c5
ExprNode::computeTemporaryTerms: minor simplifications, for symmetry with blocks code 2020-05-12 18:39:15 +02:00
Sébastien Villemot 49036f166d
Block decomposition: refactor code for computing temporary terms
In particular, in dynamic models, temporary terms are now computed for
derivatives w.r.t. exogenous, and also w.r.t. endogenous variables that do not
belong to the block.
2020-05-12 18:39:13 +02:00
Sébastien Villemot ba214a100d
Block decomposition: bugfix, cutoff option was ignored
Introduced in c699d57308
2020-05-07 18:41:01 +02:00
Sébastien Villemot 928aa977b6
Block decomposition: replace expr_t by BinaryOpNode * in a couple of places 2020-05-07 15:24:35 +02:00
Sébastien Villemot c699d57308
Block decomposition: no longer compute static Jacobian, it’s not used
Also remove a message about elements below the cutoff that was no longer
correct (elements below the cutoff have no impact on the incidence matrix
outside of normalization).
2020-05-06 18:11:11 +02:00
Sébastien Villemot a1b37288f9
Block decomposition: do not write unnecessary zeros in dynamic Jacobian
Also do cosmetic change in the corresponding code for static Jacobian.
2020-05-06 14:22:04 +02:00
Sébastien Villemot 9f361e9e37
Block decomposition: simplify code for ordering dynamic Jacobian columns 2020-05-06 14:21:24 +02:00
Sébastien Villemot 061245e50d
Block decomposition: simplify routines that write static model in MATLAB form
By the way, this probably fixes a bug in the presence of external
functions (so-called TEF terms were not properly repeated in each per-block
static file).

Also remove debugging output in the M-file.
2020-05-05 18:59:28 +02:00
Sébastien Villemot 38ccd5e0cf
Block decomposition: remove unneeded code for bytecode 2020-05-05 17:15:08 +02:00
Sébastien Villemot 5f22f00436
PAC models: handle PAC data in DynamicModel copy constructor and assignment operator 2020-05-05 16:34:51 +02:00
Sébastien Villemot 4f453320d1
Block decomposition: remove unneeded code for exogenous 2020-05-05 16:17:22 +02:00
Sébastien Villemot cb61ee8506
Block decomposition: make structures storing derivatives w.r.t. other endo/exo symmetric with those for endos belonging to the block 2020-04-30 18:24:24 +02:00
Sébastien Villemot b1a739c56a
DynamicModel: add missing members in copy constructor/assignment operator 2020-04-30 14:57:50 +02:00
Sébastien Villemot a8c2defe26
Block decomposition: compute simulation types into separate function; prologue and epilogue are no longer class members
By the way, remove the BlockType stuff which was purely informative (and it’s
not worth carrying over prologue and epilogue information just for that).
2020-04-30 12:48:16 +02:00
Sébastien Villemot 26fc71ffa7
Block decomposition: store max lead/lag of all variables in the “blocks” structure
By the way, regroup all code that computes the dynamic structure of a block
into a single function.
2020-04-30 12:03:14 +02:00
Sébastien Villemot 7f57821401
Now compute blocks[].first_equation from ModelTree::computeBlockDecompositionAndFeedbackVariablesForEachBlock
Also include various cosmetic changes.
2020-04-29 18:48:42 +02:00
Sébastien Villemot 1886746581
VariableDependencyGraph::reorderRecursiveVariables now returns indices from vertex_index
This is for consistency with other graph algorithms. Previously it would return
an index from vertex_index1.

See also 1d92adacf4 (which this commit basically
reverts).

Also do some cosmetic changes in calling graph code.
2020-04-29 18:46:15 +02:00
Sébastien Villemot 24db5e6033
Minor simplifications in graph algorithms 2020-04-29 18:12:22 +02:00
Sébastien Villemot 4948adf2cd
Block decomposition: remove unused data structure 2020-04-29 17:47:48 +02:00
Sébastien Villemot f39c687d85
Block decomposition: store mapping between endos/eqs and their block
Previously this computation was done at several places.
2020-04-29 17:42:46 +02:00