[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] valyuta/007 4ae9e8fd 2/7: Change several more ledger
|
From: |
Greg Chicares |
|
Subject: |
[lmi-commits] [lmi] valyuta/007 4ae9e8fd 2/7: Change several more ledger fields to cents |
|
Date: |
Wed, 20 Apr 2022 20:05:04 -0400 (EDT) |
branch: valyuta/007
commit 4ae9e8fd623a7d095b77cf8dd6fe5e40c654acf2
Author: Gregory W. Chicares <gchicares@sbcglobal.net>
Commit: Gregory W. Chicares <gchicares@sbcglobal.net>
Change several more ledger fields to cents
Changed these fields all at once because they're used to calculate IRRs
in 'ledger_invariant.cpp'. An IRR is the root of a polynomial, and
doesn't change if all the coefficients are multiplied by a constant 100.
'SurrChg' isn't explicitly used in IRR calculations, but it's strongly
associated with the fields that are, so it was convenient to change it
at the same time.
---
accountvalue.cpp | 10 +++++-----
custom_io_0.cpp | 6 +++---
custom_io_1.cpp | 6 +++---
ihs_acctval.cpp | 10 +++++-----
ihs_avsolve.cpp | 7 +++++--
ledger.cpp | 2 +-
ledger_evaluator.cpp | 12 ++++++------
ledger_text_formats.cpp | 36 ++++++++++++++++++------------------
solve.cpp | 6 +++---
9 files changed, 49 insertions(+), 46 deletions(-)
diff --git a/accountvalue.cpp b/accountvalue.cpp
index b8c618a8..9cfbef99 100644
--- a/accountvalue.cpp
+++ b/accountvalue.cpp
@@ -340,19 +340,19 @@ void AccountValue::DoYear
}
VariantValues().AcctVal[Year] = dblize(AVUnloaned + AVRegLn + AVPrfLn);
- VariantValues().CSVNet[Year] = VariantValues().AcctVal[Year] -
VariantValues().SurrChg[Year];
+ VariantValues().CSVNet[Year] = VariantValues().AcctVal[Year] * 100.0 -
VariantValues().SurrChg[Year];
// Update death benefit: "deathbft" currently holds benefit as of the
// beginning of month 12, but we want it as of the end of that month,
// in case the corridor or option 2 drove it up during the last month.
TxSetDeathBft();
- VariantValues().EOYDeathBft[Year] = dblize(deathbft);
+ VariantValues().EOYDeathBft[Year] = centize(deathbft);
// IHS !! Change one of these names, which differ only in the terminal 's'.
InvariantValues().GrossPmt[Year] +=
dblize(std::accumulate(GrossPmts.begin(), GrossPmts.end(), C0));
InvariantValues().Outlay[Year] =
- InvariantValues().GrossPmt [Year]
- - InvariantValues().NetWD [Year] / 100.0
- - InvariantValues().NewCashLoan[Year] / 100.0
+ InvariantValues().GrossPmt [Year] * 100.0
+ - InvariantValues().NetWD [Year]
+ - InvariantValues().NewCashLoan[Year]
;
if(Debugging)
diff --git a/custom_io_0.cpp b/custom_io_0.cpp
index 9f287d11..525ea896 100644
--- a/custom_io_0.cpp
+++ b/custom_io_0.cpp
@@ -511,7 +511,7 @@ void custom_io_0_write(Ledger const& ledger_values,
std::string const& filename)
;
std::vector<double> surr_chg(Invar.GetLength());
- assign(surr_chg, Curr_.AcctVal - Curr_.CSVNet);
+ assign(surr_chg, Curr_.AcctVal - Curr_.CSVNet / 100.0);
std::vector<double> prem_load(Invar.GetLength());
assign(prem_load, Invar.GrossPmt - Curr_.NetPmt);
@@ -524,8 +524,8 @@ void custom_io_0_write(Ledger const& ledger_values,
std::string const& filename)
os
<< std::setprecision(0)
<< Curr_.AcctVal [j]
- << ',' << Curr_.CSVNet [j]
- << ',' << Curr_.EOYDeathBft [j]
+ << ',' << Curr_.CSVNet [j] / 100.0
+ << ',' << Curr_.EOYDeathBft [j] / 100.0
<< ',' << Curr_.NetIntCredited [j] / 100.0
<< ',' << Curr_.COICharge [j] / 100.0
// Column headers suggest that 'Load' should precede 'MinPrem',
diff --git a/custom_io_1.cpp b/custom_io_1.cpp
index 65aefdf4..067f2252 100644
--- a/custom_io_1.cpp
+++ b/custom_io_1.cpp
@@ -381,7 +381,7 @@ void custom_io_1_write(Ledger const& ledger_values,
std::string const& filename)
;
std::vector<double> surr_chg(Invar.GetLength());
- assign(surr_chg, Curr_.AcctVal - Curr_.CSVNet);
+ assign(surr_chg, Curr_.AcctVal - Curr_.CSVNet / 100.0);
std::vector<double> prem_load(Invar.GetLength());
assign(prem_load, Invar.GrossPmt - Curr_.NetPmt);
@@ -394,8 +394,8 @@ void custom_io_1_write(Ledger const& ledger_values,
std::string const& filename)
os
<< std::setprecision(2)
<< Curr_.AcctVal [j]
- << ',' << Curr_.CSVNet [j]
- << ',' << Curr_.EOYDeathBft [j]
+ << ',' << Curr_.CSVNet [j] / 100.0
+ << ',' << Curr_.EOYDeathBft [j] / 100.0
<< std::setprecision(4)
<< ',' << Curr_.AnnGAIntRate [j] * 10000.0 // 'IntRate' in bp.
<< std::setprecision(2)
diff --git a/ihs_acctval.cpp b/ihs_acctval.cpp
index ce0a51e3..0a4638cd 100644
--- a/ihs_acctval.cpp
+++ b/ihs_acctval.cpp
@@ -1231,7 +1231,7 @@ void AccountValue::FinalizeYear()
VariantValues().AVGenAcct [Year] = centize(AVGenAcct + AVRegLn +
AVPrfLn);
VariantValues().AVSepAcct [Year] = centize(AVSepAcct);
VariantValues().DacTaxRsv [Year] = DacTaxRsv;
- VariantValues().CSVNet [Year] = dblize(csv_net);
+ VariantValues().CSVNet [Year] = centize(csv_net);
VariantValues().CV7702 [Year] = centize(cv_7702);
InvariantValues().Dcv [Year] = dblize(Dcv);
@@ -1248,7 +1248,7 @@ void AccountValue::FinalizeYear()
VariantValues().TermPurchased [Year] = centize(TermDB);
// Add term rider DB
VariantValues().BaseDeathBft [Year] = centize(DBReflectingCorr);
- VariantValues().EOYDeathBft [Year] = dblize(DBReflectingCorr + TermDB);
+ VariantValues().EOYDeathBft [Year] = centize(DBReflectingCorr +
TermDB);
// Monthly deduction detail
@@ -1352,9 +1352,9 @@ void AccountValue::FinalizeYear()
)
);
InvariantValues().Outlay[Year] =
- InvariantValues().GrossPmt [Year]
- - InvariantValues().NetWD [Year] / 100.0
- - InvariantValues().NewCashLoan[Year] / 100.0
+ InvariantValues().GrossPmt [Year] * 100.0
+ - InvariantValues().NetWD [Year]
+ - InvariantValues().NewCashLoan[Year]
;
InvariantValues().GptForceout[Year] = centize(YearsTotalGptForceout);
diff --git a/ihs_avsolve.cpp b/ihs_avsolve.cpp
index 397bec43..8af923a4 100644
--- a/ihs_avsolve.cpp
+++ b/ihs_avsolve.cpp
@@ -205,11 +205,13 @@ currency AccountValue::SolveTest
if(no_lapse_dur < SolveTargetDuration_)
{
// CURRENCY !! Cents in ledger will make rounding unnecessary.
+ // But is that true? Ledger contains cents as double, not as currency.
most_negative_csv = round_minutiae().c
(*std::min_element
(VariantValues().CSVNet.begin() + no_lapse_dur
,VariantValues().CSVNet.begin() + SolveTargetDuration_
)
+ / 100.0
);
}
@@ -236,13 +238,14 @@ currency AccountValue::SolveTest
// counters and iterators--it's one past the end--but indexing
// must decrement it.
// CURRENCY !! Cents in ledger will make rounding unnecessary.
- currency value =
round_minutiae().c(VariantValues().CSVNet[SolveTargetDuration_ - 1]);
+ // But is that true? Ledger contains cents as double, not as currency.
+ currency value =
round_minutiae().c(VariantValues().CSVNet[SolveTargetDuration_ - 1] / 100.0);
if(mce_solve_for_target_naar == SolveTarget_)
{
// CURRENCY !! Cents in ledger will make rounding unnecessary.
value = round_minutiae().c
(
- VariantValues().EOYDeathBft[SolveTargetDuration_ - 1]
+ VariantValues().EOYDeathBft[SolveTargetDuration_ - 1] / 100.0
- VariantValues().AcctVal [SolveTargetDuration_ - 1]
);
}
diff --git a/ledger.cpp b/ledger.cpp
index 333aa7f8..0f4d162f 100644
--- a/ledger.cpp
+++ b/ledger.cpp
@@ -489,7 +489,7 @@ std::vector<double> numeric_vector
{
attained_age [j] = j + invar.Age;
policy_year [j] = j + 1 ;
- net_death_benefit[j] = curr.EOYDeathBft[j] - curr.TotalLoanBalance[j]
/ 100.0;
+ net_death_benefit[j] = (curr.EOYDeathBft[j] -
curr.TotalLoanBalance[j]) / 100.0;
}
typedef LedgerBase const& B;
diff --git a/ledger_evaluator.cpp b/ledger_evaluator.cpp
index f67747f3..eb7fcd13 100644
--- a/ledger_evaluator.cpp
+++ b/ledger_evaluator.cpp
@@ -623,7 +623,7 @@ format_map_t static_formats()
,{"BOYAssets" , f1}
,{"BaseDeathBft" , f5}
,{"COICharge" , f5}
- ,{"CSVNet" , f1}
+ ,{"CSVNet" , f5}
,{"CV7702" , f5}
,{"ClaimsPaid" , f1}
,{"Composite" , f1}
@@ -631,7 +631,7 @@ format_map_t static_formats()
,{"DacTaxRsv" , f1}
,{"Dcv" , f1}
,{"DeathProceedsPaid" , f1}
- ,{"EOYDeathBft" , f1}
+ ,{"EOYDeathBft" , f5}
,{"EeGrossPmt" , f1}
,{"EeModalMinimumPremium" , f5}
// ,{"EeMode" , f1} // Not numeric.
@@ -653,7 +653,7 @@ format_map_t static_formats()
,{"NetPmt" , f1}
,{"NetWD" , f5}
,{"NewCashLoan" , f5}
- ,{"Outlay" , f1}
+ ,{"Outlay" , f5}
,{"PolicyFee" , f5}
,{"PrefLoanBalance" , f1}
,{"PremTaxLoad" , f1}
@@ -664,7 +664,7 @@ format_map_t static_formats()
,{"SpecAmt" , f1}
,{"SpecAmtLoad" , f5}
,{"SpouseRiderAmount" , f1}
- ,{"SurrChg" , f1}
+ ,{"SurrChg" , f5}
,{"TermPurchased" , f5}
,{"TermSpecAmt" , f5}
,{"TotalLoanBalance" , f5}
@@ -775,11 +775,11 @@ ledger_evaluator Ledger::make_evaluator() const
format_map["MiscCharges"] = f5;
std::vector<double> NetDeathBenefit(curr.EOYDeathBft);
- NetDeathBenefit -= curr.TotalLoanBalance / 100.0;
+ NetDeathBenefit -= curr.TotalLoanBalance;
vectors ["NetDeathBenefit"] = &NetDeathBenefit;
title_map ["NetDeathBenefit"] = "Net\nDeath\nBenefit";
mask_map ["NetDeathBenefit"] = "999,999,999";
- format_map["NetDeathBenefit"] = f1;
+ format_map["NetDeathBenefit"] = f5;
std::vector<double> SupplDeathBft_Current (curr.TermPurchased);
std::vector<double> SupplDeathBft_Guaranteed(guar.TermPurchased);
diff --git a/ledger_text_formats.cpp b/ledger_text_formats.cpp
index eb47891f..0035c4e0 100644
--- a/ledger_text_formats.cpp
+++ b/ledger_text_formats.cpp
@@ -78,7 +78,7 @@ std::map<std::string,ledger_metadata> const&
ledger_metadata_map()
m["CorridorFactor" ] = ledger_metadata(0,
oe_format_percentage, "Corridor Factor" );
m["AnnGAIntRate_Current" ] = ledger_metadata(2,
oe_format_percentage, "Curr Ann Gen Acct Int Rate" ); // "General
Account Crediting Rate"
m["AnnSAIntRate_Current" ] = ledger_metadata(2,
oe_format_percentage, "Curr Ann Sep Acct Int Rate" ); // "Separate
Account Net Rate"
- m["Outlay" ] = ledger_metadata(0, oe_format_normal
, "Net Outlay" );
+ m["Outlay" ] = ledger_metadata(0,
oe_cents_as_dollars , "Net Outlay" );
m["EeGrossPmt" ] = ledger_metadata(0, oe_format_normal
, "EE Gross Payment" ); // "Employee Gross Payment"
m["ErGrossPmt" ] = ledger_metadata(0, oe_format_normal
, "ER Gross Payment" ); // "Employer Gross Payment"
m["ModalMinimumPremium" ] = ledger_metadata(0,
oe_cents_as_dollars , "Modal Minimum Premium" );
@@ -567,7 +567,7 @@ void PrintCellTabDelimited
os << Invar.value_str("NetWD" ,j, 100.0) << '\t'; //
TODO ?? It's *gross* WD.
os << Invar.value_str("NewCashLoan" ,j, 100.0) << '\t';
os << Curr_.value_str("TotalLoanBalance" ,j, 100.0) << '\t';
- os << Invar.value_str("Outlay" ,j) << '\t';
+ os << Invar.value_str("Outlay" ,j, 100.0) << '\t';
os << Curr_.value_str("NetPmt" ,j) << '\t';
@@ -587,11 +587,11 @@ void PrintCellTabDelimited
os << Curr_.value_str("NetIntCredited" ,j, 100.0) << '\t';
os << Guar_.value_str("AcctVal" ,j) << '\t';
- os << Guar_.value_str("CSVNet" ,j) << '\t';
- os << Guar_.value_str("EOYDeathBft" ,j) << '\t';
+ os << Guar_.value_str("CSVNet" ,j, 100.0) << '\t';
+ os << Guar_.value_str("EOYDeathBft" ,j, 100.0) << '\t';
os << Curr_.value_str("AcctVal" ,j) << '\t';
- os << Curr_.value_str("CSVNet" ,j) << '\t';
- os << Curr_.value_str("EOYDeathBft" ,j) << '\t';
+ os << Curr_.value_str("CSVNet" ,j, 100.0) << '\t';
+ os << Curr_.value_str("EOYDeathBft" ,j, 100.0) << '\t';
if(Invar.IsInforce)
{
@@ -1027,19 +1027,19 @@ void FlatTextLedgerPrinter::PrintNumericalSummary()
const
os_.precision(2);
- os_ << std::setw(12) << invar().Outlay [row];
+ os_ << std::setw(12) << invar().Outlay [row] / 100.0;
os_ << std::setw(12) << guar_().AcctVal [row];
- os_ << std::setw(12) << guar_().CSVNet [row];
- os_ << std::setw(12) << guar_().EOYDeathBft[row];
+ os_ << std::setw(12) << guar_().CSVNet [row] / 100.0;
+ os_ << std::setw(12) << guar_().EOYDeathBft[row] / 100.0;
os_ << std::setw(12) << mdpt_().AcctVal [row];
- os_ << std::setw(12) << mdpt_().CSVNet [row];
- os_ << std::setw(12) << mdpt_().EOYDeathBft[row];
+ os_ << std::setw(12) << mdpt_().CSVNet [row] / 100.0;
+ os_ << std::setw(12) << mdpt_().EOYDeathBft[row] / 100.0;
os_ << std::setw(12) << curr_().AcctVal [row];
- os_ << std::setw(12) << curr_().CSVNet [row];
- os_ << std::setw(12) << curr_().EOYDeathBft[row];
+ os_ << std::setw(12) << curr_().CSVNet [row] / 100.0;
+ os_ << std::setw(12) << curr_().EOYDeathBft[row] / 100.0;
os_ << endrow;
}
@@ -1122,15 +1122,15 @@ void FlatTextLedgerPrinter::PrintTabularDetail() const
os_.precision(2);
- os_ << std::setw(12) << invar().Outlay [j];
+ os_ << std::setw(12) << invar().Outlay [j] / 100.0;
os_ << std::setw(12) << guar_().AcctVal [j];
- os_ << std::setw(12) << guar_().CSVNet [j];
- os_ << std::setw(12) << guar_().EOYDeathBft[j];
+ os_ << std::setw(12) << guar_().CSVNet [j] / 100.0;
+ os_ << std::setw(12) << guar_().EOYDeathBft[j] / 100.0;
os_ << std::setw(12) << curr_().AcctVal [j];
- os_ << std::setw(12) << curr_().CSVNet [j];
- os_ << std::setw(12) << curr_().EOYDeathBft[j];
+ os_ << std::setw(12) << curr_().CSVNet [j] / 100.0;
+ os_ << std::setw(12) << curr_().EOYDeathBft[j] / 100.0;
os_ << endrow;
}
diff --git a/solve.cpp b/solve.cpp
index 80fcb8fa..7b08a246 100644
--- a/solve.cpp
+++ b/solve.cpp
@@ -91,15 +91,15 @@ currency SolveTest()
Negative = std::min
(Negative
// CURRENCY !! Cents in ledger will make rounding unnecessary.
- ,round_to_cents.c(ConstThat->VariantValues().CSVNet[j])
+ ,round_to_cents.c(ConstThat->VariantValues().CSVNet[j] / 100.0)
// Ideally, it'd be this:
-// ,std::min(ConstThat->VariantValues().CSVNet[j],
ConstThat->loan_ullage_[j])
+// ,std::min(ConstThat->VariantValues().CSVNet[j] / 100.0,
ConstThat->loan_ullage_[j])
// but the antediluvian branch doesn't calculate ullage at all.
);
}
// CURRENCY !! Cents in ledger will make rounding unnecessary.
- currency z =
round_to_cents.c(ConstThat->VariantValues().CSVNet[ThatSolveTgtYear - 1]);
+ currency z =
round_to_cents.c(ConstThat->VariantValues().CSVNet[ThatSolveTgtYear - 1] /
100.0);
if(Negative < C0)
z = std::min(z, Negative);
// IHS !! If SolveTgtYr within no-lapse period...see lmi.
- [lmi-commits] [lmi] valyuta/007 updated (0b887792 -> d223b55a), Greg Chicares, 2022/04/20
- [lmi-commits] [lmi] valyuta/007 4ae9e8fd 2/7: Change several more ledger fields to cents,
Greg Chicares <=
- [lmi-commits] [lmi] valyuta/007 2cbd2ea4 3/7: Change several more ledger fields to cents, Greg Chicares, 2022/04/20
- [lmi-commits] [lmi] valyuta/007 d223b55a 7/7: Record speed measurements, Greg Chicares, 2022/04/20
- [lmi-commits] [lmi] valyuta/007 dc72a957 5/7: Document, suppress, or expunge unused formats, Greg Chicares, 2022/04/20
- [lmi-commits] [lmi] valyuta/007 ceaeb99d 6/7: Change one last ledger field to cents, Greg Chicares, 2022/04/20
- [lmi-commits] [lmi] valyuta/007 0c6db285 1/7: Change several more ledger fields to cents, Greg Chicares, 2022/04/20
- [lmi-commits] [lmi] valyuta/007 e351a5c4 4/7: Change several more ledger fields to cents, Greg Chicares, 2022/04/20