[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] odd/transcend 365cbb4 1/3: Perform a transcendental
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] odd/transcend 365cbb4 1/3: Perform a transcendental calculation annually instead of monthly |
Date: |
Thu, 28 Jan 2021 13:14:51 -0500 (EST) |
branch: odd/transcend
commit 365cbb477dfdcfe56d8dd44c2941d4bdf88a7537
Author: Gregory W. Chicares <gchicares@sbcglobal.net>
Commit: Gregory W. Chicares <gchicares@sbcglobal.net>
Perform a transcendental calculation annually instead of monthly
Of course, this calculation should be done OAOO in class InterestRates,
but until there's time for that, this small change may make a noticeable
difference in runtime performance (once the validating assertion is
expunged). Dynamic monthly interest decrements cannot affect this gross
rate, so its value does not change from month to month.
---
account_value.hpp | 3 ++-
ihs_acctval.cpp | 10 ++++++++++
ihs_avmly.cpp | 5 ++++-
3 files changed, 16 insertions(+), 2 deletions(-)
diff --git a/account_value.hpp b/account_value.hpp
index e1dce90..c5888cc 100644
--- a/account_value.hpp
+++ b/account_value.hpp
@@ -487,7 +487,8 @@ class LMI_SO AccountValue final
currency YearsAnnualPolicyFee;
currency YearsMonthlyPolicyFee;
double YearsGenAcctIntRate;
- double YearsSepAcctIntRate;
+ double YearsSepAcctIntRate; // Rename: "Net"
+ double YearsSepAcctGrossRate;
double YearsDcvIntRate;
diff --git a/ihs_acctval.cpp b/ihs_acctval.cpp
index 96816d5..bc747de 100644
--- a/ihs_acctval.cpp
+++ b/ihs_acctval.cpp
@@ -39,6 +39,7 @@
#include "ledger_variant.hpp"
#include "loads.hpp"
#include "materially_equal.hpp"
+#include "math_functions.hpp"
#include "miscellany.hpp"
#include "mortality_rates.hpp"
#include "outlay.hpp"
@@ -1398,6 +1399,15 @@ void AccountValue::SetAnnualInvariants()
)
[Year]
;
+ // SOMEDAY !! This should be done in the interest-rate class.
+ YearsSepAcctGrossRate = 0.0;
+ if(mce_gen_mdpt != GenBasis_)
+ {
+ YearsSepAcctGrossRate = i_upper_12_over_12_from_i<double>()
+ (InterestRates_->SepAcctGrossRate(SepBasis_)[Year]
+ );
+ YearsSepAcctGrossRate = round_interest_rate()(YearsSepAcctGrossRate);
+ }
YearsDcvIntRate = GetMly7702iGlp()[Year];
YearsHoneymoonValueRate = InterestRates_->HoneymoonValueRate
diff --git a/ihs_avmly.cpp b/ihs_avmly.cpp
index 5b32d63..21a5d8d 100644
--- a/ihs_avmly.cpp
+++ b/ihs_avmly.cpp
@@ -2189,6 +2189,7 @@ void AccountValue::TxCreditInt()
currency notional_sep_acct_charge = C0;
+ { // Temporary validating assertion.
// SOMEDAY !! This should be done in the interest-rate class.
double gross_sep_acct_rate = i_upper_12_over_12_from_i<double>()
(InterestRates_->SepAcctGrossRate(SepBasis_)[Year]
@@ -2198,11 +2199,13 @@ void AccountValue::TxCreditInt()
{
gross_sep_acct_rate = 0.0;
}
+ LMI_ASSERT(gross_sep_acct_rate == YearsSepAcctGrossRate);
+ }
if(C0 < AVSepAcct)
{
SepAcctIntCred = InterestCredited(AVSepAcct, YearsSepAcctIntRate);
- currency gross = InterestCredited(AVSepAcct, gross_sep_acct_rate);
+ currency gross = InterestCredited(AVSepAcct, YearsSepAcctGrossRate);
notional_sep_acct_charge = gross - SepAcctIntCred;
#if defined USE_CURRENCY_CLASS
currency result = AVSepAcct + SepAcctIntCred;