[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] master e6ed669 01/14: Test guideline premium calcula
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] master e6ed669 01/14: Test guideline premium calculations with more complications |
Date: |
Mon, 5 Apr 2021 18:26:45 -0400 (EDT) |
branch: master
commit e6ed6695784cfeb2e784940eb67d681160853182
Author: Gregory W. Chicares <gchicares@sbcglobal.net>
Commit: Gregory W. Chicares <gchicares@sbcglobal.net>
Test guideline premium calculations with more complications
Added a unit test that exercises all spreadsheet capabilities.
---
gpt_test.cpp | 79 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 79 insertions(+)
diff --git a/gpt_test.cpp b/gpt_test.cpp
index 594bca3..54f7242 100644
--- a/gpt_test.cpp
+++ b/gpt_test.cpp
@@ -206,6 +206,7 @@ class gpt_test
assay_speed();
test_spreadsheet_0();
test_spreadsheet_1();
+ test_spreadsheet_2();
}
private:
@@ -214,6 +215,7 @@ class gpt_test
static void assay_speed();
static void test_spreadsheet_0();
static void test_spreadsheet_1();
+ static void test_spreadsheet_2();
static void initialize(int issue_age);
static gpt_vector_parms v_parms();
@@ -801,6 +803,83 @@ void gpt_test::test_spreadsheet_1()
LMI_TEST(materially_equal(z.gsp(), 38927.928902970103081));
}
+/// Validate GLP and GSP using spreadsheet--exercise all parameters.
+///
+/// URL:
+/// https://download.savannah.gnu.org/releases/lmi/validate_commfns.xls
+///
+/// Change spreadsheet input to match parameters below. As above,
+/// loads and charges are initialized with decimal-power multiples of
+/// distinct primes, to make it easier to track down any discrepancy.
+/// No QABs are used because the spreadsheet doesn't support any.
+///
+/// Touchstone values hardcoded below are from 'gnumeric'.
+
+void gpt_test::test_spreadsheet_2()
+{
+ int const issue_age = 0;
+ // SOA table 00042 1980 CSO Ult ANB Male Unismoke
+ static std::vector<double> const q_m {sample_q(issue_age)};
+ int const length = lmi::ssize(q_m);
+
+ double constexpr iglp = 0.02;
+ double constexpr igsp = 0.04;
+ static double const i12glp = i_upper_12_over_12_from_i<double>()(iglp);
+ static double const i12gsp = i_upper_12_over_12_from_i<double>()(igsp);
+ std::vector<double> const glp_ic(length, i12glp);
+ std::vector<double> const gsp_ic(length, i12gsp);
+ std::vector<double> const glp_ig(length, i12glp);
+ std::vector<double> const gsp_ig(length, i12gsp);
+
+ std::vector<double> const policy_fee_annual (length, 37.0);
+ std::vector<double> const policy_fee_monthly (length, 5.0);
+ std::vector<double> const specamt_load_monthly (length, 0.000007);
+ std::vector<double> const qab_adb_rate (length, 0.0);
+ std::vector<double> const prem_load_target (length, 0.03);
+ std::vector<double> const prem_load_excess (length, 0.02);
+
+ Irc7702 z
+ (mce_gpt // a_Test7702
+ ,issue_age // a_IssueAge
+ ,100 // a_EndtAge
+ ,q_m // a_Qc
+ ,glp_ic // ic_glp
+ ,gsp_ic // ic_gsp
+ ,glp_ig // ig_glp
+ ,gsp_ig // ig_gsp
+ ,1000000.0 // a_PresentBftAmt
+ ,1000000.0 // a_PresentSpecAmt
+ ,1000000.0 // a_LeastBftAmtEver
+ ,mce_option1_for_7702 // a_PresentDBOpt
+ ,policy_fee_annual // a_AnnChgPol
+ ,policy_fee_monthly // a_MlyChgPol
+ ,specamt_load_monthly // a_MlyChgSpecAmt
+ ,1000000000.0 // a_SpecAmtLoadLimit [in effect, no
limit]
+ ,qab_adb_rate // a_MlyChgADD
+ ,1000000000.0 // a_ADDLimit [in effect, no limit]
+ ,prem_load_target // a_LoadTgt
+ ,prem_load_excess // a_LoadExc
+ ,1000000.0 // a_TargetPremium
+ ,round_to<double>(2, r_upward) // a_round_min_premium
+ ,round_to<double>(2, r_downward) // a_round_max_premium
+ ,round_to<double>(0, r_upward) // a_round_min_specamt
+ ,round_to<double>(0, r_downward) // a_round_max_specamt
+ ,0 // a_InforceYear
+ ,0 // a_InforceMonth
+ ,0.0 // a_InforceGLP
+ ,0.0 // a_InforceCumGLP
+ ,0.0 // a_InforceGSP
+ ,0.0 // a_InforceCumPremsPaid
+ );
+
+ z.Initialize7702(1000000.0, 1000000.0, mce_option2_for_7702, 1000.0);
+ LMI_TEST(materially_equal(z.glp(), 35393.654429660360620));
+
+ z.Initialize7702(1000000.0, 1000000.0, mce_option1_for_7702, 1000.0);
+ LMI_TEST(materially_equal(z.glp(), 7340.887403839152284));
+ LMI_TEST(materially_equal(z.gsp(), 92945.378758702529012));
+}
+
int test_main(int, char*[])
{
gpt_test::test();
- [lmi-commits] [lmi] master updated (dd6ee0a -> 8aa09b9), Greg Chicares, 2021/04/05
- [lmi-commits] [lmi] master 40218dc 03/14: Factor out commutation-function speed tests, Greg Chicares, 2021/04/05
- [lmi-commits] [lmi] master b8f43e0 06/14: Transpose several unit-test functions, Greg Chicares, 2021/04/05
- [lmi-commits] [lmi] master e6ed669 01/14: Test guideline premium calculations with more complications,
Greg Chicares <=
- [lmi-commits] [lmi] master b1eecea 02/14: Stabilize unit-test timing, Greg Chicares, 2021/04/05
- [lmi-commits] [lmi] master 28cabc2 04/14: Prefer lambdas to std::bind(), Greg Chicares, 2021/04/05
- [lmi-commits] [lmi] master 61a04eb 08/14: Make commutation functions default constructible, Greg Chicares, 2021/04/05
- [lmi-commits] [lmi] master df25463 12/14: Avoid operator new, Greg Chicares, 2021/04/05
- [lmi-commits] [lmi] master b657767 13/14: Remove conditionals that serve no further purpose, Greg Chicares, 2021/04/05
- [lmi-commits] [lmi] master 23fe71f 11/14: Do away with an undesirable smart pointer [290], Greg Chicares, 2021/04/05
- [lmi-commits] [lmi] master 485e19b 07/14: Favor the rule of zero, Greg Chicares, 2021/04/05
- [lmi-commits] [lmi] master 762056e 05/14: Prefer PETE's operator<<=() to assign(), Greg Chicares, 2021/04/05
- [lmi-commits] [lmi] master ed251fc 09/14: Test implicit special member functions, Greg Chicares, 2021/04/05
- [lmi-commits] [lmi] master c2087ae 10/14: Update a comment, Greg Chicares, 2021/04/05