Sébastien Villemot
f1061e8df1
Block decomposition: turn BlockType into an enum class
2020-03-20 16:38:43 +01:00
Sébastien Villemot
fcef9cf8b9
Block decomposition: further streamlining of function prototypes
2020-03-20 15:23:23 +01:00
Sébastien Villemot
bd6eee93df
Block decomposition: refactor the prototypes of various functions
...
— return output arguments on the left-hand side
— do not pass class members as input/output arguments
By the way, fix a (benign) vector allocation bug in
{Static,Dynamic}Model::computeChainRuleJacobian().
2020-03-19 17:47:12 +01:00
Sébastien Villemot
76c2e87c3b
Block decomposition: factorize data structures between StaticModel and DynamicModel
2020-03-17 18:58:34 +01:00
Houtan Bastani
7371558321
rework equation tags
...
Create new EquationTags class to simplify use of equation tags throughout the code and avoid repeated code
issue #38
2020-02-21 17:49:38 +01:00
Houtan Bastani
05f00aa33f
fix bug causing equation tags to be ignored when casting to StaticModel
2020-01-06 16:05:22 +01:00
Sébastien Villemot
e2d5a83592
Global reindentation
2019-12-20 16:59:30 +01:00
Sébastien Villemot
031c0cff5f
Various code simplifications and modernizations
2019-12-16 19:42:59 +01:00
Houtan Bastani
02cb4cc973
add compiler statement
...
Allows the user to set the compiler, flags, and libs to be used with `use_dll`
Issue #35
2019-12-04 16:57:20 +01: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
0c755460b1
Use std::filesystem instead of boost::filesystem
...
Note that there is no equivalent of boost::filesystem::unique_path(), so I
implemented ModFile::unique_path() which does something similar.
2019-09-11 14:47:48 +02:00
Sébastien Villemot
0988a1f755
Generated LaTeX files are now under <basename>/latex/
2019-07-11 17:33:53 +02:00
Sébastien Villemot
271a579808
Remove symmetric elements in 3rd derivatives
2019-06-17 15:28:33 +02:00
Sébastien Villemot
82cd95a653
Remove some unnecessary headers
2019-05-02 15:30:33 +02:00
Houtan Bastani
bf89cedd88
fix compilation of static/dynamic files on macOS
2019-04-24 17:40:50 +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
c628f21245
JSON: output derivatives at an arbitrary order
...
Backward incompatible change: the temporary terms for 3rd order are now stored
in "temporary_terms_third_derivative" (without the final "s"; same for external
functions), for consistency with the name of the slot for the derivatives
themselves ("third_derivative").
Ref dynare#217
2019-04-18 17:13:16 +02:00
Sébastien Villemot
43906691d3
JSON: simplification of method for writing temporary terms
2019-04-18 17:10:39 +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
bbab112d65
Support for output of arbitrary derivation order (in MATLAB and DLL modes)
...
Does not work for Julia mode, neither with block and bytecode.
Note: in DLL mode, the number of temporary terms in no longer given in the
‘ntt’ symbol; it must be computed using ‘M_.dynamic_tmp_nbr’.
Ref dynare#217
2019-04-12 18:13:50 +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
58adbdeddd
Compatibility fix with MATLAB ≤ R2011a
2019-03-26 15:41:48 +01:00
Sébastien Villemot
7d16fff786
Further simplifications
2019-02-21 12:16:22 +01:00
Houtan Bastani
469a328cfc
replace make_pair and make_tuple
2019-02-21 10:42:10 +01:00
Sébastien Villemot
01385d1f80
Simplify implementation of nopreprocessoroutput option
...
Simply redirect cout to /dev/null, instead of propagating a boolean
everywhere.
2018-12-20 17:08:45 +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
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
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
f01c4f85c2
Fix Julia bug introduced in previous commit
2018-11-19 16:39:05 +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
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
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
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
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
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
539fddc9f6
introduce var model table
2018-08-22 12:15:02 +02:00
Houtan Bastani
afe0e475b1
trend_component_model statement
2018-08-17 16:52:48 +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
11b1fdcffd
Fix implicit narrowing conversions (omitted in previous commit)
2018-07-18 15:12:00 +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
988a9f6e2d
std::open and std::fstream constructor accept a std::string for filename in C++11
2018-06-27 15:30:45 +02:00
Sébastien Villemot
b91ed6f78c
Move the location of static and dynamic files on the filesystem
...
- M and MEX files are now under +${MODELNAME}/
- bytecode and C source now under ${MODELNAME}/model/
2018-06-27 15:30:25 +02:00
Sébastien Villemot
130004ef47
Simplify types for storing derivatives using std::tuple
2018-06-05 15:34:34 +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
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
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
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
dd6799187c
Fix derivs w.r.t. parameters with temporary terms array
2018-05-28 15:23:15 +02:00
Sébastien Villemot
61dc80bb64
Fix missing temporary terms indexes in hessian and 3rd derivatives of static model
2018-05-28 11:59:36 +02:00
Sébastien Villemot
8657d4dc98
Fix block decomposition with temporary terms array
2018-05-28 11:58:11 +02:00
Sébastien Villemot
38ed0f2ffc
Remove unused writeChainRuleDerivative methods
2018-05-25 17:10:16 +02:00
Sébastien Villemot
c7c26190d6
Reactivate use_dll mode
2018-05-25 15:48:55 +02:00
Sébastien Villemot
64323ef730
Add compatibility layer for Matlab/Octave code not using the new temporary terms array interface
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
Sébastien Villemot
a9bfd1223b
Fix assertions that check the length of temporary terms vectors
...
Model local variables had been omitted in the length computations.
2018-05-24 17:04:16 +02:00
Sébastien Villemot
41d7496b46
Fix bug in wrapper functions (*_{dynamic,static}_resid_g1{,_g2,_g2_g3}.m)
...
The last argument (T_flag) was missing in the function definitions (but it was
used in some function calls).
2018-05-23 17:34:00 +02:00
Sébastien Villemot
3fa14031a2
Fix bug in *_{dynamic,static}_resid_g1_g2_g3.m functions
2018-05-22 12:02:48 +02:00
Stéphane Adjemian(Charybdis)
70ec52a6cc
Added a routine returning only the static jacobian.
...
Also added flags to decide which temporaries have to be (re)computed.
2018-04-10 09:45:40 +02:00
Stéphane Adjemian(Charybdis)
dfccecfb11
Fixed bug (x, exogenous variables steady state, is not a Matrix).
2018-03-29 22:23:38 +02:00
Stéphane Adjemian(Charybdis)
b52ded0eb4
Fixed doc headers for static and dynamic julia modules.
2018-03-29 09:31:25 +00:00
Stéphane Adjemian(Charybdis)
849936d81b
Same as bce9b66312
for matlab output.
2018-03-28 19:14:43 +02:00
Stéphane Adjemian(Charybdis)
bce9b66312
Added arrays providing the number of temp terms in Julia modules...
...
... For static and dynamic models.
2018-03-28 17:50:58 +02:00
Houtan Bastani
ec215e2a44
separate temporary terms: WIP
2018-03-28 16:41:48 +02:00
Houtan Bastani
13d408b058
Revert "Added new routine for the static model (only computes the jacobian)."
...
This reverts commit 7c9c83fba1
.
2018-03-28 16:14:15 +02:00
Houtan Bastani
493f98fa3a
fix typo
2018-03-27 11:01:29 +02:00
Stéphane Adjemian(Charybdis)
7c9c83fba1
Added new routine for the static model (only computes the jacobian).
2018-03-10 10:20:50 +01:00
Houtan Bastani
204457cd86
explicitly close output streams
2018-03-02 18:39:16 +01:00
Houtan Bastani
b504f160ca
move files to src directory
2018-02-15 11:48:04 +01:00