My question could be rephrased: in the preprocessor, do we only do text editing and write SIGMABAR__ = 1/(1-params(2)*params(6)); psi__ = (params(2)*(1-params(2))*params(6)^2/(params(2)*(params(2)*params(6)*SIGMABAR__)^2-(1-SIGMABAR__)^2))^0.5;
Or could we use the preprocessor mathematics routines to initially evaluate the said expressions (given that we already know params and check their validity) and output a warning if there is a problem. The _static and _dynamic would then be completely unaltered.
If this is not possible, we should make it optional in a way that does not affect performance. E.g. it could only be executed when using check. This would catch most of the problems.
-- Johannes Pfeifer Haußerstr. 29 72076 Tübingen Tel.: +49-(0)7071-6396184 Mobil.: +49-(0)170-6936820 Germany
-----Ursprüngliche Nachricht----- Von: dev-bounces@dynare.org [mailto:dev-bounces@dynare.org] Im Auftrag von Sébastien Villemot Gesendet: Montag, 30. Juli 2012 15:45 An: List for Dynare developers Betreff: Re: [DynareDev] # operator
"Johannes Pfeifer " jpfeifer@gmx.de writes:
My idea was implementing a warning like the one for NaN parameters that is displayed after the preprocessor runs. Expressions are something like a shortcut for a parameter not explicitly defined. Hence, it would be helpful to say:
Warning: Some of the expressions defined (psi) evaluated to NaN. Dynare may not be able to solve the model...
The problem with this approach is that the warnings have to be emitted >From the _static.m or _dynamic.m file. This means that the check has to be executed at every run of any of these file, and this can have a performance cost.
Maybe do you have something else in mind? Or we could make these checks optional, and not activated by default?
Currently it is very hard to debug the expressions defined by the pound operator, because they are substituted out and you cannot see to what they evaluated. Due to them being substituted out, complex expressions also do not necessarily get translated to NaN. In the specific example ppp.mod from the forum the expressions get written to the ppp_static.m file in the following way:
SIGMABAR__ = 1/(1-params(2)*params(6)); psi__ = (params(2)*(1-params(2))*params(6)^2/(params(2)*(params(2)*params(6)*S IGMABAR__)^2-(1-SIGMABAR__)^2))^0.5;
Hence, Matlab take the root of a negative number and evaluates psi__ to a complex number. Again the problem is that the preprocessor does not check whether expressions like SIGMABAR__ or psi__ evaluate to anything sensible at the start but rather substitutes them into Matlab code without evaluating them.
-----Ursprüngliche Nachricht----- Von: dev-bounces@dynare.org [mailto:dev-bounces@dynare.org] Im Auftrag von Sébastien Villemot Gesendet: Freitag, 6. Juli 2012 10:14 An: List for Dynare developers Betreff: Re: [DynareDev] # operator
"Johannes Pfeifer " jpfeifer@gmx.de writes:
as shown by the mod-file in http://www.dynare.org/phpBB3/viewtopic.php?f=1&t=3870, we don’t check whether expressions defined with the pound operator are complex or not. This may lead to cryptic error messages.
What do you think about adding such a check to the preprocessor. In this regard, checking for NaN might also be a good idea.
Actually complex expressions gets translated to NaN (since the preprocessor only knows real numbers). But we want to allow for NaN in some contexts. So it is not obvious how to deal with that.
-- Sébastien Villemot Researcher in Economics & Debian Maintainer http://www.dynare.org/sebastien Phone: +33-1-40-77-84-04 - GPG Key: 4096R/381A7594
Dev mailing list Dev@dynare.org https://www.dynare.org/cgi-bin/mailman/listinfo/dev
-- Sébastien Villemot Researcher in Economics http://www.dynare.org/sebastien Phone: +33-1-40-77-84-04