lmi-commits
[Top][All Lists]
Advanced

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

[lmi-commits] [lmi] master 1ae2b52: Expunge HOPEFULLY; don't use hobsons


From: Greg Chicares
Subject: [lmi-commits] [lmi] master 1ae2b52: Expunge HOPEFULLY; don't use hobsons_choice() [393]
Date: Sun, 12 Mar 2017 13:33:12 -0400 (EDT)

branch: master
commit 1ae2b52e15d03374d502c38d27d519d56d751e23
Author: Gregory W. Chicares <address@hidden>
Commit: Gregory W. Chicares <address@hidden>

    Expunge HOPEFULLY; don't use hobsons_choice() [393]
    
    These dubious facilities have been blocked in production for years (by
    configurable_settings::offer_hobsons_choice_) and nobody has complained.
    
    hobsons_choice() has been retained because it might someday serve some
    temporary use, but HOPEFULLY has been expunged because no convenient
    means of offering Hobson's choice is desirable.
---
 alert.hpp             | 23 ----------------------
 ihs_acctval.cpp       | 54 +++++++++++++++++++++++++--------------------------
 ihs_avmly.cpp         | 50 +++++++++++++++++++++++------------------------
 ihs_basicval.cpp      | 20 +++++++++----------
 input_realization.cpp |  2 +-
 ledger_base.cpp       |  7 ++-----
 sigfpe.cpp            |  2 +-
 7 files changed, 66 insertions(+), 92 deletions(-)

diff --git a/alert.hpp b/alert.hpp
index c59da7f..01bc65c 100644
--- a/alert.hpp
+++ b/alert.hpp
@@ -254,28 +254,5 @@ void LMI_SO test_catastrophe_report();
     << ", line " << __LINE__ << "]\n" \
     << std::flush
 
-/// (Hopefully the name of this macro is self documenting.)
-///
-/// Weak assertion that users are allowed to bypass. Use LMI_ASSERT
-/// instead wherever possible.
-///
-/// The last line eats a semicolon written after the macro invocation.
-///
-/// TODO ?? It is generally a bad idea to let users bypass assertions.
-/// Any apparent need to do this probably masks a logic error.
-
-#define HOPEFULLY(condition)                                    \
-    do                                                          \
-        {                                                       \
-        if(!(condition))                                        \
-            {                                                   \
-            hobsons_choice()                                    \
-                << "Assertion '" << (#condition) << "' failed." \
-                << LMI_FLUSH                                    \
-                ;                                               \
-            }                                                   \
-        }                                                       \
-    while(0)
-
 #endif // alert_hpp
 
diff --git a/ihs_acctval.cpp b/ihs_acctval.cpp
index 0873ad1..6d6bef5 100644
--- a/ihs_acctval.cpp
+++ b/ihs_acctval.cpp
@@ -135,7 +135,7 @@ AccountValue::AccountValue(Input const& input)
     // composite values are multiplied by the number of lives inforce.
     // Of course, a contract is not normally in force after maturity.
 
-    HOPEFULLY
+    LMI_ASSERT
         (   InvariantValues().InforceLives.size()
         ==  static_cast<unsigned int>(1 + BasicValues::GetLength())
         );
@@ -228,7 +228,7 @@ void AccountValue::SetGuarPrem()
         {
         GuarPremium = SolveGuarPremium();
         }
-    HOPEFULLY(GuarPremium < 1.0e100);
+    LMI_ASSERT(GuarPremium < 1.0e100);
     ledger_->SetGuarPremium(GuarPremium);
 }
 
@@ -552,7 +552,7 @@ void AccountValue::InitializeLife(mcenum_run_basis a_Basis)
 //============================================================================
 void AccountValue::FinalizeLife(mcenum_run_basis a_Basis)
 {
-    HOPEFULLY(RunBasis_ == a_Basis);
+    LMI_ASSERT(RunBasis_ == a_Basis);
 
     DebugEndBasis();
 
@@ -750,7 +750,7 @@ void AccountValue::SetInitialValues()
         ||   oe_prefer_separate_account == distribution_preferred_account
         )
         {
-        HOPEFULLY(Database_->Query(DB_AllowSepAcct));
+        LMI_ASSERT(Database_->Query(DB_AllowSepAcct));
         }
     // If any account preference for premium is the general account,
     // then payment into the separate account must be permitted; but
@@ -761,7 +761,7 @@ void AccountValue::SetInitialValues()
         ||   oe_prefer_separate_account == er_premium_preferred_account
         )
         {
-        HOPEFULLY(Database_->Query(DB_AllowSepAcct));
+        LMI_ASSERT(Database_->Query(DB_AllowSepAcct));
         }
 }
 
@@ -781,13 +781,13 @@ double AccountValue::IncrementBOM
         }
 
     // Paranoid check.
-    HOPEFULLY(year == Year);
-    HOPEFULLY(month == Month);
-    HOPEFULLY(MonthsSinceIssue == Month + 12 * Year);
+    LMI_ASSERT(year == Year);
+    LMI_ASSERT(month == Month);
+    LMI_ASSERT(MonthsSinceIssue == Month + 12 * Year);
     if(daily_interest_accounting)
         {
-        HOPEFULLY(365 <= days_in_policy_year && days_in_policy_year <= 366);
-        HOPEFULLY(28 <= days_in_policy_month && days_in_policy_month <= 31);
+        LMI_ASSERT(365 <= days_in_policy_year && days_in_policy_year <= 366);
+        LMI_ASSERT(28 <= days_in_policy_month && days_in_policy_month <= 31);
         }
     if
         (   year != Year
@@ -838,13 +838,13 @@ void AccountValue::IncrementEOM
         }
 
     // Paranoid check.
-    HOPEFULLY(year == Year);
-    HOPEFULLY(month == Month);
-    HOPEFULLY(MonthsSinceIssue == Month + 12 * Year);
+    LMI_ASSERT(year == Year);
+    LMI_ASSERT(month == Month);
+    LMI_ASSERT(MonthsSinceIssue == Month + 12 * Year);
     if(daily_interest_accounting)
         {
-        HOPEFULLY(365 <= days_in_policy_year && days_in_policy_year <= 366);
-        HOPEFULLY(28 <= days_in_policy_month && days_in_policy_month <= 31);
+        LMI_ASSERT(365 <= days_in_policy_year && days_in_policy_year <= 366);
+        LMI_ASSERT(28 <= days_in_policy_month && days_in_policy_month <= 31);
         }
 
     // Save arguments, constraining their values to be nonnegative,
@@ -864,7 +864,7 @@ void AccountValue::IncrementEOY(int year)
         }
 
     // Paranoid check.
-    HOPEFULLY(year == Year);
+    LMI_ASSERT(year == Year);
 
     FinalizeYear();
 }
@@ -1030,7 +1030,7 @@ void AccountValue::InitializeSpecAmt()
         }
 
     SurrChgSpecAmt = InvariantValues().SpecAmt[0];
-    HOPEFULLY(0.0 <= SurrChgSpecAmt);
+    LMI_ASSERT(0.0 <= SurrChgSpecAmt);
     // TODO ?? SurrChgSpecAmt is not used yet.
 
     // TODO ?? Perform specamt strategy here?
@@ -1203,8 +1203,8 @@ double AccountValue::SurrChg()
     // negative base amounts, which would result in surrender charge
     // components having an unexpected sign.
 
-//    HOPEFULLY(0.0 <= CumPmts); // TODO ?? Fails on a few test cases: should 
it?
-    HOPEFULLY(0.0 <= InvariantValues().SpecAmt[0]);
+//    LMI_ASSERT(0.0 <= CumPmts); // TODO ?? Fails on a few test cases: should 
it?
+    LMI_ASSERT(0.0 <= InvariantValues().SpecAmt[0]);
 
     return
             YearsSurrChgAVMult      * std::max(0.0, TotalAccountValue())
@@ -1501,7 +1501,7 @@ void AccountValue::FinalizeYear()
 
         for(int j = 0; j < 12; ++j)
             {
-            HOPEFULLY(materially_equal(GrossPmts[j], EeGrossPmts[j] + 
ErGrossPmts[j]));
+            LMI_ASSERT(materially_equal(GrossPmts[j], EeGrossPmts[j] + 
ErGrossPmts[j]));
             InvariantValues().GrossPmt  [Year]  += GrossPmts[j];
             InvariantValues().EeGrossPmt[Year]  += EeGrossPmts[j];
             InvariantValues().ErGrossPmt[Year]  += ErGrossPmts[j];
@@ -1510,7 +1510,7 @@ void AccountValue::FinalizeYear()
             {
             InvariantValues().InitPrem = InvariantValues().GrossPmt[Year];
             }
-        HOPEFULLY
+        LMI_ASSERT
             (materially_equal
                 (   InvariantValues().GrossPmt  [Year]
                 ,   InvariantValues().EeGrossPmt[Year]
@@ -1642,7 +1642,7 @@ void AccountValue::SetAnnualInvariants()
 //============================================================================
 double AccountValue::GetPartMortQ(int a_year) const
 {
-    HOPEFULLY(a_year <= BasicValues::GetLength());
+    LMI_ASSERT(a_year <= BasicValues::GetLength());
     if(!yare_input_.UsePartialMortality || ItLapsed)
         {
         return 0.0;
@@ -1782,7 +1782,7 @@ double AccountValue::InforceLivesBoy() const
         }
 
     unsigned int index = Year;
-    HOPEFULLY(index < InvariantValues().InforceLives.size());
+    LMI_ASSERT(index < InvariantValues().InforceLives.size());
     return InvariantValues().InforceLives[index];
 }
 
@@ -1798,7 +1798,7 @@ double AccountValue::InforceLivesEoy() const
         }
 
     unsigned int index = 1 + Year;
-    HOPEFULLY(index < InvariantValues().InforceLives.size());
+    LMI_ASSERT(index < InvariantValues().InforceLives.size());
     return InvariantValues().InforceLives[index];
 }
 
@@ -1828,7 +1828,7 @@ void AccountValue::CoordinateCounters()
                 next_anniversary.julian_day_number()
             -   current_anniversary.julian_day_number()
             ;
-        HOPEFULLY(365 <= days_in_policy_year && days_in_policy_year <= 366);
+        LMI_ASSERT(365 <= days_in_policy_year && days_in_policy_year <= 366);
 
         calendar_date current_monthiversary = add_years_and_months
             (yare_input_.EffectiveDate
@@ -1847,9 +1847,9 @@ void AccountValue::CoordinateCounters()
             -   current_monthiversary.julian_day_number()
             ;
 
-        HOPEFULLY(28 <= days_in_policy_month && days_in_policy_month <= 31);
+        LMI_ASSERT(28 <= days_in_policy_month && days_in_policy_month <= 31);
 
-//        HOPEFULLY
+//        LMI_ASSERT
 //            (   days_in_policy_month
 //            ==  current_monthiversary.days_in_month()
 //            );
diff --git a/ihs_avmly.cpp b/ihs_avmly.cpp
index 84713f2..7e5179b 100644
--- a/ihs_avmly.cpp
+++ b/ihs_avmly.cpp
@@ -263,9 +263,9 @@ void AccountValue::process_payment(double payment)
     // contracts. We deem net payments to have the same proportion
     // as gross payments, which we do have for ee and er separately.
 
-    HOPEFULLY(0.0 <=   GrossPmts[Month]);
-    HOPEFULLY(0.0 <= EeGrossPmts[Month]);
-    HOPEFULLY(0.0 <= ErGrossPmts[Month]);
+    LMI_ASSERT(0.0 <=   GrossPmts[Month]);
+    LMI_ASSERT(0.0 <= EeGrossPmts[Month]);
+    LMI_ASSERT(0.0 <= ErGrossPmts[Month]);
 
     double net_pmt = payment;
 
@@ -542,11 +542,11 @@ void AccountValue::TxExch1035()
         return;
         }
 
-    HOPEFULLY(Year == InforceYear);
-    HOPEFULLY(Month == InforceMonth);
-    HOPEFULLY(0.0 ==   GrossPmts[Month]);
-    HOPEFULLY(0.0 == EeGrossPmts[Month]);
-    HOPEFULLY(0.0 == ErGrossPmts[Month]);
+    LMI_ASSERT(Year == InforceYear);
+    LMI_ASSERT(Month == InforceMonth);
+    LMI_ASSERT(0.0 ==   GrossPmts[Month]);
+    LMI_ASSERT(0.0 == EeGrossPmts[Month]);
+    LMI_ASSERT(0.0 == ErGrossPmts[Month]);
 
     // Policy issue date is always a modal payment date.
     GrossPmts[Month] = External1035Amount + Internal1035Amount;
@@ -599,15 +599,15 @@ void AccountValue::TxExch1035()
 
     NetPmts[Month] = GrossPmts[Month] - actual_load;
 
-    HOPEFULLY(0.0 == AVGenAcct);
-    HOPEFULLY(0.0 == AVSepAcct);
+    LMI_ASSERT(0.0 == AVGenAcct);
+    LMI_ASSERT(0.0 == AVSepAcct);
     process_payment(NetPmts[Month]);
 
     DBReflectingCorr = 0.0;
     TxSetDeathBft();
     TxSetTermAmt();
     // TODO ?? TAXATION !! Should 1035 exchanges be handled somewhere else?
-    HOPEFULLY(0.0 == Dcv);
+    LMI_ASSERT(0.0 == Dcv);
     Irc7702A_->Update1035Exch7702A
         (Dcv
         ,NetPmts[Month]
@@ -633,7 +633,7 @@ void AccountValue::TxExch1035()
         // Immediately after a 1035 exchange, DCV should be
         // the 1035 amount reduced by any premium-based loads,
         // but only for the current rate basis.
-        HOPEFULLY(materially_equal(Dcv, NetPmts[Month]));
+        LMI_ASSERT(materially_equal(Dcv, NetPmts[Month]));
 
         // The initial seven-pay premium shown on the illustration
         // must be its value immediately after any 1035 exchange,
@@ -644,7 +644,7 @@ void AccountValue::TxExch1035()
             );
         }
 
-    HOPEFULLY
+    LMI_ASSERT
         (materially_equal
             (GrossPmts[Month]
             ,EeGrossPmts[Month] + ErGrossPmts[Month]
@@ -864,7 +864,7 @@ void AccountValue::ChangeSupplAmtBy(double delta)
 // adjustment to be nonpositive. Other approaches are possible.
 void AccountValue::ChangeSurrChgSpecAmtBy(double delta)
 {
-    HOPEFULLY(delta <= 0.0);
+    LMI_ASSERT(delta <= 0.0);
     SurrChgSpecAmt += delta;
     SurrChgSpecAmt = std::max(0.0, SurrChgSpecAmt);
     // TODO ?? 'SurrChgSpecAmt' isn't used yet.
@@ -1236,7 +1236,7 @@ void AccountValue::TxAscertainDesiredPayment()
         return;
         }
 
-    HOPEFULLY(materially_equal(GrossPmts[Month], EeGrossPmts[Month] + 
ErGrossPmts[Month]));
+    LMI_ASSERT(materially_equal(GrossPmts[Month], EeGrossPmts[Month] + 
ErGrossPmts[Month]));
 
     double eepmt = 0.0;
     if(ee_pay_this_month)
@@ -1264,8 +1264,8 @@ void AccountValue::TxAscertainDesiredPayment()
         GrossPmts  [Month] += erpmt;
         }
 
-    HOPEFULLY(materially_equal(GrossPmts[Month], EeGrossPmts[Month] + 
ErGrossPmts[Month]));
-    HOPEFULLY(GrossPmts[Month] < 1.0e100);
+    LMI_ASSERT(materially_equal(GrossPmts[Month], EeGrossPmts[Month] + 
ErGrossPmts[Month]));
+    LMI_ASSERT(GrossPmts[Month] < 1.0e100);
 
     // On the issue date (which is always a modal payment date), store
     // annualized planned premium, including dumpin and 1035 proceeds,
@@ -1295,7 +1295,7 @@ void AccountValue::TxAscertainDesiredPayment()
         GrossPmts  [Month] += z;
         }
 
-    HOPEFULLY(materially_equal(GrossPmts[Month], EeGrossPmts[Month] + 
ErGrossPmts[Month]));
+    LMI_ASSERT(materially_equal(GrossPmts[Month], EeGrossPmts[Month] + 
ErGrossPmts[Month]));
 
     if(0 == Year && 0 == Month)
         {
@@ -1308,7 +1308,7 @@ void AccountValue::TxAscertainDesiredPayment()
         GrossPmts  [Month] += Dumpin;
         }
 
-    HOPEFULLY(materially_equal(GrossPmts[Month], EeGrossPmts[Month] + 
ErGrossPmts[Month]));
+    LMI_ASSERT(materially_equal(GrossPmts[Month], EeGrossPmts[Month] + 
ErGrossPmts[Month]));
 }
 
 //============================================================================
@@ -1323,7 +1323,7 @@ void AccountValue::TxLimitPayment(double a_maxpmt)
     // we shouldn't.
 // TODO ?? TAXATION !! Clean this up, and put GPT limit here, on prem net of 
WD.
 
-    HOPEFULLY(materially_equal(GrossPmts[Month], EeGrossPmts[Month] + 
ErGrossPmts[Month]));
+    LMI_ASSERT(materially_equal(GrossPmts[Month], EeGrossPmts[Month] + 
ErGrossPmts[Month]));
 
     if(mce_reduce_prem == yare_input_.AvoidMecMethod && 
!Irc7702A_->IsMecAlready())
         {
@@ -1347,7 +1347,7 @@ void AccountValue::TxLimitPayment(double a_maxpmt)
         GrossPmts[Month] = EeGrossPmts[Month] + ErGrossPmts[Month];
         }
 
-    HOPEFULLY(materially_equal(GrossPmts[Month], EeGrossPmts[Month] + 
ErGrossPmts[Month]));
+    LMI_ASSERT(materially_equal(GrossPmts[Month], EeGrossPmts[Month] + 
ErGrossPmts[Month]));
 
     if(Solving || mce_run_gen_curr_sep_full == RunBasis_)
         {
@@ -1361,7 +1361,7 @@ void AccountValue::TxLimitPayment(double a_maxpmt)
         GrossPmts[Month] = EeGrossPmts[Month] + ErGrossPmts[Month];
         }
 
-    HOPEFULLY
+    LMI_ASSERT
         (materially_equal
             (GrossPmts[Month]
             ,EeGrossPmts[Month] + ErGrossPmts[Month]
@@ -1420,12 +1420,12 @@ void AccountValue::TxAcceptPayment(double a_pmt)
         return;
         }
 
-    HOPEFULLY(0.0 <= a_pmt);
+    LMI_ASSERT(0.0 <= a_pmt);
     // Internal 1035 exchanges may be exempt from premium tax; they're
     // handled elsewhere, so here the exempt amount is always zero.
     double actual_load = GetPremLoad(a_pmt, 0.0);
     double net_pmt = a_pmt - actual_load;
-    HOPEFULLY(0.0 <= net_pmt);
+    LMI_ASSERT(0.0 <= net_pmt);
     NetPmts[Month] += net_pmt;
 
     // If a payment on an ROP contract is treated as an adjustable event,
@@ -2536,7 +2536,7 @@ void AccountValue::TxTakeWD()
 
     double av = TotalAccountValue();
     double csv = av - SurrChg_[Year];
-    HOPEFULLY(0.0 <= SurrChg_[Year]);
+    LMI_ASSERT(0.0 <= SurrChg_[Year]);
     if(csv <= 0.0)
         {
 // TODO ?? What should this be?
diff --git a/ihs_basicval.cpp b/ihs_basicval.cpp
index a651330..aae6601 100644
--- a/ihs_basicval.cpp
+++ b/ihs_basicval.cpp
@@ -160,9 +160,9 @@ void BasicValues::Init()
 
     IssueAge = yare_input_.IssueAge;
     RetAge   = yare_input_.RetirementAge;
-    HOPEFULLY(IssueAge < 100);
-    HOPEFULLY(RetAge <= 100);
-    HOPEFULLY(yare_input_.RetireesCanEnroll || IssueAge <= RetAge);
+    LMI_ASSERT(IssueAge < 100);
+    LMI_ASSERT(RetAge <= 100);
+    LMI_ASSERT(yare_input_.RetireesCanEnroll || IssueAge <= RetAge);
 
     EndtAge = static_cast<int>(Database_->Query(DB_MaturityAge));
     Length = EndtAge - IssueAge;
@@ -254,9 +254,9 @@ void BasicValues::GPTServerInit()
 
     IssueAge = yare_input_.IssueAge;
     RetAge   = yare_input_.RetirementAge;
-    HOPEFULLY(IssueAge < 100);
-    HOPEFULLY(RetAge <= 100);
-    HOPEFULLY(yare_input_.RetireesCanEnroll || IssueAge <= RetAge);
+    LMI_ASSERT(IssueAge < 100);
+    LMI_ASSERT(RetAge <= 100);
+    LMI_ASSERT(yare_input_.RetireesCanEnroll || IssueAge <= RetAge);
 
     StateOfDomicile_ = 
mc_state_from_string(ProductData_->datum("InsCoDomicile"));
     StateOfJurisdiction_ = yare_input_.StateOfJurisdiction;
@@ -676,7 +676,7 @@ void BasicValues::SetPermanentInvariants()
     LapseIgnoresSurrChg = Database_->Query(DB_LapseIgnoresSurrChg  );
     SurrChgOnIncr       = Database_->Query(DB_SurrChgOnIncr        );
     SurrChgOnDecr       = Database_->Query(DB_SurrChgOnDecr        );
-    HOPEFULLY(!SurrChgOnDecr); // Surrchg change on decrease not supported.
+    LMI_ASSERT(!SurrChgOnDecr); // Surrchg change on decrease not supported.
 
     Database_->Query(FreeWDProportion, DB_FreeWdProportion);
 
@@ -702,8 +702,8 @@ void BasicValues::SetPermanentInvariants()
     // product which has no term rider and doesn't permit experience
     // rating, so we assert those preconditions and write simple code
     // for 'unusual' COI banding that ignores those features.
-    HOPEFULLY(!(UseUnusualCOIBanding && yare_input_.UseExperienceRating));
-    HOPEFULLY(!(UseUnusualCOIBanding && Database_->Query(DB_AllowTerm)));
+    LMI_ASSERT(!(UseUnusualCOIBanding && yare_input_.UseExperienceRating));
+    LMI_ASSERT(!(UseUnusualCOIBanding && Database_->Query(DB_AllowTerm)));
 
     // Flat extras can be used even with guaranteed issue, e.g., for
     // aviation, occupation, avocation, or foreign travel. Admin
@@ -861,7 +861,7 @@ void BasicValues::SetMaxSurvivalDur()
                 ;
             }
         }
-    HOPEFULLY(MaxSurvivalDur <= EndtAge);
+    LMI_ASSERT(MaxSurvivalDur <= EndtAge);
 }
 
 //============================================================================
diff --git a/input_realization.cpp b/input_realization.cpp
index 272ac80..27ef66a 100644
--- a/input_realization.cpp
+++ b/input_realization.cpp
@@ -1114,7 +1114,7 @@ void Input::make_term_rider_consistent(bool aggressively)
         && !global_settings::instance().regression_testing()
         )
         {
-        hobsons_choice()
+        alarum()
             << "Method '"
             << TermAdjustmentMethod.str()
             << "' is unreliable."
diff --git a/ledger_base.cpp b/ledger_base.cpp
index 0993358..4592faf 100644
--- a/ledger_base.cpp
+++ b/ledger_base.cpp
@@ -348,10 +348,7 @@ namespace
         {
         if(0.0 == a_ScalingFactor)
             {
-            hobsons_choice()
-                << "Scaling factor is zero. Report will be invalid."
-                << LMI_FLUSH
-                ;
+            alarum() << "Scaling factor is zero." << LMI_FLUSH;
             return "ZERO";
             }
 
@@ -419,7 +416,7 @@ void LedgerBase::ApplyScaleFactor(double a_Mult)
     LMI_ASSERT(0.0 != m_scaling_factor);
     if(1.0 != m_scaling_factor)
         {
-        hobsons_choice() << "Cannot scale the same ledger twice." << LMI_FLUSH;
+        alarum() << "Cannot scale the same ledger twice." << LMI_FLUSH;
         }
 
     m_scaling_factor = a_Mult;
diff --git a/sigfpe.cpp b/sigfpe.cpp
index 422efbc..e8fd82d 100644
--- a/sigfpe.cpp
+++ b/sigfpe.cpp
@@ -41,7 +41,7 @@
 
 void floating_point_error_handler(int)
 {
-    hobsons_choice() << "Floating point error." << LMI_FLUSH;
+    alarum() << "Floating point error." << LMI_FLUSH;
 
     if(SIG_ERR == std::signal(SIGFPE, floating_point_error_handler))
         {



reply via email to

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