lmi-commits
[Top][All Lists]
Advanced

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

[lmi-commits] [lmi] master 915e4ef 03/14: Avoid reading back from ledger


From: Greg Chicares
Subject: [lmi-commits] [lmi] master 915e4ef 03/14: Avoid reading back from ledger in class AccountValue
Date: Sun, 6 Sep 2020 07:50:37 -0400 (EDT)

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

    Avoid reading back from ledger in class AccountValue
    
    Established a local vector 'partial_mortality_lx', and used it instead
    of reading 'InvariantValues().InforceLives'.
---
 account_value.hpp |  1 +
 ihs_acctval.cpp   | 20 +++++++++++---------
 ihs_avdebug.cpp   |  2 +-
 3 files changed, 13 insertions(+), 10 deletions(-)

diff --git a/account_value.hpp b/account_value.hpp
index 55b5ec0..6681257 100644
--- a/account_value.hpp
+++ b/account_value.hpp
@@ -584,6 +584,7 @@ class LMI_SO AccountValue final
     double  YearsTotalSepAcctLoad;
 
     std::vector<double> partial_mortality_qx;
+    std::vector<double> partial_mortality_lx;
 
     // For experience rating.
     double  CoiRetentionRate;
diff --git a/ihs_acctval.cpp b/ihs_acctval.cpp
index c0b9dfd..7e2b68b 100644
--- a/ihs_acctval.cpp
+++ b/ihs_acctval.cpp
@@ -424,7 +424,8 @@ void AccountValue::InitializeLife(mcenum_run_basis a_Basis)
         (   lmi::ssize(InvariantValues().InforceLives)
         ==  1 + BasicValues::GetLength()
         );
-    partial_mortality_qx.resize(BasicValues::GetLength());
+    partial_mortality_qx.resize(    BasicValues::GetLength());
+    partial_mortality_lx.resize(1 + BasicValues::GetLength());
     // 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,
@@ -433,21 +434,22 @@ void AccountValue::InitializeLife(mcenum_run_basis 
a_Basis)
     if(yare_input_.UsePartialMortality)
         {
         double inforce_lives = yare_input_.NumberOfIdenticalLives;
-        InvariantValues().InforceLives[0] = inforce_lives;
+        partial_mortality_lx[0] = inforce_lives;
         for(int j = 0; j < BasicValues::GetLength(); ++j)
             {
             partial_mortality_qx[j] = GetPartMortQ(j);
             inforce_lives *= 1.0 - partial_mortality_qx[j];
-            InvariantValues().InforceLives[1 + j] = inforce_lives;
+            partial_mortality_lx[1 + j] = inforce_lives;
             }
         }
     else
         {
-        InvariantValues().InforceLives.assign
-            (InvariantValues().InforceLives.size()
+        partial_mortality_lx.assign
+            (partial_mortality_lx.size()
             ,yare_input_.NumberOfIdenticalLives
             );
         }
+    InvariantValues().InforceLives = partial_mortality_lx;
 
     // It is at best superfluous to do this for every basis.
     // TAXATION !! Don't do that then.
@@ -1497,7 +1499,7 @@ double AccountValue::GetSepAcctAssetsInforce() const
         return 0.0;
         }
 
-    return SepAcctValueAfterDeduction * InvariantValues().InforceLives[Year];
+    return SepAcctValueAfterDeduction * partial_mortality_lx[Year];
 }
 
 //============================================================================
@@ -1533,7 +1535,7 @@ double AccountValue::GetCurtateNetClaimsInforce() const
         }
 
     LMI_ASSERT(11 == Month);
-    return YearsNetClaims * InvariantValues().InforceLives[Year];
+    return YearsNetClaims * partial_mortality_lx[Year];
 }
 
 //============================================================================
@@ -1608,7 +1610,7 @@ double AccountValue::InforceLivesBoy() const
         return 0.0;
         }
 
-    return InvariantValues().InforceLives.at(Year);
+    return partial_mortality_lx.at(Year);
 }
 
 //============================================================================
@@ -1622,7 +1624,7 @@ double AccountValue::InforceLivesEoy() const
         return 0.0;
         }
 
-    return InvariantValues().InforceLives.at(1 + Year);
+    return partial_mortality_lx.at(1 + Year);
 }
 
 //============================================================================
diff --git a/ihs_avdebug.cpp b/ihs_avdebug.cpp
index e59bae3..9b0fe78 100644
--- a/ihs_avdebug.cpp
+++ b/ihs_avdebug.cpp
@@ -435,7 +435,7 @@ void AccountValue::DebugPrint()
         (eInforceFactor
         ,ItLapsed
             ? 0.0
-            : InvariantValues().InforceLives[Year] / 
yare_input_.NumberOfIdenticalLives
+            : partial_mortality_lx[Year] / yare_input_.NumberOfIdenticalLives
         );
 
     // TODO ?? Claims appear as zero because SetClaims() is called not



reply via email to

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