lmi-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lmi-commits] [lmi] master 26db3ec 04/14: Move an assertion upstream, an


From: Greg Chicares
Subject: [lmi-commits] [lmi] master 26db3ec 04/14: Move an assertion upstream, and generalize it
Date: Thu, 1 Apr 2021 18:15:16 -0400 (EDT)

branch: master
commit 26db3ec52ff1bd02b56ff6b2d8a2e45f3ebbe4a4
Author: Gregory W. Chicares <gchicares@sbcglobal.net>
Commit: Gregory W. Chicares <gchicares@sbcglobal.net>

    Move an assertion upstream, and generalize it
    
    All 'C..._' must be nonzero after the initial duration. Asserted so
    in assert_preconditions() rather than in only one constructor. Moved
    associated documentation to a more natural place, rewording it, in
    particular to explain why a vector that must be uniformly zero after
    the initial duration is preferable to a scalar representing only the
    initial value. The reason, if not obvious, is that a universal formula
      max(A, Bgen, Cgen) - Dgen
    is clearer than one with conditional alternatives
      max(A, Bgen, Cgen) - Dgen  (first duration only)
      max(A, Bgen      ) - Dgen  (all other durations)
---
 i7702.cpp      | 13 ++++++++++---
 i7702_init.cpp | 14 +++-----------
 2 files changed, 13 insertions(+), 14 deletions(-)

diff --git a/i7702.cpp b/i7702.cpp
index 14f4b4d..b484bfa 100644
--- a/i7702.cpp
+++ b/i7702.cpp
@@ -92,10 +92,10 @@
 ///   for loans: charged - spread
 ///   usually no guarantee for separate account, making Bsep zero
 ///
-/// C: initial short-term guarantees
+/// C: initial short-term guarantees--ignored for GLP only
+///   "extending no more than one year" (DEFRA Blue Book, page 649)
+///   a vector for convenience, uniformly zero after the issue year
 ///   usually altogether avoided by careful product design
-///   variable loan rate may cause Cvlr to be nonzero
-///   always zero in practice for lmi, which doesn't yet implement VLR
 ///
 /// D: asset-based charges
 ///   lowest value each year, if dependent on assets, premiums, etc.
@@ -229,6 +229,8 @@ i7702::i7702
 
 void i7702::assert_preconditions()
 {
+    LMI_ASSERT(0 < length_);
+
     LMI_ASSERT(length_ == lmi::ssize(Bgen_   ));
     LMI_ASSERT(length_ == lmi::ssize(Bsep_   ));
     LMI_ASSERT(length_ == lmi::ssize(Bflr_   ));
@@ -246,6 +248,11 @@ void i7702::assert_preconditions()
     LMI_ASSERT(length_ == lmi::ssize(use_sep_));
     LMI_ASSERT(length_ == lmi::ssize(use_flr_));
     LMI_ASSERT(length_ == lmi::ssize(use_vlr_));
+
+    LMI_ASSERT(each_equal(++Cgen_.begin(), Cgen_.end(), 0.0));
+    LMI_ASSERT(each_equal(++Csep_.begin(), Csep_.end(), 0.0));
+    LMI_ASSERT(each_equal(++Cflr_.begin(), Cflr_.end(), 0.0));
+    LMI_ASSERT(each_equal(++Cvlr_.begin(), Cvlr_.end(), 0.0));
 }
 
 void i7702::initialize()
diff --git a/i7702_init.cpp b/i7702_init.cpp
index 3c6aed1..9e15766 100644
--- a/i7702_init.cpp
+++ b/i7702_init.cpp
@@ -29,7 +29,7 @@
 #include "et_vector.hpp"
 #include "global_settings.hpp"          // 7702 !! pyx
 #include "math_functions.hpp"
-#include "miscellany.hpp"               // each_equal(), minmax
+#include "miscellany.hpp"               // minmax
 #include "stratified_charges.hpp"
 
 i7702::i7702
@@ -64,8 +64,6 @@ i7702::i7702
     ,ig_glp_   (length_)
     ,ig_gsp_   (length_)
 {
-    // 7702 !! Should 'C*' members be scalar--first year only?
-
     std::vector<double> const zero(length_);
 
     database.query_into(DB_AllowGenAcct  , use_gen_);
@@ -98,12 +96,8 @@ i7702::i7702
     assign(Bflr_, fixed_loan_rate    - guar_loan_spread);
     assign(Bvlr_, variable_loan_rate - guar_loan_spread);
 
-    // According to the DEFRA Blue Book (page 649),
-    //   "short-term guarantees (extending no more than one year)"
-    // may be ignored for GLP only. Therefore, DB_ShortTermIntGuar7702
-    // must be zero after the first year. It is taken as pertaining to
-    // Cgen_ and Csep_, to cover every case that Cflr_ and Cvlr_ do
-    // not address.
+    // Take DB_ShortTermIntGuar7702 as pertaining to Cgen_ and Csep_,
+    // to cover every case that Cflr_ and Cvlr_ do not address.
     //
     // If lmi someday implements VLR, then the current VLR rate on
     // the issue date generally constitutes a short-term guarantee
@@ -113,8 +107,6 @@ i7702::i7702
     // so unlikely that lmi's database doesn't provide for it yet.
 
     database.query_into(DB_ShortTermIntGuar7702, Cgen_);
-    LMI_ASSERT(!Cgen_.empty());
-    LMI_ASSERT(each_equal(++Cgen_.begin(), Cgen_.end(), 0.0));
     Csep_ = Cgen_;
 
     database.query_into(DB_CurrSepAcctLoad, Dsep_);



reply via email to

[Prev in Thread] Current Thread [Next in Thread]