Merge branch 'master' into fix-mcmc-algorithm
commit
c0aaabc329
|
@ -24,7 +24,7 @@ endif
|
|||
|
||||
pdf-local: $(PDF_TARGETS)
|
||||
|
||||
EXTRA_DIST = guide.tex guide.bbl bibmad.sty bvar-a-la-sims.tex dr.tex dr.bib
|
||||
EXTRA_DIST = guide.tex guide.bbl bibmad.sty bvar-a-la-sims.tex dr.tex dr.bib dynare.plots
|
||||
|
||||
guide.pdf: guide.tex guide.bbl bibmad.sty
|
||||
$(PDFLATEX) guide
|
||||
|
|
|
@ -1070,7 +1070,7 @@ This is the long version of the variable name. Its value is stored in
|
|||
@example
|
||||
var c gnp q1 q2;
|
||||
var(deflator=A) i b;
|
||||
var c $C$ [long_name=`Consumption'];
|
||||
var c $C$ (long_name=`Consumption');
|
||||
@end example
|
||||
|
||||
@end deffn
|
||||
|
@ -4286,16 +4286,16 @@ The following information will be displayed by the command:
|
|||
results from posterior optimization (also for maximum likelihood)
|
||||
|
||||
@item
|
||||
marginal log density
|
||||
marginal log data density
|
||||
|
||||
@item
|
||||
mean and shortest confidence interval from posterior simulation
|
||||
posterior mean and highest posterior density interval (shortest credible set) from posterior simulation
|
||||
|
||||
@item
|
||||
Metropolis-Hastings convergence graphs that still need to be documented
|
||||
|
||||
@item
|
||||
graphs with prior, posterior and mode
|
||||
graphs with prior, posterior, and mode
|
||||
|
||||
@item
|
||||
graphs of smoothed shocks, smoothed observation errors, smoothed and historical variables
|
||||
|
|
|
@ -63,7 +63,6 @@ case ${MATLAB_ARCH} in
|
|||
ax_mexopts_ok="yes"
|
||||
;;
|
||||
maci | maci64)
|
||||
SDKROOT='/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.6.sdk'
|
||||
MACOSX_DEPLOYMENT_TARGET='10.6'
|
||||
if test "${MATLAB_ARCH}" = "maci"; then
|
||||
ARCHS='i386'
|
||||
|
@ -71,12 +70,12 @@ case ${MATLAB_ARCH} in
|
|||
ARCHS='x86_64'
|
||||
fi
|
||||
MATLAB_DEFS="$MATLAB_DEFS -DNDEBUG"
|
||||
MATLAB_CFLAGS="-fno-common -no-cpp-precomp -arch $ARCHS -isysroot $SDKROOT -mmacosx-version-min=$MACOSX_DEPLOYMENT_TARGET -fexceptions -O2"
|
||||
MATLAB_LDFLAGS_NOMAP="-L$MATLAB/bin/${MATLAB_ARCH} -Wl,-twolevel_namespace -undefined error -arch $ARCHS -Wl,-syslibroot,$SDKROOT -mmacosx-version-min=$MACOSX_DEPLOYMENT_TARGET -bundle"
|
||||
MATLAB_CFLAGS="-fno-common -arch $ARCHS -mmacosx-version-min=$MACOSX_DEPLOYMENT_TARGET -fexceptions"
|
||||
MATLAB_CXXFLAGS="-fno-common -fexceptions -arch $ARCHS -mmacosx-version-min=$MACOSX_DEPLOYMENT_TARGET"
|
||||
MATLAB_FFLAGS="-fexceptions -fbackslash -arch $ARCHS"
|
||||
MATLAB_LDFLAGS_NOMAP="-L$MATLAB/bin/${MATLAB_ARCH} -Wl,-twolevel_namespace -undefined error -arch $ARCHS -mmacosx-version-min=$MACOSX_DEPLOYMENT_TARGET -bundle"
|
||||
MATLAB_LDFLAGS="$MATLAB_LDFLAGS_NOMAP -Wl,-exported_symbols_list,$(pwd)/$srcdir/mexFunction-MacOSX.map"
|
||||
MATLAB_LIBS="-lmx -lmex -lmat -lstdc++ -lmwlapack"
|
||||
MATLAB_CXXFLAGS="-fno-common -no-cpp-precomp -fexceptions -arch $ARCHS -isysroot $SDKROOT -mmacosx-version-min=$MACOSX_DEPLOYMENT_TARGET -O2"
|
||||
MATLAB_FFLAGS="-fexceptions -fbackslash -arch $ARCHS"
|
||||
# Starting from MATLAB 7.5, BLAS and LAPACK are in distinct libraries
|
||||
AX_COMPARE_VERSION([$MATLAB_VERSION], [ge], [7.5], [MATLAB_LIBS="${MATLAB_LIBS} -lmwblas"])
|
||||
ax_mexopts_ok="yes"
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
function y = solve_two_boundaries(fname, y, x, params, steady_state, y_index, nze, periods, y_kmin_l, y_kmax_l, is_linear, Block_Num, y_kmin, maxit_, solve_tolf, lambda, cutoff, stack_solve_algo, M, oo)
|
||||
function [y, oo]= solve_two_boundaries(fname, y, x, params, steady_state, y_index, nze, periods, y_kmin_l, y_kmax_l, is_linear, Block_Num, y_kmin, maxit_, solve_tolf, lambda, cutoff, stack_solve_algo, M, oo)
|
||||
% Computes the deterministic simulation of a block of equation containing
|
||||
% both lead and lag variables using relaxation methods
|
||||
%
|
||||
|
@ -32,10 +32,13 @@ function y = solve_two_boundaries(fname, y, x, params, steady_state, y_index, nz
|
|||
% - 2 GMRES
|
||||
% - 3 BicGStab
|
||||
% - 4 Optimal path length
|
||||
% M [structure] Model description
|
||||
% oo [structure] Results
|
||||
%
|
||||
% OUTPUTS
|
||||
% y [matrix] All endogenous variables of the model
|
||||
%
|
||||
% oo [structure] Results
|
||||
%
|
||||
% ALGORITHM
|
||||
% Newton with LU or GMRES or BicGstab
|
||||
%
|
||||
|
|
|
@ -210,13 +210,15 @@ DynamicModel::writeModelEquationsOrdered_M(const string &dynamic_basename) const
|
|||
ostringstream tmp_output, tmp1_output, global_output;
|
||||
expr_t lhs = NULL, rhs = NULL;
|
||||
BinaryOpNode *eq_node;
|
||||
ostringstream Uf[symbol_table.endo_nbr()];
|
||||
ostringstream Ufoss;
|
||||
vector<string> Uf(symbol_table.endo_nbr(), "");
|
||||
map<expr_t, int> reference_count;
|
||||
temporary_terms_t local_temporary_terms;
|
||||
ofstream output;
|
||||
int nze, nze_exo, nze_exo_det, nze_other_endo;
|
||||
vector<int> feedback_variables;
|
||||
ExprNodeOutputType local_output_type;
|
||||
Ufoss.str("");
|
||||
|
||||
local_output_type = oMatlabDynamicModelSparse;
|
||||
if (global_temporary_terms)
|
||||
|
@ -536,7 +538,9 @@ DynamicModel::writeModelEquationsOrdered_M(const string &dynamic_basename) const
|
|||
feedback_variables.push_back(variable_ID);
|
||||
output << " % equation " << equation_ID+1 << " variable : " << sModel
|
||||
<< " (" << variable_ID+1 << ") " << c_Equation_Type(equ_type) << " symb_id=" << symbol_table.getID(eEndogenous, variable_ID) << endl;
|
||||
Uf[equation_ID] << " b(" << i+1-block_recursive << "+Per_J_) = -residual(" << i+1-block_recursive << ", it_)";
|
||||
Ufoss << " b(" << i+1-block_recursive << "+Per_J_) = -residual(" << i+1-block_recursive << ", it_)";
|
||||
Uf[equation_ID] += Ufoss.str();
|
||||
Ufoss.str("");
|
||||
output << " residual(" << i+1-block_recursive << ", it_) = (";
|
||||
goto end;
|
||||
default:
|
||||
|
@ -708,21 +712,24 @@ DynamicModel::writeModelEquationsOrdered_M(const string &dynamic_basename) const
|
|||
if (eq >= block_recursive && var >= block_recursive)
|
||||
{
|
||||
if (lag == 0)
|
||||
Uf[eqr] << "+g1(" << eq+1-block_recursive
|
||||
<< "+Per_J_, " << var+1-block_recursive
|
||||
<< "+Per_K_)*y(it_, " << varr+1 << ")";
|
||||
Ufoss << "+g1(" << eq+1-block_recursive
|
||||
<< "+Per_J_, " << var+1-block_recursive
|
||||
<< "+Per_K_)*y(it_, " << varr+1 << ")";
|
||||
else if (lag == 1)
|
||||
Uf[eqr] << "+g1(" << eq+1-block_recursive
|
||||
<< "+Per_J_, " << var+1-block_recursive
|
||||
<< "+Per_y_)*y(it_+1, " << varr+1 << ")";
|
||||
Ufoss << "+g1(" << eq+1-block_recursive
|
||||
<< "+Per_J_, " << var+1-block_recursive
|
||||
<< "+Per_y_)*y(it_+1, " << varr+1 << ")";
|
||||
else if (lag > 0)
|
||||
Uf[eqr] << "+g1(" << eq+1-block_recursive
|
||||
<< "+Per_J_, " << var+1-block_recursive
|
||||
<< "+y_size*(it_+" << lag-1 << "))*y(it_+" << lag << ", " << varr+1 << ")";
|
||||
else if (lag < 0)
|
||||
Uf[eqr] << "+g1(" << eq+1-block_recursive
|
||||
<< "+Per_J_, " << var+1-block_recursive
|
||||
<< "+y_size*(it_" << lag-1 << "))*y(it_" << lag << ", " << varr+1 << ")";
|
||||
Ufoss << "+g1(" << eq+1-block_recursive
|
||||
<< "+Per_J_, " << var+1-block_recursive
|
||||
<< "+y_size*(it_+" << lag-1 << "))*y(it_+" << lag << ", " << varr+1 << ")";
|
||||
else
|
||||
Ufoss << "+g1(" << eq+1-block_recursive
|
||||
<< "+Per_J_, " << var+1-block_recursive
|
||||
<< "+y_size*(it_" << lag-1 << "))*y(it_" << lag << ", " << varr+1 << ")";
|
||||
Uf[eqr] += Ufoss.str();
|
||||
Ufoss.str("");
|
||||
|
||||
if (lag == 0)
|
||||
tmp_output << " g1(" << eq+1-block_recursive << "+Per_J_, "
|
||||
<< var+1-block_recursive << "+Per_K_) = ";
|
||||
|
@ -751,7 +758,7 @@ DynamicModel::writeModelEquationsOrdered_M(const string &dynamic_basename) const
|
|||
for (unsigned int i = 0; i < block_size; i++)
|
||||
{
|
||||
if (i >= block_recursive)
|
||||
output << " " << Uf[getBlockEquationID(block, i)].str() << ";\n";
|
||||
output << " " << Uf[getBlockEquationID(block, i)] << ";\n";
|
||||
#ifdef CONDITION
|
||||
output << " if (fabs(condition(" << i+1 << "))<fabs(u(" << i << "+Per_u_)))\n";
|
||||
output << " condition(" << i+1 << ")=u(" << i+1 << "+Per_u_);\n";
|
||||
|
@ -2043,12 +2050,12 @@ DynamicModel::writeSparseDynamicMFile(const string &dynamic_basename, const stri
|
|||
mDynamicModelFile << " else\n";
|
||||
mDynamicModelFile << " blck_num = 1;\n";
|
||||
mDynamicModelFile << " end;\n";
|
||||
mDynamicModelFile << " y = solve_two_boundaries('" << dynamic_basename << "_" << block + 1 << "'"
|
||||
mDynamicModelFile << " [y oo_] = solve_two_boundaries('" << dynamic_basename << "_" << block + 1 << "'"
|
||||
<<", y, x, params, steady_state, y_index, " << nze
|
||||
<<", options_.periods, " << max_leadlag_block[block].first
|
||||
<<", " << max_leadlag_block[block].second
|
||||
<<", " << blocks_linear[block]
|
||||
<<", blck_num, y_kmin, options_.simul.maxit, options_.solve_tolf, options_.slowc, " << cutoff << ", options_.stack_solve_algo);\n";
|
||||
<<", blck_num, y_kmin, options_.simul.maxit, options_.solve_tolf, options_.slowc, " << cutoff << ", options_.stack_solve_algo, M_, oo_);\n";
|
||||
mDynamicModelFile << " tmp = y(:,M_.block_structure.block(" << block + 1 << ").variable);\n";
|
||||
mDynamicModelFile << " if any(isnan(tmp) | isinf(tmp))\n";
|
||||
mDynamicModelFile << " disp(['Inf or Nan value during the resolution of block " << block <<"']);\n";
|
||||
|
|
|
@ -69,6 +69,9 @@ string eofbuff;
|
|||
// Increments location counter for every token read
|
||||
#define YY_USER_ACTION location_increment(yylloc, yytext);
|
||||
%}
|
||||
|
||||
DATE -?[0-9]+([YyAa]|[Mm]([1-9]|1[0-2])|[Qq][1-4]|[Ww]([1-9]{1}|[1-4][0-9]|5[0-2]))
|
||||
|
||||
%%
|
||||
/* Code put at the beginning of yylex() */
|
||||
%{
|
||||
|
@ -205,7 +208,24 @@ string eofbuff;
|
|||
<INITIAL>corr {BEGIN DYNARE_STATEMENT; return token::CORR;}
|
||||
|
||||
/* Inside of a Dynare statement */
|
||||
<DYNARE_STATEMENT>dates {dates_parens_nb=0; BEGIN DATES_STATEMENT; yylval->string_val = new string("dates");}
|
||||
<DYNARE_STATEMENT>{DATE} {
|
||||
char *yycopy = strdup(yytext);
|
||||
char *uput = yycopy + yyleng;
|
||||
unput(')');
|
||||
unput('\'');
|
||||
while (uput > yycopy)
|
||||
unput(*--uput);
|
||||
unput('\'');
|
||||
unput('(');
|
||||
unput('s');
|
||||
unput('e');
|
||||
unput('t');
|
||||
unput('a');
|
||||
unput('d');
|
||||
free( yycopy );
|
||||
}
|
||||
<DYNARE_STATEMENT>${DATE} { yylloc->step(); *yyout << yytext + 1; }
|
||||
<DYNARE_STATEMENT>dates {dates_parens_nb=0; BEGIN DATES_STATEMENT; yylval->string_val = new string("dates");}
|
||||
<DYNARE_STATEMENT>file {return token::FILE;}
|
||||
<DYNARE_STATEMENT>datafile {return token::DATAFILE;}
|
||||
<DYNARE_STATEMENT>nobs {return token::NOBS;}
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
*/
|
||||
|
||||
#include "Statement.hh"
|
||||
#include <boost/xpressive/xpressive.hpp>
|
||||
|
||||
ModFileStructure::ModFileStructure() :
|
||||
check_present(false),
|
||||
|
@ -74,7 +75,14 @@ NativeStatement::NativeStatement(const string &native_statement_arg) :
|
|||
void
|
||||
NativeStatement::writeOutput(ostream &output, const string &basename) const
|
||||
{
|
||||
output << native_statement << endl;
|
||||
using namespace boost::xpressive;
|
||||
string date_regex = "(-?\\d+([YyAa]|[Mm]([1-9]|1[0-2])|[Qq][1-4]|[Ww]([1-9]{1}|[1-4]\\d|5[0-2])))";
|
||||
sregex regex_lookbehind = sregex::compile("(?<!\\$|\\d|[a-zA-Z]|\\')" + date_regex);
|
||||
sregex regex_dollar = sregex::compile("(\\$)"+date_regex);
|
||||
|
||||
string ns = regex_replace(native_statement, regex_lookbehind, "dates('$&')");
|
||||
ns = regex_replace(ns, regex_dollar, "$2" ); //replace $DATE with DATE
|
||||
output << ns << endl;
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -86,8 +86,6 @@ private:
|
|||
//! If current context is the body of a loop, contains the location of the beginning of the body
|
||||
Macro::parser::location_type for_body_loc;
|
||||
|
||||
//! Temporary variable used for counting parens in dates statement
|
||||
int dates_parens_nb;
|
||||
//! Temporary variable used in FOR_BODY mode
|
||||
string for_body_tmp;
|
||||
//! Temporary variable used in FOR_BODY mode
|
||||
|
|
|
@ -51,7 +51,6 @@ typedef Macro::parser::token token;
|
|||
%x FOR_BODY
|
||||
%x THEN_BODY
|
||||
%x ELSE_BODY
|
||||
%x COPY_DATE_INFO
|
||||
|
||||
%{
|
||||
// Increments location counter for every token read
|
||||
|
@ -61,7 +60,6 @@ typedef Macro::parser::token token;
|
|||
SPC [ \t]+
|
||||
EOL (\r)?\n
|
||||
CONT \\\\
|
||||
DATE (-[1-9][0-9]*|[0-9]+)([YyAa]|[Mm]([1-9]|1[0-2])|[Qq][1-4]|[Ww]([1-9]{1}|[1-4][0-9]|5[0-2]))
|
||||
|
||||
%%
|
||||
/* Code put at the beginning of yylex() */
|
||||
|
@ -89,21 +87,6 @@ DATE (-[1-9][0-9]*|[0-9]+)([YyAa]|[Mm]([1-9]|1[0-2])|[Qq][1-4]|[Ww]([1-9]{1}|[1-
|
|||
<INITIAL>^{SPC}*@# { yylloc->step(); BEGIN(STMT); }
|
||||
<INITIAL>@\{ { yylloc->step(); BEGIN(EXPR); }
|
||||
|
||||
<INITIAL>{DATE} { yylloc->step(); *yyout << "dates('" << yytext << "')"; }
|
||||
<INITIAL>${DATE} { yylloc->step(); *yyout << yytext + 1; }
|
||||
|
||||
<INITIAL>dates{SPC}*\({SPC}* { yylloc->step(); *yyout << "dates("; dates_parens_nb=1; BEGIN(COPY_DATE_INFO); }
|
||||
<COPY_DATE_INFO><<EOF>> { driver.error(*yylloc, "Unexpected end of file in dates statement"); }
|
||||
<COPY_DATE_INFO>{EOL} { yylloc->lines(1); yylloc->step(); }
|
||||
<COPY_DATE_INFO>\( { yylloc->step(); *yyout << yytext; dates_parens_nb++; }
|
||||
<COPY_DATE_INFO>\) {
|
||||
yylloc->step();
|
||||
*yyout << yytext;
|
||||
if (--dates_parens_nb == 0)
|
||||
BEGIN(INITIAL);
|
||||
}
|
||||
<COPY_DATE_INFO>. { yylloc->step(); *yyout << yytext; }
|
||||
|
||||
<EXPR>\} { BEGIN(INITIAL); return token::EOL; }
|
||||
|
||||
<STMT>{CONT}{SPC}*{EOL} { yylloc->lines(1); yylloc->step(); }
|
||||
|
|
Loading…
Reference in New Issue