[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
{
- [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 <=
- [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, 2020/09/06
- [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