lmi-commits
[Top][All Lists]
Advanced

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

[lmi-commits] [4853] Refactor


From: Greg Chicares
Subject: [lmi-commits] [4853] Refactor
Date: Fri, 23 Apr 2010 15:40:19 +0000

Revision: 4853
          http://svn.sv.gnu.org/viewvc/?view=rev&root=lmi&revision=4853
Author:   chicares
Date:     2010-04-23 15:40:19 +0000 (Fri, 23 Apr 2010)
Log Message:
-----------
Refactor

Modified Paths:
--------------
    lmi/trunk/ChangeLog
    lmi/trunk/accountvalue.cpp
    lmi/trunk/basic_values.hpp
    lmi/trunk/basicvalues.cpp
    lmi/trunk/ihs_acctval.cpp
    lmi/trunk/ihs_avmly.cpp
    lmi/trunk/ihs_avsolve.cpp
    lmi/trunk/ihs_avstrtgy.cpp
    lmi/trunk/ihs_basicval.cpp
    lmi/trunk/interest_rates.cpp
    lmi/trunk/ledger_invariant.cpp
    lmi/trunk/loads.cpp
    lmi/trunk/mortality_rates_fetch.cpp

Modified: lmi/trunk/ChangeLog
===================================================================
--- lmi/trunk/ChangeLog 2010-04-23 14:40:28 UTC (rev 4852)
+++ lmi/trunk/ChangeLog 2010-04-23 15:40:19 UTC (rev 4853)
@@ -24972,3 +24972,30 @@
   version.hpp
 Mark release candidate.
 
+20100423T1401Z <address@hidden> [756]
+
+  round_to_test.cpp
+Demonstrate that dereferencing a null pointer cras
+
+20100423T1440Z <address@hidden> [756]
+
+  round_to.hpp
+  round_to_test.cpp
+Remove the anomaly demonstrated 20100423T1401Z.
+
+20100423T1540Z <address@hidden> [756]
+
+  accountvalue.cpp
+  basic_values.hpp
+  basicvalues.cpp
+  ihs_acctval.cpp
+  ihs_avmly.cpp
+  ihs_avsolve.cpp
+  ihs_avstrtgy.cpp
+  ihs_basicval.cpp
+  interest_rates.cpp
+  ledger_invariant.cpp
+  loads.cpp
+  mortality_rates_fetch.cpp
+Refactor.
+

Modified: lmi/trunk/accountvalue.cpp
===================================================================
--- lmi/trunk/accountvalue.cpp  2010-04-23 14:40:28 UTC (rev 4852)
+++ lmi/trunk/accountvalue.cpp  2010-04-23 15:40:19 UTC (rev 4853)
@@ -41,7 +41,6 @@
 #include "loads.hpp"
 #include "mortality_rates.hpp"
 #include "outlay.hpp"
-#include "rounding_rules.hpp"
 
 #include <algorithm> // std::max(), std::min()
 #include <cmath>     // std::pow()
@@ -495,7 +494,7 @@
             }
         }
 
-    SA = GetRoundingRules().round_specamt()(SA);
+    SA = round_specamt()(SA);
 
     for(int j = 0; j < BasicValues::GetLength(); j++)
         {
@@ -552,7 +551,7 @@
             fatal_error() << "Case " << YearsDBOpt << " not found." << 
LMI_FLUSH;
             }
         }
-    ActualSpecAmt = GetRoundingRules().round_specamt()(ActualSpecAmt);
+    ActualSpecAmt = round_specamt()(ActualSpecAmt);
 
     // Carry the new spec amt forward into all future years.
     for(int j = Year; j < BasicValues::GetLength(); j++)
@@ -701,7 +700,7 @@
 //            (DB-AV)/YearsCorridorFactor - AV
 
     // Subtract premium load from gross premium yielding net premium.
-    NetPmts[Month] = GetRoundingRules().round_net_premium()
+    NetPmts[Month] = round_net_premium()
         (GrossPmts[Month] * (1.0 - YearsPremLoadTgt)
         );
     // Should we instead do the following?
@@ -770,7 +769,7 @@
             }
         }
 
-    deathbft = GetRoundingRules().round_death_benefit()(deathbft);
+    deathbft = round_death_benefit()(deathbft);
 
     // SOMEDAY !! Accumulate average death benefit for profit testing here.
 }
@@ -782,11 +781,9 @@
     TxSetDeathBft();
 
     // Negative AV doesn't increase NAAR.
-    NAAR = GetRoundingRules().round_naar()
-        (deathbft * mlyguarv - (AVUnloaned + AVRegLn + AVPrfLn)
-        );
+    NAAR = round_naar()(deathbft * mlyguarv - (AVUnloaned + AVRegLn + 
AVPrfLn));
 
-    CoiCharge = GetRoundingRules().round_coi_charge()(NAAR * YearsCoiRate0);
+    CoiCharge = round_coi_charge()(NAAR * YearsCoiRate0);
 }
 
 //============================================================================
@@ -827,9 +824,7 @@
     if(0.0 < AVUnloaned)
         {
         // IHS !! Each interest increment is rounded separately in lmi.
-        double z = GetRoundingRules().round_interest_credit()
-            (AVUnloaned * YearsGenAcctIntRate
-            );
+        double z = round_interest_credit()(AVUnloaned * YearsGenAcctIntRate);
         AVUnloaned += z;
         }
     // Loaned account value cannot be negative.
@@ -848,22 +843,14 @@
 
     // We may want to display credited interest separately.
     // IHS !! Each interest increment is rounded separately in lmi.
-    RegLnIntCred = GetRoundingRules().round_interest_credit()
-        (AVRegLn * YearsRegLnIntCredRate
-        );
-    PrfLnIntCred = GetRoundingRules().round_interest_credit()
-        (AVPrfLn * YearsPrfLnIntCredRate
-        );
+    RegLnIntCred = round_interest_credit()(AVRegLn * YearsRegLnIntCredRate);
+    PrfLnIntCred = round_interest_credit()(AVPrfLn * YearsPrfLnIntCredRate);
 
     AVRegLn += RegLnIntCred;
     AVPrfLn += PrfLnIntCred;
 
-    double RegLnIntAccrued = GetRoundingRules().round_interest_credit()
-        (RegLnBal * YearsRegLnIntDueRate
-        );
-    double PrfLnIntAccrued = GetRoundingRules().round_interest_credit()
-        (PrfLnBal * YearsPrfLnIntDueRate
-        );
+    double RegLnIntAccrued = round_interest_credit()(RegLnBal * 
YearsRegLnIntDueRate);
+    double PrfLnIntAccrued = round_interest_credit()(PrfLnBal * 
YearsPrfLnIntDueRate);
 
     RegLnBal += RegLnIntAccrued;
     PrfLnBal += PrfLnIntAccrued;
@@ -927,7 +914,7 @@
 // TODO ??            ActualSpecAmt = std::min(ActualSpecAmt, deathbft - wd);
             ActualSpecAmt -= wd;
             ActualSpecAmt = std::max(ActualSpecAmt, MinSpecAmt);
-            ActualSpecAmt = GetRoundingRules().round_specamt()(ActualSpecAmt);
+            ActualSpecAmt = round_specamt()(ActualSpecAmt);
             // TODO ?? If WD causes AV < min AV, do we:
             //   reduce the WD?
             //   lapse the policy?
@@ -989,7 +976,7 @@
     IntAdj = (IntAdj - 1.0) / IntAdj;
     MaxLoan *= 1.0 - IntAdj;
     MaxLoan = std::max(0.0, MaxLoan);
-    MaxLoan = GetRoundingRules().round_loan()(MaxLoan);
+    MaxLoan = round_loan()(MaxLoan);
 
     // IHS !! Preferred loan calculations would go here: implemented in lmi.
 

Modified: lmi/trunk/basic_values.hpp
===================================================================
--- lmi/trunk/basic_values.hpp  2010-04-23 14:40:28 UTC (rev 4852)
+++ lmi/trunk/basic_values.hpp  2010-04-23 15:40:19 UTC (rev 4853)
@@ -112,7 +112,6 @@
     double                DomiciliaryPremiumTaxLoad()  const;
     bool                  IsPremiumTaxLoadTiered()     const;
     bool                  IsSubjectToIllustrationReg() const;
-    rounding_rules const& GetRoundingRules()           const;
     double                InvestmentManagementFee()    const;
 
     boost::shared_ptr<Input const>        Input_;
@@ -175,6 +174,26 @@
     std::vector<double> GetCurrSpecAmtLoadTable()       const;
     std::vector<double> GetGuarSpecAmtLoadTable()       const;
 
+    round_to<double> const& round_specamt           () const {return 
round_specamt_           ;}
+    round_to<double> const& round_death_benefit     () const {return 
round_death_benefit_     ;}
+    round_to<double> const& round_naar              () const {return 
round_naar_              ;}
+    round_to<double> const& round_coi_rate          () const {return 
round_coi_rate_          ;}
+    round_to<double> const& round_coi_charge        () const {return 
round_coi_charge_        ;}
+    round_to<double> const& round_gross_premium     () const {return 
round_gross_premium_     ;}
+    round_to<double> const& round_net_premium       () const {return 
round_net_premium_       ;}
+    round_to<double> const& round_interest_rate     () const {return 
round_interest_rate_     ;}
+    round_to<double> const& round_interest_credit   () const {return 
round_interest_credit_   ;}
+    round_to<double> const& round_withdrawal        () const {return 
round_withdrawal_        ;}
+    round_to<double> const& round_loan              () const {return 
round_loan_              ;}
+    round_to<double> const& round_corridor_factor   () const {return 
round_corridor_factor_   ;}
+    round_to<double> const& round_surrender_charge  () const {return 
round_surrender_charge_  ;}
+    round_to<double> const& round_irr               () const {return 
round_irr_               ;}
+    round_to<double> const& round_min_specamt       () const {return 
round_min_specamt_       ;}
+    round_to<double> const& round_max_specamt       () const {return 
round_max_specamt_       ;}
+    round_to<double> const& round_min_premium       () const {return 
round_min_premium_       ;}
+    round_to<double> const& round_max_premium       () const {return 
round_max_premium_       ;}
+    round_to<double> const& round_interest_rate_7702() const {return 
round_interest_rate_7702_;}
+
   protected:
     double GetModalMinPrem
         (int         a_year
@@ -354,26 +373,6 @@
     bool                    PremiumTaxLoadIsTieredInStateOfDomicile;
     bool                    PremiumTaxLoadIsTieredInStateOfJurisdiction;
 
-    round_to<double>        round_specamt;
-    round_to<double>        round_death_benefit;
-    round_to<double>        round_naar;
-    round_to<double>        round_coi_rate;
-    round_to<double>        round_coi_charge;
-    round_to<double>        round_gross_premium;
-    round_to<double>        round_net_premium;
-    round_to<double>        round_interest_rate;
-    round_to<double>        round_interest_credit;
-    round_to<double>        round_withdrawal;
-    round_to<double>        round_loan;
-    round_to<double>        round_corridor_factor;
-    round_to<double>        round_surrender_charge;
-    round_to<double>        round_irr;
-    round_to<double>        round_min_specamt;
-    round_to<double>        round_max_specamt;
-    round_to<double>        round_min_premium;
-    round_to<double>        round_max_premium;
-    round_to<double>        round_interest_rate_7702;
-
   private:
     double GetModalPrem
         (int                   a_year
@@ -440,6 +439,27 @@
     std::vector<double> Mly7702qc;
     std::vector<double> MlyDcvqc;
     mutable std::vector<double> Non7702CompliantCorridor;
+
+    void SetRoundingFunctors();
+    round_to<double> round_specamt_           ;
+    round_to<double> round_death_benefit_     ;
+    round_to<double> round_naar_              ;
+    round_to<double> round_coi_rate_          ;
+    round_to<double> round_coi_charge_        ;
+    round_to<double> round_gross_premium_     ;
+    round_to<double> round_net_premium_       ;
+    round_to<double> round_interest_rate_     ;
+    round_to<double> round_interest_credit_   ;
+    round_to<double> round_withdrawal_        ;
+    round_to<double> round_loan_              ;
+    round_to<double> round_corridor_factor_   ;
+    round_to<double> round_surrender_charge_  ;
+    round_to<double> round_irr_               ;
+    round_to<double> round_min_specamt_       ;
+    round_to<double> round_max_specamt_       ;
+    round_to<double> round_min_premium_       ;
+    round_to<double> round_max_premium_       ;
+    round_to<double> round_interest_rate_7702_;
 };
 
 inline int BasicValues::GetLength() const
@@ -497,11 +517,6 @@
     return IsSubjectToIllustrationReg_;
 }
 
-inline rounding_rules const& BasicValues::GetRoundingRules() const
-{
-    return *RoundingRules_;
-}
-
 double lowest_premium_tax_load
     (TDatabase          const& db
     ,stratified_charges const& stratified

Modified: lmi/trunk/basicvalues.cpp
===================================================================
--- lmi/trunk/basicvalues.cpp   2010-04-23 14:40:28 UTC (rev 4852)
+++ lmi/trunk/basicvalues.cpp   2010-04-23 15:40:19 UTC (rev 4853)
@@ -38,7 +38,6 @@
 #include "loads.hpp"
 #include "mortality_rates.hpp"
 #include "outlay.hpp"
-#include "rounding_rules.hpp"
 #include "surrchg_rates.hpp"
 
 #include <algorithm> // std::max()
@@ -54,10 +53,29 @@
 
 //============================================================================
 BasicValues::BasicValues(Input const& input)
-    :Input_               (new Input(input))
-    ,yare_input_          (input)
-    ,StateOfJurisdiction_ (mce_s_CT)
-    ,StateOfDomicile_     (mce_s_CT)
+    :Input_                   (new Input(input))
+    ,yare_input_              (input)
+    ,StateOfJurisdiction_     (mce_s_CT)
+    ,StateOfDomicile_         (mce_s_CT)
+    ,round_specamt_           (0, r_upward    )
+    ,round_death_benefit_     (2, r_to_nearest)
+    ,round_naar_              (2, r_to_nearest)
+    ,round_coi_rate_          (8, r_downward  )
+    ,round_coi_charge_        (2, r_to_nearest)
+    ,round_gross_premium_     (2, r_to_nearest)
+    ,round_net_premium_       (2, r_to_nearest)
+    ,round_interest_rate_     (0, r_not_at_all)
+    ,round_interest_credit_   (2, r_to_nearest)
+    ,round_withdrawal_        (2, r_to_nearest)
+    ,round_loan_              (2, r_to_nearest)
+    ,round_corridor_factor_   (2, r_to_nearest)
+    ,round_surrender_charge_  (2, r_to_nearest)
+    ,round_irr_               (5, r_downward  )
+    ,round_min_specamt_       (0, r_upward    )
+    ,round_max_specamt_       (0, r_downward  )
+    ,round_min_premium_       (2, r_upward    )
+    ,round_max_premium_       (2, r_downward  )
+    ,round_interest_rate_7702_(0, r_not_at_all)
 {
     Init();
 }
@@ -102,8 +120,6 @@
         ;
     IsSubjectToIllustrationReg_ = is_subject_to_ill_reg(GetLedgerType());
 
-    RoundingRules_.reset(new rounding_rules);
-
     // IHS !! Just a dummy initialization here--implemented in lmi.
     SpreadFor7702_.assign(Length, 0.0);
 

Modified: lmi/trunk/ihs_acctval.cpp
===================================================================
--- lmi/trunk/ihs_acctval.cpp   2010-04-23 14:40:28 UTC (rev 4852)
+++ lmi/trunk/ihs_acctval.cpp   2010-04-23 15:40:19 UTC (rev 4853)
@@ -1048,7 +1048,7 @@
         ,SurrChgRates_->SpecamtRateDurationalFactor().end() - year
         ,std::inserter(new_layer, new_layer.begin())
         ,boost::bind
-            (round_surrender_charge
+            (round_surrender_charge()
             ,boost::bind(std::multiplies<double>(), _1, z)
             )
         );
@@ -1081,7 +1081,7 @@
             ,       SurrChg_.end()
             ,year + SurrChg_.begin()
             ,boost::bind
-                (round_surrender_charge
+                (round_surrender_charge()
                 ,boost::bind(std::multiplies<double>(), _1, multiplier)
                 )
             );

Modified: lmi/trunk/ihs_avmly.cpp
===================================================================
--- lmi/trunk/ihs_avmly.cpp     2010-04-23 14:40:28 UTC (rev 4852)
+++ lmi/trunk/ihs_avmly.cpp     2010-04-23 15:40:19 UTC (rev 4853)
@@ -639,7 +639,7 @@
         // must be its value immediately after any 1035 exchange,
         // which by its nature occurs before a seven-pay premium
         // can be calculated.
-        InvariantValues().InitSevenPayPrem = round_max_premium
+        InvariantValues().InitSevenPayPrem = round_max_premium()
             (Irc7702A_->GetPresent7pp()
             );
         }
@@ -689,7 +689,7 @@
     ,double monthly_rate
     ) const
 {
-    return round_interest_credit(principal * ActualMonthlyRate(monthly_rate));
+    return round_interest_credit()(principal * 
ActualMonthlyRate(monthly_rate));
 }
 
 //============================================================================
@@ -779,7 +779,7 @@
                     - ActualSpecAmt
                     ;
                 }
-            TermSpecAmt = round_specamt(TermSpecAmt);
+            TermSpecAmt = round_specamt()(TermSpecAmt);
             }
         }
     else
@@ -798,7 +798,7 @@
 
     // If the minimum isn't met, then force it.
     ActualSpecAmt = std::max(ActualSpecAmt, MinSpecAmt);
-    ActualSpecAmt = round_specamt(ActualSpecAmt);
+    ActualSpecAmt = round_specamt()(ActualSpecAmt);
     AddSurrChgLayer(Year, std::max(0.0, ActualSpecAmt - prior_specamt));
 
     // Carry the new specamt forward into all future years.
@@ -1486,7 +1486,7 @@
         ||  materially_equal(total_load, sum_of_separate_loads)
         );
 
-    return round_net_premium(sum_of_separate_loads);
+    return round_net_premium()(sum_of_separate_loads);
 }
 
 //============================================================================
@@ -1739,7 +1739,7 @@
         (DBIgnoringCorr
         ,YearsCorridorFactor * cash_value_for_corridor
         );
-    DBReflectingCorr = round_death_benefit(DBReflectingCorr);
+    DBReflectingCorr = round_death_benefit()(DBReflectingCorr);
     // This overrides the value assigned above. There's more than one
     // way to interpret 7702A "death benefit"; this is just one.
     DB7702A = DBReflectingCorr + TermDB;
@@ -1792,7 +1792,7 @@
         }
 
     TermDB = std::max(0.0, TermSpecAmt + DBIgnoringCorr - DBReflectingCorr);
-    TermDB = round_death_benefit(TermDB);
+    TermDB = round_death_benefit()(TermDB);
 }
 
 //============================================================================
@@ -1843,7 +1843,7 @@
         (DBReflectingCorr * DBDiscountRate[Year]
         ,std::max(0.0, TotalAccountValue())
         );
-    NAAR = std::max(0.0, round_naar(NAAR));
+    NAAR = std::max(0.0, round_naar()(NAAR));
 
 // TODO ?? This doesn't work. We need to reconsider the basic transactions.
 //  double naar_forceout = std::max(0.0, NAAR - MaxNAAR);
@@ -1873,17 +1873,17 @@
         &&  mce_gen_curr == GenBasis_
         )
         {
-        ActualCoiRate = round_coi_rate
+        ActualCoiRate = round_coi_rate()
             (std::min
                 (GetBandedCoiRates(mce_gen_guar, ActualSpecAmt)[Year]
                 ,coi_rate * (case_k_factor + CoiRetentionRate)
                 )
             );
-        double retention_rate = round_coi_rate(coi_rate * CoiRetentionRate);
-        retention_charge = round_coi_charge(NAAR * retention_rate);
+        double retention_rate = round_coi_rate()(coi_rate * CoiRetentionRate);
+        retention_charge = round_coi_charge()(NAAR * retention_rate);
         }
 
-    CoiCharge    = round_coi_charge(NAAR * ActualCoiRate);
+    CoiCharge    = round_coi_charge()(NAAR * ActualCoiRate);
     NetCoiCharge = CoiCharge - retention_charge;
     YearsTotalCoiCharge += CoiCharge;
 
@@ -2099,7 +2099,7 @@
         YearsSepAcctLoadRate += stratified_load;
         YearsSepAcctLoadRate += tiered_comp;
         YearsSepAcctLoadRate = 
i_upper_12_over_12_from_i<double>()(YearsSepAcctLoadRate);
-        round_interest_rate(YearsSepAcctLoadRate);
+        round_interest_rate()(YearsSepAcctLoadRate);
         }
 
     SepAcctLoad = YearsSepAcctLoadRate * AVSepAcct;
@@ -2224,7 +2224,7 @@
     double gross_sep_acct_rate = i_upper_12_over_12_from_i<double>()
         (InterestRates_->SepAcctGrossRate(SepBasis_)[Year]
         );
-    gross_sep_acct_rate = round_interest_rate(gross_sep_acct_rate);
+    gross_sep_acct_rate = round_interest_rate()(gross_sep_acct_rate);
     if(mce_gen_mdpt == GenBasis_)
         {
         gross_sep_acct_rate = 0.0;
@@ -2761,7 +2761,7 @@
     //
     MaxLoan *= 1.0 - (reg_loan_factor) / (1.0 + reg_loan_factor);
 
-    MaxLoan = round_loan(MaxLoan);
+    MaxLoan = round_loan()(MaxLoan);
 
     // I do not think we want a MaxLoan < current level of indebtedness.
     MaxLoan = std::max((AVRegLn + AVPrfLn), MaxLoan);

Modified: lmi/trunk/ihs_avsolve.cpp
===================================================================
--- lmi/trunk/ihs_avsolve.cpp   2010-04-23 14:40:28 UTC (rev 4852)
+++ lmi/trunk/ihs_avsolve.cpp   2010-04-23 15:40:19 UTC (rev 4853)
@@ -353,33 +353,33 @@
 //          upper_bound  = 1000000.0 * Outlay_->GetPmts()[0];
 // is not satisfactory; what would be better?
             solve_set_fn = &AccountValue::SolveSetSpecAmt;
-            decimals     = round_specamt.decimals();
+            decimals     = round_specamt().decimals();
             // TODO ?? Respect minimum specamt?
             }
             break;
         case mce_solve_ee_prem:
             {
             solve_set_fn = &AccountValue::SolveSetEePrem;
-            decimals     = round_gross_premium.decimals();
+            decimals     = round_gross_premium().decimals();
             }
             break;
         case mce_solve_er_prem:
             {
             solve_set_fn = &AccountValue::SolveSetErPrem;
-            decimals     = round_gross_premium.decimals();
+            decimals     = round_gross_premium().decimals();
             }
             break;
         case mce_solve_loan:
             {
             solve_set_fn = &AccountValue::SolveSetLoan;
-            decimals     = round_loan.decimals();
+            decimals     = round_loan().decimals();
             }
             break;
         case mce_solve_wd:
             {
             // TODO ?? Is minimum wd respected?
             solve_set_fn = &AccountValue::SolveSetWD;
-            decimals     = round_withdrawal.decimals();
+            decimals     = round_withdrawal().decimals();
             if(yare_input_.WithdrawToBasisThenLoan)
                 {
                 // Withdrawals and loans might be rounded differently.
@@ -387,8 +387,8 @@
                 // withdrawals, both should be rounded to the less
                 // precise number of decimals normally used for either.
                 decimals = std::min
-                    (round_withdrawal.decimals()
-                    ,round_loan      .decimals()
+                    (round_withdrawal().decimals()
+                    ,round_loan      ().decimals()
                     );
                 }
             }

Modified: lmi/trunk/ihs_avstrtgy.cpp
===================================================================
--- lmi/trunk/ihs_avstrtgy.cpp  2010-04-23 14:40:28 UTC (rev 4852)
+++ lmi/trunk/ihs_avstrtgy.cpp  2010-04-23 15:40:19 UTC (rev 4853)
@@ -162,7 +162,7 @@
     for
         (int j = 0; j < BasicValues::Length; ++j)
         {
-        double z = round_specamt(CalculateSpecAmtFromStrategy(j, 0));
+        double z = round_specamt()(CalculateSpecAmtFromStrategy(j, 0));
         DeathBfts_->set_specamt(z, j, 1 + j);
         }
 }

Modified: lmi/trunk/ihs_basicval.cpp
===================================================================
--- lmi/trunk/ihs_basicval.cpp  2010-04-23 14:40:28 UTC (rev 4852)
+++ lmi/trunk/ihs_basicval.cpp  2010-04-23 15:40:19 UTC (rev 4853)
@@ -252,6 +252,7 @@
                 ).get_rounding_rules()
             )
         );
+    SetRoundingFunctors();
     StratifiedCharges_.reset
         (new 
stratified_charges(AddDataDir(ProductData_->datum("TierFilename")))
         );
@@ -262,7 +263,7 @@
 
     // Multilife contracts will need a vector of mortality-rate objects.
 
-    // Mortality and interest rates require database.
+    // Mortality and interest rates require database and rounding.
     // Interest rates require tiered data and 7702 spread.
     MortalityRates_.reset(new MortalityRates (*this));
     InterestRates_ .reset(new InterestRates  (*this));
@@ -338,6 +339,7 @@
                 ).get_rounding_rules()
             )
         );
+    SetRoundingFunctors();
     StratifiedCharges_.reset
         (new 
stratified_charges(AddDataDir(ProductData_->datum("TierFilename")))
         );
@@ -479,7 +481,7 @@
         (MlyDcvqc.begin()
         ,MlyDcvqc.end()
         ,MlyDcvqc.begin()
-        ,round_coi_rate
+        ,round_coi_rate()
         );
     if(std::string::npos != yare_input_.Comments.find("idiosyncrasy_dcvq"))
         {
@@ -663,10 +665,10 @@
             ,Loads_->target_premium_load_7702_excluding_premium_tax()
             ,Loads_->excess_premium_load_7702_excluding_premium_tax()
             ,InitialTargetPremium
-            ,round_min_premium
-            ,round_max_premium
-            ,round_min_specamt
-            ,round_max_specamt
+            ,round_min_premium()
+            ,round_max_premium()
+            ,round_min_specamt()
+            ,round_max_specamt()
             )
         );
 }
@@ -686,7 +688,7 @@
             ,true  // TODO ?? Use table for NSP: hardcoded for now.
             ,MortalityRates_->SevenPayRates()
             ,MortalityRates_->CvatNspRates()
-            ,round_max_premium
+            ,round_max_premium()
             )
         );
 }
@@ -843,29 +845,32 @@
 
     Database_->Query(MinPremIntSpread_, DB_MinPremIntSpread);
 
-    round_specamt            = RoundingRules_->round_specamt           ();
-    round_death_benefit      = RoundingRules_->round_death_benefit     ();
-    round_naar               = RoundingRules_->round_naar              ();
-    round_coi_rate           = RoundingRules_->round_coi_rate          ();
-    round_coi_charge         = RoundingRules_->round_coi_charge        ();
-    round_gross_premium      = RoundingRules_->round_gross_premium     ();
-    round_net_premium        = RoundingRules_->round_net_premium       ();
-    round_interest_rate      = RoundingRules_->round_interest_rate     ();
-    round_interest_credit    = RoundingRules_->round_interest_credit   ();
-    round_withdrawal         = RoundingRules_->round_withdrawal        ();
-    round_loan               = RoundingRules_->round_loan              ();
-    round_corridor_factor    = RoundingRules_->round_corridor_factor   ();
-    round_surrender_charge   = RoundingRules_->round_surrender_charge  ();
-    round_irr                = RoundingRules_->round_irr               ();
-    round_min_specamt        = RoundingRules_->round_min_specamt       ();
-    round_max_specamt        = RoundingRules_->round_max_specamt       ();
-    round_min_premium        = RoundingRules_->round_min_premium       ();
-    round_max_premium        = RoundingRules_->round_max_premium       ();
-    round_interest_rate_7702 = RoundingRules_->round_interest_rate_7702();
-
     SetMaxSurvivalDur();
 }
 
+void BasicValues::SetRoundingFunctors()
+{
+    round_specamt_            = RoundingRules_->round_specamt           ();
+    round_death_benefit_      = RoundingRules_->round_death_benefit     ();
+    round_naar_               = RoundingRules_->round_naar              ();
+    round_coi_rate_           = RoundingRules_->round_coi_rate          ();
+    round_coi_charge_         = RoundingRules_->round_coi_charge        ();
+    round_gross_premium_      = RoundingRules_->round_gross_premium     ();
+    round_net_premium_        = RoundingRules_->round_net_premium       ();
+    round_interest_rate_      = RoundingRules_->round_interest_rate     ();
+    round_interest_credit_    = RoundingRules_->round_interest_credit   ();
+    round_withdrawal_         = RoundingRules_->round_withdrawal        ();
+    round_loan_               = RoundingRules_->round_loan              ();
+    round_corridor_factor_    = RoundingRules_->round_corridor_factor   ();
+    round_surrender_charge_   = RoundingRules_->round_surrender_charge  ();
+    round_irr_                = RoundingRules_->round_irr               ();
+    round_min_specamt_        = RoundingRules_->round_min_specamt       ();
+    round_max_specamt_        = RoundingRules_->round_max_specamt       ();
+    round_min_premium_        = RoundingRules_->round_min_premium       ();
+    round_max_premium_        = RoundingRules_->round_max_premium       ();
+    round_interest_rate_7702_ = RoundingRules_->round_interest_rate_7702();
+}
+
 //============================================================================
 void BasicValues::SetLowestPremiumTaxLoad()
 {
@@ -1150,7 +1155,7 @@
     ) const
 {
     double temp = MortalityRates_->SevenPayRates()[0];
-    return round_max_premium(temp * epsilon_plus_one * a_specamt / a_mode);
+    return round_max_premium()(temp * epsilon_plus_one * a_specamt / a_mode);
 }
 
 /// Calculate premium using a target-premium ratio.
@@ -1165,7 +1170,7 @@
     ,double      a_specamt
     ) const
 {
-    return round_max_premium
+    return round_max_premium()
         (
             (   Database_->Query(DB_TgtPremPolFee)
             +       a_specamt
@@ -1189,7 +1194,7 @@
     ) const
 {
     double temp = GetCorridorFactor()[0];
-    return round_max_premium((epsilon_plus_one * a_specamt / temp) / a_mode);
+    return round_max_premium()((epsilon_plus_one * a_specamt / temp) / a_mode);
 }
 
 //============================================================================
@@ -1213,7 +1218,7 @@
 // term rider, dumpin
 
     z /= a_mode;
-    return round_max_premium(epsilon_plus_one * z);
+    return round_max_premium()(epsilon_plus_one * z);
 }
 
 //============================================================================
@@ -1236,7 +1241,7 @@
 // term rider, dumpin
 
     z /= a_mode;
-    return round_max_premium(epsilon_plus_one * z);
+    return round_max_premium()(epsilon_plus_one * z);
 }
 
 /// Determine an approximate "pay as you go" modal premium.
@@ -1313,7 +1318,7 @@
     z *= GetAnnuityValueMlyDed(a_year, a_mode);
     z += annual_charge;
 
-    return round_min_premium(z);
+    return round_min_premium()(z);
 }
 
 //============================================================================
@@ -1395,7 +1400,7 @@
         // seven-pay table, then this seems not to give the same
         // result as the seven-pay premium type.
         double annualized_pmt = a_ee_mode * a_ee_pmt + a_er_mode * a_er_pmt;
-        return round_min_specamt
+        return round_min_specamt()
             (annualized_pmt / GetModalPremTgtFromTable(0, a_ee_mode, 1)
             );
         }
@@ -1423,7 +1428,7 @@
     ) const
 {
     double annualized_pmt = a_ee_mode * a_ee_pmt + a_er_mode * a_er_pmt;
-    return round_min_specamt
+    return round_min_specamt()
         (annualized_pmt / MortalityRates_->SevenPayRates()[0]
         );
 }
@@ -1474,7 +1479,7 @@
 {
     double annualized_pmt = a_ee_mode * a_ee_pmt + a_er_mode * a_er_pmt;
     double rate = GetCorridorFactor()[0];
-    return round_min_specamt(annualized_pmt * rate);
+    return round_min_specamt()(annualized_pmt * rate);
 }
 
 /// In general, strategies linking specamt and premium commute. The
@@ -1553,7 +1558,7 @@
         )[0]
         ;
 
-    return round_max_specamt(z);
+    return round_max_specamt()(z);
 }
 
 /// 'Unusual' banding is one particular approach we needed to model.

Modified: lmi/trunk/interest_rates.cpp
===================================================================
--- lmi/trunk/interest_rates.cpp        2010-04-23 14:40:28 UTC (rev 4852)
+++ lmi/trunk/interest_rates.cpp        2010-04-23 15:40:19 UTC (rev 4853)
@@ -35,7 +35,6 @@
 #include "dbnames.hpp"
 #include "math_functors.hpp"
 #include "miscellany.hpp" // each_equal()
-#include "rounding_rules.hpp"
 #include "yare_input.hpp"
 
 #include <algorithm>
@@ -255,8 +254,8 @@
 
 InterestRates::InterestRates(BasicValues const& v)
     :Length_             (v.GetLength())
-    ,RoundIntRate_       (v.GetRoundingRules().round_interest_rate())
-    ,Round7702Rate_      (v.GetRoundingRules().round_interest_rate_7702())
+    ,RoundIntRate_       (v.round_interest_rate())
+    ,Round7702Rate_      (v.round_interest_rate_7702())
     ,Zero_               (Length_)
     ,NeedMidpointRates_  (v.IsSubjectToIllustrationReg())
     ,GenAcctRateType_    (v.yare_input_.GeneralAccountRateType)

Modified: lmi/trunk/ledger_invariant.cpp
===================================================================
--- lmi/trunk/ledger_invariant.cpp      2010-04-23 14:40:28 UTC (rev 4852)
+++ lmi/trunk/ledger_invariant.cpp      2010-04-23 15:40:19 UTC (rev 4853)
@@ -47,7 +47,6 @@
 #include "miscellany.hpp"
 #include "outlay.hpp"
 #include "product_data.hpp"
-#include "rounding_rules.hpp"
 
 #include <algorithm>
 #include <ostream>
@@ -398,7 +397,7 @@
     // Zero-initialize almost everything.
     Init();
 
-    irr_precision = b->GetRoundingRules().round_irr().decimals();
+    irr_precision = b->round_irr().decimals();
 
 // TODO ?? These names are confusing. EePmt and ErPmt are *input* values.
 // If they're entered as $1000 for all years, then they have that value

Modified: lmi/trunk/loads.cpp
===================================================================
--- lmi/trunk/loads.cpp 2010-04-23 14:40:28 UTC (rev 4852)
+++ lmi/trunk/loads.cpp 2010-04-23 15:40:19 UTC (rev 4853)
@@ -37,7 +37,6 @@
 #include "et_vector.hpp"
 #include "math_functors.hpp"
 #include "mc_enum_types_aux.hpp" // mc_n_ enumerators
-#include "rounding_rules.hpp"
 
 #include <algorithm>
 #include <functional>
@@ -63,7 +62,7 @@
         ,V.Database_->Query(DB_PmTxAmortPeriod)
         ,V.Database_->Query(DB_AssetChargeType)
         ,V.IsSubjectToIllustrationReg()
-        ,V.GetRoundingRules().round_interest_rate()
+        ,V.round_interest_rate()
         ,V.yare_input_.ExtraCompensationOnPremium
         ,V.yare_input_.ExtraCompensationOnAssets
         ,V.yare_input_.ExtraMonthlyCustodialFee

Modified: lmi/trunk/mortality_rates_fetch.cpp
===================================================================
--- lmi/trunk/mortality_rates_fetch.cpp 2010-04-23 14:40:28 UTC (rev 4852)
+++ lmi/trunk/mortality_rates_fetch.cpp 2010-04-23 15:40:19 UTC (rev 4853)
@@ -31,7 +31,6 @@
 #include "basic_values.hpp"
 #include "database.hpp"
 #include "dbnames.hpp"
-#include "rounding_rules.hpp"
 #include "yare_input.hpp"
 
 #include <algorithm>
@@ -78,7 +77,7 @@
     // TODO ?? Defectively, this data member is not yet used.
     PartialMortalityMultiplier_ = 
basic_values.yare_input_.PartialMortalityMultiplier;
 
-    round_coi_rate_ = basic_values.GetRoundingRules().round_coi_rate();
+    round_coi_rate_ = basic_values.round_coi_rate();
 
 // TODO ?? Rethink these "delicate" things. Should raw rates be stored
 // temporarily in some other manner, e.g. using a handle-body idiom?





reply via email to

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