From ed9cd6c9342a1737f88fc3fc7669a8fa55213cd2 Mon Sep 17 00:00:00 2001 From: Tom Veasey Date: Wed, 20 Jan 2021 11:16:23 +0000 Subject: [PATCH 1/3] Correct a bug in upgrade from pre 6.3 state --- include/maths/CTimeSeriesModel.h | 6 ++++++ lib/maths/CTimeSeriesModel.cc | 12 +++++++++++- lib/maths/unittest/CTimeSeriesModelTest.cc | 14 ++++++++++++-- 3 files changed, 29 insertions(+), 3 deletions(-) diff --git a/include/maths/CTimeSeriesModel.h b/include/maths/CTimeSeriesModel.h index 7ca78c8f05..7dd3313cc1 100644 --- a/include/maths/CTimeSeriesModel.h +++ b/include/maths/CTimeSeriesModel.h @@ -214,6 +214,9 @@ class MATHS_EXPORT CUnivariateTimeSeriesModel : public CModel { //! Get the residual model. const CPrior& residualModel() const; + + //! Get the decay rate controllers. + const TDecayRateController2Ary* decayRateControllers() const; //@} private: @@ -681,6 +684,9 @@ class MATHS_EXPORT CMultivariateTimeSeriesModel : public CModel { //! Get the residual model. const CMultivariatePrior& residualModel() const; + + //! Get the decay rate controllers. + const TDecayRateController2Ary* decayRateControllers() const; //@} private: diff --git a/lib/maths/CTimeSeriesModel.cc b/lib/maths/CTimeSeriesModel.cc index 117c1a4a83..140819dbac 100644 --- a/lib/maths/CTimeSeriesModel.cc +++ b/lib/maths/CTimeSeriesModel.cc @@ -1451,6 +1451,11 @@ const CPrior& CUnivariateTimeSeriesModel::residualModel() const { return *m_ResidualModel; } +const CUnivariateTimeSeriesModel::TDecayRateController2Ary* +CUnivariateTimeSeriesModel::decayRateControllers() const { + return m_Controllers.get(); +} + CUnivariateTimeSeriesModel::CUnivariateTimeSeriesModel(const CUnivariateTimeSeriesModel& other, std::size_t id, bool isForForecast) @@ -2751,7 +2756,7 @@ bool CMultivariateTimeSeriesModel::acceptRestoreTraverser(const SModelRestorePar RESTORE_SETUP_TEARDOWN( CONTROLLER_OLD_TAG, m_Controllers = std::make_unique(), - core::CPersistUtils::restore(CONTROLLER_6_3_TAG, *m_Controllers, traverser), + core::CPersistUtils::restore(CONTROLLER_OLD_TAG, *m_Controllers, traverser), /**/) RESTORE_SETUP_TEARDOWN( TREND_OLD_TAG, m_TrendModel.push_back(TDecompositionPtr()), @@ -2849,6 +2854,11 @@ const CMultivariatePrior& CMultivariateTimeSeriesModel::residualModel() const { return *m_ResidualModel; } +const CMultivariateTimeSeriesModel::TDecayRateController2Ary* +CMultivariateTimeSeriesModel::decayRateControllers() const { + return m_Controllers.get(); +} + CMultivariateTimeSeriesModel::EUpdateResult CMultivariateTimeSeriesModel::updateTrend(const CModelAddSamplesParams& params, const TTimeDouble2VecSizeTrVec& samples) { diff --git a/lib/maths/unittest/CTimeSeriesModelTest.cc b/lib/maths/unittest/CTimeSeriesModelTest.cc index fe99ed616e..e7ddd4c82c 100644 --- a/lib/maths/unittest/CTimeSeriesModelTest.cc +++ b/lib/maths/unittest/CTimeSeriesModelTest.cc @@ -1762,7 +1762,7 @@ BOOST_AUTO_TEST_CASE(testPersist) { // TODO LOG_DEBUG(<< "Correlates"); } -BOOST_AUTO_TEST_CASE(testUpgrade) { +BOOST_AUTO_TEST_CASE(testUpgradeFrom6p2) { // Test upgrade is minimally disruptive. We test the upgraded model // predicted confidence intervals verses the values we obtain from // the previous model. Note the confidence interval depends on both @@ -1829,7 +1829,12 @@ BOOST_AUTO_TEST_CASE(testUpgrade) { boost::lexical_cast(expectedInterval[j]), boost::lexical_cast(interval[j]), 0.0001); } - } + } + BOOST_TEST_REQUIRE(restoredModel.decayRateControllers() != nullptr); + BOOST_TEST_REQUIRE((*restoredModel.decayRateControllers())[0].checks() != 0); + BOOST_TEST_REQUIRE((*restoredModel.decayRateControllers())[1].checks() != 0); + BOOST_TEST_REQUIRE((*restoredModel.decayRateControllers())[0].dimension() == 1); + BOOST_TEST_REQUIRE((*restoredModel.decayRateControllers())[1].dimension() == 1); } LOG_DEBUG(<< "Multivariate"); @@ -1879,6 +1884,11 @@ BOOST_AUTO_TEST_CASE(testUpgrade) { boost::lexical_cast(interval[j]), 0.0001); } } + BOOST_TEST_REQUIRE(restoredModel.decayRateControllers() != nullptr); + BOOST_TEST_REQUIRE((*restoredModel.decayRateControllers())[0].checks() != 0); + BOOST_TEST_REQUIRE((*restoredModel.decayRateControllers())[1].checks() != 0); + BOOST_TEST_REQUIRE((*restoredModel.decayRateControllers())[0].dimension() == 3); + BOOST_TEST_REQUIRE((*restoredModel.decayRateControllers())[1].dimension() == 3); } } From 59e91ce853c227fa52078b2cc671e5b5ad7b0800 Mon Sep 17 00:00:00 2001 From: Tom Veasey Date: Wed, 20 Jan 2021 11:22:50 +0000 Subject: [PATCH 2/3] Docs --- docs/CHANGELOG.asciidoc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/CHANGELOG.asciidoc b/docs/CHANGELOG.asciidoc index eb5d9f78c9..cba4376ebf 100644 --- a/docs/CHANGELOG.asciidoc +++ b/docs/CHANGELOG.asciidoc @@ -47,6 +47,8 @@ if the time series has non-diurnal seasonality. (See {ml-pull}1634[#1634].) * Compute importance of hyperparameters optimized in the fine parameter tuning step. (See {ml-pull}1627[#1627].) +* Correct upgrade for pre-6.3 state for lat_long anomaly anomaly detectors. (See + {ml-pull}1681[#1681].) == {es} version 7.11.0 From 229cb92440e0445b07e736a1e4390eb305b1016a Mon Sep 17 00:00:00 2001 From: Tom Veasey Date: Wed, 20 Jan 2021 12:49:28 +0000 Subject: [PATCH 3/3] Formatting --- lib/maths/unittest/CTimeSeriesModelTest.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/maths/unittest/CTimeSeriesModelTest.cc b/lib/maths/unittest/CTimeSeriesModelTest.cc index e7ddd4c82c..05c746fccf 100644 --- a/lib/maths/unittest/CTimeSeriesModelTest.cc +++ b/lib/maths/unittest/CTimeSeriesModelTest.cc @@ -1829,7 +1829,7 @@ BOOST_AUTO_TEST_CASE(testUpgradeFrom6p2) { boost::lexical_cast(expectedInterval[j]), boost::lexical_cast(interval[j]), 0.0001); } - } + } BOOST_TEST_REQUIRE(restoredModel.decayRateControllers() != nullptr); BOOST_TEST_REQUIRE((*restoredModel.decayRateControllers())[0].checks() != 0); BOOST_TEST_REQUIRE((*restoredModel.decayRateControllers())[1].checks() != 0);