Sébastien Villemot
36fcbf6cfe
Functions that write C files now return the paths to the generated files
...
This avoids computing those paths two times (the second time when compiling them).
2022-10-04 16:00:30 +02:00
Sébastien Villemot
3d9ac26aa6
Remove all instances of the “map.find(key)->second” pattern
...
This is unsafe since the find() method can return a past-the-end iterator,
which should be tested for.
Replace most instances by calls to the std::map::at() method (which throws if
the key is unknown), and which is incidentally more readable.
2022-09-27 12:56:16 +02:00
Sébastien Villemot
18037fd29a
Drop code for supporting temporary terms corresponding to model-local variables
...
Since model-local variables are now substituted out of the model at an early
stage (see cfb41d291c
), such temporary terms are
no longer generated.
2022-09-26 17:34:20 +02:00
Sébastien Villemot
5b12354dc3
Minor performance improvement in copy constructors/assignments of ModelTree and DynamicModel
2022-09-21 17:37:02 +02:00
Sébastien Villemot
1088cc4242
Improve informative messages about derivatives and block decomposition
...
When computing the derivatives or block decomposition of the planner objective,
the epilogue or the original Ramsey model, the preprocessor would talk about
dynamic/static model, which was confusing. It now uses the right terminology.
2022-09-14 17:51:36 +02:00
Sébastien Villemot
d67f569035
Always compute block decomposition, even if “block” option was not passed
...
If block decomposition fails, error out if “block” option was passed, but not
otherwise.
This commit does not modify the generated files.
This is a preliminary step for dynare#1859.
2022-09-13 16:16:00 +02:00
Sébastien Villemot
1aead92cd5
Fix bug in block derivatives w.r.t. exogenous deterministic
2022-09-12 17:38:47 +02:00
Johannes Pfeifer
da5b36704d
Add missing whitespace in output of BGP warning
2022-08-03 10:52:08 +02:00
Sébastien Villemot
a58109d094
Bytecode: refactor methods for writing .cod and .bin files in the block decomposition case
2022-07-20 16:02:24 +02:00
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
ae150d2b1f
Bytecode: refactor routines for creating .cod file in non-block mode
2022-07-13 18:51:01 +02:00
Sébastien Villemot
89debf429a
Factorize code for writing JSON output
2022-07-12 18:04:05 +02:00
Sébastien Villemot
6da24fc763
Fix bug in JSON output for dynamic derivatives w.r.t. parameters
...
Variable and parameter indices were wrong (offset by 1).
2022-07-12 17:45:00 +02:00
Sébastien Villemot
9e6c01f132
Streamline some function names
2022-07-12 17:04:41 +02:00
Sébastien Villemot
a541d23055
Minor simplification
2022-07-12 16:39:17 +02:00
Sébastien Villemot
157c67e04b
New helpers to simplify common operations with derivation IDs
2022-07-12 16:30:45 +02:00
Sébastien Villemot
2013056a2c
Fix bug in JSON output for derivatives w.r.t. parameters
...
Confusion between a symbol ID and a derivation ID, which could lead to invalid
output or crash.
2022-07-12 16:23:44 +02:00
Sébastien Villemot
7fd78606ae
Fix bug in MATLAB/Octave output introduced in 3e1f9dbb82
2022-07-12 16:23:32 +02:00
Sébastien Villemot
1d71386f01
Further templating of helpers for writing output files
...
So that more stuff is computed at compile-time (using constexpr features).
2022-07-12 16:23:28 +02:00
Sébastien Villemot
9c3eeb7c8d
Refactor code for writing derivatives w.r.t. parameters
2022-07-12 16:18:16 +02:00
Sébastien Villemot
8da663a110
Further factorization in methods for writing static and dynamic files
2022-07-12 16:05:15 +02:00
MichelJuillard
3e1f9dbb82
use @inbounds blocks instead of @inbounds for each line
2022-07-12 13:07:33 +02:00
MichelJuillard
a4556896db
Julia functions Float64 -> <: Real
2022-07-12 11:15:51 +02:00
Sébastien Villemot
5174c3b52c
Minor simplification
2022-07-11 22:30:50 +02:00
Sébastien Villemot
f38c8278ae
Refactor methods for writing static and dynamic files
...
– factorize common code between the static and the dynamic version
– reorganise language-specific code into dedicated functions
– use a function template in the main helper to do some computations
at compile-time (using constexpr features)
2022-07-11 22:29:28 +02:00
Sébastien Villemot
c8b046ec86
Simplification using non-default std::ofstream constructor
2022-07-11 22:17:36 +02:00
Sébastien Villemot
6d2d73a5d7
Bytecode: refactor output methods around an enum class similar to ExprNodeOutputType
...
By the way, add assertions to ensure that assignment LHS output type is only
used on VariableNode(s) and AbstractExternalFunctionNode(s).
2022-07-06 16:46:40 +02:00
Sébastien Villemot
3b99ac5df0
Remove unused parameters to various methods
2022-06-24 17:11:38 +02:00
Sébastien Villemot
9bd2973034
Refactor bytecode output around a new BytecodeWriter class and operator<< overloads
2022-06-24 13:10:04 +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
83693e4427
Bytecode: stop using unsigned integers where signed ones avoid unnecessary casts
2022-06-20 17:49:31 +02:00
Sébastien Villemot
5cd5676c8e
Bytecode: directly use several enums inside instruction classes
2022-06-20 15:19:08 +02:00
Sébastien Villemot
82751d21fe
Remove useless debugging code
2022-06-17 12:46:32 +02:00
Sébastien Villemot
a85730313c
Split CodeInterpreter.hh into two headers
...
– a generic one: CommonEnums.hh
– and a bytecode-specific one: Bytecode.hh
By the way, rename global constant “near_zero” into “power_deriv_near_zero”,
for clarity.
2022-06-16 17:53:23 +02:00
Sébastien Villemot
9b04c5436e
Block decomposition: fix crash when a variable appears in an equation but has zero symbolic derivative
2022-06-13 16:32:58 +02:00
Sébastien Villemot
ee8ee7c27f
Optimization: use move semantics in a few more places
2022-06-13 14:27:19 +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
9ace2dc413
C++17 modernization: take advantage of class template argument deduction
2022-06-07 14:35:26 +02:00
Sébastien Villemot
0b5c88109f
Various simplifications
2022-06-07 14:34:30 +02:00
Sébastien Villemot
8b5e33b87a
Avoid name clash between function parameter and class member
2022-06-03 20:38:07 +02:00
Sébastien Villemot
171cd65566
Fix bytecode compilation of external function nodes
2022-05-20 11:43:02 +02:00
Sébastien Villemot
591b5e5f9e
Always create bytecode output
...
And, symmetrically, when the “bytecode” option is requested by the user, always
create the .m static/dynamic files.
The “bytecode” option therefore no longer modifies the preprocessor output.
2022-05-19 14:49:46 +02:00
Sébastien Villemot
0284b249f5
Remove unused “bytecode” argument in {Static,Dynamic}Model::computingPass()
2022-05-19 14:10:22 +02:00
Sébastien Villemot
3e94250582
C++17 modernization: use std::optional in ExprNode::getPacOptimizingShareAndExprNodes()
2022-05-16 19:10:16 +02:00
Sébastien Villemot
0eb11d3323
C++17 modernization: use std::optional in expression matching functions
2022-05-16 19:10:16 +02:00
Sébastien Villemot
3496d77eb4
C++17 modernization: use std::optional to store orig diff vars in VAR and TCM
...
By the way, remove the unused TrendComponentModelTable::getOrigDiffVar() method.
2022-05-16 19:10:16 +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
fc037a4352
Simplify printing of booleans using std::boolalpha
2022-05-16 19:10:15 +02:00
Sébastien Villemot
92d3b8166a
C++17 modernization: use std::optional for equation line numbers
2022-05-16 19:10:15 +02:00