Commit 871cbbe4 authored by Sébastien Villemot's avatar Sébastien Villemot
Browse files

Construct the filename of the dynamic MEX file only at the deepest level

In the calling chain, only pass the basename of the MOD file.
parent 325a2ea9
......@@ -30,7 +30,7 @@ InitializeKalmanFilter::~InitializeKalmanFilter()
{
}
InitializeKalmanFilter::InitializeKalmanFilter(const std::string &dynamicDllFile, size_t n_endo_arg, size_t n_exo_arg,
InitializeKalmanFilter::InitializeKalmanFilter(const std::string &basename, size_t n_endo_arg, size_t n_exo_arg,
const std::vector<size_t> &zeta_fwrd_arg, const std::vector<size_t> &zeta_back_arg,
const std::vector<size_t> &zeta_mixed_arg, const std::vector<size_t> &zeta_static_arg,
const std::vector<size_t> &zeta_varobs_back_mixed_arg,
......@@ -42,7 +42,7 @@ InitializeKalmanFilter::InitializeKalmanFilter(const std::string &dynamicDllFile
lyapunov_tol(lyapunov_tol_arg),
zeta_varobs_back_mixed(zeta_varobs_back_mixed_arg),
detrendData(varobs_arg, noconstant_arg),
modelSolution(dynamicDllFile, n_endo_arg, n_exo_arg, zeta_fwrd_arg, zeta_back_arg,
modelSolution(basename, n_endo_arg, n_exo_arg, zeta_fwrd_arg, zeta_back_arg,
zeta_mixed_arg, zeta_static_arg, qz_criterium_arg),
discLyapFast(zeta_varobs_back_mixed.size()),
g_x(n_endo_arg, zeta_back_arg.size() + zeta_mixed_arg.size()),
......
......@@ -43,7 +43,7 @@ public:
/*!
\param[in] zeta_varobs_back_mixed_arg The union of indices of observed, backward and mixed variables
*/
InitializeKalmanFilter(const std::string &dynamicDllFile, size_t n_endo, size_t n_exo, const std::vector<size_t> &zeta_fwrd_arg,
InitializeKalmanFilter(const std::string &basename, size_t n_endo, size_t n_exo, const std::vector<size_t> &zeta_fwrd_arg,
const std::vector<size_t> &zeta_back_arg, const std::vector<size_t> &zeta_mixed_arg, const std::vector<size_t> &zeta_static_arg,
const std::vector<size_t> &zeta_varobs_back_mixed_arg,
const std::vector<size_t> &varobs_arg,
......
......@@ -31,7 +31,7 @@ KalmanFilter::~KalmanFilter()
}
KalmanFilter::KalmanFilter(const std::string &dynamicDllFile, size_t n_endo, size_t n_exo,
KalmanFilter::KalmanFilter(const std::string &basename, size_t n_endo, size_t n_exo,
const std::vector<size_t> &zeta_fwrd_arg, const std::vector<size_t> &zeta_back_arg,
const std::vector<size_t> &zeta_mixed_arg, const std::vector<size_t> &zeta_static_arg,
double qz_criterium_arg, const std::vector<size_t> &varobs_arg,
......@@ -44,7 +44,7 @@ KalmanFilter::KalmanFilter(const std::string &dynamicDllFile, size_t n_endo, siz
Finv(varobs_arg.size(), varobs_arg.size()), K(zeta_varobs_back_mixed.size(), varobs_arg.size()), KFinv(zeta_varobs_back_mixed.size(), varobs_arg.size()),
oldKFinv(zeta_varobs_back_mixed.size(), varobs_arg.size()), a_init(zeta_varobs_back_mixed.size()),
a_new(zeta_varobs_back_mixed.size()), vt(varobs_arg.size()), vtFinv(varobs_arg.size()), riccati_tol(riccati_tol_arg),
initKalmanFilter(dynamicDllFile, n_endo, n_exo, zeta_fwrd_arg, zeta_back_arg, zeta_mixed_arg,
initKalmanFilter(basename, n_endo, n_exo, zeta_fwrd_arg, zeta_back_arg, zeta_mixed_arg,
zeta_static_arg, zeta_varobs_back_mixed, varobs_arg, qz_criterium_arg, lyapunov_tol_arg, noconstant_arg, info),
FUTP(varobs_arg.size()*(varobs_arg.size()+1)/2)
{
......
......@@ -49,7 +49,7 @@ class KalmanFilter
public:
virtual ~KalmanFilter();
KalmanFilter(const std::string &dynamicDllFile, size_t n_endo, size_t n_exo, const std::vector<size_t> &zeta_fwrd_arg,
KalmanFilter(const std::string &basename, size_t n_endo, size_t n_exo, const std::vector<size_t> &zeta_fwrd_arg,
const std::vector<size_t> &zeta_back_arg, const std::vector<size_t> &zeta_mixed_arg, const std::vector<size_t> &zeta_static_arg,
double qz_criterium_arg, const std::vector<size_t> &varobs_arg,
double riccati_tol_arg, double lyapunov_tol_arg,
......
......@@ -25,14 +25,14 @@
#include "LogLikelihoodMain.hh"
LogLikelihoodMain::LogLikelihoodMain(const std::string &dynamicDllFile, EstimatedParametersDescription &estiParDesc, size_t n_endo, size_t n_exo,
LogLikelihoodMain::LogLikelihoodMain(const std::string &basename, EstimatedParametersDescription &estiParDesc, size_t n_endo, size_t n_exo,
const std::vector<size_t> &zeta_fwrd_arg, const std::vector<size_t> &zeta_back_arg,
const std::vector<size_t> &zeta_mixed_arg, const std::vector<size_t> &zeta_static_arg, const double qz_criterium,
const std::vector<size_t> &varobs, double riccati_tol, double lyapunov_tol,
bool noconstant_arg, int &info_arg)
: estSubsamples(estiParDesc.estSubsamples),
logLikelihoodSubSample(dynamicDllFile, estiParDesc, n_endo, n_exo, zeta_fwrd_arg, zeta_back_arg, zeta_mixed_arg, zeta_static_arg, qz_criterium,
logLikelihoodSubSample(basename, estiParDesc, n_endo, n_exo, zeta_fwrd_arg, zeta_back_arg, zeta_mixed_arg, zeta_static_arg, qz_criterium,
varobs, riccati_tol, lyapunov_tol, noconstant_arg, info_arg),
vll(estiParDesc.getNumberOfPeriods()), // time dimension size of data
detrendedData(varobs.size(), estiParDesc.getNumberOfPeriods())
......
......@@ -37,7 +37,7 @@ private:
public:
virtual ~LogLikelihoodMain();
LogLikelihoodMain(const std::string &dynamicDllFile, EstimatedParametersDescription &estiParDesc, size_t n_endo, size_t n_exo,
LogLikelihoodMain(const std::string &basename, EstimatedParametersDescription &estiParDesc, size_t n_endo, size_t n_exo,
const std::vector<size_t> &zeta_fwrd_arg, const std::vector<size_t> &zeta_back_arg, const std::vector<size_t> &zeta_mixed_arg,
const std::vector<size_t> &zeta_static_arg, const double qz_criterium_arg, const std::vector<size_t> &varobs_arg,
double riccati_tol_arg, double lyapunov_tol_arg,
......
......@@ -29,12 +29,12 @@ LogLikelihoodSubSample::~LogLikelihoodSubSample()
{
};
LogLikelihoodSubSample::LogLikelihoodSubSample(const std::string &dynamicDllFile, EstimatedParametersDescription &INestiParDesc, size_t n_endo, size_t n_exo,
LogLikelihoodSubSample::LogLikelihoodSubSample(const std::string &basename, EstimatedParametersDescription &INestiParDesc, size_t n_endo, size_t n_exo,
const std::vector<size_t> &zeta_fwrd_arg, const std::vector<size_t> &zeta_back_arg,
const std::vector<size_t> &zeta_mixed_arg, const std::vector<size_t> &zeta_static_arg, const double qz_criterium,
const std::vector<size_t> &varobs, double riccati_tol, double lyapunov_tol, bool noconstant_arg, int &INinfo) :
startPenalty(-1e8), estiParDesc(INestiParDesc),
kalmanFilter(dynamicDllFile, n_endo, n_exo, zeta_fwrd_arg, zeta_back_arg, zeta_mixed_arg, zeta_static_arg, qz_criterium,
kalmanFilter(basename, n_endo, n_exo, zeta_fwrd_arg, zeta_back_arg, zeta_mixed_arg, zeta_static_arg, qz_criterium,
varobs, riccati_tol, lyapunov_tol, noconstant_arg, INinfo), eigQ(n_exo), eigH(varobs.size()), info(INinfo)
{
};
......
......@@ -36,7 +36,7 @@ class LogLikelihoodSubSample
{
public:
LogLikelihoodSubSample(const std::string &dynamicDllFile, EstimatedParametersDescription &estiParDesc, size_t n_endo, size_t n_exo,
LogLikelihoodSubSample(const std::string &basename, EstimatedParametersDescription &estiParDesc, size_t n_endo, size_t n_exo,
const std::vector<size_t> &zeta_fwrd_arg, const std::vector<size_t> &zeta_back_arg,
const std::vector<size_t> &zeta_mixed_arg, const std::vector<size_t> &zeta_static_arg, const double qz_criterium,
const std::vector<size_t> &varobs_arg, double riccati_tol_in, double lyapunov_tol, bool noconstant_arg, int &info);
......
......@@ -30,14 +30,14 @@
/**
* compute the steady state (2nd stage), and computes first order approximation
*/
ModelSolution::ModelSolution(const std::string &dynamicDllFile, size_t n_endo_arg, size_t n_exo_arg, const std::vector<size_t> &zeta_fwrd_arg,
ModelSolution::ModelSolution(const std::string &basename, size_t n_endo_arg, size_t n_exo_arg, const std::vector<size_t> &zeta_fwrd_arg,
const std::vector<size_t> &zeta_back_arg, const std::vector<size_t> &zeta_mixed_arg,
const std::vector<size_t> &zeta_static_arg, double INqz_criterium) :
n_endo(n_endo_arg), n_exo(n_exo_arg), // n_jcols = Num of Jacobian columns = nStat+2*nPred+3*nBoth+2*nForw+nExog
n_jcols(n_exo+n_endo+ zeta_back_arg.size() /*nsPred*/ + zeta_fwrd_arg.size() /*nsForw*/ +2*zeta_mixed_arg.size()),
jacobian(n_endo, n_jcols), residual(n_endo), Mx(1, n_exo),
decisionRules(n_endo_arg, n_exo_arg, zeta_fwrd_arg, zeta_back_arg, zeta_mixed_arg, zeta_static_arg, INqz_criterium),
dynamicDLLp(dynamicDllFile),
dynamicDLLp(basename),
llXsteadyState(n_jcols-n_exo)
{
Mx.setAll(0.0);
......
......@@ -38,7 +38,7 @@ class ModelSolution
{
public:
ModelSolution(const std::string &dynamicDllFile, size_t n_endo, size_t n_exo, const std::vector<size_t> &zeta_fwrd_arg,
ModelSolution(const std::string &basename, size_t n_endo, size_t n_exo, const std::vector<size_t> &zeta_fwrd_arg,
const std::vector<size_t> &zeta_back_arg, const std::vector<size_t> &zeta_mixed_arg,
const std::vector<size_t> &zeta_static_arg, double qz_criterium);
virtual ~ModelSolution() {};
......
......@@ -650,10 +650,8 @@ logMCMCposterior(VectorConstView &estParams, const MatrixConstView &data,
// Construct arguments of constructor of LogLikelihoodMain
char *fName = mxArrayToString(mxGetField(M_, 0, "fname"));
std::string resultsFileStem(fName);
std::string dynamicDllFile(fName);
std::string basename(fName);
mxFree(fName);
dynamicDllFile += "_dynamic";
dynamicDllFile += MEXEXT;
size_t n_endo = (size_t) *mxGetPr(mxGetField(M_, 0, "endo_nbr"));
size_t n_exo = (size_t) *mxGetPr(mxGetField(M_, 0, "exo_nbr"));
......@@ -716,7 +714,7 @@ logMCMCposterior(VectorConstView &estParams, const MatrixConstView &data,
// Allocate LogPosteriorDensity object
int info;
LogPosteriorDensity lpd(dynamicDllFile, epd, n_endo, n_exo, zeta_fwrd, zeta_back, zeta_mixed, zeta_static,
LogPosteriorDensity lpd(basename, epd, n_endo, n_exo, zeta_fwrd, zeta_back, zeta_mixed, zeta_static,
qz_criterium, varobs, riccati_tol, lyapunov_tol, noconstant, info);
// Construct MHMCMC Sampler
......
......@@ -116,10 +116,8 @@ logposterior(VEC1 &estParams, const MatrixConstView &data,
// Construct arguments of constructor of LogLikelihoodMain
char *fName = mxArrayToString(mxGetField(M_, 0, "fname"));
std::string dynamicDllFile(fName);
std::string basename(fName);
mxFree(fName);
dynamicDllFile += "_dynamic";
dynamicDllFile += MEXEXT;
size_t n_endo = (size_t) *mxGetPr(mxGetField(M_, 0, "endo_nbr"));
size_t n_exo = (size_t) *mxGetPr(mxGetField(M_, 0, "exo_nbr"));
......@@ -184,7 +182,7 @@ logposterior(VEC1 &estParams, const MatrixConstView &data,
bool noconstant = (bool) *mxGetPr(mxGetField(options_, 0, "noconstant"));
// Allocate LogPosteriorDensity object
LogPosteriorDensity lpd(dynamicDllFile, epd, n_endo, n_exo, zeta_fwrd, zeta_back, zeta_mixed, zeta_static,
LogPosteriorDensity lpd(basename, epd, n_endo, n_exo, zeta_fwrd, zeta_back, zeta_mixed, zeta_static,
qz_criterium, varobs, riccati_tol, lyapunov_tol, noconstant, info);
// Construct arguments of compute() method
......
......@@ -23,14 +23,14 @@
using namespace std;
DynamicModelDLL::DynamicModelDLL(const std::string &dynamicDllFile) throw (TSException)
DynamicModelDLL::DynamicModelDLL(const std::string &basename) throw (TSException)
{
std::string fName;
#if !defined(__CYGWIN32__) && !defined(_WIN32)
if (dynamicDllFile[0] != '/')
if (basename[0] != '/')
fName = "./";
#endif
fName += dynamicDllFile;
fName += basename + "_dynamic" + MEXEXT;
try
{
......
......@@ -52,7 +52,7 @@ private:
public:
// construct and load Dynamic model DLL
DynamicModelDLL(const std::string &dynamicDllFile) throw (TSException);
DynamicModelDLL(const std::string &basename) throw (TSException);
virtual ~DynamicModelDLL();
//! evaluate Dynamic model DLL
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment