Currently two threads are used (one for the dynamic MEX, one for the static
MEX). When the sparse representation is implemented, four threads will be used.
Closes: #41
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.
Elements of params_derivatives could be accessed without them being defined,
thus causing illegal memory read.
Ensure that these elements always exist. By the way, use std::map::at() instead
of std::map::find() to trigger an exception instead of an illegal memory read
in that case.
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.
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.
There were actually two distinct bugs, leading to incorrect results in some
corner cases:
– in the “evaluate” mode of the bytecode MEX, the temporary terms of the
derivatives “evaluate” blocks were not evaluated at runtime; but these
temporary terms may be needed for residuals of subsequent blocks;
– when the bytecode MEX was only computing residuals of the model (and not 1st
order derivatives), the temporary terms of the derivatives were not evaluated
at runtime; but these temporary terms may be needed for residuals of subsequent
blocks.
The “temporary_terms_union.insert(it)” statement introduced in the previous
commit was in the wrong block.
By the way, replace the “switch” by an “if constexpr”.
– 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)
We follow the advice given by Josuttis in his book about move semantics.
Deleting those member fuctions can be a bug if we want to allow copy semantics,
because overload resolution will no longer fallback to the copy
constructor/assignment operator when given an rvalue.
In particular, this explain why it was not possible to delete the move
assignment operator of the StaticModel class.
– Indicate whether we are trying to normalize the static or dynamic model
– If failed to normalize the static model, suggest to use the “no_static”
option
– Remove a superfluous error message
Consequently drop “occbin” option to “model”.
Incidentally, allow more values in equation tag names (previously some keywords
such as “alpha” were disallowed).
Ref. #68
Writes the number of temporary terms of the planner objective function derivatives objective_tmp_nbr in the driver.m file.
Useful for the k-order approximations of welfare.
For the time being, the preprocessor will refuse that this option be used with
any command other than estimation.
By the way, remove occbin_likelihood and occbin_smoother options to estimation.
Ref. dynare#569
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.