diff --git a/CHANGES b/CHANGES index 679d5202e..b8fc81766 100644 --- a/CHANGES +++ b/CHANGES @@ -3,6 +3,9 @@ QUESO: Quantification of Uncertainty for Estimation, Simulation, and Optimization. ----------------------------------------------------- +Version 0.56.2 (Feb 2, 2017) + * Fixed missing factory symbols when linking statically + Version 0.56.1 (Dec 15, 2016) * queso.h and config_queso.h had some duplicate #defines. These have been consodlidated and queso.h has been deprecated. diff --git a/configure.ac b/configure.ac index 582eaa7a8..9a70ce996 100644 --- a/configure.ac +++ b/configure.ac @@ -2,7 +2,7 @@ # Process this file with autoconf to produce a configure script. AC_PREREQ(2.65) -AC_INIT([queso], [0.56.1], [queso-users@googlegroups.com]) +AC_INIT([queso], [0.56.2], [queso-users@googlegroups.com]) PACKAGE_DESCRIPTION="The parallel C++ statistical library QUESO: Quantification of uncertainty for estimation, simulation and optimization" AC_SUBST([PACKAGE_DESCRIPTION]) PACKAGE_URL="https://github.com/libqueso/queso" diff --git a/inc/queso/Makefile.am b/inc/queso/Makefile.am index 06e3d0e7f..11f071d57 100644 --- a/inc/queso/Makefile.am +++ b/inc/queso/Makefile.am @@ -29,6 +29,7 @@ BUILT_SOURCES += VectorSpace.h BUILT_SOURCES += VectorSubset.h BUILT_SOURCES += getpot.h BUILT_SOURCES += AlgorithmFactory.h +BUILT_SOURCES += AlgorithmFactoryInitializer.h BUILT_SOURCES += BaseInputOptionsParser.h BUILT_SOURCES += BasicPdfsBase.h BUILT_SOURCES += BasicPdfsBoost.h @@ -65,6 +66,7 @@ BUILT_SOURCES += RngBoost.h BUILT_SOURCES += RngGsl.h BUILT_SOURCES += ScopedPtr.h BUILT_SOURCES += SharedPtr.h +BUILT_SOURCES += TKFactoryInitializer.h BUILT_SOURCES += TKFactoryLogitRandomWalk.h BUILT_SOURCES += TKFactoryMALA.h BUILT_SOURCES += TKFactoryRandomWalk.h @@ -257,6 +259,8 @@ getpot.h: $(top_srcdir)/src/contrib/getpot/getpot.h $(AM_V_GEN)rm -f $@ && $(LN_S) $< $@ AlgorithmFactory.h: $(top_srcdir)/src/core/inc/AlgorithmFactory.h $(AM_V_GEN)rm -f $@ && $(LN_S) $< $@ +AlgorithmFactoryInitializer.h: $(top_srcdir)/src/core/inc/AlgorithmFactoryInitializer.h + $(AM_V_GEN)rm -f $@ && $(LN_S) $< $@ BaseInputOptionsParser.h: $(top_srcdir)/src/core/inc/BaseInputOptionsParser.h $(AM_V_GEN)rm -f $@ && $(LN_S) $< $@ BasicPdfsBase.h: $(top_srcdir)/src/core/inc/BasicPdfsBase.h @@ -329,6 +333,8 @@ ScopedPtr.h: $(top_srcdir)/src/core/inc/ScopedPtr.h $(AM_V_GEN)rm -f $@ && $(LN_S) $< $@ SharedPtr.h: $(top_srcdir)/src/core/inc/SharedPtr.h $(AM_V_GEN)rm -f $@ && $(LN_S) $< $@ +TKFactoryInitializer.h: $(top_srcdir)/src/core/inc/TKFactoryInitializer.h + $(AM_V_GEN)rm -f $@ && $(LN_S) $< $@ TKFactoryLogitRandomWalk.h: $(top_srcdir)/src/core/inc/TKFactoryLogitRandomWalk.h $(AM_V_GEN)rm -f $@ && $(LN_S) $< $@ TKFactoryMALA.h: $(top_srcdir)/src/core/inc/TKFactoryMALA.h diff --git a/src/Makefile.am b/src/Makefile.am index 50453c356..6a6b5acaa 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -79,11 +79,9 @@ libqueso_la_SOURCES += core/src/OptimizerOptions.C libqueso_la_SOURCES += core/src/BaseInputOptionsParser.C libqueso_la_SOURCES += core/src/BoostInputOptionsParser.C libqueso_la_SOURCES += core/src/TransitionKernelFactory.C -libqueso_la_SOURCES += core/src/TKFactoryStochasticNewton.C -libqueso_la_SOURCES += core/src/TKFactoryRandomWalk.C -libqueso_la_SOURCES += core/src/TKFactoryLogitRandomWalk.C libqueso_la_SOURCES += core/src/AlgorithmFactory.C -libqueso_la_SOURCES += core/src/TKFactoryMALA.C +libqueso_la_SOURCES += core/src/TKFactoryInitializer.C +libqueso_la_SOURCES += core/src/AlgorithmFactoryInitializer.C # Sources that need libmesh @@ -322,6 +320,8 @@ libqueso_include_HEADERS += core/inc/TKFactoryRandomWalk.h libqueso_include_HEADERS += core/inc/TKFactoryLogitRandomWalk.h libqueso_include_HEADERS += core/inc/AlgorithmFactory.h libqueso_include_HEADERS += core/inc/TKFactoryMALA.h +libqueso_include_HEADERS += core/inc/TKFactoryInitializer.h +libqueso_include_HEADERS += core/inc/AlgorithmFactoryInitializer.h # Headers that need libmesh libqueso_include_HEADERS += core/inc/FunctionBase.h diff --git a/src/core/inc/AlgorithmFactory.h b/src/core/inc/AlgorithmFactory.h index eecbc518e..179490b73 100644 --- a/src/core/inc/AlgorithmFactory.h +++ b/src/core/inc/AlgorithmFactory.h @@ -108,7 +108,13 @@ class AlgorithmFactoryImp : public AlgorithmFactory virtual ~AlgorithmFactoryImp() {} private: - virtual SharedPtr >::Type build_algorithm(); + virtual SharedPtr >::Type build_algorithm() + { + SharedPtr >::Type new_alg; + new_alg.reset(new DerivedAlgorithm(*(this->m_env), *(this->m_tk))); + return new_alg; + } + }; } // namespace QUESO diff --git a/src/core/src/TKFactoryRandomWalk.C b/src/core/inc/AlgorithmFactoryInitializer.h similarity index 61% rename from src/core/src/TKFactoryRandomWalk.C rename to src/core/inc/AlgorithmFactoryInitializer.h index b7f28ad46..c151d3b15 100644 --- a/src/core/src/TKFactoryRandomWalk.C +++ b/src/core/inc/AlgorithmFactoryInitializer.h @@ -22,27 +22,19 @@ // //-----------------------------------------------------------------------el- -#include -#include +#ifndef QUESO_ALGORITHM_FACTORY_INITIALIZER_H +#define QUESO_ALGORITHM_FACTORY_INITIALIZER_H namespace QUESO { -template -SharedPtr >::Type -TKFactoryRandomWalk::build_tk() +class AlgorithmFactoryInitializer { - SharedPtr >::Type new_tk; +public: + AlgorithmFactoryInitializer(); + virtual ~AlgorithmFactoryInitializer(); +}; - new_tk.reset(new DerivedTK(this->m_options->m_prefix.c_str(), - *(this->m_vectorSpace), - *(this->m_dr_scales), - *(this->m_initial_cov_matrix))); +} // namespace QUESO - return new_tk; -} - -// Instantiate all the transition kernel factories -TKFactoryRandomWalk > tk_factory_random_walk("random_walk"); - -} // namespace QUESO +#endif // QUESO_ALGORITHM_FACTORY_INITIALIZER_H diff --git a/src/core/src/TKFactoryMALA.C b/src/core/inc/TKFactoryInitializer.h similarity index 56% rename from src/core/src/TKFactoryMALA.C rename to src/core/inc/TKFactoryInitializer.h index 738f9f462..6d70905d8 100644 --- a/src/core/src/TKFactoryMALA.C +++ b/src/core/inc/TKFactoryInitializer.h @@ -22,33 +22,19 @@ // //-----------------------------------------------------------------------el- -#include -#include -#include +#ifndef QUESO_TK_FACTORY_INITIALIZER_H +#define QUESO_TK_FACTORY_INITIALIZER_H namespace QUESO { -template -SharedPtr >::Type -TKFactoryMALA::build_tk() +class TKFactoryInitializer { - SharedPtr >::Type new_tk; - - // Assume the problem is Bayesian - const BayesianJointPdf * target_bayesian_pdf = - dynamic_cast *>( - this->m_target_pdf); - - new_tk.reset(new DerivedTK(this->m_options->m_prefix.c_str(), - *target_bayesian_pdf, - *(this->m_dr_scales), - *(this->m_initial_cov_matrix))); - - return new_tk; -} - -// Instantiate all the transition kernel factories -TKFactoryMALA > tk_factory_mala("mala"); +public: + TKFactoryInitializer(); + virtual ~TKFactoryInitializer(); +}; } // namespace QUESO + +#endif // QUESO_TK_FACTORY_INITIALIZER_H diff --git a/src/core/inc/TKFactoryLogitRandomWalk.h b/src/core/inc/TKFactoryLogitRandomWalk.h index 5d7cb2f98..2bbaee616 100644 --- a/src/core/inc/TKFactoryLogitRandomWalk.h +++ b/src/core/inc/TKFactoryLogitRandomWalk.h @@ -54,7 +54,23 @@ class TKFactoryLogitRandomWalk : public TransitionKernelFactory virtual ~TKFactoryLogitRandomWalk() {} protected: - virtual SharedPtr >::Type build_tk(); + virtual SharedPtr >::Type build_tk() + { + SharedPtr >::Type new_tk; + + // Cast the domain to a box. Might this cast fail? + const BoxSubset & boxSubset = + dynamic_cast & >( + this->m_target_pdf->domainSet()); + + new_tk.reset(new DerivedTK(this->m_options->m_prefix.c_str(), + boxSubset, + *(this->m_dr_scales), + *(this->m_initial_cov_matrix))); + + return new_tk; + } + }; } // namespace QUESO diff --git a/src/core/inc/TKFactoryMALA.h b/src/core/inc/TKFactoryMALA.h index dd073c3e1..dea98b951 100644 --- a/src/core/inc/TKFactoryMALA.h +++ b/src/core/inc/TKFactoryMALA.h @@ -27,6 +27,7 @@ #include #include +#include namespace QUESO { @@ -52,7 +53,23 @@ class TKFactoryMALA : public TransitionKernelFactory virtual ~TKFactoryMALA() {} protected: - virtual SharedPtr >::Type build_tk(); + virtual SharedPtr >::Type build_tk() + { + SharedPtr >::Type new_tk; + + // Assume the problem is Bayesian + const BayesianJointPdf * target_bayesian_pdf = + dynamic_cast *>( + this->m_target_pdf); + + new_tk.reset(new DerivedTK(this->m_options->m_prefix.c_str(), + *target_bayesian_pdf, + *(this->m_dr_scales), + *(this->m_initial_cov_matrix))); + + return new_tk; + } + }; } // namespace QUESO diff --git a/src/core/inc/TKFactoryRandomWalk.h b/src/core/inc/TKFactoryRandomWalk.h index 097cf522b..e5e40cc28 100644 --- a/src/core/inc/TKFactoryRandomWalk.h +++ b/src/core/inc/TKFactoryRandomWalk.h @@ -52,7 +52,18 @@ class TKFactoryRandomWalk : public TransitionKernelFactory virtual ~TKFactoryRandomWalk() {} protected: - virtual SharedPtr >::Type build_tk(); + virtual SharedPtr >::Type build_tk() + { + SharedPtr >::Type new_tk; + + new_tk.reset(new DerivedTK(this->m_options->m_prefix.c_str(), + *(this->m_vectorSpace), + *(this->m_dr_scales), + *(this->m_initial_cov_matrix))); + + return new_tk; + } + }; } // namespace QUESO diff --git a/src/core/inc/TKFactoryStochasticNewton.h b/src/core/inc/TKFactoryStochasticNewton.h index 3304e17a1..c3ba4b551 100644 --- a/src/core/inc/TKFactoryStochasticNewton.h +++ b/src/core/inc/TKFactoryStochasticNewton.h @@ -52,7 +52,18 @@ class TKFactoryStochasticNewton : public TransitionKernelFactory virtual ~TKFactoryStochasticNewton() {} protected: - virtual SharedPtr >::Type build_tk(); + virtual SharedPtr >::Type build_tk() + { + SharedPtr >::Type new_tk; + + new_tk.reset(new DerivedTK(this->m_options->m_prefix.c_str(), + *(this->m_vectorSpace), + *(this->m_dr_scales), + *(this->m_pdf_synchronizer))); + + return new_tk; + } + }; } // namespace QUESO diff --git a/src/core/src/AlgorithmFactory.C b/src/core/src/AlgorithmFactory.C index 2c0ebc709..ab7b51ee5 100644 --- a/src/core/src/AlgorithmFactory.C +++ b/src/core/src/AlgorithmFactory.C @@ -38,21 +38,7 @@ Factory >::factory_map() return _factory_map; } -// AlgorithmFactoryImp implementation -template -SharedPtr >::Type -AlgorithmFactoryImp::build_algorithm() -{ - SharedPtr >::Type new_alg; - new_alg.reset(new DerivedAlgorithm(*(this->m_env), *(this->m_tk))); - return new_alg; -} - const BaseEnvironment * AlgorithmFactory::m_env = NULL; const BaseTKGroup * AlgorithmFactory::m_tk = NULL; -// Register with the factory -AlgorithmFactoryImp > random_walk_alg("random_walk"); -AlgorithmFactoryImp > logit_random_walk_alg("logit_random_walk"); - } // namespace QUESO diff --git a/src/core/src/TKFactoryStochasticNewton.C b/src/core/src/AlgorithmFactoryInitializer.C similarity index 61% rename from src/core/src/TKFactoryStochasticNewton.C rename to src/core/src/AlgorithmFactoryInitializer.C index 75d0ac4eb..ad7f87af4 100644 --- a/src/core/src/TKFactoryStochasticNewton.C +++ b/src/core/src/AlgorithmFactoryInitializer.C @@ -22,27 +22,23 @@ // //-----------------------------------------------------------------------el- -#include -#include +#include +#include namespace QUESO { -template -SharedPtr >::Type -TKFactoryStochasticNewton::build_tk() +AlgorithmFactoryInitializer::AlgorithmFactoryInitializer() { - SharedPtr >::Type new_tk; + // Instantiate all the algorithm factories + static AlgorithmFactoryImp > random_walk_alg("random_walk"); + static AlgorithmFactoryImp > logit_random_walk_alg("logit_random_walk"); - new_tk.reset(new DerivedTK(this->m_options->m_prefix.c_str(), - *(this->m_vectorSpace), - *(this->m_dr_scales), - *(this->m_pdf_synchronizer))); - - return new_tk; } -// Instantiate all the transition kernel factories -TKFactoryStochasticNewton > tk_factory_stochastic_newton("stochastic_newton"); +AlgorithmFactoryInitializer::~AlgorithmFactoryInitializer() +{ + // Do nothing +} } // namespace QUESO diff --git a/src/core/src/TKFactoryLogitRandomWalk.C b/src/core/src/TKFactoryInitializer.C similarity index 55% rename from src/core/src/TKFactoryLogitRandomWalk.C rename to src/core/src/TKFactoryInitializer.C index 05f847c87..aad0f693c 100644 --- a/src/core/src/TKFactoryLogitRandomWalk.C +++ b/src/core/src/TKFactoryInitializer.C @@ -22,32 +22,32 @@ // //-----------------------------------------------------------------------el- +#include + +#include +#include #include +#include +#include #include +#include +#include namespace QUESO { -template -SharedPtr >::Type -TKFactoryLogitRandomWalk::build_tk() +TKFactoryInitializer::TKFactoryInitializer() { - SharedPtr >::Type new_tk; - - // Cast the domain to a box. Might this cast fail? - const BoxSubset & boxSubset = - dynamic_cast & >( - this->m_target_pdf->domainSet()); - - new_tk.reset(new DerivedTK(this->m_options->m_prefix.c_str(), - boxSubset, - *(this->m_dr_scales), - *(this->m_initial_cov_matrix))); - - return new_tk; + // Instantiate all the transition kernel factories + static TKFactoryRandomWalk > tk_factory_random_walk("random_walk"); + static TKFactoryLogitRandomWalk > tk_factory_logit_random_walk("logit_random_walk"); + static TKFactoryStochasticNewton > tk_factory_stochastic_newton("stochastic_newton"); + static TKFactoryMALA > tk_factory_mala("mala"); } -// Instantiate all the transition kernel factories -TKFactoryLogitRandomWalk > tk_factory_logit_random_walk("logit_random_walk"); +TKFactoryInitializer::~TKFactoryInitializer() +{ + // Do nothing +} -} // namespace QUESO +} // namespace QUESO diff --git a/src/stats/src/MetropolisHastingsSG.C b/src/stats/src/MetropolisHastingsSG.C index 48b7b97db..3234d4e15 100644 --- a/src/stats/src/MetropolisHastingsSG.C +++ b/src/stats/src/MetropolisHastingsSG.C @@ -35,7 +35,9 @@ #include +#include #include +#include #include namespace QUESO { @@ -544,6 +546,10 @@ MetropolisHastingsSG::commonConstructor() dynamic_cast & >(m_targetPdf.domainSet())); } + // This instantiates all the transition kernels with their associated + // factories + TKFactoryInitializer tk_factory_initializer; + TransitionKernelFactory::set_vectorspace(m_vectorSpace); TransitionKernelFactory::set_options(*m_optionsObj); TransitionKernelFactory::set_pdf_synchronizer(*m_targetPdfSynchronizer); @@ -552,6 +558,9 @@ MetropolisHastingsSG::commonConstructor() TransitionKernelFactory::set_target_pdf(m_targetPdf); m_tk = TransitionKernelFactory::build(m_optionsObj->m_tk); + // This instantiates all the algorithms with their associated factories + AlgorithmFactoryInitializer algorithm_factory_initializer; + AlgorithmFactory::set_environment(m_env); AlgorithmFactory::set_tk(*m_tk); m_algorithm = AlgorithmFactory::build(m_optionsObj->m_algorithm);