[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] master c933ec3 4/4: Implement verify_products()
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] master c933ec3 4/4: Implement verify_products() |
Date: |
Sun, 10 Mar 2019 20:15:34 -0400 (EDT) |
branch: master
commit c933ec3c5184af12c6e3c8b75d260792e5574ea8
Author: Gregory W. Chicares <address@hidden>
Commit: Gregory W. Chicares <address@hidden>
Implement verify_products()
This early implementation needs refinement.
---
verify_products.cpp | 75 +++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 75 insertions(+)
diff --git a/verify_products.cpp b/verify_products.cpp
index 742755b..56c5872 100644
--- a/verify_products.cpp
+++ b/verify_products.cpp
@@ -23,8 +23,83 @@
#include "verify_products.hpp"
+#include "actuarial_table.hpp"
+#include "ce_product_name.hpp"
+#include "cso_tables.hpp"
+#include "data_directory.hpp" // AddDataDir()
+#include "database.hpp"
+#include "input.hpp"
+#include "mc_enum.hpp" // all_strings<>()
+#include "product_data.hpp"
+#include "ssize_lmi.hpp"
+#include "yare_input.hpp"
+
+#include <iostream>
+#include <string>
+#include <vector>
+
/// Verify all products.
void verify_products()
{
+ std::vector<std::string> const& products = ce_product_name().all_strings();
+ for(auto const& z : products)
+ {
+ std::cout << "Testing product " << z << '\n';
+ Input input;
+ input["ProductName"] = z;
+ for(auto const& g : all_strings<mcenum_gender>())
+ {
+ input["Gender"] = g;
+ for(auto const& s : all_strings<mcenum_smoking>())
+ {
+ input["Smoking"] = s;
+ yare_input yi(input);
+ product_database db(yi);
+ oenum_cso_era const era = db.query<oenum_cso_era>(DB_CsoEra);
+ oenum_alb_or_anb const a_b =
db.query<oenum_alb_or_anb>(DB_AgeLastOrNearest);
+ int const t = db.query<int>(DB_Irc7702QTable);
+ if(0 == t)
+ continue;
+ std::vector<double> v0 = cso_table
+ (era
+ ,oe_orthodox
+ ,a_b
+ ,mce_gender (g).value()
+ ,mce_smoking(s).value()
+ );
+ product_data p(z);
+ std::string const f = AddDataDir(p.datum("Irc7702QFilename"));
+ actuarial_table a(f, t);
+ std::vector<double> v1 = a.values
+ (a.min_age()
+ ,1 + a.max_age() - a.min_age()
+ );
+ if(v0 == v1)
+ {
+ std::cout << "validated: table " << t << ' ' << g << ' '
<< s << std::endl;
+ }
+ else
+ {
+ std::cout << "PROBLEM: " << z << ' ' << g << ' ' << s <<
std::endl;
+ std::cout << lmi::ssize(v0) << ' ' << lmi::ssize(v1) <<
'\n';
+ std::cout
+ << "\n CSO era: " << era
+ << "\n ALB or ANB: " << a_b
+ << "\n table file: " << f
+ << "\n table number: " << t
+ << "\n min age: " << a.min_age()
+ << "\n max age: " << a.max_age()
+ << "\n length: " << a.max_age() - a.min_age()
+ << "\n v0.front(): " << v0.front()
+ << "\n v1.front(): " << v1.front()
+ << "\n v0.back (): " << v0.back ()
+ << "\n v1.back (): " << v1.back ()
+ << std::endl
+ ;
+ }
+ }
+ }
+ }
+ std::cout << std::endl;
}
- [lmi-commits] [lmi] master updated (b53f392 -> c933ec3), Greg Chicares, 2019/03/10
- [lmi-commits] [lmi] master 45f2664 1/4: Fix defect introduced 20050114T1947Z: array bound too large, Greg Chicares, 2019/03/10
- [lmi-commits] [lmi] master c933ec3 4/4: Implement verify_products(),
Greg Chicares <=
- [lmi-commits] [lmi] master db02bb1 3/4: Implement cso_table(), Greg Chicares, 2019/03/10
- [lmi-commits] [lmi] master 39822aa 2/4: Add data: {1980, 2001, 2017} CSO {ALB, ANB} {F, M, U} {S, N, U}, Greg Chicares, 2019/03/10