diff --git a/m4/ax_mexopts.m4 b/m4/ax_mexopts.m4 index a676a79c0..695678648 100644 --- a/m4/ax_mexopts.m4 +++ b/m4/ax_mexopts.m4 @@ -1,4 +1,4 @@ -dnl Copyright (C) 2009-2011 Dynare Team +dnl Copyright (C) 2009-2012 Dynare Team dnl dnl This file is part of Dynare. dnl @@ -62,7 +62,7 @@ case ${MATLAB_ARCH} in ax_mexopts_ok="yes" ;; maci | maci64) - SDKROOT='/Developer/SDKs/MacOSX10.6.sdk' + 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' diff --git a/matlab/DsgeVarLikelihood.m b/matlab/DsgeVarLikelihood.m index 840842cef..c00c4e92c 100644 --- a/matlab/DsgeVarLikelihood.m +++ b/matlab/DsgeVarLikelihood.m @@ -35,7 +35,9 @@ function [fval,grad,hess,exit_flag,info,PHI,SIGMAu,iXX,prior] = DsgeVarLikelihoo % along with Dynare. If not, see . % Declaration of the persistent variables. -persistent penalty dsge_prior_weight_idx +persistent dsge_prior_weight_idx + +penalty = BayesInfo.penalty; grad=[]; hess=[]; @@ -46,16 +48,6 @@ SIGMAu = []; iXX = []; prior = []; -% Initialization of the penalty -if ~nargin || isempty(penalty) - penalty = 1e8; - if ~nargin, return, end -end -if nargin==1 - penalty = xparam1; - return -end - % Initialization of of the index for parameter dsge_prior_weight in Model.params. if isempty(dsge_prior_weight_idx) dsge_prior_weight_idx = strmatch('dsge_prior_weight',Model.param_names); diff --git a/matlab/cmaes.m b/matlab/cmaes.m index a2ef613c0..c0b6d215c 100644 --- a/matlab/cmaes.m +++ b/matlab/cmaes.m @@ -644,11 +644,11 @@ else % flgresume end % initialize random number generator - if ischar(opts.Seed) - randn('state', eval(opts.Seed)); % random number generator state - else - randn('state', opts.Seed); - end +% $$$ if ischar(opts.Seed) +% $$$ randn('state', eval(opts.Seed)); % random number generator state +% $$$ else +% $$$ randn('state', opts.Seed); +% $$$ end %qqq % load(opts.SaveFilename, 'startseed'); % randn('state', startseed); diff --git a/matlab/dsge_likelihood.m b/matlab/dsge_likelihood.m index 0b770a0d4..245eb66fd 100644 --- a/matlab/dsge_likelihood.m +++ b/matlab/dsge_likelihood.m @@ -130,22 +130,7 @@ function [fval,DLIK,Hess,exit_flag,ys,trend_coeff,info,Model,DynareOptions,Bayes % AUTHOR(S) stephane DOT adjemian AT univ DASH lemans DOT FR -% Declaration of the penalty as a persistent variable. - -% Persistent variable 'penalty' is used to compute an endogenous penalty to -% the value 'fval' when various conditions are encountered. These conditions -% set also 'exit_flag' equal to 0 instead of 1. It is only when -% dsge_likelihood() is called by an optimizer called by -% dynare_estimation_1() that 'exit_flag' is ignored and penalized 'fval' is -% actually used. -% In that case, 'penalty' is properly initialized, at the very end of the -% present function, by a call to dsge_likelihood() made in -% initial_estimation_checks(). If a condition triggers exit_flag == -% 0, initial_estimation_checks() triggers an error. -% In summary, an initial call to the present function, without triggering -% any condition, guarantees that 'penalty' is properly initialized when needed. - -persistent penalty +penalty = BayesInfo.penalty; % Initialization of the returned variables and others... fval = []; @@ -568,16 +553,16 @@ if analytic_derivation, if full_Hess DTj = DT(:,:,j+offset); DPj = dum; - for i=1:j, - DTi = DT(:,:,i+offset); - DPi = DP(:,:,i+offset); - D2Tij = D2T(:,:,i,j); - D2Omij = D2Om(:,:,i,j); + for i=1:j+offset, + DTi = DT(:,:,i); + DPi = DP(:,:,i); + D2Tij = D2T(:,:,i,j+offset); + D2Omij = D2Om(:,:,i,j+offset); tmp = D2Tij*Pstar*T' + T*Pstar*D2Tij' + DTi*DPj*T' + DTj*DPi*T' + T*DPj*DTi' + T*DPi*DTj' + DTi*Pstar*DTj' + DTj*Pstar*DTi' + D2Omij; dum = lyapunov_symm(T,tmp,DynareOptions.qz_criterium,DynareOptions.lyapunov_complex_threshold); dum(abs(dum)<1.e-12) = 0; - D2P(:,:,i+offset,j+offset) = dum; - D2P(:,:,j+offset,i+offset) = dum; + D2P(:,:,i,j+offset) = dum; + D2P(:,:,j+offset,i) = dum; end end end @@ -771,9 +756,6 @@ end % Update DynareOptions.kalman_algo. DynareOptions.kalman_algo = kalman_algo; -% Update the penalty. -penalty = fval; - if analytic_derivation==0 && nargout==2, lik=lik(start:end,:); DLIK=[-lnprior; lik(:)]; diff --git a/matlab/k_order_pert.m b/matlab/k_order_pert.m index fe0973964..0fb2355ec 100644 --- a/matlab/k_order_pert.m +++ b/matlab/k_order_pert.m @@ -159,7 +159,7 @@ for i=1:n1 xx = x(:,m); y(:,(i-1)*n1*n2+(j-1)*n2+k) = xx; if j ~= i - y(:,(j-1)*n1*n2+(i-1)*n2+i) = xx; + y(:,(j-1)*n1*n2+(i-1)*n2+k) = xx; end end end diff --git a/matlab/k_order_perturbation.m b/matlab/k_order_perturbation.m new file mode 100644 index 000000000..566a28117 --- /dev/null +++ b/matlab/k_order_perturbation.m @@ -0,0 +1,53 @@ +% [err, g_0, g_1, g_2, g_3, derivs] = k_order_perturbation(dr,DynareModel,DynareOptions) +% computes a k_order_petrubation solution for k=1,2,3 +% +% INPUTS +% dr: struct describing the reduced form solution of the model. +% DynareModel: struct jobs's parameters +% DynareOptions: struct job's options +% +% OUTPUTS +% err: double err code (currently unused) +% g_0: vector dynare++ output. Constant effect of future volatility (in +% dr.order_var order) on the decision rule +% (=ghs2/2). Contains zero when order of +% approximation is 1. +% g_1: matrix dynare++ output. First order Taylor coefficients +% of decision rule. When order of approximation +% is 3, the. Contains both the effect of +% state endogenous variable and shocks. The rows +% are in dr.order_var order. The columns are in +% dr.order_var order of state endogenous +% variables and shocks +% g_2: matrix dynare++ output. Second order Taylor coefficients of decision +% rule. Contains both the effect of state endogenous +% variable and shocks. The rows are in dr.order_var +% order. Each row corresponds to the vectorized +% version of the lower triangle of the Hessian +% matrix. The Taylor coefficient (1/2) is +% included. The columns of the Hessian matrix are in +% dr.order_var order of state endogenous variables +% and shocks +% g_3: matrix dynare++ output. Third order Taylor coefficients of decision +% rule. Contains both the effect of state endogenous +% variable and shocks. The rows are in dr.order_var +% order. Each row corresponds to the vectorized +% version of the 3rd order derivatives tensor where each +% combination of variables appears only once. +% The Taylor coefficient (1/6) is +% included. Inside the tensor, the variables are in +% dr.order_var order of state endogenous variables +% and shocks +% derivs struct contains the original derivatives of the +% decision function (ghx, ghu, ghxx, ghxu, ghuu, +% ghs2, ghxxx, ghxxu, ghxuu,ghuuu, ghxss, ghuss), +% keeping the effect of future volatility +% separate (in ghs2, ghxss and ghuss). The +% derivatives matrices contain full versions of +% the Hessian matrices and 3rd order +% tensor. Symmetric derivatives are repeated. The +% Taylor coefficients (1/2 and 1/6) aren't +% included. +% k_order_peturbation is a compiled MEX function. It's source code is in +% dynare/mex/sources/k_order_perturbation.cc and it uses code provided by +% dynare++ diff --git a/matlab/metropolis_hastings_initialization.m b/matlab/metropolis_hastings_initialization.m index 80c2f3532..2d6e7f07d 100644 --- a/matlab/metropolis_hastings_initialization.m +++ b/matlab/metropolis_hastings_initialization.m @@ -180,9 +180,6 @@ if ~options_.load_mh_file && ~options_.mh_recover % separate initializaton for each chain JSUM = 0; for j=1:nblck, - JSUM = JSUM + sum(100*clock); - randn('state',JSUM); - rand('state',JSUM); record.Seeds(j).Normal = randn('state'); record.Seeds(j).Unifor = rand('state'); end diff --git a/mex/build/matlab/configure.ac b/mex/build/matlab/configure.ac index 4a3f115d7..ca948b4db 100644 --- a/mex/build/matlab/configure.ac +++ b/mex/build/matlab/configure.ac @@ -1,6 +1,6 @@ dnl Process this file with autoconf to produce a configure script. -dnl Copyright (C) 2009-2011 Dynare Team +dnl Copyright (C) 2009-2012 Dynare Team dnl dnl This file is part of Dynare. dnl @@ -17,7 +17,7 @@ dnl dnl You should have received a copy of the GNU General Public License dnl along with Dynare. If not, see . -AC_PREREQ([2.61]) +AC_PREREQ([2.62]) AC_INIT([dynare], [4.4-unstable]) AC_CONFIG_SRCDIR([configure.ac]) AM_INIT_AUTOMAKE([-Wall -Werror foreign]) diff --git a/mex/build/octave/configure.ac b/mex/build/octave/configure.ac index 348557981..da3c6e2ac 100644 --- a/mex/build/octave/configure.ac +++ b/mex/build/octave/configure.ac @@ -1,6 +1,6 @@ dnl Process this file with autoconf to produce a configure script. -dnl Copyright (C) 2009-2011 Dynare Team +dnl Copyright (C) 2009-2012 Dynare Team dnl dnl This file is part of Dynare. dnl @@ -17,7 +17,7 @@ dnl dnl You should have received a copy of the GNU General Public License dnl along with Dynare. If not, see . -AC_PREREQ([2.61]) +AC_PREREQ([2.62]) AC_INIT([dynare], [4.4-unstable]) AC_CONFIG_SRCDIR([configure.ac]) AM_INIT_AUTOMAKE([-Wall -Werror foreign]) diff --git a/mex/sources/k_order_perturbation/k_order_perturbation.cc b/mex/sources/k_order_perturbation/k_order_perturbation.cc index 59100d23c..fba8b8ec4 100644 --- a/mex/sources/k_order_perturbation/k_order_perturbation.cc +++ b/mex/sources/k_order_perturbation/k_order_perturbation.cc @@ -260,8 +260,6 @@ extern "C" { // run stochastic steady app.walkStochSteady(); - app.get_rule_ders()->print(); - /* Write derivative outputs into memory map */ map mm; app.getFoldDecisionRule().writeMMap(mm, string());