lmi-commits
[Top][All Lists]
Advanced

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

[lmi-commits] [lmi] master 14c2920 07/14: Factor out partial-mortality c


From: Greg Chicares
Subject: [lmi-commits] [lmi] master 14c2920 07/14: Factor out partial-mortality calculations
Date: Sun, 6 Sep 2020 07:50:38 -0400 (EDT)

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

    Factor out partial-mortality calculations
    
    Factored a sizable block of code out of a large function and into a
    small standalone function.
    
    Slightly reworded the defect marker, which is actually bogus, as will
    be discussed in a forthcoming commit.
---
 account_value.hpp |  1 +
 ihs_acctval.cpp   | 62 +++++++++++++++++++++++++++++--------------------------
 2 files changed, 34 insertions(+), 29 deletions(-)

diff --git a/account_value.hpp b/account_value.hpp
index 523cea0..638f3e0 100644
--- a/account_value.hpp
+++ b/account_value.hpp
@@ -210,6 +210,7 @@ class LMI_SO AccountValue final
 
     double SolveGuarPremium        ();
 
+    void set_partial_mortality     ();
     double GetPartMortQ            (int year) const;
 
     void PerformSpecAmtStrategy();
diff --git a/ihs_acctval.cpp b/ihs_acctval.cpp
index f090ddc..d08c5e2 100644
--- a/ihs_acctval.cpp
+++ b/ihs_acctval.cpp
@@ -411,35 +411,7 @@ void AccountValue::InitializeLife(mcenum_run_basis a_Basis)
         );
     double sa = specamt_for_7702(0);
 
-    // Iff partial mortality is used, save yearly values in a vector
-    // for use elsewhere in this class, and store yearly inforce lives
-    // (assuming no one ever lapses) in the invariant ledger object.
-    //
-    // A contract may be in force at the end of its maturity year,
-    // and it's necessary to treat it that way because other year-end
-    // composite values are multiplied by the number of lives inforce.
-    // Of course, a contract is not normally in force after maturity.
-
-    double const inforce_lives = yare_input_.NumberOfIdenticalLives;
-    partial_mortality_qx .resize(    BasicValues::GetLength());
-    partial_mortality_tpx.resize(1 + BasicValues::GetLength(), 1.0);
-    partial_mortality_lx .resize(1 + BasicValues::GetLength(), inforce_lives);
-    // TODO ?? 'InvariantValues().InforceLives' may be thought of as
-    // counting potential inforce lives: it does not reflect lapses.
-    // It should either reflect lapses or be renamed. Meanwhile,
-    // InforceLivesBoy() and InforceLivesEoy() may be used where
-    // lapses should be taken into account.
-    if(yare_input_.UsePartialMortality)
-        {
-        // partial_mortality_lx[0] was set above.
-        for(int j = 0; j < BasicValues::GetLength(); ++j)
-            {
-            partial_mortality_qx[j] = GetPartMortQ(j);
-            double const px = 1.0 - partial_mortality_qx[j];
-            partial_mortality_tpx[1 + j] = px * partial_mortality_tpx[j];
-            partial_mortality_lx [1 + j] = px * partial_mortality_lx [j];
-            }
-        }
+    set_partial_mortality();
     InvariantValues().InforceLives = partial_mortality_lx;
 
     // It is at best superfluous to do this for every basis.
@@ -1459,6 +1431,38 @@ void AccountValue::SetAnnualInvariants()
     YearsDacTaxLoadRate     = Loads_->dac_tax_load                    ()[Year];
 }
 
+void AccountValue::set_partial_mortality()
+{
+    // Iff partial mortality is used, save yearly values in a vector
+    // for use elsewhere in this class, and store yearly inforce lives
+    // (assuming no one ever lapses) in the invariant ledger object.
+    //
+    // A contract may be in force at the end of its maturity year,
+    // and it's necessary to treat it that way because other year-end
+    // composite values are multiplied by the number of lives inforce.
+    // Of course, a contract is not normally in force after maturity.
+
+    double const inforce_lives = yare_input_.NumberOfIdenticalLives;
+    partial_mortality_qx .resize(    BasicValues::GetLength());
+    partial_mortality_tpx.resize(1 + BasicValues::GetLength(), 1.0);
+    partial_mortality_lx .resize(1 + BasicValues::GetLength(), inforce_lives);
+    // TODO ?? These actuarial functions may be thought of as
+    // counting potential inforce lives: they do not reflect lapses.
+    // InforceLivesBoy() and InforceLivesEoy() may be used where
+    // lapses should be taken into account.
+    if(yare_input_.UsePartialMortality)
+        {
+        // partial_mortality_lx[0] was set above.
+        for(int j = 0; j < BasicValues::GetLength(); ++j)
+            {
+            partial_mortality_qx[j] = GetPartMortQ(j);
+            double const px = 1.0 - partial_mortality_qx[j];
+            partial_mortality_tpx[1 + j] = px * partial_mortality_tpx[j];
+            partial_mortality_lx [1 + j] = px * partial_mortality_lx [j];
+            }
+        }
+}
+
 //============================================================================
 double AccountValue::GetPartMortQ(int a_year) const
 {



reply via email to

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