private void AddSubCosts(LCA1Total1 totStock, LCC1Calculator lccInput) { foreach (SubPrice1 subprice in lccInput.SubPrice1s) { AddSubCost(totStock, subprice, lccInput); } }
//need to add the correct subcost price type with the correct parent pricetotal private static void SetCostTotals(LCC1Calculator lifeCycleInput) { //init at zero (these get summed in npv and lcc comp and investment calcors) lifeCycleInput.LCCInput.OCPrice = 0; lifeCycleInput.LCCInput.AOHPrice = 0; lifeCycleInput.LCCInput.CAPPrice = 0; lifeCycleInput.OCTotalCost = 0; lifeCycleInput.AOHTotalCost = 0; lifeCycleInput.CAPTotalCost = 0; //set the totals //ok to use the default order of the subcosts foreach (SubPrice1 subprice in lifeCycleInput.SubPrice1s) { SetInputBasePrice(lifeCycleInput, subprice.SubPType, subprice.SubPTotal); } //set lcc total lifeCycleInput.LCCTotalCost = lifeCycleInput.OCTotalCost + lifeCycleInput.AOHTotalCost + lifeCycleInput.CAPTotalCost; //set eaa total lifeCycleInput.EAATotalCost = GeneralRules.CalculateEquivalentAnnualAnnuity(lifeCycleInput.LCCTotalCost, lifeCycleInput.ServiceLifeYears, lifeCycleInput.LCCInput.Local.RealRate, lifeCycleInput.LCCInput.Local.NominalRate); //set unit cost if (lifeCycleInput.PerUnitAmount == 0) { lifeCycleInput.PerUnitAmount = 1; } lifeCycleInput.UnitTotalCost = lifeCycleInput.LCCTotalCost / lifeCycleInput.PerUnitAmount; }
private bool RunLCA1Calculation(LCA1CalculatorHelper.CALCULATOR_TYPES calculatorType, ref XElement currentElement, ref XElement currentCalculationsElement) { bool bHasCalculations = false; switch (calculatorType) { case LCA1CalculatorHelper.CALCULATOR_TYPES.buildcost1: //serialize, run calcs, and deserialize LCC1Calculator lcc1 = new LCC1Calculator(); bHasCalculations = lcc1.SetLCC1Calculations(calculatorType, this.GCCalculatorParams, ref currentCalculationsElement, ref currentElement); break; case LCA1CalculatorHelper.CALCULATOR_TYPES.buildbenefit1: //serialize, run calcs, and deserialize LCB1Calculator lcb1 = new LCB1Calculator(); bHasCalculations = lcb1.SetLCB1Calculations(calculatorType, this.GCCalculatorParams, ref currentCalculationsElement, ref currentElement); break; default: //should be running an analysis break; } return(bHasCalculations); }
public void SetDescendantLCA1StockInputAttributes(string attNameExt, CalculatorParameters calcParams, ref XmlWriter writer) { //the lcatotal1 analyzer adds its totals to the base lcc1calculator linked view //less duplication and easier to display and extend if (writer != null) { //set the base analyzer this.SetCalculatorAttributes(attNameExt, ref writer); bool bHasCalcs = false; if (this.SubP1Stock.SubPrice1s != null) { if (this.SubP1Stock.SubPrice1s.Count > 0) { LCC1Calculator lcc = (LCC1Calculator)this.SubP1Stock.SubPrice1s.FirstOrDefault(); if (lcc != null) { //set locals lcc.LCCInput.Local.SetLocalAttributesForCalculator(attNameExt, calcParams, ref writer); lcc.SetLCC1Attributes(attNameExt, ref writer); bHasCalcs = true; } } } //don't need both subps and subpstock if (!bHasCalcs) { this.SetTotalLCA1StocksAttributes(attNameExt, ref writer); } } }
private void UpdateBaseInputUnitPrices(LCC1Calculator lifeCycleInput) { //base input prices are entered as total costs (composite capital input) //they have to enter units and amounts, units should generally be "each" lifeCycleInput.LCCInput.OCPrice = lifeCycleInput.OCTotalCost; lifeCycleInput.LCCInput.AOHPrice = lifeCycleInput.AOHTotalCost; lifeCycleInput.LCCInput.CAPPrice = lifeCycleInput.CAPTotalCost; //operating and capital budgets use TotalAMAOH lifeCycleInput.LCCInput.TotalAMAOH = lifeCycleInput.EAATotalCost; }
private bool SetAnalyses(LCA1Stock lca1Stock) { bool bHasAnalysis = false; bool bHasTotals = false; bool adjustTotals = true; //only the totStocks are used to store numerical results //calcprops and analyzerprops stored in lca1stock lca1Stock.Total1 = new LCA1Total1(); //need one property set lca1Stock.Total1.SubApplicationType = lca1Stock.CalcParameters.SubApplicationType.ToString(); //these are the lcc and lcb calculations //the initial aggregation must have serialized them correctly as lcc or lcb calcors //costs foreach (SubPrice1 ind in lca1Stock.SubP1Stock.SubPrice1s) { if (ind.CalculatorType == LCA1CalculatorHelper.CALCULATOR_TYPES.buildcost1.ToString()) { LCC1Calculator lccInput = (LCC1Calculator)ind; //ind.SubPrice1s holds the subprices collection (which must also be totaled) bHasTotals = AddCostToTotalStock(lca1Stock.Total1, lca1Stock.Multiplier, lccInput, adjustTotals); //stock needs some calculator properties (date) BILCA1StockAnalyzer.CopyBaseElementProperties(lccInput.LCCInput, lca1Stock); lca1Stock.Date = lccInput.LCCInput.Date; if (bHasTotals) { bHasAnalysis = true; } } } //benefits foreach (SubPrice1 ind in lca1Stock.SubP2Stock.SubPrice1s) { if (ind.CalculatorType == LCA1CalculatorHelper.CALCULATOR_TYPES.buildbenefit1.ToString()) { LCB1Calculator lcbOutput = (LCB1Calculator)ind; //ind.SubPrice1s holds the subprices collection (which must also be totaled) bHasTotals = AddBenefitToTotalStock(lca1Stock.Total1, lca1Stock.Multiplier, lcbOutput, adjustTotals); //stock needs some calculator properties (date) BILCA1StockAnalyzer.CopyBaseElementProperties(lcbOutput.LCBOutput, lca1Stock); //lca1Stock.Date = lcbOutput.LCBOutput.Date; if (bHasTotals) { bHasAnalysis = true; } } } return(bHasAnalysis); }
private static void SetInputBasePrice(LCC1Calculator lifeCycleInput, string priceType, double cost) { if (priceType == SubPrice1.PRICE_TYPE.oc.ToString()) { lifeCycleInput.OCTotalCost += cost; } else if (priceType == SubPrice1.PRICE_TYPE.aoh.ToString()) { lifeCycleInput.AOHTotalCost += cost; } else if (priceType == SubPrice1.PRICE_TYPE.cap.ToString()) { lifeCycleInput.CAPTotalCost += cost; } }
private void AddSubCost(LCA1Total1 totStock, SubPrice1 subprice, LCC1Calculator lccInput) { //make sure that each subprice has a corresponding stock totStock.SubP1Stock.AddSubPrice1ToStocks(subprice); //add cumulative totals (material, equipment, labor) foreach (SubPrice1Stock stock in totStock.SubP1Stock.SubPrice1Stocks) { if ((stock.TotalSubP1Label == subprice.SubPLabel && subprice.SubPLabel != string.Empty)) { stock.TotalSubP1Total += subprice.SubPTotal; stock.TotalSubP1Price += subprice.SubPPrice; stock.TotalSubP1Amount += subprice.SubPAmount; stock.TotalSubP1TotalPerUnit = stock.TotalSubP1Total / lccInput.PerUnitAmount; } } }
public static void ChangeInputByMultiplier(LCC1Calculator lccInput, double multiplier) { lccInput.OCTotalCost = lccInput.OCTotalCost * multiplier; lccInput.AOHTotalCost = lccInput.AOHTotalCost * multiplier; lccInput.CAPTotalCost = lccInput.CAPTotalCost * multiplier; //multiplicative, so ok to multiply; but final number is summation lccInput.LCCTotalCost = lccInput.LCCTotalCost * multiplier; lccInput.EAATotalCost = lccInput.EAATotalCost * multiplier; //unit is derived from total lccInput.UnitTotalCost = lccInput.LCCTotalCost / lccInput.PerUnitAmount; //subcosts foreach (SubPrice1 subprice in lccInput.SubPrice1s) { subprice.SubPTotal = subprice.SubPTotal * multiplier; subprice.SubPTotalPerUnit = subprice.SubPTotalPerUnit / lccInput.PerUnitAmount; } }
public virtual void CopyLCC1Properties( LCC1Calculator calculator) { this.CopyCalculatorProperties(calculator); this.CopySharedObjectProperties(calculator); this.CopySubPrice1sProperties(calculator); this.ServiceLifeYears = calculator.ServiceLifeYears; this.YearsFromBaseDate = calculator.YearsFromBaseDate; this.PlanningConstructionYears = calculator.PlanningConstructionYears; this.PerUnitAmount = calculator.PerUnitAmount; this.PerUnitUnit = calculator.PerUnitUnit; this.LCCInput = new Input(calculator.LCCInput); this.OCTotalCost = calculator.OCTotalCost; this.AOHTotalCost = calculator.AOHTotalCost; this.CAPTotalCost = calculator.CAPTotalCost; this.LCCTotalCost = calculator.LCCTotalCost; this.EAATotalCost = calculator.EAATotalCost; this.UnitTotalCost = calculator.UnitTotalCost; }
public void SetDescendantLCA1StockInputAttributes(string attNameExt, CalculatorParameters calcParams, ref XElement calculator, XElement currentElement) { //the lcatotal1 analyzer adds its totals to the base lcc1calculator linked view //less duplication and easier to display and extend if (calculator != null) { //can display input totals using two analyzers if (this.AnalyzerType == LCA1AnalyzerHelper.ANALYZER_TYPES.lcatotal1.ToString() || this.AnalyzerType == LCA1AnalyzerHelper.ANALYZER_TYPES.lcastat1.ToString() || this.AnalyzerType == LCA1AnalyzerHelper.ANALYZER_TYPES.lcachangeyr.ToString() || this.AnalyzerType == LCA1AnalyzerHelper.ANALYZER_TYPES.lcachangeid.ToString() || this.AnalyzerType == LCA1AnalyzerHelper.ANALYZER_TYPES.lcachangealt.ToString() || this.AnalyzerType == LCA1AnalyzerHelper.ANALYZER_TYPES.lcaprogress1.ToString()) { string sAttNameExt = string.Empty; this.SetAndRemoveCalculatorAttributes(sAttNameExt, ref calculator); bool bHasCalcs = false; if (this.SubP1Stock.SubPrice1s != null) { if (this.SubP1Stock.SubPrice1s.Count > 0) { LCC1Calculator lcc = (LCC1Calculator)this.SubP1Stock.SubPrice1s.FirstOrDefault(); if (lcc != null) { //set locals lcc.LCCInput.Local.SetLocalAttributesForCalculator(calcParams, ref calculator); lcc.SetLCC1Attributes(string.Empty, ref calculator); bHasCalcs = true; } } } //don't need both subps and subpstock if (!bHasCalcs) { this.SetTotalLCA1StocksAttributes(attNameExt, ref calculator); } } } }
private static double GetMultipliedTotal(LCC1Calculator lccInput, double total, string priceType, double multiplier) { double dbMultipliedTotal = total; if (priceType == SubPrices.PRICE_TYPES.oc.ToString()) { dbMultipliedTotal = total * lccInput.LCCInput.OCAmount * multiplier; } else if (priceType == SubPrices.PRICE_TYPES.aoh.ToString()) { dbMultipliedTotal = total * lccInput.LCCInput.AOHAmount * multiplier; } else if (priceType == SubPrices.PRICE_TYPES.cap.ToString()) { dbMultipliedTotal = total * lccInput.LCCInput.CAPAmount * multiplier; } else { dbMultipliedTotal = total * multiplier; } return(dbMultipliedTotal); }
public static void ChangeInputByInputMultipliers(LCC1Calculator lccInput, double multiplier) { //total cost already was multiplied by amount now needs to be multiplied by times lccInput.OCTotalCost = lccInput.OCTotalCost * lccInput.LCCInput.OCAmount * multiplier; lccInput.AOHTotalCost = lccInput.AOHTotalCost * lccInput.LCCInput.AOHAmount * multiplier; lccInput.CAPTotalCost = lccInput.CAPTotalCost * lccInput.LCCInput.CAPAmount * multiplier; //recalculate total costs lccInput.LCCTotalCost = lccInput.OCTotalCost + lccInput.AOHTotalCost + lccInput.CAPTotalCost; lccInput.EAATotalCost = GeneralRules.CalculateEquivalentAnnualAnnuity(lccInput.LCCTotalCost, lccInput.ServiceLifeYears, lccInput.LCCInput.Local.RealRate, lccInput.LCCInput.Local.NominalRate); lccInput.UnitTotalCost = lccInput.LCCTotalCost / lccInput.PerUnitAmount; //subcosts can use all three price amounts foreach (SubPrice1 subprice in lccInput.SubPrice1s) { subprice.SubPTotal = GetMultipliedTotal(lccInput, subprice.SubPTotal, subprice.SubPType, multiplier); subprice.SubPTotalPerUnit = subprice.SubPTotal / lccInput.PerUnitAmount; //display the multiplier-adjusted quantity of each subprice1 //this number can be used directly in statistical aggregations subprice.SubPAmount = GetMultipliedTotal(lccInput, subprice.SubPAmount, subprice.SubPType, multiplier); } }
public bool AddCostToTotalStock(LCA1Total1 totStock, double multiplier, LCC1Calculator lccInput, bool adjustTotals) { bool bHasCalculations = false; //inheriting classes usually run this class, but adjust their own totals if (adjustTotals) { //multipliers (input.times) //don't change per hour building costs, only total costs if (totStock.SubApplicationType == Constants.SUBAPPLICATION_TYPES.inputprices.ToString()) { //i.e. lccInput.cost = lccInput.cost * multiplier (1 in stock analyzers) ChangeInputByMultiplier(lccInput, multiplier); } else { //i.e. lccInput.cost = lccInput.cost * multiplier * input.ocamount //multiplier = input.times * oc.amount * tp.amount ChangeInputByInputMultipliers(lccInput, multiplier); } } //multiplier adjusted costs totStock.TotalOCCost += lccInput.OCTotalCost; totStock.TotalAOHCost += lccInput.AOHTotalCost; totStock.TotalCAPCost += lccInput.CAPTotalCost; totStock.TotalLCCCost += lccInput.LCCTotalCost; totStock.TotalEAACost += lccInput.EAATotalCost; //unit cost is derived from totstock totStock.TotalUnitCost = totStock.TotalLCCCost / lccInput.PerUnitAmount; //subcosts AddSubCosts(totStock, lccInput); bHasCalculations = true; return(bHasCalculations); }
/// <summary> /// Purpose Calculate life cycle costs. /// Calculations come from NIST 135. /// </summary> public bool RunCostCalculations(LCC1Calculator lifeCycleInput) { bool bHasCalcs = false; GeneralRules.GROWTH_SERIES_TYPES eGrowthType; //five subcosts to calculate double dbSubPrice1Total = 0; double dbSubPrice2Total = 0; double dbSubPrice3Total = 0; double dbSubPrice4Total = 0; double dbSubPrice5Total = 0; double dbSubPrice6Total = 0; double dbSubPrice7Total = 0; double dbSubPrice8Total = 0; double dbSubPrice9Total = 0; double dbSubPrice10Total = 0; //only the real rate and constant dollars are used //but keep these for possible future use double dbNominalRate = 0; double dbRealRate = 0; double dbInflationRate = 0; //the totals have to be discounted and escalated from these initial totals //(multiplicative means that price does not have to be used) //ok to use the default order of the subcosts int i = 1; foreach (SubPrice1 subprice in lifeCycleInput.SubPrice1s) { if (i == 1) { dbSubPrice1Total = subprice.SubPAmount * subprice.SubPPrice; } else if (i == 2) { dbSubPrice2Total = subprice.SubPAmount * subprice.SubPPrice; } else if (i == 3) { dbSubPrice3Total = subprice.SubPAmount * subprice.SubPPrice; } else if (i == 4) { dbSubPrice4Total = subprice.SubPAmount * subprice.SubPPrice; } else if (i == 5) { dbSubPrice5Total = subprice.SubPAmount * subprice.SubPPrice; } else if (i == 6) { dbSubPrice6Total = subprice.SubPAmount * subprice.SubPPrice; } else if (i == 7) { dbSubPrice7Total = subprice.SubPAmount * subprice.SubPPrice; } else if (i == 8) { dbSubPrice8Total = subprice.SubPAmount * subprice.SubPPrice; } else if (i == 9) { dbSubPrice9Total = subprice.SubPAmount * subprice.SubPPrice; } else if (i == 10) { dbSubPrice10Total = subprice.SubPAmount * subprice.SubPPrice; } i++; } //init calculation parameters dbRealRate = lifeCycleInput.LCCInput.Local.RealRate; dbNominalRate = lifeCycleInput.LCCInput.Local.NominalRate; dbInflationRate = 0; GeneralRules.MissingRate(ref dbRealRate, ref dbNominalRate, ref dbInflationRate); if (dbRealRate > 0.999) { dbRealRate = dbRealRate / 100; } if (dbNominalRate > 0.999) { dbNominalRate = dbNominalRate / 100; } if (dbInflationRate > 0.999) { dbInflationRate = dbInflationRate / 100; } lifeCycleInput.LCCInput.Local.RealRate = dbRealRate; lifeCycleInput.LCCInput.Local.NominalRate = dbNominalRate; lifeCycleInput.LCCInput.Local.InflationRate = dbInflationRate; //get the recurring cost factors //ok to use the default order of the subcosts i = 1; foreach (SubPrice1 subprice in lifeCycleInput.SubPrice1s) { eGrowthType = GeneralRules.GetGrowthType(subprice.SubPEscType); if (i == 1) { subprice.SubPTotal = GeneralRules.GetGradientRealDiscountValue(dbSubPrice1Total, dbRealRate, lifeCycleInput.ServiceLifeYears, lifeCycleInput.YearsFromBaseDate, lifeCycleInput.PlanningConstructionYears, eGrowthType, subprice.SubPEscRate, subprice.SubPFactor, subprice.SubPYears, subprice.SubPYearTimes, subprice.SubPSalvValue); } else if (i == 2) { subprice.SubPTotal = GeneralRules.GetGradientRealDiscountValue(dbSubPrice2Total, dbRealRate, lifeCycleInput.ServiceLifeYears, lifeCycleInput.YearsFromBaseDate, lifeCycleInput.PlanningConstructionYears, eGrowthType, subprice.SubPEscRate, subprice.SubPFactor, subprice.SubPYears, subprice.SubPYearTimes, subprice.SubPSalvValue); } else if (i == 3) { subprice.SubPTotal = GeneralRules.GetGradientRealDiscountValue(dbSubPrice3Total, dbRealRate, lifeCycleInput.ServiceLifeYears, lifeCycleInput.YearsFromBaseDate, lifeCycleInput.PlanningConstructionYears, eGrowthType, subprice.SubPEscRate, subprice.SubPFactor, subprice.SubPYears, subprice.SubPYearTimes, subprice.SubPSalvValue); } else if (i == 4) { subprice.SubPTotal = GeneralRules.GetGradientRealDiscountValue(dbSubPrice4Total, dbRealRate, lifeCycleInput.ServiceLifeYears, lifeCycleInput.YearsFromBaseDate, lifeCycleInput.PlanningConstructionYears, eGrowthType, subprice.SubPEscRate, subprice.SubPFactor, subprice.SubPYears, subprice.SubPYearTimes, subprice.SubPSalvValue); } else if (i == 5) { subprice.SubPTotal = GeneralRules.GetGradientRealDiscountValue(dbSubPrice5Total, dbRealRate, lifeCycleInput.ServiceLifeYears, lifeCycleInput.YearsFromBaseDate, lifeCycleInput.PlanningConstructionYears, eGrowthType, subprice.SubPEscRate, subprice.SubPFactor, subprice.SubPYears, subprice.SubPYearTimes, subprice.SubPSalvValue); } else if (i == 6) { subprice.SubPTotal = GeneralRules.GetGradientRealDiscountValue(dbSubPrice6Total, dbRealRate, lifeCycleInput.ServiceLifeYears, lifeCycleInput.YearsFromBaseDate, lifeCycleInput.PlanningConstructionYears, eGrowthType, subprice.SubPEscRate, subprice.SubPFactor, subprice.SubPYears, subprice.SubPYearTimes, subprice.SubPSalvValue); } else if (i == 7) { subprice.SubPTotal = GeneralRules.GetGradientRealDiscountValue(dbSubPrice7Total, dbRealRate, lifeCycleInput.ServiceLifeYears, lifeCycleInput.YearsFromBaseDate, lifeCycleInput.PlanningConstructionYears, eGrowthType, subprice.SubPEscRate, subprice.SubPFactor, subprice.SubPYears, subprice.SubPYearTimes, subprice.SubPSalvValue); } else if (i == 8) { subprice.SubPTotal = GeneralRules.GetGradientRealDiscountValue(dbSubPrice8Total, dbRealRate, lifeCycleInput.ServiceLifeYears, lifeCycleInput.YearsFromBaseDate, lifeCycleInput.PlanningConstructionYears, eGrowthType, subprice.SubPEscRate, subprice.SubPFactor, subprice.SubPYears, subprice.SubPYearTimes, subprice.SubPSalvValue); } else if (i == 9) { subprice.SubPTotal = GeneralRules.GetGradientRealDiscountValue(dbSubPrice9Total, dbRealRate, lifeCycleInput.ServiceLifeYears, lifeCycleInput.YearsFromBaseDate, lifeCycleInput.PlanningConstructionYears, eGrowthType, subprice.SubPEscRate, subprice.SubPFactor, subprice.SubPYears, subprice.SubPYearTimes, subprice.SubPSalvValue); } else if (i == 10) { subprice.SubPTotal = GeneralRules.GetGradientRealDiscountValue(dbSubPrice10Total, dbRealRate, lifeCycleInput.ServiceLifeYears, lifeCycleInput.YearsFromBaseDate, lifeCycleInput.PlanningConstructionYears, eGrowthType, subprice.SubPEscRate, subprice.SubPFactor, subprice.SubPYears, subprice.SubPYearTimes, subprice.SubPSalvValue); } subprice.SubPTotalPerUnit = subprice.SubPTotal / lifeCycleInput.PerUnitAmount; i++; } //set lifeCyleInput's total properties to these values SetCostTotals(lifeCycleInput); //update the base input's prices (unit costs, not full costs) UpdateBaseInputUnitPrices(lifeCycleInput); bHasCalcs = true; return(bHasCalcs); }
//copy constructor public LCC1Calculator(LCC1Calculator lca1Calc) : base(lca1Calc) { CopyLCC1Properties(lca1Calc); }