lmi-commits
[Top][All Lists]
Advanced

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

[lmi-commits] [5345] Refactor to eliminate an ugly workaround


From: Greg Chicares
Subject: [lmi-commits] [5345] Refactor to eliminate an ugly workaround
Date: Fri, 06 Jan 2012 09:17:50 +0000

Revision: 5345
          http://svn.sv.gnu.org/viewvc/?view=rev&root=lmi&revision=5345
Author:   chicares
Date:     2012-01-06 09:17:50 +0000 (Fri, 06 Jan 2012)
Log Message:
-----------
Refactor to eliminate an ugly workaround

Modified Paths:
--------------
    lmi/trunk/gpt_specamt.cpp
    lmi/trunk/ihs_irc7702.cpp
    lmi/trunk/ihs_irc7702.hpp

Modified: lmi/trunk/gpt_specamt.cpp
===================================================================
--- lmi/trunk/gpt_specamt.cpp   2012-01-06 07:51:43 UTC (rev 5344)
+++ lmi/trunk/gpt_specamt.cpp   2012-01-06 09:17:50 UTC (rev 5345)
@@ -103,8 +103,7 @@
     double operator()(double a_Trial)
         {
         SpecAmt = a_Trial;
-        Irc7702_.Initialize7702(a_Trial);
-        const_cast<double&>(Irc7702_.TargetPremium) = 
Values_.GetAnnualTgtPrem(Duration, SpecAmt);
+        Irc7702_.Initialize7702(a_Trial); // No longer needed.
         return
                 Irc7702_.CalculatePremium
                     (EIOBasis_
@@ -114,6 +113,7 @@
                     ,a_Trial
                     ,NetPmtFactorTgt
                     ,NetPmtFactorExc
+                    ,Values_.GetAnnualTgtPrem(Duration, SpecAmt)
                     )
             -   Premium
             ;

Modified: lmi/trunk/ihs_irc7702.cpp
===================================================================
--- lmi/trunk/ihs_irc7702.cpp   2012-01-06 07:51:43 UTC (rev 5344)
+++ lmi/trunk/ihs_irc7702.cpp   2012-01-06 09:17:50 UTC (rev 5345)
@@ -842,6 +842,7 @@
         ,a_LeastBftAmtEver
         ,PvNpfLvlTgt[Get4PctBasis(a_DBOpt)][a_Duration]
         ,PvNpfLvlExc[Get4PctBasis(a_DBOpt)][a_Duration]
+        ,TargetPremium
         );
 }
 
@@ -862,10 +863,17 @@
         ,a_LeastBftAmtEver
         ,PvNpfSglTgt[Opt1Int6Pct][a_Duration]
         ,PvNpfSglExc[Opt1Int6Pct][a_Duration]
+        ,TargetPremium
         );
 }
 
-//============================================================================
+/// Calculate a guideline premium.
+///
+/// This function encompasses both GLP and GSP. It is designed to have
+/// no side effects, and to depend only on its arguments and on data
+/// members that are set in the ctor and not subsequently changed--so
+/// it's safe for FindSpecAmt::operator()() to call it iteratively.
+
 double Irc7702::CalculatePremium
     (EIOBasis const& a_EIOBasis
     ,int             a_Duration
@@ -874,13 +882,14 @@
     ,double          a_LeastBftAmtEver
     ,double          a_NetPmtFactorTgt
     ,double          a_NetPmtFactorExc
+    ,double          a_TargetPremium
     ) const
 {
     LMI_ASSERT(a_SpecAmt <= a_BftAmt);
     LMI_ASSERT(0.0 != a_NetPmtFactorTgt);
     LMI_ASSERT(0.0 != a_NetPmtFactorExc);
 
-    // TODO ?? This implementation is correct only if TargetPremium
+    // TODO ?? This implementation is correct only if target premium
     // is fixed forever at issue; otherwise, distinct target premiums
     // must be passed for each of the quantities A, B, and C. Should
     // those targets be calculated for status x+[t], or x+t? (The
@@ -897,7 +906,7 @@
         /
         a_NetPmtFactorTgt
         ;
-    if(z <= TargetPremium)
+    if(z <= a_TargetPremium)
         {
         return z;
         }
@@ -908,7 +917,7 @@
         +   std::min(SpecAmtLoadLimit, a_SpecAmt) * 
PvChgSpecAmt[a_EIOBasis][a_Duration]
         +   std::min(ADDLimit, a_SpecAmt) * PvChgADD[a_EIOBasis][a_Duration]
         +   a_BftAmt * PvChgMort[a_EIOBasis][a_Duration]
-        +       TargetPremium
+        +       a_TargetPremium
             *   (a_NetPmtFactorExc - a_NetPmtFactorTgt)
         )
         /

Modified: lmi/trunk/ihs_irc7702.hpp
===================================================================
--- lmi/trunk/ihs_irc7702.hpp   2012-01-06 07:51:43 UTC (rev 5344)
+++ lmi/trunk/ihs_irc7702.hpp   2012-01-06 09:17:50 UTC (rev 5345)
@@ -169,6 +169,7 @@
         ,double                     a_LeastBftAmtEver
         ,double                     a_NetPmtFactorTgt
         ,double                     a_NetPmtFactorExc
+        ,double                     a_TargetPremium
         ) const;
     static EIOBasis Get4PctBasis
         (mcenum_dbopt_7702          a_DBOpt




reply via email to

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