Documentation ¶
Index ¶
- Constants
- Variables
- func AccessVector(v []float64, index int) float64
- func AlmostEqualRelativeAndAbs(A float64, B float64, maxDiff float64, maxReldiff float64) bool
- func BinCheckModelFiles(f1, f2 string)
- func BinDumpModel(c []float64, A [][]float64, b []float64, x []float64, vid *[]int32, ...) error
- func BinLoadModel(filename string) ([]float64, [][]float64, []float64, []float64, *[]int32)
- func GetInputStrStrMapFromFile(f string) (*map[string]string, error)
- func GetInputStringsMapFromToml(filename string) (*map[string]string, error)
- func NewInputStringsMap() map[string]string
- func PrintAndClearMsg(f *os.File, msgList *WarnErrorList)
- func PrintInputParamsStrMapToBuffer(m map[string]string) string
- func RenderFloat(format string, n float64) string
- func RenderInteger(format string, n int) string
- func TersPrintArray(a []float64)
- func TersPrintMatrix(a [][]float64) error
- func UpdateInputStringsMap(ipsm *map[string]string, key, value string) error
- func WriteFileInputParamsStrMap(f *os.File, m map[string]string)
- type Acctype
- type AppOutput
- type InputParams
- type MaxWhat
- type ModelNote
- type ModelSpecs
- func (ms ModelSpecs) AssetByTag(name string) (value, brate, assetRR, basis, owed, prime, ageToSell float64)
- func (ms ModelSpecs) AssetByTagAndField(tag, field string) float64
- func (ms ModelSpecs) BuildModel() ([]float64, [][]float64, []float64, []ModelNote)
- func (ms ModelSpecs) ConsistencyCheckBrackets(X *[]float64) (OK bool)
- func (ms ModelSpecs) ConsistencyCheckSpendable(X *[]float64) (OK bool)
- func (ms ModelSpecs) EarlyPenaltyCharged(year int, xp *[]float64) (earlytax float64, rothearly bool)
- func (ms ModelSpecs) GetRMD(xp *[]float64, year int, j int) float64
- func (ms ModelSpecs) IncomeSummary(year int, xp *[]float64) (T, spendable, tax, rate, ncgtax, earlytax float64, rothearly bool)
- func (ms ModelSpecs) OptimizeLPModel(A *[][]float64, b *[]float64) (oA *[][]float64, ob *[]float64, info *[]OptInfo)
- func (ms ModelSpecs) PrecheckConsistency() bool
- func (ms ModelSpecs) PrintAccountTrans(xp *[]float64)
- func (ms ModelSpecs) PrintAccountWithdrawals(xp *[]float64)
- func (ms ModelSpecs) PrintActivitySummary(xp *[]float64)
- func (ms ModelSpecs) PrintAssetSummary()
- func (ms ModelSpecs) PrintBaseConfig(xp *[]float64)
- func (ms ModelSpecs) PrintCapGainsBrackets(xp *[]float64)
- func (ms ModelSpecs) PrintIncomeExpenseDetails()
- func (ms ModelSpecs) PrintInputParamsStrMap(m map[string]string)
- func (ms ModelSpecs) PrintModelMatrix(c []float64, A [][]float64, b []float64, notes []ModelNote, s []float64, ...)
- func (ms ModelSpecs) PrintObjectFunctionSolution(c []float64, row []float64)
- func (ms ModelSpecs) PrintShadowTaxBrackets(xp *[]float64)
- func (ms ModelSpecs) PrintTax(xp *[]float64)
- func (ms ModelSpecs) PrintTaxBrackets(xp *[]float64)
- func (ms ModelSpecs) WriteLPFormatModel(c []float64, A [][]float64, b []float64, notes []ModelNote, filename string, ...) error
- func (ms ModelSpecs) WriteObjectFunctionSolution(c []float64, row []float64, modelfile *os.File)
- type OptInfo
- type TaxStatus
- type Taxinfo
- type VectorVarIndex
- func (v VectorVarIndex) B(i, j int) int
- func (v VectorVarIndex) D(i int) int
- func (v VectorVarIndex) S(i int) int
- func (v VectorVarIndex) Sy(i, l int) int
- func (v VectorVarIndex) Varstr(indx int) string
- func (v VectorVarIndex) W(i, j int) int
- func (v VectorVarIndex) X(i, k int) int
- func (v VectorVarIndex) Y(i, l int) int
- type WarnErrorList
- func (s *WarnErrorList) AppendError(errorstr string)
- func (s *WarnErrorList) AppendWarning(warning string)
- func (s *WarnErrorList) ClearErrors()
- func (s *WarnErrorList) ClearWarnings()
- func (s *WarnErrorList) GetError(i int) string
- func (s *WarnErrorList) GetErrorCount() int
- func (s *WarnErrorList) GetWarning(i int) string
- func (s *WarnErrorList) GetWarningCount() int
Constants ¶
const BrokeragePercentDefault = 4.0
const FilingStatusDefault = Joint
const InflactionRatePercent = 2.5
const InflateContribDefault = false
const MaxStreams = 10
MaxStreams is the maximam number of streams for each: income, expense, asset
const MaximizeDefault = Spending
const ReturnRatePercent = 6.0
Default values if not defined
Variables ¶
var InputStrDefs = []string{
"setName",
"filingStatus",
"key1",
"key2",
"eT_Age1",
"eT_Age2",
"eT_RetireAge1",
"eT_RetireAge2",
"eT_PlanThroughAge1",
"eT_PlanThroughAge2",
"eT_DefinedContributionPlanStart1",
"eT_DefinedContributionPlanStart2",
"eT_DefinedContributionPlanEnd1",
"eT_DefinedContributionPlanEnd2",
"eT_PIA1",
"eT_PIA2",
"eT_SS_Start1",
"eT_SS_Start2",
"eT_TDRA1",
"eT_TDRA2",
"eT_TDRA_Rate1",
"eT_TDRA_Rate2",
"eT_TDRA_Contrib1",
"eT_TDRA_Contrib2",
"eT_TDRA_ContribStartAge1",
"eT_TDRA_ContribStartAge2",
"eT_TDRA_ContribEndAge1",
"eT_TDRA_ContribEndAge2",
"eT_TDRA_ContribInflate1",
"eT_TDRA_ContribInflate2",
"eT_Roth1",
"eT_Roth2",
"eT_Roth_Rate1",
"eT_Roth_Rate2",
"eT_Roth_Contrib1",
"eT_Roth_Contrib2",
"eT_Roth_ContribStartAge1",
"eT_Roth_ContribStartAge2",
"eT_Roth_ContribEndAge1",
"eT_Roth_ContribEndAge2",
"eT_Roth_ContribInflate1",
"eT_Roth_ContribInflate2",
"eT_Aftatax",
"eT_Aftatax_Basis",
"eT_Aftatax_Rate",
"eT_Aftatax_Contrib",
"eT_Aftatax_ContribStartAge",
"eT_Aftatax_ContribEndAge",
"eT_Aftatax_ContribInflate",
"eT_DesiredIncome",
"eT_MaxIncome",
"eT_iRatePercent",
"eT_rRatePercent",
"eT_maximize",
"dollarsInThousands",
}
var InputStreamStrDefs = []string{
"eT_Income",
"eT_IncomeAmount",
"eT_IncomeStartAge",
"eT_IncomeEndAge",
"eT_IncomeInflate",
"eT_IncomeTax",
"eT_Expense",
"eT_ExpenseAmount",
"eT_ExpenseStartAge",
"eT_ExpenseEndAge",
"eT_ExpenseInflate",
"eT_ExpenseTax",
"eT_Asset",
"eT_AssetValue",
"eT_AssetAgeToSell",
"eT_AssetCostAndImprovements",
"eT_AssetOwedAtAgeToSell",
"eT_AssetPrimaryResidence",
"eT_AssetRRatePercent",
"eT_AssetBrokeragePercent",
}
var TomlStrDefs = []string{
"title",
"retirement_type",
"@iam.key1",
"@iam.key2",
"iam.%0.age",
"iam.%1.age",
"iam.%0.retire",
"iam.%1.retire",
"iam.%0.through",
"iam.%1.through",
"iam.%0.definedContributionPlan#1",
"iam.%1.definedContributionPlan#1",
"iam.%0.definedContributionPlan#2",
"iam.%1.definedContributionPlan#2",
"SocialSecurity.%0.amount",
"SocialSecurity.%1.amount",
"SocialSecurity.%0.age#1",
"SocialSecurity.%1.age#1",
"IRA.%0.bal",
"IRA.%1.bal",
"IRA.%0.rate",
"IRA.%1.rate",
"IRA.%0.contrib",
"IRA.%1.contrib",
"IRA.%0.period#1",
"IRA.%1.period#1",
"IRA.%0.period#2",
"IRA.%1.period#2",
"IRA.%0.inflation",
"IRA.%1.inflation",
"roth.%0.bal",
"roth.%1.bal",
"roth.%0.rate",
"roth.%1.rate",
"roth.%0.contrib",
"roth.%1.contrib",
"roth.%0.period#1",
"roth.%1.period#1",
"roth.%0.period#2",
"roth.%1.period#2",
"roth.%0.inflation",
"roth.%1.inflation",
"aftertax.bal",
"aftertax.basis",
"aftertax.rate",
"aftertax.contrib",
"aftertax.period#1",
"aftertax.period#2",
"aftertax.inflation",
"min.income.amount",
"max.income.amount",
"inflation",
"returns",
"maximize",
"dollarsInThousands",
}
TomlStrDefs works with InputStrDefs to Map Toml information to rplanlib API static portion
List of toml paths to user supplied information. Includes editing codes for correcting as needed at runtime. '@' means the corresponding key in InputStrDefs should be used to set
iam key names
'%n' means the nth iam key name is to be substituted here '%i' means the current stream key name is to be substituted here '#n' means that the resulting string is a range string and the nth
number from the range should be extracted and used for assignment
After converting the toml paths there should not be any of these codes remaining. The resulting path and the corresponding key from InputStrDefs are used together to retreave and set the value in the Input String map.
var TomlStreamStrDefs = []string{
"@income",
"income.%i.amount",
"income.%i.age#1",
"income.%i.age#2",
"income.%i.inflation",
"income.%i.tax",
"@expense",
"expense.%i.amount",
"expense.%i.age#1",
"expense.%i.age#2",
"expense.%i.inflation",
"expense.%i.tax",
"@asset",
"asset.%i.value",
"asset.%i.ageToSell",
"asset.%i.costAndImprovements",
"asset.%i.owedAtAgeToSell",
"asset.%i.primaryResidence",
"asset.%i.rate",
"asset.%i.brokerageRate",
}
TomlStreamStrDefs works with InputStreamStrDefs to Map Toml information to rplanlib API dynamic portion (per stream portion)
var Version = struct { Major string Minor string Patch string Str string }{"0", "5", "6", "beta"}
Functions ¶
func AccessVector ¶
func BinCheckModelFiles ¶
func BinCheckModelFiles(f1, f2 string)
func BinDumpModel ¶
func BinDumpModel(c []float64, A [][]float64, b []float64, x []float64, vid *[]int32, fname string) error
BinDumpModel writes a comparable binary version of the retirement plan model
func BinLoadModel ¶
BinLoadModel reads a binary file, extracting c, A, b of a Linear Program
func GetInputStrStrMapFromFile ¶ added in v0.4.32
func GetInputStringsMapFromToml ¶ added in v0.4.32
func NewInputStringsMap ¶
NewInputStringsMap returns a map with all available settings set to the empty string
func PrintAndClearMsg ¶ added in v0.4.32
func PrintAndClearMsg(f *os.File, msgList *WarnErrorList)
func PrintInputParamsStrMapToBuffer ¶ added in v0.4.30
for _, p := range proverbs { n, err := writer.Write([]byte(p)) if err != nil { fmt.Println(err) os.Exit(1) } if n != len(p) { fmt.Println("failed to write data") os.Exit(1) } }
Print out the active input parameters (string string map)
func RenderFloat ¶
RenderFloat converts floats into more human readable versions with grouping
func RenderInteger ¶
RenderInteger converts integers to be more human readable by grouping
func TersPrintArray ¶
func TersPrintArray(a []float64)
func TersPrintMatrix ¶
func UpdateInputStringsMap ¶
Types ¶
type AppOutput ¶
type AppOutput struct {
// contains filtered or unexported fields
}
AppOutput holds the info needed for writing output tables and csv
func NewAppOutput ¶
NewAppOutput creats an initialized AppOutput object
type InputParams ¶
type InputParams struct { FilingStatus TaxStatus MyKey1 string MyKey2 string Age1 int Age2 int RetireAge1 int RetireAge2 int PlanThroughAge1 int PlanThroughAge2 int DefinedContributionPlanStart1 int DefinedContributionPlanStart2 int DefinedContributionPlanEnd1 int DefinedContributionPlanEnd2 int PIA1 int PIA2 int SSStart1 int SSStart2 int TDRA1 int TDRA2 int TDRARate1 float64 TDRARate2 float64 TDRAContrib1 int TDRAContrib2 int TDRAContribStart1 int TDRAContribStart2 int TDRAContribEnd1 int TDRAContribEnd2 int TDRAContribInflate1 bool TDRAContribInflate2 bool Roth1 int Roth2 int RothRate1 float64 RothRate2 float64 RothContrib1 int RothContrib2 int RothContribStart1 int RothContribStart2 int RothContribEnd1 int RothContribEnd2 int RothContribInflate1 bool RothContribInflate2 bool Aftatax int AftataxBasis int // TODO Add to Mobile AftataxRate float64 AftataxContrib int AftataxContribStart int AftataxContribEnd int AftataxContribInflate bool IRatePercent float64 // TODO add to Mobile IRate float64 // local, not mobile RRatePercent float64 // TODO add to Mobile RRate float64 // local, not mobile Maximize MaxWhat // "Spending" or "PlusEstate" // TODO add to Mobile Min int // TODO add to Mobile Max int // TODO add to Mobile PrePlanYears int StartPlan int EndPlan int AgeDelta int Numyr int Accmap map[Acctype]int Numacc int Income []stream Expense []stream Assets []asset }
InputParams are the model params constructed from driver program string input
func NewInputParams ¶
func NewInputParams(ip map[string]string, warnList *WarnErrorList) (*InputParams, error)
NewInputParams takes string inputs and converts them to model inputs assigning default values where needed
type MaxWhat ¶
type MaxWhat int
MaxWhat is what is to be maximized while creating a plan (Spending, PlusEstate)
type ModelNote ¶
type ModelNote struct {
// contains filtered or unexported fields
}
ModelNote contains section information for the constraint model
type ModelSpecs ¶
type ModelSpecs struct { Ip InputParams Vindx VectorVarIndex Ti Taxinfo Ao AppOutput AllowTdraRothraDeposits bool // The following was through 'S' LiquidAssetPlanStart float64 IlliquidAssetPlanStart float64 IlliquidAssetPlanEnd float64 Accounttable []account Retirees []retiree SS [][]float64 // SS[0] is combined, SS[1] for retiree1 ... SSspecs []ssI // ss specs for each retiree: pia, fra, ... Income [][]float64 // income[0] is combined, income[1] first income stream... AssetSale [][]float64 // assetSale[0] combined, assetSale[1] first asset (net from sales) Expenses [][]float64 // expenses[0] combined, expensee[1] first expense Taxed []float64 CgAssetTaxed []float64 // taxable from asset sales Errfile *os.File Logfile *os.File OneK float64 DeveloperInfo bool UsePieceWiseMethod bool }
ModelSpecs struct contains the needed info for building an RPlanner constraint model
func NewModelSpecs ¶
func NewModelSpecs(vindx VectorVarIndex, ti Taxinfo, ip InputParams, RoundToOneK bool, developerInfo bool, fourPercentRule bool, errfile *os.File, logfile *os.File, csvfile *os.File, tablefile *os.File, wel *WarnErrorList) (*ModelSpecs, error)
NewModelSpecs creates a ModelSpecs object
func (ModelSpecs) AssetByTag ¶ added in v0.4.24
func (ms ModelSpecs) AssetByTag(name string) (value, brate, assetRR, basis, owed, prime, ageToSell float64)
TODO FixMe this function should be place somewhere more appropriete
func (ModelSpecs) AssetByTagAndField ¶ added in v0.4.36
func (ms ModelSpecs) AssetByTagAndField(tag, field string) float64
TODO FixMe this function should be place somewhere more appropriete
func (ModelSpecs) BuildModel ¶
func (ms ModelSpecs) BuildModel() ([]float64, [][]float64, []float64, []ModelNote)
BuildModel for: Minimize: c^T * x Subject to: A_ub * x <= b_ub all vars positive
func (ModelSpecs) ConsistencyCheckBrackets ¶ added in v0.4.32
func (ms ModelSpecs) ConsistencyCheckBrackets(X *[]float64) (OK bool)
TODO FIXME should use ms.logfile by default and f is not nil as a second output path
func (ModelSpecs) ConsistencyCheckSpendable ¶ added in v0.4.32
func (ms ModelSpecs) ConsistencyCheckSpendable(X *[]float64) (OK bool)
func (ModelSpecs) EarlyPenaltyCharged ¶ added in v0.4.27
func (ms ModelSpecs) EarlyPenaltyCharged(year int, xp *[]float64) (earlytax float64, rothearly bool)
EarlyPenaltyCharged returns the charged amount of penalty and whether any portion of the penalty was from a Roth account
func (ModelSpecs) GetRMD ¶ added in v0.5.6
func (ms ModelSpecs) GetRMD(xp *[]float64, year int, j int) float64
func (ModelSpecs) IncomeSummary ¶
func (ms ModelSpecs) IncomeSummary(year int, xp *[]float64) (T, spendable, tax, rate, ncgtax, earlytax float64, rothearly bool)
IncomeSummary returns key indicators to summarize income
func (ModelSpecs) OptimizeLPModel ¶
func (ms ModelSpecs) OptimizeLPModel(A *[][]float64, b *[]float64) (oA *[][]float64, ob *[]float64, info *[]OptInfo)
OptimizeLPModel create a new model by eliminating redundent and zero constraint
func (ModelSpecs) PrecheckConsistency ¶ added in v0.4.32
func (ms ModelSpecs) PrecheckConsistency() bool
PrecheckConsistency is, I think, checked elsewhere; delete?
func (ModelSpecs) PrintAccountTrans ¶
func (ms ModelSpecs) PrintAccountTrans(xp *[]float64)
func (ModelSpecs) PrintAccountWithdrawals ¶
func (ms ModelSpecs) PrintAccountWithdrawals(xp *[]float64)
func (ModelSpecs) PrintActivitySummary ¶
func (ms ModelSpecs) PrintActivitySummary(xp *[]float64)
func (ModelSpecs) PrintAssetSummary ¶ added in v0.4.24
func (ms ModelSpecs) PrintAssetSummary()
func (ModelSpecs) PrintBaseConfig ¶
func (ms ModelSpecs) PrintBaseConfig(xp *[]float64)
func (ModelSpecs) PrintCapGainsBrackets ¶
func (ms ModelSpecs) PrintCapGainsBrackets(xp *[]float64)
func (ModelSpecs) PrintIncomeExpenseDetails ¶
func (ms ModelSpecs) PrintIncomeExpenseDetails()
func (ModelSpecs) PrintInputParamsStrMap ¶ added in v0.4.24
func (ms ModelSpecs) PrintInputParamsStrMap(m map[string]string)
Print out the active input parameters (string string map)
func (ModelSpecs) PrintModelMatrix ¶
func (ms ModelSpecs) PrintModelMatrix(c []float64, A [][]float64, b []float64, notes []ModelNote, s []float64, nonBindingOnly bool, optinfo *[]OptInfo)
PrintModelMatrix prints to object function (cx) and constraint matrix (Ax<=b)
func (ModelSpecs) PrintObjectFunctionSolution ¶ added in v0.4.36
func (ms ModelSpecs) PrintObjectFunctionSolution(c []float64, row []float64)
func (ModelSpecs) PrintShadowTaxBrackets ¶
func (ms ModelSpecs) PrintShadowTaxBrackets(xp *[]float64)
func (ModelSpecs) PrintTax ¶
func (ms ModelSpecs) PrintTax(xp *[]float64)
func (ModelSpecs) PrintTaxBrackets ¶
func (ms ModelSpecs) PrintTaxBrackets(xp *[]float64)
func (ModelSpecs) WriteLPFormatModel ¶ added in v0.4.37
func (ms ModelSpecs) WriteLPFormatModel(c []float64, A [][]float64, b []float64, notes []ModelNote, filename string, row []float64, cmdline string) error
PrintModelMatrix prints to object function (cx) and constraint matrix (Ax<=b)
func (ModelSpecs) WriteObjectFunctionSolution ¶ added in v0.4.39
func (ms ModelSpecs) WriteObjectFunctionSolution(c []float64, row []float64, modelfile *os.File)
type Taxinfo ¶
type Taxinfo struct { Taxtable tableref2d // income tax table Capgainstable tableref2d // capital gains tax table RMD tableref1d // Required Minimum Distribution table Stded float64 // standard deduction Primeresidence float64 // exclusion for prime residence AccountEstateTax map[Acctype]float64 Contribspecs map[string]float64 Penalty float64 // for early withdrawal SStaxable float64 // taxable portion of SS SSnotTaxable float64 // non-taxable portion of SS }
Taxinfo contains the centeral tax information
func NewTaxInfo ¶
NewTaxInfo creates the applicable tax structure
type VectorVarIndex ¶
type VectorVarIndex struct { // inplements the vector var index functions Years int Taxbins int Cgbins int Accounts int Accmap map[Acctype]int Accname []string Xcount int Sycount int Ycount int Wcount int Bcount int Scount int Dcount int Vsize int Systart int Ystart int Wstart int Bstart int Sstart int Dstart int // contains filtered or unexported fields }
VectorVarIndex contains the index information to convert from variable index to vector index
func NewVectorVarIndex ¶
func NewVectorVarIndex(iyears, itaxbins, icgbins int, iaccmap map[Acctype]int, errfile *os.File) (VectorVarIndex, error)
NewVectorVarIndex creates an object for index translation
func (VectorVarIndex) B ¶
func (v VectorVarIndex) B(i, j int) int
B (i,j) returns the variable index in a variable vector
func (VectorVarIndex) D ¶
func (v VectorVarIndex) D(i int) int
D (i) returns the variable index in a variable vector
func (VectorVarIndex) S ¶
func (v VectorVarIndex) S(i int) int
S (i) returns the variable index in a variable vector
func (VectorVarIndex) Sy ¶
func (v VectorVarIndex) Sy(i, l int) int
Sy (i,l) returns the variable index in a variable vector
func (VectorVarIndex) Varstr ¶
func (v VectorVarIndex) Varstr(indx int) string
Varstr returns the variable name and index(s) for the variable at indx in the variable vector
func (VectorVarIndex) W ¶
func (v VectorVarIndex) W(i, j int) int
W (i,j) returns the variable index in a variable vector
func (VectorVarIndex) X ¶
func (v VectorVarIndex) X(i, k int) int
X (i,k) returns the variable index in a variable vector
func (VectorVarIndex) Y ¶
func (v VectorVarIndex) Y(i, l int) int
Y (i,l) returns the variable index in a variable vector
type WarnErrorList ¶
type WarnErrorList struct {
// contains filtered or unexported fields
}
func NewWarnErrorList ¶
func NewWarnErrorList() *WarnErrorList
func (*WarnErrorList) AppendError ¶
func (s *WarnErrorList) AppendError(errorstr string)
func (*WarnErrorList) AppendWarning ¶
func (s *WarnErrorList) AppendWarning(warning string)
func (*WarnErrorList) ClearErrors ¶
func (s *WarnErrorList) ClearErrors()
func (*WarnErrorList) ClearWarnings ¶
func (s *WarnErrorList) ClearWarnings()
func (*WarnErrorList) GetError ¶
func (s *WarnErrorList) GetError(i int) string
func (*WarnErrorList) GetErrorCount ¶
func (s *WarnErrorList) GetErrorCount() int
func (*WarnErrorList) GetWarning ¶
func (s *WarnErrorList) GetWarning(i int) string
func (*WarnErrorList) GetWarningCount ¶
func (s *WarnErrorList) GetWarningCount() int