private void AddObservation(ref XElement obsElement, ref CalculatorParameters calcParameters, ref string attName, ref string attValue) { string sAttributeValueList = string.Empty; //convert the attribute name to the statistical object property names //used in further analyses (i.e. output.amount to output.tramount) CostBenefitCalculator.ConvertAttributeNameToStatisticName( calcParameters.CurrentElementNodeName, ref attName); if (!string.IsNullOrEmpty(attName)) { if (obsElement.Attribute(attName) != null) { //add to the existing observations string sOldAttValue = CalculatorHelpers.GetAttribute( obsElement, attName); string sTotalAttsValue = string.Concat(sOldAttValue, Constants.STRING_DELIMITER, attValue); sAttributeValueList = string.Concat(sTotalAttsValue, Constants.FILENAME_DELIMITER, calcParameters.AnalyzerParms.FilePositionIndex.ToString()); //double delimited string: 2.52_1;3.25_1 attValue = sAttributeValueList; } else { //add to a new observation //always use standard delimited string sAttributeValueList = string.Concat(attValue, Constants.FILENAME_DELIMITER, calcParameters.AnalyzerParms.FilePositionIndex.ToString()); //double delimited string: 2.52_1;3.25_1 attValue = sAttributeValueList; } } }
private void SetBaseStatistics() { if (CostBenefitCalculator.NameIsAStatistic( this.CalcParams.AnalyzerParms.ObservationAttributeName)) { if ((!this.CalcParams.AnalyzerParms.NodeName.EndsWith(Input.INPUT_PRICE_TYPES.input.ToString())) && (this.AnalyzerType != ARSAnalyzerHelper.ANALYZER_TYPES.resources01 && (!this.AnalyzerType.ToString().StartsWith(ARSAnalyzerHelper.ANALYZER_TYPES.resources02.ToString())))) { SetBasicStatistics(); } else { //resource use analyses are in a separate stat analyzer } } else { if (this.CalcParams.AnalyzerParms.ObservationAttributeName.Equals( CostBenefitStatistic01.TRName) || this.CalcParams.AnalyzerParms.ObservationAttributeName.Equals( CostBenefitStatistic01.TRUnit)) { //the observation builder aggregates these two attributes //into delimited strings which need to be parsed SetBasicDescriptors(); } } }
public virtual void SetBenefitStatisticProperty(int filePosition, int nodePosition, string attName, string attValue, string nodeName) { if (attName.Contains(CostBenefitStatistic01.MEAN)) { this.CalcParams.AnalyzerParms.BenefitStatistics[filePosition][nodePosition] .SetMeanBenefitsProperties(attName, attValue); } else if (attName.Contains(CostBenefitStatistic01.SD)) { this.CalcParams.AnalyzerParms.BenefitStatistics[filePosition][nodePosition] .SetStdDevBenefitsProperties(attName, attValue); } else if (attName.Contains(CostBenefitStatistic01.VAR2)) { this.CalcParams.AnalyzerParms.BenefitStatistics[filePosition][nodePosition] .SetVarianceBenefitsProperties(attName, attValue); } else if (attName.Contains(CostBenefitStatistic01.MED)) { this.CalcParams.AnalyzerParms.BenefitStatistics[filePosition][nodePosition] .SetMedianBenefitsProperties(attName, attValue); } else if (attName.Contains(CostBenefitStatistic01.N)) { this.CalcParams.AnalyzerParms.BenefitStatistics[filePosition][nodePosition] .SetNBenefitsProperties(attName, attValue); } else { if (CostBenefitCalculator.NameIsAStatistic(attName)) { this.CalcParams.AnalyzerParms.BenefitStatistics[filePosition][nodePosition] .SetTotalBenefitsProperty(attName, attValue); } else { //late concession if (attName.Equals(CostBenefitStatistic01.TRName) || attName.Equals(CostBenefitStatistic01.TRUnit)) { this.CalcParams.AnalyzerParms.BenefitStatistics[filePosition][nodePosition] .SetTotalBenefitsProperty(attName, attValue); } //not needed with most collections when they are //initialized correctly //this.CalcParams.AnalyzerParms.BenefitStatistics[filePosition][nodePosition] // .SetCalculatorProperties(attName, attValue); } } }
public virtual void SetCostStatisticProperty(int filePosition, int nodePosition, string attName, string attValue, string nodeName) { if (attName.Contains(CostBenefitStatistic01.MEAN)) { this.CalcParams.AnalyzerParms.CostStatistics[filePosition][nodePosition] .SetMeanCostsProperties(attName, attValue); } else if (attName.Contains(CostBenefitStatistic01.SD)) { this.CalcParams.AnalyzerParms.CostStatistics[filePosition][nodePosition] .SetStdDevCostsProperties(attName, attValue); } else if (attName.Contains(CostBenefitStatistic01.VAR2)) { this.CalcParams.AnalyzerParms.CostStatistics[filePosition][nodePosition] .SetVarianceCostsProperties(attName, attValue); } else if (attName.Contains(CostBenefitStatistic01.MED)) { this.CalcParams.AnalyzerParms.CostStatistics[filePosition][nodePosition] .SetMedianCostsProperties(attName, attValue); } else if (attName.Contains(CostBenefitStatistic01.N)) { this.CalcParams.AnalyzerParms.CostStatistics[filePosition][nodePosition] .SetNCostsProperties(attName, attValue); } else { //set base statistic props if (CostBenefitCalculator.NameIsAStatistic(attName)) { this.CalcParams.AnalyzerParms.CostStatistics[filePosition][nodePosition] .SetTotalCostsProperty(attName, attValue); } else { //names written separately (unlike setbenstatprop) ////most collections were initialized with the base descriptors ////they need //this.CalcParams.AnalyzerParms.CostStatistics[filePosition][nodePosition] // .SetCalculatorProperties(attName, attValue); } } }
public virtual void InitTotalNPV1StocksProperties(CostBenefitCalculator baseElement) { //this is called during the initial calculator collections //it adds those initial calcs to correct agg stock //base calculator holds totals //each agg has to set CalcParameters during object construction if (this.AnalyzerType == NPV1AnalyzerHelper.ANALYZER_TYPES.npvstat1.ToString()) { this.Stat1 = new NPV1Stat1(); this.Stat1.CopyCalculatorProperties(baseElement); this.Stat1.CopyTotalCostsProperties(baseElement); this.Stat1.CopyTotalBenefitsProperties(baseElement); } else if (this.AnalyzerType == NPV1AnalyzerHelper.ANALYZER_TYPES.npvchangeyr.ToString() || this.AnalyzerType == NPV1AnalyzerHelper.ANALYZER_TYPES.npvchangeid.ToString() || this.AnalyzerType == NPV1AnalyzerHelper.ANALYZER_TYPES.npvchangealt.ToString()) { this.Change1 = new NPV1Change1(); this.Change1.CopyCalculatorProperties(baseElement); this.Change1.CopyTotalCostsProperties(baseElement); this.Change1.CopyTotalBenefitsProperties(baseElement); } else if (this.AnalyzerType == NPV1AnalyzerHelper.ANALYZER_TYPES.npvprogress1.ToString()) { this.Progress1 = new NPV1Progress1(); this.Progress1.CopyCalculatorProperties(baseElement); this.Progress1.CopyTotalCostsProperties(baseElement); this.Progress1.CopyTotalBenefitsProperties(baseElement); } else { this.Total1 = new NPV1Total1(); this.Total1.CopyCalculatorProperties(baseElement); this.Total1.CopyTotalCostsProperties(baseElement); this.Total1.CopyTotalBenefitsProperties(baseElement); } }
private bool NeedsStatistic(string observationValue) { bool bNeedsStatistic = false; if (!string.IsNullOrEmpty( this.CalcParams.AnalyzerParms.ObservationAttributeValue)) { //1. double check whether this needs a statistic if (CostBenefitCalculator.NameIsAStatistic( this.CalcParams.AnalyzerParms.ObservationAttributeName)) { //2. if a single observation value is a number //it can generate a statistic bool bIsNumber = CalculatorHelpers.ValidateIsNumber(observationValue); if (bIsNumber) { bNeedsStatistic = true; } } } return(bNeedsStatistic); }
public ME2Stock SetME2Properties(CostBenefitCalculator baseElement, XElement currentCalculationsElement, XElement currentElement) { ME2Stock me2 = new ME2Stock(this.GCCalculatorParams, this.GCCalculatorParams.AnalyzerParms.AnalyzerType); //204 not used //if (this.ME2DescendentStock != null) //{ // //only property set by analyzer // me2.TotalME2Stage = this.ME2DescendentStock.TotalME2Stage; //} ME2Calculator me2Calc = new ME2Calculator(this.GCCalculatorParams); me2.CalcParameters.CurrentElementNodeName = currentElement.Name.LocalName; bool bHasCalcs = false; if (currentCalculationsElement != null) { //have to make sure its not a stockanalyzer string sCalculatorType = CalculatorHelpers.GetAttribute( currentCalculationsElement, Calculator1.cCalculatorType); if (sCalculatorType == ME2CalculatorHelper.CALCULATOR_TYPES.me2.ToString()) { //deserialize xml to object me2Calc.SetME2Properties(currentCalculationsElement, currentElement); //only need alttype and targettype (alts are groupedby using base elements) baseElement.AlternativeType = me2Calc.AlternativeType; baseElement.TargetType = me2Calc.TargetType; bHasCalcs = true; } } if (!bHasCalcs) { //see if a sibling holds the calculations (currentCalcs could be the analyzer) XElement lv = CalculatorHelpers.GetChildLinkedViewUsingAttribute(currentElement, Calculator1.cCalculatorType, ME2CalculatorHelper.CALCULATOR_TYPES.me2.ToString()); if (lv != null) { //deserialize xml to object me2Calc.SetME2Properties(lv, currentElement); //only need alttype and targettype (alts are groupedby using base elements) baseElement.AlternativeType = me2Calc.AlternativeType; baseElement.TargetType = me2Calc.TargetType; bHasCalcs = true; } } if (!bHasCalcs) { //else don't need the ids from calculator me2.CopyCalculatorProperties(baseElement); } //all calcs and analyses are stored in the appropriate analysis object (i.e. me2.Total, me2.Stat) me2.InitTotalME2StocksProperties(); //copy the initial calculator to the appropriate analysis object.ME2Indicators collection me2.CopyME2CalculatorToME2Stock(me2Calc); me2.AnalyzerType = this.GCCalculatorParams.AnalyzerParms.AnalyzerType; //label and date comes from baseelement me2.Label = baseElement.Label; me2.Date = baseElement.Date; //kiss with the multipliers me2.Multiplier = baseElement.Multiplier; me2.CalculatorId = me2Calc.Id; //adjust id if children analyzers are being inserted/updated ChangeCalculatorIdForUpdatedChildren(currentElement, ref currentCalculationsElement, me2); return(me2); }