public bool AddTimelinessOpComp1ToStock(double multiplier, TimelinessOpComp1 machnpvoc)
        {
            bool bHasCalculations = false;

            //this should only be done at tp stock analysis level when the opcomps were correctly
            //adjusted by output collection and by tp.amount (i.e. use opcomp.ReSetParentTimePeriodProperties)
            this.Machinery2Stock.TotalAmount             += (machnpvoc.Amount * multiplier);
            this.Machinery2Stock.TotalLaborAvailable     += (machnpvoc.LaborAvailable);
            this.Machinery2Stock.TotalWorkdayProbability += (machnpvoc.WorkdayProbability);
            this.Machinery2Stock.TotalTimelinessPenalty1 += (machnpvoc.TimelinessPenalty1);
            this.Machinery2Stock.TotalTimelinessPenaltyDaysFromStart1 += (machnpvoc.TimelinessPenaltyDaysFromStart1);
            this.Machinery2Stock.TotalTimelinessPenalty2 += (machnpvoc.TimelinessPenalty2 * multiplier);
            this.Machinery2Stock.TotalTimelinessPenaltyDaysFromStart2 += (machnpvoc.TimelinessPenaltyDaysFromStart2);
            this.Machinery2Stock.TotalWorkdaysLimit                += (machnpvoc.WorkdaysLimit * multiplier);
            this.Machinery2Stock.TotalFieldCapacity                += (machnpvoc.FieldCapacity);
            this.Machinery2Stock.TotalAreaCovered                  += (machnpvoc.AreaCovered * multiplier);
            this.Machinery2Stock.TotalFieldDays                    += (machnpvoc.FieldDays * multiplier);
            this.Machinery2Stock.TotalOutputPrice                  += (machnpvoc.OutputPrice);
            this.Machinery2Stock.TotalOutputYield                  += (machnpvoc.OutputYield);
            this.Machinery2Stock.TotalProbableFieldDays            += (machnpvoc.ProbableFieldDays * multiplier);
            this.Machinery2Stock.TotalTimelinessPenaltyCost        += (machnpvoc.TimelinessPenaltyCost * multiplier);
            this.Machinery2Stock.TotalTimelinessPenaltyCostPerHour += (machnpvoc.TimelinessPenaltyCostPerHour);
            this.Machinery2Stock.TotalR += (machnpvoc.TotalR);
            //next ancestor needs a stateful machnpvoc that has been adjusted
            //by multiplier: machnpvoc has multiplicative adjustments
            //i.e. budget adjustement = in.times * op.amount * tp.amount)
            ChangeMachinery2InputByMultiplier(machnpvoc, multiplier);
            bHasCalculations = true;
            return(bHasCalculations);
        }
        public static bool AddTimelinessOpComp1ToStock(Machinery2Stock mach2Stock,
                                                       double multiplier, TimelinessOpComp1 machnpvoc)
        {
            bool bHasCalculations = false;

            //this should only be done at tp stock analysis level when the opcomps were correctly
            //adjusted by output collection and by tp.amount (i.e. use opcomp.ReSetParentTimePeriodProperties)
            mach2Stock.TotalAmount             += (machnpvoc.Amount * multiplier);
            mach2Stock.TotalLaborAvailable     += (machnpvoc.LaborAvailable);
            mach2Stock.TotalWorkdayProbability += (machnpvoc.WorkdayProbability);
            mach2Stock.TotalTimelinessPenalty1 += (machnpvoc.TimelinessPenalty1);
            mach2Stock.TotalTimelinessPenaltyDaysFromStart1 += (machnpvoc.TimelinessPenaltyDaysFromStart1);
            mach2Stock.TotalTimelinessPenalty2 += (machnpvoc.TimelinessPenalty2 * multiplier);
            mach2Stock.TotalTimelinessPenaltyDaysFromStart2 += (machnpvoc.TimelinessPenaltyDaysFromStart2);
            mach2Stock.TotalWorkdaysLimit                += (machnpvoc.WorkdaysLimit * multiplier);
            mach2Stock.TotalFieldCapacity                += (machnpvoc.FieldCapacity);
            mach2Stock.TotalAreaCovered                  += (machnpvoc.AreaCovered * multiplier);
            mach2Stock.TotalFieldDays                    += (machnpvoc.FieldDays * multiplier);
            mach2Stock.TotalOutputPrice                  += (machnpvoc.OutputPrice);
            mach2Stock.TotalOutputYield                  += (machnpvoc.OutputYield);
            mach2Stock.TotalProbableFieldDays            += (machnpvoc.ProbableFieldDays * multiplier);
            mach2Stock.TotalTimelinessPenaltyCost        += (machnpvoc.TimelinessPenaltyCost * multiplier);
            mach2Stock.TotalTimelinessPenaltyCostPerHour += (machnpvoc.TimelinessPenaltyCostPerHour);
            mach2Stock.TotalR += (machnpvoc.TotalR);
            bHasCalculations   = true;
            return(bHasCalculations);
        }
Exemple #3
0
 public virtual void CopyTimelinessOC1Properties(
     TimelinessOpComp1 calculator)
 {
     this.PlannedStartDate   = calculator.PlannedStartDate;
     this.ActualStartDate    = calculator.ActualStartDate;
     this.LaborAvailable     = calculator.LaborAvailable;
     this.WorkdayProbability = calculator.WorkdayProbability;
     this.TimelinessPenalty1 = calculator.TimelinessPenalty1;
     this.TimelinessPenaltyDaysFromStart1 = calculator.TimelinessPenaltyDaysFromStart1;
     this.TimelinessPenalty2 = calculator.TimelinessPenalty2;
     this.TimelinessPenaltyDaysFromStart2 = calculator.TimelinessPenaltyDaysFromStart2;
     this.WorkdaysLimit                = calculator.WorkdaysLimit;
     this.Amount                       = calculator.Amount;
     this.Unit                         = calculator.Unit;
     this.FieldCapacity                = calculator.FieldCapacity;
     this.AreaCovered                  = calculator.AreaCovered;
     this.FieldDays                    = calculator.FieldDays;
     this.OutputName                   = calculator.OutputName;
     this.OutputUnit                   = calculator.OutputUnit;
     this.OutputPrice                  = calculator.OutputPrice;
     this.OutputYield                  = calculator.OutputYield;
     this.CompositionAmount            = calculator.CompositionAmount;
     this.CompositionUnit              = calculator.CompositionUnit;
     this.OutputTimes                  = calculator.OutputTimes;
     this.ProbableFieldDays            = calculator.ProbableFieldDays;
     this.ProbableFinishDate           = calculator.ProbableFinishDate;
     this.TimelinessPenaltyCost        = calculator.TimelinessPenaltyCost;
     this.TimelinessPenaltyCostPerHour = calculator.TimelinessPenaltyCostPerHour;
     this.TotalR                       = calculator.TotalR;
 }
        public bool SetInputMachinery2StockJointCalculations(ref XElement currentCalculationsElement,
                                                             ref XElement currentElement)
        {
            bool bHasCalculations = false;

            //set the parent opcomp for holding collection of machinputs
            if (this.TimelinessOpComp == null)
            {
                this.TimelinessOpComp = new TimelinessOpComp1();
                this.TimelinessOpComp.TimelinessOpComps = new List <TimelinessOpComp1>();
            }
            //run the base mach1input calcs to set machinery costs
            bHasCalculations = this.SetInputMachineryStockCalculations(ref currentCalculationsElement,
                                                                       ref currentElement);
            //set calculatorid (primary way to display calculation attributes)
            CalculatorHelpers.SetCalculatorId(currentCalculationsElement, currentElement);
            //add to collection
            if (this.TimelinessOpComp.Inputs == null)
            {
                this.TimelinessOpComp.Inputs = new List <Input>();
            }
            //note that machinput can be retrieved by converting the input to the
            //Machinery1Input type (machinput = (Machinery1Input) input)
            if (this.Mach1Input != null)
            {
                this.TimelinessOpComp.Inputs.Add(this.Mach1Input);
            }
            return(bHasCalculations);
        }
Exemple #5
0
        public bool SetOpOrCompMachinery2StockCalculations(
            XElement currentCalculationsElement, XElement currentElement)
        {
            //set timeliness cost penalties only
            bool bHasCalculations = false;

            //set the parent tp for holding collection of opcomps
            if (this.TimelinessTimePeriod == null)
            {
                this.TimelinessTimePeriod = new TimelinessTimePeriod1();
            }

            //reset the outputs and rerun the timeliness cost using the outputs, and tp.amount, for this budget
            //parenttp was set during addancestor event
            double dbTPAmount = (this.GCCalculatorParams.ParentTimePeriod != null)
                ? this.GCCalculatorParams.ParentTimePeriod.Amount : 1;

            this.TimelinessOpComp.ReSetParentTimePeriodProperties(dbTPAmount, this.TimelinessTimePeriod.Outcomes);
            //reset the attributes to real outputs (this is usually true)
            this.TimelinessOpComp.SetTimelinessOC1Attributes(string.Empty, currentCalculationsElement);
            //need to display some base atts with calculated results
            this.TimelinessOpComp.SetTimelinessBaseAttributes(string.Empty, currentCalculationsElement);
            //set calculatorid (primary way to display calculation attributes)
            CalculatorHelpers.SetCalculatorId(
                currentCalculationsElement, currentElement);
            //add the machnpvoc to the machStock.machstocks dictionary
            //the count is 1-based, while iNodePosition is 0-based
            //so the count is the correct next index position
            int iNodePosition = this.Machinery2Stock.GetNodePositionCount(
                this.GCCalculatorParams.AnalyzerParms.FilePositionIndex, this.TimelinessOpComp);

            if (iNodePosition < 0)
            {
                iNodePosition = 0;
            }
            bHasCalculations = this.Machinery2Stock
                               .AddMachinery2StocksToDictionary(
                this.GCCalculatorParams.AnalyzerParms.FilePositionIndex, iNodePosition,
                this.TimelinessOpComp);
            //keep this consistent with other stock calculators
            //reset machStock.machstocks fileposition index
            //next opOrComp's machstock will be inserted in next index
            this.GCCalculatorParams.AnalyzerParms.FilePositionIndex += 1;
            //add to collection
            if (this.TimelinessTimePeriod.TimelinessOpComps == null)
            {
                this.TimelinessTimePeriod.TimelinessOpComps = new List <TimelinessOpComp1>();
            }
            this.TimelinessTimePeriod.TimelinessOpComps.Add(this.TimelinessOpComp);
            //reset for next collection
            this.TimelinessOpComp = null;
            bHasCalculations      = true;
            return(bHasCalculations);
        }
 public static void AddStock1TotalsToElement(Machinery1Stock mach1Stock,
                                             TimelinessOpComp1 currentTOC, ref XElement opCompCalcElement)
 {
     //these have already been adjusted by input multipliers (ocamount, times)
     //and opcomp mulipliers (amount)
     currentTOC.TotalOC = mach1Stock.TotalFuelCost + mach1Stock.TotalLaborCost
                          + mach1Stock.TotalRepairCost + mach1Stock.TotalLubeOilCost;
     currentTOC.TotalAOH = mach1Stock.TotalCapitalRecoveryCost
                           + mach1Stock.TotalTaxesHousingInsuranceCost;
     CalculatorHelpers.SetAttributeDoubleF2(opCompCalcElement,
                                            CostBenefitCalculator.TOC, currentTOC.TotalOC);
     CalculatorHelpers.SetAttributeDoubleF2(opCompCalcElement,
                                            CostBenefitCalculator.TAOH, currentTOC.TotalAOH);
 }
Exemple #7
0
        public static bool TimelinessPenaltyIncreasesUsingNewDate(TimelinessOpComp1 tocToChange,
                                                                  DateTime newActualDate)
        {
            bool   bCostIncreases      = false;
            double startingPenaltyCost = tocToChange.TimelinessPenaltyCost;

            //returns the date adjusted toc to calling procedure, so send in a new one
            SetTimelinessPenaltyNewActualDate(tocToChange, newActualDate);
            if (tocToChange.TimelinessPenaltyCost > startingPenaltyCost)
            {
                bCostIncreases = true;
            }
            return(bCostIncreases);
        }
Exemple #8
0
        public static bool RunSchedulingCalculations(CalculatorParameters calcParameters)
        {
            bool bIsDone = false;
            //step two of operation and component npv calculator
            //has parameters that are used in labor and capital stock planning
            //clean up those parameters here
            TimelinessOpComp1 npvOC = new TimelinessOpComp1();

            //set the object's properties from the calcdoc
            npvOC.SetTimelinessOC1Properties(calcParameters.LinkedViewElement);
            //set the calcdoc from the object
            npvOC.SetTimelinessOC1Attributes(string.Empty, calcParameters.LinkedViewElement);
            bIsDone = true;
            return(bIsDone);
        }
Exemple #9
0
        //add a TimelinessOpComp1 to the baseStat.Machinery2Stocks dictionary
        public static bool AddMachinery2StocksToDictionary(
            this Machinery2Stock baseStat,
            int filePosition, int nodePosition, TimelinessOpComp1 calculator)
        {
            bool bIsAdded = false;

            if (filePosition < 0 || nodePosition < 0)
            {
                baseStat.ErrorMessage
                    = Errors.MakeStandardErrorMsg("ANALYSES_INDEX_OUTOFBOUNDS");
                return(false);
            }
            if (baseStat.Machinery2Stocks == null)
            {
                baseStat.Machinery2Stocks
                    = new Dictionary <int, List <TimelinessOpComp1> >();
            }
            if (baseStat.Machinery2Stocks.ContainsKey(filePosition))
            {
                if (baseStat.Machinery2Stocks[filePosition] != null)
                {
                    for (int i = 0; i <= nodePosition; i++)
                    {
                        if (baseStat.Machinery2Stocks[filePosition].Count <= i)
                        {
                            baseStat.Machinery2Stocks[filePosition]
                            .Add(new TimelinessOpComp1());
                        }
                    }
                    baseStat.Machinery2Stocks[filePosition][nodePosition]
                             = calculator;
                    bIsAdded = true;
                }
            }
            else
            {
                //add the missing dictionary entry
                List <TimelinessOpComp1> baseStats
                    = new List <TimelinessOpComp1>();
                KeyValuePair <int, List <TimelinessOpComp1> > newStat
                    = new KeyValuePair <int, List <TimelinessOpComp1> >(
                          filePosition, baseStats);
                baseStat.Machinery2Stocks.Add(newStat);
                bIsAdded = AddMachinery2StocksToDictionary(baseStat,
                                                           filePosition, nodePosition, calculator);
            }
            return(bIsAdded);
        }
Exemple #10
0
        public static int GetNodePositionCount(this Machinery2Stock baseStat,
                                               int filePosition, TimelinessOpComp1 calculator)
        {
            int iNodeCount = 0;

            if (baseStat.Machinery2Stocks == null)
            {
                return(iNodeCount);
            }
            if (baseStat.Machinery2Stocks.ContainsKey(filePosition))
            {
                if (baseStat.Machinery2Stocks[filePosition] != null)
                {
                    iNodeCount = baseStat.Machinery2Stocks[filePosition].Count;
                }
            }
            return(iNodeCount);
        }
 public static void ChangeMachinery2InputByMultiplier(TimelinessOpComp1 machnpvoc,
                                                      double multiplier)
 {
     //the next ancestor needs to aggregate with whatever multiplier
     //was used by immediate descendant (i.e. Input.Times for opOrComp,
     //Operation.Amount for timeperiod, TimePeriod.Amount for budget;
     machnpvoc.Amount             = (machnpvoc.Amount * multiplier);
     machnpvoc.LaborAvailable     = (machnpvoc.LaborAvailable);
     machnpvoc.WorkdayProbability = (machnpvoc.WorkdayProbability);
     machnpvoc.TimelinessPenalty1 = (machnpvoc.TimelinessPenalty1);
     machnpvoc.TimelinessPenaltyDaysFromStart1 = (machnpvoc.TimelinessPenaltyDaysFromStart1);
     machnpvoc.TimelinessPenalty2 = (machnpvoc.TimelinessPenalty2);
     machnpvoc.TimelinessPenaltyDaysFromStart2 = (machnpvoc.TimelinessPenaltyDaysFromStart2);
     machnpvoc.WorkdaysLimit         = (machnpvoc.WorkdaysLimit * multiplier);
     machnpvoc.FieldCapacity         = (machnpvoc.FieldCapacity);
     machnpvoc.AreaCovered           = (machnpvoc.AreaCovered * multiplier);
     machnpvoc.FieldDays             = (machnpvoc.FieldDays * multiplier);
     machnpvoc.OutputPrice           = (machnpvoc.OutputPrice);
     machnpvoc.OutputYield           = (machnpvoc.OutputYield);
     machnpvoc.ProbableFieldDays     = (machnpvoc.ProbableFieldDays * multiplier);
     machnpvoc.TimelinessPenaltyCost = (machnpvoc.TimelinessPenaltyCost * multiplier);
 }
        public bool SetOpOrCompMachinery2StockCalculations(
            ref XElement currentCalculationsElement, ref XElement currentElement)
        {
            //set timeliness cost penalties only
            bool bHasCalculations = false;

            //if (this.GCCalculatorParams.SubApplicationType == Constants.SUBAPPLICATION_TYPES.operationprices
            //    || this.GCCalculatorParams.SubApplicationType == Constants.SUBAPPLICATION_TYPES.componentprices)
            //{
            //    //standard getally calcs will retrieve npv operation calculator
            //    //which must not be overwritten or replaced in db record which must not be overwritten
            //    //if UseSameCalcInChildren = true
            //    CalculatorHelpers.ReplaceAnalyzerCalculator(this.GCCalculatorParams, currentElement,
            //        ARSAnalyzerHelper.ANALYZER_TYPES.resources02.ToString(),
            //        ref currentCalculationsElement);
            //}
            //set the parent tp for holding collection of opcomps
            if (this.TimelinessTimePeriod == null)
            {
                this.TimelinessTimePeriod = new TimelinessTimePeriod1();
            }

            //reset the outputs and rerun the timeliness cost using the outputs, and tp.amount, for this budget
            //parenttp was set during addancestor event
            double dbTPAmount = (this.GCCalculatorParams.ParentTimePeriod != null)
                ? this.GCCalculatorParams.ParentTimePeriod.Amount : 1;

            this.TimelinessOpComp.ReSetParentTimePeriodProperties(dbTPAmount, this.TimelinessTimePeriod.Outcomes);
            //reset the attributes to real outputs (this is usually true)
            this.TimelinessOpComp.SetTimelinessOC1Attributes(string.Empty, currentCalculationsElement);
            //need to display some base atts with calculated results
            this.TimelinessOpComp.SetTimelinessBaseAttributes(string.Empty, currentCalculationsElement);
            //set calculatorid (primary way to display calculation attributes)
            CalculatorHelpers.SetCalculatorId(
                currentCalculationsElement, currentElement);
            //add the machnpvoc to the machStock.machstocks dictionary
            //the count is 1-based, while iNodePosition is 0-based
            //so the count is the correct next index position
            int iNodePosition = this.Machinery2Stock.GetNodePositionCount(
                this.GCCalculatorParams.AnalyzerParms.FilePositionIndex, this.TimelinessOpComp);

            if (iNodePosition < 0)
            {
                iNodePosition = 0;
            }
            bHasCalculations = this.Machinery2Stock
                               .AddMachinery2StocksToDictionary(
                this.GCCalculatorParams.AnalyzerParms.FilePositionIndex, iNodePosition,
                this.TimelinessOpComp);
            //keep this consistent with other stock calculators
            //reset machStock.machstocks fileposition index
            //next opOrComp's machstock will be inserted in next index
            this.GCCalculatorParams.AnalyzerParms.FilePositionIndex += 1;
            //add to collection
            if (this.TimelinessTimePeriod.TimelinessOpComps == null)
            {
                this.TimelinessTimePeriod.TimelinessOpComps = new List <TimelinessOpComp1>();
            }
            this.TimelinessTimePeriod.TimelinessOpComps.Add(this.TimelinessOpComp);
            //reset for next collection
            this.TimelinessOpComp = null;
            bHasCalculations      = true;
            return(bHasCalculations);
        }
        public bool SetOpOrCompMachinery2StockJointCalculations(ref XElement currentCalculationsElement,
                                                                ref XElement currentElement)
        {
            bool bHasCalculations = false;

            if (this.GCCalculatorParams.SubApplicationType == Constants.SUBAPPLICATION_TYPES.operationprices ||
                this.GCCalculatorParams.SubApplicationType == Constants.SUBAPPLICATION_TYPES.componentprices)
            {
                string sAnalyzerType = CalculatorHelpers.GetAnalyzerType(currentCalculationsElement);
                if (sAnalyzerType != this.GCCalculatorParams.AnalyzerParms.AnalyzerType)
                {
                    //standard getally calcs may retrieve resource 01 calculator
                    //(because finds relatedcalculatortype=agmachinery)
                    //which must not be overwritten if UseSameCalcInChildren = true
                    currentCalculationsElement = CalculatorHelpers.GetChildLinkedViewUsingAttribute(currentElement,
                                                                                                    Calculator1.cAnalyzerType, this.GCCalculatorParams.AnalyzerParms.AnalyzerType);
                    //CalculatorHelpers.ReplaceAnalyzerCalculator(this.GCCalculatorParams, currentElement,
                    //   this.GCCalculatorParams.AnalyzerParms.AnalyzerType,
                    //    ref currentCalculationsElement);
                }
            }
            //step 4. Run both mach1stock and mach2stock calculations keeping both indices synch
            string sCalculatorType = CalculatorHelpers.CALCULATOR_TYPES.operation2.ToString();

            if (currentElement.Name.LocalName.EndsWith(OperationComponent.OPERATION_PRICE_TYPES.operation.ToString()))
            {
                sCalculatorType = CalculatorHelpers.CALCULATOR_TYPES.operation2.ToString();
            }
            else if (currentElement.Name.LocalName.EndsWith(OperationComponent.COMPONENT_PRICE_TYPES.component.ToString()))
            {
                sCalculatorType = CalculatorHelpers.CALCULATOR_TYPES.component2.ToString();
            }
            if (currentCalculationsElement == null)
            {
                //either a base resource01 calculation was not run
                //or it was never added to base npv calculator
                currentCalculationsElement = new XElement(this.GCCalculatorParams.LinkedViewElement);
            }
            //i.e. make sure to use the baseNPV linked view holding base machinery cost and timeliness penalty information
            XElement baseNPVCalculation = CalculatorHelpers.GetChildLinkedViewUsingAttribute(currentElement,
                                                                                             Calculator1.cCalculatorType, sCalculatorType);

            if (baseNPVCalculation == null)
            {
                //the display will point out bad params if currentCalcEl is wrong
                baseNPVCalculation = currentCalculationsElement;
            }
            ////set machinery cost totals
            //int iFPIndex = this.GCCalculatorParams.AnalyzerParms.FilePositionIndex;
            //when this method is called from opcomp or input group
            if (this.TimelinessOpComp == null)
            {
                this.TimelinessOpComp = new TimelinessOpComp1();
            }
            //note that the machnpvoc calculator can not change Operation properties
            //but needs several properties from the Operation (i.e. Id, Amount)
            this.TimelinessOpComp.SetOperationComponentProperties(this.GCCalculatorParams,
                                                                  currentCalculationsElement, currentElement);
            //init mach2Stock props
            this.Machinery2Stock.SetCalculatorProperties(currentCalculationsElement);
            this.TimelinessOpComp.SetTimelinessOC1Properties(baseNPVCalculation);
            //baseNPVCalc must be used to set machinery calcs
            this.SetOpOrCompMachineryStockCalculations(ref currentCalculationsElement, ref currentElement);
            //reset opcomp.amount to base (not the stored linkedview amount)
            this.TimelinessOpComp.SetTimelinessBaseProperties(currentElement);
            //set machinery cost totals
            int iFPIndex = this.GCCalculatorParams.AnalyzerParms.FilePositionIndex;

            this.GCCalculatorParams.AnalyzerParms.FilePositionIndex = iFPIndex;
            //set timeliness penalty totals
            bHasCalculations = SetOpOrCompMachinery2StockCalculations(ref currentCalculationsElement, ref currentElement);
            //keep the newly set fileposition index
            return(bHasCalculations);
        }
Exemple #14
0
        public static void SetTimelinessPenaltyNewActualDate(TimelinessOpComp1 tocToChange,
                                                             DateTime newActualDate)
        {
            tocToChange.ActualStartDate = newActualDate;
            tocToChange.FieldDays       = (tocToChange.AreaCovered != 0) ? (tocToChange.Amount / tocToChange.AreaCovered) : 0;
            //the number they enter whether 10 or .01 is the probability
            double dbWorkdayProbablity = tocToChange.WorkdayProbability / 100;

            dbWorkdayProbablity            = (dbWorkdayProbablity != 0) ? dbWorkdayProbablity : -1;
            tocToChange.ProbableFieldDays  = tocToChange.FieldDays / dbWorkdayProbablity;
            tocToChange.ProbableFinishDate = tocToChange.ActualStartDate.AddDays(tocToChange.ProbableFieldDays);
            //penalty only if actual start date is later than planned
            TimeSpan tsPlannedvsActualPenaltyDays = tocToChange.PlannedStartDate - tocToChange.ActualStartDate;
            int      iDays = tsPlannedvsActualPenaltyDays.Days;

            if (iDays < 0)
            {
                if (tocToChange.PlannedStartDate < tocToChange.ActualStartDate)
                {
                    iDays = iDays * -1;
                }
            }
            else if (iDays > 0)
            {
                if (tocToChange.PlannedStartDate > tocToChange.ActualStartDate)
                {
                    iDays = iDays * -1;
                }
            }

            double dbPenaltyDays        = (iDays + tocToChange.ProbableFieldDays) - tocToChange.TimelinessPenaltyDaysFromStart1;
            double dbTotalOutputBenefit = tocToChange.Amount * tocToChange.OutputPrice * tocToChange.OutputYield * tocToChange.CompositionAmount * tocToChange.OutputTimes;

            tocToChange.TotalR = dbTotalOutputBenefit;
            if (dbPenaltyDays > 0)
            {
                //the number they enter whether 10 or .01 is the penalty
                double dbTimelinessPenalty = tocToChange.TimelinessPenalty1 / 100;
                //penalty runs for all days
                tocToChange.TimelinessPenaltyCost = dbTotalOutputBenefit * dbTimelinessPenalty * dbPenaltyDays;
                if (tocToChange.TimelinessPenaltyCost > dbTotalOutputBenefit)
                {
                    tocToChange.TimelinessPenaltyCost = dbTotalOutputBenefit;
                }
                //add additional penalty (i.e. 65 - (30 + 30))
                dbPenaltyDays = (iDays + tocToChange.ProbableFieldDays) - (tocToChange.TimelinessPenaltyDaysFromStart1 + tocToChange.TimelinessPenaltyDaysFromStart2);
                if (dbPenaltyDays > 0)
                {
                    //additional penalty
                    //i.e. (1) / 100 = .01 penalty
                    dbTimelinessPenalty = (tocToChange.TimelinessPenalty2) / 100;
                    //additional penalty runs only for additional days
                    tocToChange.TimelinessPenaltyCost = tocToChange.TimelinessPenaltyCost + (dbTotalOutputBenefit * dbTimelinessPenalty * dbPenaltyDays);
                    if (tocToChange.TimelinessPenaltyCost > dbTotalOutputBenefit)
                    {
                        tocToChange.TimelinessPenaltyCost = dbTotalOutputBenefit;
                    }
                }
            }
            else
            {
                tocToChange.TimelinessPenaltyCost = 0;
            }
            if (tocToChange.FieldCapacity == 0)
            {
                tocToChange.FieldCapacity = -1;
            }
            //1000 / (100 hours = .2 hrs/acre * 500 acres)
            double dbTotalHours = (1 / tocToChange.FieldCapacity) * tocToChange.Amount;

            if (dbTotalHours > 0)
            {
                tocToChange.TimelinessPenaltyCostPerHour = tocToChange.TimelinessPenaltyCost / dbTotalHours;
            }
            else
            {
                tocToChange.TimelinessPenaltyCostPerHour = 0;
            }
        }
Exemple #15
0
        //163 started using tr to calc penalty
        private bool ResetOutcomeProperties(List <Outcome> outcomes)
        {
            bool bHasNewOutputs         = false;
            TimelinessOpComp1 tempCalcs = new TimelinessOpComp1();

            if (outcomes != null)
            {
                if (outcomes.Count > 0)
                {
                    foreach (Outcome outcome in outcomes)
                    {
                        if (outcome.Outputs != null)
                        {
                            foreach (Output output in outcome.Outputs)
                            {
                                //don't process when machin calcs have not beeen completed
                                if (this.FieldCapacity != 0)
                                {
                                    //either name must be contained in the other
                                    if (output.Name.ToLower().IndexOf(this.OutputName.ToLower()) >= 0 ||
                                        this.OutputName.ToLower().IndexOf(output.Name.ToLower()) >= 0)
                                    {
                                        if (output.CompositionAmount <= 0)
                                        {
                                            output.CompositionAmount = 1;
                                        }
                                        if (output.Times <= 0)
                                        {
                                            output.Times = 1;
                                        }
                                        //use the one with the highest revenue
                                        output.TotalR = outcome.Amount * output.CompositionAmount * output.Times * output.Amount * output.Price;
                                        if (output.TotalR > tempCalcs.TotalR)
                                        {
                                            tempCalcs.OutputName        = output.Name;
                                            tempCalcs.OutputPrice       = output.Price;
                                            tempCalcs.OutputUnit        = output.Unit;
                                            tempCalcs.OutputYield       = output.Amount;
                                            tempCalcs.CompositionAmount = output.CompositionAmount;
                                            tempCalcs.CompositionUnit   = output.CompositionUnit;
                                            tempCalcs.OutputTimes       = output.Times;
                                            tempCalcs.TotalR            = output.TotalR;
                                            bHasNewOutputs = true;
                                        }
                                    }
                                }
                            }
                        }
                    }
                    //use first output
                    if (!bHasNewOutputs)
                    {
                        if (outcomes.FirstOrDefault().Outputs != null)
                        {
                            Output output = outcomes.FirstOrDefault().Outputs.FirstOrDefault();
                            this.OutputName        = output.Name;
                            this.OutputPrice       = output.Price;
                            this.OutputUnit        = output.Unit;
                            this.OutputYield       = output.Amount;
                            this.CompositionAmount = output.CompositionAmount;
                            this.CompositionUnit   = output.CompositionUnit;
                            this.OutputTimes       = output.Times;
                            this.TotalR            = output.TotalR;
                            bHasNewOutputs         = true;
                        }
                    }
                    else
                    {
                        //switch to this tps output
                        this.OutputName        = tempCalcs.OutputName;
                        this.OutputPrice       = tempCalcs.OutputPrice;
                        this.OutputUnit        = tempCalcs.OutputUnit;
                        this.OutputYield       = tempCalcs.OutputYield;
                        this.CompositionAmount = tempCalcs.CompositionAmount;
                        this.CompositionUnit   = tempCalcs.CompositionUnit;
                        this.OutputTimes       = tempCalcs.OutputTimes;
                        this.TotalR            = tempCalcs.TotalR;
                    }
                }
            }
            return(bHasNewOutputs);
        }
Exemple #16
0
 //copy constructor
 public TimelinessOpComp1(TimelinessOpComp1 npvOC)
     : base()
 {
     CopyTimelinessOC1Properties(npvOC);
 }