[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] valyuta/004 1b71a77 1/2: Perform a transcendental ca
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] valyuta/004 1b71a77 1/2: Perform a transcendental calculation annually instead of monthly |
Date: |
Mon, 21 Dec 2020 17:27:36 -0500 (EST) |
branch: valyuta/004
commit 1b71a77905a35c2eaa57ac81c249276f312d9d32
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 2309a88..ea21410 100644
--- a/account_value.hpp
+++ b/account_value.hpp
@@ -483,7 +483,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 41c9e01..b0d64f0 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"
@@ -1388,6 +1389,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 789c737..aa22266 100644
--- a/ihs_avmly.cpp
+++ b/ihs_avmly.cpp
@@ -2212,6 +2212,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]
@@ -2221,11 +2222,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;
AVSepAcct += SepAcctIntCred;
}