//set up benefit and cost collections that can then be //analyzed by basic statistical analyzers (mean, sd, median) public virtual void SetBasicCollections(XElement currentElement) { //need to parse an attribute name in a componly analysis this.CalcParams.AnalyzerParms.FilePositionIndex = 0; //set the benefits and costs collections if (this.CalcParams.AnalyzerParms.NodeName .EndsWith(Outcome.OUTCOME_PRICE_TYPES.outcome.ToString())) { this.CalcParams.AnalyzerParms.BenefitObjectsCount += 1; this.CalcParams.AnalyzerParms.NodePositionIndex = this.CalcParams.AnalyzerParms.BenefitObjectsCount - 1; CostBenefitStatistic01 baseStat = new CostBenefitStatistic01(); baseStat.SetCalculatorProperties(currentElement); baseStat.SetStatisticGeneralProperties(currentElement); //set the "All" column (holds sum of all outputs) AddBenefitStatisticsToDictionary( this.CalcParams.AnalyzerParms.FilePositionIndex, this.CalcParams.AnalyzerParms.NodePositionIndex, baseStat); } else { this.CalcParams.AnalyzerParms.CostObjectsCount += 1; this.CalcParams.AnalyzerParms.NodePositionIndex = this.CalcParams.AnalyzerParms.CostObjectsCount - 1; CostBenefitStatistic01 baseStat = new CostBenefitStatistic01(); baseStat.SetCalculatorProperties(currentElement); baseStat.SetStatisticGeneralProperties(currentElement); //need a new coststat object for each output object AddCostStatisticsToDictionary( this.CalcParams.AnalyzerParms.FilePositionIndex, this.CalcParams.AnalyzerParms.NodePositionIndex, baseStat); } }
private void SetNameProperties(CostBenefitStatistic01 stat, XElement currentElement) { if (this.CalcParams.AnalyzerParms.AnalyzerGeneralType == ANALYZER_GENERAL_TYPES.outputbased) { //need to set the existing name and unit to a stat name and unit //(if it hasn't already been done) string sName = CalculatorHelpers .GetAttribute(currentElement, CostBenefitStatistic01.TRName); if (string.IsNullOrEmpty(sName)) { //analyzers sometimes use more than one analyzer //so the first may or may not have converted the name already sName = CalculatorHelpers .GetAttribute(currentElement, Calculator1.cName); } stat.TotalRName = sName; string sUnit = CalculatorHelpers .GetAttribute(currentElement, CostBenefitStatistic01.TRUnit); if (string.IsNullOrEmpty(sUnit)) { sUnit = CalculatorHelpers .GetAttribute(currentElement, Constants.UNIT); if (string.IsNullOrEmpty(sUnit)) { sUnit = CalculatorHelpers .GetAttribute(currentElement, Output.OUTPUT_BASE_UNIT); } } stat.TotalRUnit = sUnit; } }
private void MakeBenefitSummaryElement(CostBenefitStatistic01 summaryBenefit, ref XmlWriter writer) { //write the summarybenefits collection to the benefits element //write the new attributes using a writer //the summary doesn't have an extension string sAttNameExtension = string.Empty; summaryBenefit.SetTotalBenefitsAttributes(sAttNameExtension, ref writer); summaryBenefit.SetNBenefitsAttributes(sAttNameExtension, ref writer); summaryBenefit.SetMeanBenefitsAttributes(sAttNameExtension, ref writer); summaryBenefit.SetStdDevBenefitsAttributes(sAttNameExtension, ref writer); }
public virtual void AddCostStatisticsToDictionary( int filePosition, int nodePosition, CostBenefitStatistic01 baseStat) { if (filePosition < 0 || nodePosition < 0) { this.CalcParams.ErrorMessage = Errors.MakeStandardErrorMsg("ANALYSES_INDEX_OUTOFBOUNDS"); return; } if (this.CalcParams.AnalyzerParms.CostStatistics == null) { this.CalcParams.AnalyzerParms.CostStatistics = new Dictionary <int, List <CostBenefitStatistic01> >(); } if (this.CalcParams.AnalyzerParms.CostStatistics.ContainsKey(filePosition)) { if (this.CalcParams.AnalyzerParms.CostStatistics[filePosition] != null) { for (int i = 0; i <= nodePosition; i++) { if (this.CalcParams.AnalyzerParms.CostStatistics[filePosition].Count <= i) { this.CalcParams.AnalyzerParms.CostStatistics[filePosition] .Add(new CostBenefitStatistic01()); } } this.CalcParams.AnalyzerParms.CostStatistics[filePosition][nodePosition] = baseStat; } } else { //add the missing dictionary entry List <CostBenefitStatistic01> baseStats = new List <CostBenefitStatistic01>(); KeyValuePair <int, List <CostBenefitStatistic01> > newStat = new KeyValuePair <int, List <CostBenefitStatistic01> >( filePosition, baseStats); this.CalcParams.AnalyzerParms.CostStatistics.Add(newStat); AddCostStatisticsToDictionary(filePosition, nodePosition, baseStat); } }
private void MakeCostSummaryElement(CostBenefitStatistic01 summaryCost, ref XmlWriter writer) { //write the summarybenefits collection to the benefits element //write the new attributes using a writer //the summary column doesn't have an extension string sAttNameExtension = string.Empty; //limit attributes to those needed or file size balloons summaryCost.SetAmortCostsAttributes(sAttNameExtension, ref writer); if ((!this.CalcParams.AnalyzerParms.NodeName.EndsWith(Input.INPUT_PRICE_TYPES.input.ToString())) && (!this.CalcParams.AnalyzerParms.NodeName.EndsWith(OperationComponent.OPERATION_PRICE_TYPES.operation.ToString())) && (!this.CalcParams.AnalyzerParms.NodeName.EndsWith(OperationComponent.COMPONENT_PRICE_TYPES.component.ToString()))) { summaryCost.SetAmortBenefitsAttributes(sAttNameExtension, ref writer); } }
private void MakeBenefitSummaryElement(ref XmlWriter writer) { //the first member of the benefits collection needs to be //a summation of the sibling members if (this.CalcParams.AnalyzerParms.BenefitStatistics != null) { int iNodeCount = 0; int iFilePosition = 0; CostBenefitStatistic01 sumAllComparison = new CostBenefitStatistic01(); foreach (KeyValuePair <int, List <CostBenefitStatistic01> > kvp in this.CalcParams.AnalyzerParms.BenefitStatistics) { iFilePosition = kvp.Key; iNodeCount = 0; foreach (CostBenefitStatistic01 benefitStat in kvp.Value) { //the "All" column is nothing more than a summation of //index columns (and should not be interpreted differently) sumAllComparison.TotalRName = CostBenefitStatistic01.ALL; sumAllComparison.TotalRUnit = CostBenefitStatistic01.ALL; sumAllComparison.TotalAMR += benefitStat.TotalAMR; sumAllComparison.TotalAMR_N += benefitStat.TotalAMR_N; sumAllComparison.TotalAMR_MEAN += benefitStat.TotalAMR_MEAN; //keep it simple; just need good sample analyzers at this point sumAllComparison.TotalAMR_SD += benefitStat.TotalAMR_SD; sumAllComparison.TotalRPrice += benefitStat.TotalRPrice; sumAllComparison.TotalRPrice_MEAN += benefitStat.TotalRPrice_MEAN; sumAllComparison.TotalRPrice_SD += benefitStat.TotalRPrice_SD; sumAllComparison.TotalRCompositionAmount += benefitStat.TotalRCompositionAmount; sumAllComparison.TotalRCompositionAmount_MEAN += benefitStat.TotalRCompositionAmount_MEAN; sumAllComparison.TotalRCompositionAmount_SD += benefitStat.TotalRCompositionAmount_SD; sumAllComparison.TotalRAmount += benefitStat.TotalRAmount; sumAllComparison.TotalRAmount_MEAN += benefitStat.TotalRAmount_MEAN; sumAllComparison.TotalRAmount_SD += benefitStat.TotalRAmount_SD; iNodeCount += 1; } } MakeBenefitSummaryElement(sumAllComparison, ref writer); } }
//set up benefit and cost collections that can then be //analyzed by effectiveness analyzers (cost per unit output) public virtual void SetOutputBasedCollections(XElement currentElement) { //need to parse an attribute name in a componly analysis this.CalcParams.AnalyzerParms.FilePositionIndex = 0; //set the benefits and costs collections (basestats.count = outputs.count) if (this.CalcParams.AnalyzerParms.NodeName .EndsWith(Outcome.OUTCOME_PRICE_TYPES.outcome.ToString())) { //two attributes are used to set the benefits and costs collections //the benefits count must be set before the costs collection, //so the order that the nodes get streamed is critical if (this.CalcParams.AnalyzerParms.BenefitObjectsCount == 0) { this.CalcParams.AnalyzerParms.BenefitObjectsCount += 1; this.CalcParams.AnalyzerParms.NodePositionIndex = this.CalcParams.AnalyzerParms.BenefitObjectsCount - 1; //first output is the "All" column holding summation of outputs CostBenefitStatistic01 baseAllStat = new CostBenefitStatistic01(); baseAllStat.SetCalculatorProperties(currentElement); //the all column's stats will be a summation of outputs and //get set after the Benefits collection has been filled baseAllStat.SetStatisticGeneralProperties(currentElement); //set the "All" column (holds sum of all outputs) AddBenefitStatisticsToDictionary( this.CalcParams.AnalyzerParms.FilePositionIndex, this.CalcParams.AnalyzerParms.NodePositionIndex, baseAllStat); } //this is not a conditional clause //set the first output column this.CalcParams.AnalyzerParms.BenefitObjectsCount += 1; this.CalcParams.AnalyzerParms.NodePositionIndex = this.CalcParams.AnalyzerParms.BenefitObjectsCount - 1; CostBenefitStatistic01 baseStat = new CostBenefitStatistic01(); //set totals baseStat.SetCalculatorProperties(currentElement); //set statistics baseStat.SetStatisticGeneralProperties(currentElement); baseStat.SetMeanBenefitsProperties(currentElement); baseStat.SetMedianBenefitsProperties(currentElement); baseStat.SetNBenefitsProperties(currentElement); baseStat.SetStdDevBenefitsProperties(currentElement); //convert app names to stat names SetNameProperties(baseStat, currentElement); //set the "All" column (holds sum of all outputs) AddBenefitStatisticsToDictionary( this.CalcParams.AnalyzerParms.FilePositionIndex, this.CalcParams.AnalyzerParms.NodePositionIndex, baseStat); } else { this.CalcParams.AnalyzerParms.CostObjectsCount += 1; this.CalcParams.AnalyzerParms.NodePositionIndex = this.CalcParams.AnalyzerParms.CostObjectsCount - 1; //ce analyses use the benefitsobject count to set //the zero-based number of nodes for (int i = 0; i <= this.CalcParams.AnalyzerParms.BenefitObjectsCount - 1; i++) { CostBenefitStatistic01 baseStat = new CostBenefitStatistic01(); baseStat.SetCalculatorProperties(currentElement); baseStat.SetStatisticGeneralProperties(currentElement); //need a new coststat object for each output object AddCostStatisticsToDictionary( this.CalcParams.AnalyzerParms.FilePositionIndex, i, baseStat); } } }