[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] master e010c8f 04/15: Distinguish tabular minimum an
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] master e010c8f 04/15: Distinguish tabular minimum and target premiums |
Date: |
Tue, 27 Aug 2019 13:50:18 -0400 (EDT) |
branch: master
commit e010c8fda56b1d7a7948271c325003c0cf8e7bbd
Author: Gregory W. Chicares <address@hidden>
Commit: Gregory W. Chicares <address@hidden>
Distinguish tabular minimum and target premiums
Expunged GetModalPrem() and GetModalSpecAmt(), moving their respective
implementations into the functions that formerly called them, and there
distinguishing tabular minimum and target premiums.
Adding new enumerators 'oe_modal_min_table' and 'oe_modal_tgt_table',
as an expunged comment had suggested, would have been less good: that
approach would have allowed target type to be 'oe_modal_min_table', and
minimum type to be 'oe_modal_tgt_table'--IOW, it would have introduced
an inherent logic error into the design.
For tabular minimum premiums, commented-out code indicates how monthly
policy fee might be handled. It's commented out for now because it would
cause regressions; deciding whether those are correct or not is deferred
to a separate commit.
---
basic_values.hpp | 10 -----
ihs_basicval.cpp | 109 +++++++++++++++++++++++--------------------------------
2 files changed, 46 insertions(+), 73 deletions(-)
diff --git a/basic_values.hpp b/basic_values.hpp
index 8e153f0..f590c1f 100644
--- a/basic_values.hpp
+++ b/basic_values.hpp
@@ -374,12 +374,6 @@ class LMI_SO BasicValues
BasicValues(BasicValues const&) = delete;
BasicValues& operator=(BasicValues const&) = delete;
- double GetModalPrem
- (int a_year
- ,mcenum_mode a_mode
- ,double a_specamt
- ,oenum_modal_prem_type a_prem_type
- ) const;
double mly_ded_discount_factor(int year, mcenum_mode mode) const;
std::pair<double,double> approx_mly_ded
(int year
@@ -395,10 +389,6 @@ class LMI_SO BasicValues
,mcenum_mode mode
,double specamt
) const;
- double GetModalSpecAmt
- (double annualized_pmt
- ,oenum_modal_prem_type premium_type
- ) const;
double GetModalSpecAmtMlyDed(double annualized_pmt, mcenum_mode) const;
std::vector<double> GetActuarialTable
diff --git a/ihs_basicval.cpp b/ihs_basicval.cpp
index c57aeca..4494717 100644
--- a/ihs_basicval.cpp
+++ b/ihs_basicval.cpp
@@ -630,10 +630,7 @@ void BasicValues::SetPermanentInvariants()
database().query_into(DB_TgtPremFixedAtIssue , TgtPremFixedAtIssue);
database().query_into(DB_TgtPremMonthlyPolFee , TgtPremMonthlyPolFee);
// Assertion: see comments on GetModalPremTgtFromTable().
- LMI_ASSERT
- ( 0.0 == TgtPremMonthlyPolFee
- || (oe_modal_table == TgtPremType && oe_modal_table != MinPremType)
- );
+ LMI_ASSERT(0.0 == TgtPremMonthlyPolFee || oe_modal_table == TgtPremType);
database().query_into(DB_CurrCoiTable0Limit , CurrCoiTable0Limit);
database().query_into(DB_CurrCoiTable1Limit , CurrCoiTable1Limit);
LMI_ASSERT(0.0 <= CurrCoiTable0Limit);
@@ -843,7 +840,16 @@ double BasicValues::GetModalMinPrem
,double a_specamt
) const
{
- return GetModalPrem(a_year, a_mode, a_specamt, MinPremType);
+ switch(MinPremType)
+ {
+ case oe_monthly_deduction:
+ return GetModalPremMlyDed (a_year, a_mode, a_specamt);
+ case oe_modal_nonmec:
+ return GetModalPremMaxNonMec (a_year, a_mode, a_specamt);
+ case oe_modal_table:
+ return GetModalPremMinFromTable(a_year, a_mode, a_specamt);
+ }
+ throw "Unreachable--silences a compiler diagnostic.";
}
/// Calculate target premium.
@@ -858,25 +864,14 @@ double BasicValues::GetModalTgtPrem
) const
{
int const target_year = TgtPremFixedAtIssue ? 0 : a_year;
- return GetModalPrem(target_year, a_mode, a_specamt, TgtPremType);
-}
-
-//============================================================================
-double BasicValues::GetModalPrem
- (int a_year
- ,mcenum_mode a_mode
- ,double a_specamt
- ,oenum_modal_prem_type a_prem_type
- ) const
-{
- switch(a_prem_type)
+ switch(TgtPremType)
{
case oe_monthly_deduction:
- return GetModalPremMlyDed (a_year, a_mode, a_specamt);
+ return GetModalPremMlyDed (target_year, a_mode, a_specamt);
case oe_modal_nonmec:
- return GetModalPremMaxNonMec (a_year, a_mode, a_specamt);
+ return GetModalPremMaxNonMec (target_year, a_mode, a_specamt);
case oe_modal_table:
- return GetModalPremTgtFromTable(a_year, a_mode, a_specamt);
+ return GetModalPremTgtFromTable(target_year, a_mode, a_specamt);
}
throw "Unreachable--silences a compiler diagnostic.";
}
@@ -905,9 +900,6 @@ double BasicValues::GetModalPremMaxNonMec
/// generally fixed at issue. This calculation remains naive in that
/// the initial specified amount may also be fixed at issue, but that
/// choice is left to the caller.
-///
-/// As the GetModalSpecAmt() documentation for 'oe_modal_table' says,
-/// target and minimum premiums really ought to distinguished.
double BasicValues::GetModalPremMinFromTable
(int // a_year // Unused.
@@ -918,7 +910,13 @@ double BasicValues::GetModalPremMinFromTable
return round_max_premium()
(ldbl_eps_plus_one_times
(
+#if 0
+ ( Loads_->monthly_policy_fee(mce_gen_curr)[0] * 12
+ + (a_specamt * MortalityRates_->MinimumPremiumRates()[0])
+ )
+#else
(a_specamt * MortalityRates_->MinimumPremiumRates()[0])
+#endif // 0
/ a_mode
)
);
@@ -933,7 +931,7 @@ double BasicValues::GetModalPremMinFromTable
///
/// 'TgtPremMonthlyPolFee' is applied here, not in GetModalTgtPrem(),
/// because it is more appropriate here. In the other two cases that
-/// GetModalPrem() contemplates:
+/// GetModalTgtPrem() contemplates:
/// - 'oe_monthly_deduction': deductions would naturally include any
/// policy fee;
/// - 'oe_modal_nonmec': 7702A seven-pay premiums are net by their
@@ -941,12 +939,7 @@ double BasicValues::GetModalPremMinFromTable
/// (conservative) table-derived 7pp, then 'oe_modal_table' should
/// be used instead.
/// Therefore, an assertion (where 'TgtPremMonthlyPolFee' is assigned)
-/// requires that the fee be zero in those cases, and also fires if
-/// this function is used for minimum premium with a nonzero fee
-/// (because no GetModalPremMinFromTable() has yet been written).
-///
-/// As the GetModalSpecAmt() documentation for 'oe_modal_table' says,
-/// target and minimum premiums really ought to distinguished.
+/// requires that the fee be zero in those cases.
double BasicValues::GetModalPremTgtFromTable
(int // a_year // Unused.
@@ -1367,38 +1360,39 @@ std::pair<double,double>
BasicValues::GetListBillPremMlyDedEx
);
}
-//============================================================================
double BasicValues::GetModalSpecAmtMax(double annualized_pmt) const
{
- return GetModalSpecAmt(annualized_pmt, MinPremType);
-}
-
-//============================================================================
-double BasicValues::GetModalSpecAmtTgt(double annualized_pmt) const
-{
- return GetModalSpecAmt(annualized_pmt, TgtPremType);
+ switch(MinPremType)
+ {
+ case oe_monthly_deduction:
+ return GetModalSpecAmtMlyDed(annualized_pmt, mce_annual);
+ case oe_modal_nonmec:
+ return GetModalSpecAmtMinNonMec(annualized_pmt);
+ case oe_modal_table:
+ return round_min_specamt()
+ (
+#if 0
+ ( annualized_pmt
+ - Loads_->monthly_policy_fee(mce_gen_curr)[0] * 12
+ )
+#else
+ annualized_pmt
+#endif // 0
+ / MortalityRates_->MinimumPremiumRates()[0]
+ );
+ }
+ throw "Unreachable--silences a compiler diagnostic.";
}
-/// Calculate specified amount as a simple function of premium.
-///
-/// A choice of several such simple functions is offered here to avoid
-/// code duplication in GetModalSpecAmtMax() and GetModalSpecAmtTgt().
-/// SOMEDAY !! However, in the 'oe_modal_table' case, distinct target
-/// and minimum tables and policy fees should be provided instead, and
-/// the present implementation moved into the calling functions.
-///
/// Argument 'annualized_pmt' is net of any policy fee, such as might
/// be included in a target premium. It's only a scalar, intended to
/// represent an initial premium; reason: it's generally inappropriate
/// for a specified-amount strategy to produce a result that varies by
/// duration.
-double BasicValues::GetModalSpecAmt
- (double annualized_pmt
- ,oenum_modal_prem_type premium_type
- ) const
+double BasicValues::GetModalSpecAmtTgt(double annualized_pmt) const
{
- switch(premium_type)
+ switch(TgtPremType)
{
case oe_monthly_deduction:
return GetModalSpecAmtMlyDed(annualized_pmt, mce_annual);
@@ -2041,18 +2035,7 @@ std::vector<double> BasicValues::GetTgtPremRates() const
return GetTable
(product().datum("TgtPremFilename")
,DB_TgtPremTable
-// Use this line instead:
-// ,oe_modal_table == TgtPremType
-// once the comment concerning GetModalPremMinFromTable()
-// in GetModalPremTgtFromTable() is addressed. Meanwhile, this kludge
-// permits table-driven minimum premiums in certain circumstances.
- ,oe_modal_table == TgtPremType || oe_modal_table == MinPremType
-// To fix this properly, implement a new GetModalPremTgtFromTable();
-// separate 'oe_modal_table' into distinct enumerators such as
-// 'oe_modal_min_table' and 'oe_modal_tgt_table'; and add a minimum-
-// premium rate table. More attention should be paid to the conditions
-// under which minimum and target premiums are recalculated--e.g.,
-// they might change iff specamt changes.
+ ,oe_modal_table == TgtPremType
);
}
- [lmi-commits] [lmi] master updated (e0bf6c4 -> 80e47f2), Greg Chicares, 2019/08/27
- [lmi-commits] [lmi] master fee9d55 02/15: Support tabular minimum premiums, Greg Chicares, 2019/08/27
- [lmi-commits] [lmi] master a1d772b 03/15: Prefer 'switch' to if...else_if...else, Greg Chicares, 2019/08/27
- [lmi-commits] [lmi] master 3d6e389 07/15: Simplify single-premium logic, Greg Chicares, 2019/08/27
- [lmi-commits] [lmi] master a74799d 06/15: Add a 'GuarCoiWhence' database entity, Greg Chicares, 2019/08/27
- [lmi-commits] [lmi] master e010c8f 04/15: Distinguish tabular minimum and target premiums,
Greg Chicares <=
- [lmi-commits] [lmi] master 3e7a753 05/15: Resolve and document the policy-fee issue noted in the last commit, Greg Chicares, 2019/08/27
- [lmi-commits] [lmi] master 6b1abc0 11/15: Rework {flexible, single}-premium footnotes, Greg Chicares, 2019/08/27
- [lmi-commits] [lmi] master b2e4af3 08/15: Make 'IsSinglePremium' enumerative, Greg Chicares, 2019/08/27
- [lmi-commits] [lmi] master 6596a29 12/15: Reformat to highlight similarity, Greg Chicares, 2019/08/27
- [lmi-commits] [lmi] master 80e47f2 15/15: Substitute product-database strings for literal text, Greg Chicares, 2019/08/27
- [lmi-commits] [lmi] master 2994f27 13/15: Simplify and condense, Greg Chicares, 2019/08/27
- [lmi-commits] [lmi] master 04f9369 01/15: Add <MinPremFilename>, Greg Chicares, 2019/08/27
- [lmi-commits] [lmi] master d684bec 14/15: Move mce_ill_reg product description into {{ProductDescription}}, Greg Chicares, 2019/08/27
- [lmi-commits] [lmi] master 12f58cd 10/15: Simplify single-premium conditionals, Greg Chicares, 2019/08/27
- [lmi-commits] [lmi] master ed48b1d 09/15: Move a 'PolicyLegalName' adjustment into '.policy', Greg Chicares, 2019/08/27