lmi-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lmi-commits] [lmi] master 406b267 3/4: Split selected tables out of cla


From: Greg Chicares
Subject: [lmi-commits] [lmi] master 406b267 3/4: Split selected tables out of class BasicValues into a new TU
Date: Sat, 8 Jun 2019 12:15:26 -0400 (EDT)

branch: master
commit 406b26756aee2c9b1f47e11c31b5ed59c3b3a690
Author: Gregory W. Chicares <address@hidden>
Commit: Gregory W. Chicares <address@hidden>

    Split selected tables out of class BasicValues into a new TU
    
    Added the new TU in this commit; deduplication will follow in the next.
    
    For now at least, the new TU encompasses only 7702 and 7702A tables,
    along with target-premium tables. The proximate goal is to provide
    known-valid values on the 7702 basis:
      qx from built-in mortality tables of trusted provenance, and
      7Px, Ax, and 1/Ax from first principles,
    as reliable touchstones for validating tables provided by pricing
    actuaries. Target-premium tables are included only so that class
    actuarial_table can be hidden completely from the GPT and MEC servers
    (otherwise, they'd still need that class for targets only).
    
    Achieving that proximate goal also makes it trivial to provide specimen
    implementations of old products with a new CSO table.
    
    In the longer term, most or all tables can be consolidated in this new
    TU, making it the sole point of access to class actuarial_table.
---
 Makefile.am      |   2 +
 basic_tables.cpp | 204 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 basic_tables.hpp |  68 +++++++++++++++++++
 objects.make     |   1 +
 4 files changed, 275 insertions(+)

diff --git a/Makefile.am b/Makefile.am
index 209079b..fce017e 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -392,6 +392,7 @@ libantediluvian_la_LIBADD = \
 
 liblmi_la_SOURCES = \
     authenticity.cpp \
+    basic_tables.cpp \
     commutation_functions.cpp \
     cso_table.cpp \
     financial.cpp \
@@ -1214,6 +1215,7 @@ noinst_HEADERS = \
     any_member.hpp \
     assert_lmi.hpp \
     authenticity.hpp \
+    basic_tables.hpp \
     basic_values.hpp \
     boost_regex.hpp \
     bourn_cast.hpp \
diff --git a/basic_tables.cpp b/basic_tables.cpp
new file mode 100644
index 0000000..b62b169
--- /dev/null
+++ b/basic_tables.cpp
@@ -0,0 +1,204 @@
+// Basic tables.
+//
+// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 
2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 Gregory 
W. Chicares.
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License version 2 as
+// published by the Free Software Foundation.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software Foundation,
+// Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+//
+// http://savannah.nongnu.org/projects/lmi
+// email: <address@hidden>
+// snail: Chicares, 186 Belle Woods Drive, Glastonbury CT 06033, USA
+
+#include "pchfile.hpp"
+
+#include "basic_tables.hpp"
+
+#include "actuarial_table.hpp"
+#include "data_directory.hpp"
+#include "dbnames.hpp"                  // e_database_key
+#include "oecumenic_enumerations.hpp"
+
+#include <string>
+
+namespace
+{
+std::vector<double> basic_table_rates
+    (product_data     const& product
+    ,product_database const& database
+    ,std::string      const& table_name
+    ,e_database_key          table_id
+    ,int                     issue_age
+    ,int                     years_to_maturity
+    )
+{
+    return actuarial_table_rates
+        (AddDataDir(product.datum(table_name))
+        ,database.query<int>(table_id)
+        ,issue_age
+        ,years_to_maturity
+        );
+}
+} // Unnamed namespace
+
+std::vector<double> LMI_SO irc_7702_q
+    (product_data     const& product
+    ,product_database const& database
+    ,int                     issue_age
+    ,int                     years_to_maturity
+    )
+{
+    switch(database.query<oenum_7702_q_whence>(DB_Irc7702QWhence))
+        {
+        case oe_7702_q_builtin:
+            {
+            throw "Not yet implemented.";
+            }
+        case oe_7702_q_external_table:
+            {
+            return basic_table_rates
+                (product
+                ,database
+                ,"Irc7702QFilename"
+                ,DB_Irc7702QTable
+                ,issue_age
+                ,years_to_maturity
+                );
+            }
+        }
+    throw "Unreachable--silences a compiler diagnostic.";
+}
+
+std::vector<double> LMI_SO irc_7702A_7pp
+    (product_data     const& product
+    ,product_database const& database
+    ,int                     issue_age
+    ,int                     years_to_maturity
+    )
+{
+    switch(database.query<oenum_7702_7pp_whence>(DB_SevenPayWhence))
+        {
+        case oe_7702_7pp_first_principles:
+            {
+            throw "Not yet implemented (and don't forget rounding).";
+            }
+        case oe_7702_7pp_from_table:
+            {
+            return basic_table_rates
+                (product
+                ,database
+                ,"SevenPayFilename"
+                ,DB_SevenPayTable
+                ,issue_age
+                ,years_to_maturity
+                );
+            }
+        }
+    throw "Unreachable--silences a compiler diagnostic.";
+}
+
+std::vector<double> LMI_SO irc_7702_nsp
+    (product_data     const& product
+    ,product_database const& database
+    ,int                     issue_age
+    ,int                     years_to_maturity
+    )
+{
+    switch(database.query<oenum_7702_nsp_whence>(DB_Irc7702NspWhence))
+        {
+        case oe_7702_nsp_first_principles:
+            {
+            throw "Not yet implemented (and don't forget rounding).";
+            }
+        case oe_7702_nsp_from_table:
+            {
+            return basic_table_rates
+                (product
+                ,database
+                ,"Irc7702NspFilename"
+                ,DB_Irc7702NspTable
+                ,issue_age
+                ,years_to_maturity
+                );
+            }
+        case oe_7702_nsp_reciprocal_cvat_corridor:
+            {
+            throw "Not yet implemented (and don't forget rounding).";
+            }
+        }
+    throw "Unreachable--silences a compiler diagnostic.";
+}
+
+std::vector<double> LMI_SO cvat_corridor_factors
+    (product_data     const& product
+    ,product_database const& database
+    ,int                     issue_age
+    ,int                     years_to_maturity
+    )
+{
+    switch(database.query<oenum_7702_corr_whence>(DB_CorridorWhence))
+        {
+        case oe_7702_corr_first_principles:
+            {
+            throw "Not yet implemented (and don't forget rounding).";
+            }
+        case oe_7702_corr_from_table:
+            {
+            return basic_table_rates
+                (product
+                ,database
+                ,"CvatCorridorFilename"
+                ,DB_CorridorTable
+                ,issue_age
+                ,years_to_maturity
+                );
+            }
+        }
+    throw "Unreachable--silences a compiler diagnostic.";
+}
+
+std::vector<double> LMI_SO target_premium_rates
+    (product_data     const& product
+    ,product_database const& database
+    ,int                     issue_age
+    ,int                     years_to_maturity
+    )
+{
+    switch(database.query<oenum_modal_prem_type>(DB_TgtPremType))
+        {
+        case oe_monthly_deduction:
+            {
+            throw "Not yet implemented (and don't forget rounding).";
+            }
+        case oe_modal_nonmec:
+            {
+            return irc_7702A_7pp
+                (product
+                ,database
+                ,issue_age
+                ,years_to_maturity
+                );
+            }
+        case oe_modal_table:
+            {
+            return basic_table_rates
+                (product
+                ,database
+                ,"TgtPremFilename"
+                ,DB_TgtPremTable
+                ,issue_age
+                ,years_to_maturity
+                );
+            }
+        }
+    throw "Unreachable--silences a compiler diagnostic.";
+}
diff --git a/basic_tables.hpp b/basic_tables.hpp
new file mode 100644
index 0000000..e3056fd
--- /dev/null
+++ b/basic_tables.hpp
@@ -0,0 +1,68 @@
+// Basic tables.
+//
+// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 
2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 Gregory 
W. Chicares.
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License version 2 as
+// published by the Free Software Foundation.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software Foundation,
+// Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+//
+// http://savannah.nongnu.org/projects/lmi
+// email: <address@hidden>
+// snail: Chicares, 186 Belle Woods Drive, Glastonbury CT 06033, USA
+
+#ifndef basic_tables_hpp
+#define basic_tables_hpp
+
+#include "config.hpp"
+
+#include "database.hpp"
+#include "product_data.hpp"
+#include "so_attributes.hpp"
+
+#include <vector>
+
+std::vector<double> LMI_SO irc_7702_q
+    (product_data     const& product
+    ,product_database const& database
+    ,int                     issue_age
+    ,int                     years_to_maturity
+    );
+
+std::vector<double> LMI_SO irc_7702A_7pp
+    (product_data     const& product
+    ,product_database const& database
+    ,int                     issue_age
+    ,int                     years_to_maturity
+    );
+
+std::vector<double> LMI_SO irc_7702_nsp
+    (product_data     const& product
+    ,product_database const& database
+    ,int                     issue_age
+    ,int                     years_to_maturity
+    );
+
+std::vector<double> LMI_SO cvat_corridor_factors
+    (product_data     const& product
+    ,product_database const& database
+    ,int                     issue_age
+    ,int                     years_to_maturity
+    );
+
+std::vector<double> LMI_SO target_premium_rates
+    (product_data     const& product
+    ,product_database const& database
+    ,int                     issue_age
+    ,int                     years_to_maturity
+    );
+
+#endif // basic_tables_hpp
diff --git a/objects.make b/objects.make
index f332a07..d9172ed 100644
--- a/objects.make
+++ b/objects.make
@@ -276,6 +276,7 @@ antediluvian_common_objects := \
 lmi_common_objects := \
   $(common_common_objects) \
   authenticity.o \
+  basic_tables.o \
   commutation_functions.o \
   cso_table.o \
   financial.o \



reply via email to

[Prev in Thread] Current Thread [Next in Thread]