[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
- [lmi-commits] [lmi] master updated (c4f84b4 -> 59860e3), Greg Chicares, 2020/09/06
- [lmi-commits] [lmi] master 123b572 01/14: Avoid reading back from ledger in class AccountValue, Greg Chicares, 2020/09/06
- [lmi-commits] [lmi] master b4eb422 02/14: Rename a variable, Greg Chicares, 2020/09/06
- [lmi-commits] [lmi] master 14c2920 07/14: Factor out partial-mortality calculations, Greg Chicares, 2020/09/06
- [lmi-commits] [lmi] master 338d589 10/14: Call set_partial_mortality() OAOO, Greg Chicares, 2020/09/06
- [lmi-commits] [lmi] master 915e4ef 03/14: Avoid reading back from ledger in class AccountValue,
Greg Chicares <=
- [lmi-commits] [lmi] master 540e3ca 04/14: Simplify, Greg Chicares, 2020/09/06
- [lmi-commits] [lmi] master 73d5f2b 06/14: Refactor for terseness, Greg Chicares, 2020/09/06
- [lmi-commits] [lmi] master 2bcf8d3 08/14: Move commentary outside function body, Greg Chicares, 2020/09/06
- [lmi-commits] [lmi] master 7b9b0cf 11/14: Resolve a marked defect [339], Greg Chicares, 2020/09/06
- [lmi-commits] [lmi] master 3cbd888 12/14: Improve documentation, Greg Chicares, 2020/09/06
- [lmi-commits] [lmi] master 3ff6e18 13/14: Add and use trivial const accessors, Greg Chicares, 2020/09/06
- [lmi-commits] [lmi] master 1f2d652 05/14: Calculate and store partial-mortality tpx along with lx, Greg Chicares, 2020/09/06
- [lmi-commits] [lmi] master a1d6c16 09/14: Improve documentation, Greg Chicares, 2020/09/06
- [lmi-commits] [lmi] master 59860e3 14/14: Move partial mortality into base class, Greg Chicares, 2020/09/06