[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] master 94539e9 2/4: Remove improvidently added param
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] master 94539e9 2/4: Remove improvidently added parameter-object members |
Date: |
Wed, 5 May 2021 12:35:14 -0400 (EDT) |
branch: master
commit 94539e96d0ab551d217e92a5573537dad3495b44
Author: Gregory W. Chicares <gchicares@sbcglobal.net>
Commit: Gregory W. Chicares <gchicares@sbcglobal.net>
Remove improvidently added parameter-object members
Substantially reverted commit 10299f32061c of 20210418T2056Z.
The members that had been added to gpt_scalar_parms proved inconsonant
with the original version of that parameter object, and broke a crucial
invariant: that it is used only by gpt_cf_triad::calculate_premium()
(and in private code that only that function can invoke). Restored that
invariant and moved precondition assertions back into that function,
eliminating the disliked assert_sanity().
---
gpt_cf_triad_test.cpp | 1 -
gpt_commutation_functions.cpp | 79 +++++++++++--------------------------------
gpt_commutation_functions.hpp | 16 +--------
3 files changed, 20 insertions(+), 76 deletions(-)
diff --git a/gpt_cf_triad_test.cpp b/gpt_cf_triad_test.cpp
index 0a1b89f..40acdc1 100644
--- a/gpt_cf_triad_test.cpp
+++ b/gpt_cf_triad_test.cpp
@@ -319,7 +319,6 @@ gpt_scalar_parms gpt_cf_triad_test::s_parms()
,.qab_child_amt = 5000.0
,.qab_waiver_amt = 50000.0
};
- assert_sanity(z);
return z;
}
diff --git a/gpt_commutation_functions.cpp b/gpt_commutation_functions.cpp
index 7351c2b..eb3ef11 100644
--- a/gpt_commutation_functions.cpp
+++ b/gpt_commutation_functions.cpp
@@ -52,62 +52,6 @@ std::vector<T>& back_sum(std::vector<T>& v, E e)
}
} // Unnamed namespace.
-/// Assert sanity of a 'gpt_scalar_parms' object.
-///
-/// Asserted invariants:
-/// - all members not named /inforce_.*/ are nonnegative
-/// (inforce amounts are unrestricted)
-/// - the endowment benefit does not exceed the (f)(3) benefit
-/// - 'issued_today' and 'duration' are mutually consistent:
-/// - if the policy was issued today, its duration must be zero
-/// - if duration != 0, the policy cannot have been issued today
-/// - a 1035 exchange can occur only on the issue date
-///
-/// 7702 !! Reconsider this:
-/// Both 'gpt_scalar_parms' and 'gpt_vector_parms' were designed as
-/// simple parameter objects, and each was originally intended to be
-/// passed to one function only, so it was okay to assert invariants
-/// only where they were passed in. For 'gpt_vector_parms', that's
-/// still true. But 'gpt_scalar_parms' has acquired more members and
-/// more uses, and more invariants, so arguably it is no longer a
-/// "behaviorless aggregate".
-
-void assert_sanity(gpt_scalar_parms const& args)
-{
- LMI_ASSERT(0 <= args.duration );
- LMI_ASSERT(0.0 <= args.f3_bft );
- LMI_ASSERT(0.0 <= args.endt_bft );
- LMI_ASSERT(0.0 <= args.target_prem );
- LMI_ASSERT(0.0 <= args.chg_sa_base );
- LMI_ASSERT(0.0 <= args.gross_1035 );
- // inforce_glp unrestricted
- // inforce_cum_glp unrestricted
- // inforce_gsp unrestricted
- // inforce_cum_pmt unrestricted
- LMI_ASSERT(0.0 <= args.qab_gio_amt );
- LMI_ASSERT(0.0 <= args.qab_adb_amt );
- LMI_ASSERT(0.0 <= args.qab_term_amt );
- LMI_ASSERT(0.0 <= args.qab_spouse_amt);
- LMI_ASSERT(0.0 <= args.qab_child_amt );
- LMI_ASSERT(0.0 <= args.qab_waiver_amt);
-
- LMI_ASSERT(args.endt_bft <= args.f3_bft);
-
- if(args.issued_today)
- {
- LMI_ASSERT(0 == args.duration);
- }
- if(0 != args.duration)
- {
- LMI_ASSERT(!args.issued_today);
- }
-
- if(0.0 != args.gross_1035)
- {
- LMI_ASSERT(args.issued_today);
- }
-}
-
/// Constructor.
///
/// Asserted preconditions: All argument vectors, including those in
@@ -277,8 +221,10 @@ gpt_cf_triad::gpt_cf_triad
/// but then sometimes one would need to be thrown away (as when
/// specified amount is determined by a GLP or GSP strategy).
///
-/// Asserted preconditions: Parameter object 'args' is sane, and
-/// 'args.duration' is a valid index.
+/// Asserted preconditions:
+/// - duration is within its natural bounds
+/// - other members of 'args' are nonnegative
+/// - the endowment benefit does not exceed the (f)(3) benefit
///
/// Asserted postcondition: Returned GLP or GSP is nonnegative; thus,
/// while adjusted premium 'A+B-C' may be negative, {A,B,C} are all
@@ -294,8 +240,21 @@ double gpt_cf_triad::calculate_premium
,mcenum_dbopt_7702 dbo
) const
{
- assert_sanity(args);
- LMI_ASSERT(args.duration < length_);
+ LMI_ASSERT(0 <= args.duration );
+ LMI_ASSERT( args.duration < length_);
+
+ LMI_ASSERT(0.0 <= args.f3_bft );
+ LMI_ASSERT(0.0 <= args.endt_bft );
+ LMI_ASSERT(0.0 <= args.target_prem );
+ LMI_ASSERT(0.0 <= args.chg_sa_base );
+ LMI_ASSERT(0.0 <= args.qab_gio_amt );
+ LMI_ASSERT(0.0 <= args.qab_adb_amt );
+ LMI_ASSERT(0.0 <= args.qab_term_amt );
+ LMI_ASSERT(0.0 <= args.qab_spouse_amt);
+ LMI_ASSERT(0.0 <= args.qab_child_amt );
+ LMI_ASSERT(0.0 <= args.qab_waiver_amt);
+
+ LMI_ASSERT(args.endt_bft <= args.f3_bft);
gpt_commfns const& cf =
(oe_glp == glp_or_gsp && mce_option1_for_7702 == dbo) ? cf_glp_dbo_1
diff --git a/gpt_commutation_functions.hpp b/gpt_commutation_functions.hpp
index dcc9763..151946e 100644
--- a/gpt_commutation_functions.hpp
+++ b/gpt_commutation_functions.hpp
@@ -24,7 +24,7 @@
#include "config.hpp"
-#include "mc_enum_type_enums.hpp" // mcenum_dbopt_7702,
mcenum_defn_life_ins
+#include "mc_enum_type_enums.hpp" // mcenum_dbopt_7702
#include "oecumenic_enumerations.hpp" // oenum_glp_or_gsp
#include <vector>
@@ -86,11 +86,6 @@ struct gpt_vector_parms
/// 'chg_sa_base' is the base for any specified-amount load. It may
/// differ from 'specamt', e.g., by being limited to a scalar maximum,
/// by including a term amount, or by being set immutably at issue.
-///
-/// GLP and GSP may be wanted even for CVAT contracts, e.g. so that
-/// a premium pattern such as "GSP for one year, then nothing" can be
-/// illustrated for both GPT and CVAT. 'defn_life_ins' facilitates
-/// skipping GPT restrictions for CVAT contracts in such a case.
struct gpt_scalar_parms
{
@@ -99,14 +94,7 @@ struct gpt_scalar_parms
double endt_bft { 0.0};
double target_prem { 0.0};
double chg_sa_base { 0.0};
- mcenum_defn_life_ins defn_life_ins { mce_gpt};
mcenum_dbopt_7702 dbopt_7702 {mce_option1_for_7702};
- double gross_1035 { 0.0};
- bool issued_today { false};
- double inforce_glp { 0.0};
- double inforce_cum_glp { 0.0};
- double inforce_gsp { 0.0};
- double inforce_cum_pmt { 0.0};
double qab_gio_amt { 0.0};
double qab_adb_amt { 0.0};
double qab_term_amt { 0.0};
@@ -117,8 +105,6 @@ struct gpt_scalar_parms
bool operator==(gpt_scalar_parms const&) const = default;
};
-void assert_sanity(gpt_scalar_parms const&);
-
/// Commutation functions specialized for GPT calculations.
///
/// All members are private: only its one friend can use this class.