Exemplo n.º 1
0
        public override LossStateCollection2 GetLossState()
        {
            LossStateCollection2 lossCol = new LossStateCollection2(1);

            double[] allSubjectLosses;

            //Handle Net or Gross postions
            if (positionType == PositionType.Gross)
            {
                allSubjectLosses = subjectLoss.AllLoss();
            }
            else if (positionType == PositionType.Ceded)
            {
                allSubjectLosses = subjectLoss.AllLoss().Select(loss => loss * -1).ToArray();
            }
            else
            {
                throw new NotSupportedException("Cannot handle positionType: " + positionType.ToString());
            }

            lossCol.SetSubjectLosses(subjectLoss.AllLoss());
            lossCol.SetRecoverableLosses(subjectLoss.AllLoss());

            return(lossCol);
        }
Exemplo n.º 2
0
        public void SumLossesFrom(LossStateCollection2 otherLosses)
        {
            if (this.NumBldgs == otherLosses.NumBldgs)
            {
                double[] othersubjectloss = otherLosses.subjectloss;
                double[] otherexcess      = otherLosses.excess;
                double[] otherrecoverable = otherLosses.recoverable;
                double[] otherdeductible  = otherLosses.deductible;

                for (int i = 0; i < NumBldgs; i++)
                {
                    subjectloss[i] += othersubjectloss[i];
                    excess[i]      += otherexcess[i];
                    recoverable[i] += otherrecoverable[i];
                    deductible[i]  += otherdeductible[i];
                }
            }
            else if (this.NumBldgs == 1)
            {
                subjectloss[0] += otherLosses.GetTotalSum.S;
                excess[0]      += otherLosses.GetTotalSum.X;
                recoverable[0] += otherLosses.GetTotalSum.R;
                deductible[0]  += otherLosses.GetTotalSum.D;
            }

            CalcTotalSum();
        }
Exemplo n.º 3
0
 public CoverageAtomicRITE(string _subperil, ExposureType _expType, RITE _rite, long ID)
 {
     SubPeril                         = _subperil;
     ExpType                          = _expType;
     RITE                             = _rite;
     RITCharacterisiticID             = ID;
     CurrentAllocationStateCollection = new AllocationStateCollection2(RITE.ActNumOfSampleBldgs);
     //CurrentAllocationStateSummed = new AllocationState();
     CurrentLossStateCollection = new LossStateCollection2(RITE.ActNumOfSampleBldgs);
 }
Exemplo n.º 4
0
        public LossStateCollection2 CopyToLossState()
        {
            LossStateCollection2 lossCol = new LossStateCollection2(NumBldgs);

            Array.Copy(subjectloss, lossCol.SubjectLoss, NumBldgs);
            Array.Copy(excess, lossCol.Excess, NumBldgs);
            Array.Copy(recoverable, lossCol.Recoverable, NumBldgs);
            Array.Copy(deductible, lossCol.Deductible, NumBldgs);

            return(lossCol);
        }
Exemplo n.º 5
0
 public override void Reset()
 {
     base.Reset();
     if (IsPerRisk)
     {
         CurrentLossStateCollection = new LossStateCollection2(PrimarySubject.Schedule.ActNumOfBldgs);
     }
     else
     {
         CurrentLossStateCollection = new LossStateCollection2(1);
     }
     //CurrentLossState.Reset();
     CurrentAllocationState.Reset();
 }
Exemplo n.º 6
0
        public void TermFunction(LossStateCollection2 LossFromBelow)
        {
            int NumBldgs = CurrNode.CurrentLossStateCollection.NumBldgs;

            //int intObjCount = IntObject.Count();
            double[] excessFromBelow = LossFromBelow.Excess;
            double[] dedFromBelow    = LossFromBelow.Deductible;
            double[] lossFromBelow   = LossFromBelow.SubjectLoss;
            double[] recovFromBelow  = LossFromBelow.Recoverable;

            double[] nodeexcess = CurrNode.CurrentLossStateCollection.Excess;
            double[] nodeded    = CurrNode.CurrentLossStateCollection.Deductible;
            double[] nodeloss   = CurrNode.CurrentLossStateCollection.SubjectLoss;
            double[] noderecov  = CurrNode.CurrentLossStateCollection.Recoverable;

            //if (LossFromBelow.NumBldgs != CurrNode.CurrentLossStateCollection.NumBldgs)
            //    throw new ArgumentOutOfRangeException("Number of buildings from below must equal number of buildings in current trem node...when performing interaction!");

            DeductibleCollection sortedDeductibles = CurrNode.Deductibles.SortByExecOrder(CurrNode.Deductibles);


            //Intialize
            if (LossFromBelow.NumBldgs == CurrNode.CurrentLossStateCollection.NumBldgs)
            {
                //CurrNode.CurrentLossStateCollection.collection[i].X = IntObject[i].ExcessFromChildren;
                //CurrNode.CurrentLossStateCollection.collection[i].D = IntObject[i].DedFromChildren;

                Array.Copy(excessFromBelow, nodeexcess, NumBldgs);
                Array.Copy(dedFromBelow, nodeded, NumBldgs);
            }
            else
            {
                //CurrNode.CurrentLossStateCollection.collection[i].X = 0;
                //CurrNode.CurrentLossStateCollection.collection[i].D = 0;

                Array.Clear(CurrNode.CurrentLossStateCollection.Excess, 0, NumBldgs);
                Array.Clear(CurrNode.CurrentLossStateCollection.Deductible, 0, NumBldgs);
            }

            //Do Ground-up sub-Limit first
            foreach (Limit limObj in CurrNode.Limits)
            {
                if (limObj.LimitIsNetOfDed == false)
                {
                    double limitTot = 0;
                    if (limObj.LimType == TermValueType.Numeric)
                    {
                        limitTot = limObj.Amount;
                    }
                    else if (limObj.LimType == TermValueType.PercentCovered)
                    {
                        limitTot = limObj.Amount / 100 * CurrNode.GetTIV();
                    }
                    else if (limObj.LimType == TermValueType.PercentAffected)
                    {
                        limitTot = limObj.Amount / 100 * CurrNode.GetAffectedTIV();
                    }
                    else if (limObj.LimType == TermValueType.PercentLoss)
                    {
                        limitTot = limObj.Amount / 100 * CurrNode.CurrentLossStateCollection.GetTotalSum.S;
                    }
                    else
                    {
                        throw new InvalidOperationException("Lim TermValueType is not Known");
                    }

                    double limit = limitTot;
                    for (int i = 0; i < NumBldgs; i++)
                    {
                        if (AggType == Aggregation.PerBuilding)
                        {
                            limit = limitTot * multiArr[i];
                        }

                        nodeexcess[i] = Math.Max(nodeexcess[i], Math.Max(0.0, nodeloss[i] - limit));
                    }

                    CurrNode.CurrentLossStateCollection.AdjustX();
                }  //end: each Group-up Sub-Limits
            }

            //then do all Deductibles one by one, all deductibles are already in the right exec order
            foreach (Deductible dedObj in sortedDeductibles)
            {
                double dedTot = 0;
                if (dedObj.DedType == TermValueType.Numeric)
                {
                    dedTot = dedObj.Amount;
                }
                else if (dedObj.DedType == TermValueType.PercentCovered)
                {
                    dedTot = dedObj.Amount * CurrNode.GetTIV();
                }
                else if (dedObj.DedType == TermValueType.PercentAffected)
                {
                    dedTot = dedObj.Amount * CurrNode.GetAffectedTIV();
                }
                else if (dedObj.DedType == TermValueType.PercentLoss)
                {
                    dedTot = dedObj.Amount * CurrNode.CurrentLossStateCollection.GetTotalSum.S;
                }
                else
                {
                    throw new InvalidOperationException("Ded TermValueType is not Known");
                }

                double ded = dedTot;
                for (int i = 0; i < NumBldgs; i++)
                {
                    if (AggType == Aggregation.PerBuilding)
                    {
                        ded = dedTot * multiArr[i];
                    }

                    if (dedObj.DedIsFranchise)
                    {
                        ded = (nodeloss[i] > ded) ? 0.0 : nodeloss[i];
                    }
                    else
                    {
                        ded = Math.Min(nodeloss[i], ded);
                    }

                    if (dedObj.DedInterType == DedInteractionType.SingleLargest)
                    {
                        nodeded[i] = LossFromBelow.GetLargestDed();
                    }
                    else if (dedObj.DedInterType == DedInteractionType.MAX)
                    {
                        nodeded[i] = Math.Min(nodeded[i], ded);
                    }
                    else if (dedObj.DedInterType == DedInteractionType.MIN)
                    {
                        nodeded[i] = Math.Max(nodeded[i], ded);
                    }
                    else if (dedObj.DedInterType == DedInteractionType.Absorbing)
                    {
                        nodeded[i] = Math.Max(nodeded[i], ded - nodeexcess[i]);
                    }
                    else
                    {
                        throw new InvalidOperationException("Interaction Type is not Known");
                    }
                }

                CurrNode.CurrentLossStateCollection.AdjustD();
            } //end: all deds


            //for (int i = 0; i < NumBldgs; i++)
            //{
            //    CurrNode.CurrentLossStateCollection.AdjustD();
            //}

            CurrNode.CurrentLossStateCollection.AdjustD();

            //then do all NetOfDed Sub-Limit
            foreach (Limit limObj in CurrNode.Limits)
            {
                if (limObj.LimitIsNetOfDed)
                {
                    double limitTot = 0;
                    if (limObj.LimType == TermValueType.Numeric)
                    {
                        limitTot = limObj.Amount;
                    }
                    else if (limObj.LimType == TermValueType.PercentCovered)
                    {
                        limitTot = limObj.Amount * CurrNode.GetTIV();
                    }
                    else if (limObj.LimType == TermValueType.PercentAffected)
                    {
                        limitTot = limObj.Amount * CurrNode.GetAffectedTIV();
                    }
                    else if (limObj.LimType == TermValueType.PercentLoss)
                    {
                        limitTot = limObj.Amount * CurrNode.CurrentLossStateCollection.GetTotalSum.S;
                    }
                    else
                    {
                        throw new InvalidOperationException("Lim TermValueType is not Known");
                    }

                    double limit = limitTot;
                    for (int i = 0; i < NumBldgs; i++)
                    {
                        if (AggType == Aggregation.PerBuilding)
                        {
                            limit = limitTot * multiArr[i];
                        }

                        nodeexcess[i] = Math.Max(nodeexcess[i], nodeloss[i] - nodeded[i] - limit);

                        //CurrNode.CurrentLossStateCollection.collection[i].AdjustX();
                    }

                    CurrNode.CurrentLossStateCollection.AdjustX();
                }
            } //end: NetOfDed sub-limit
        }
Exemplo n.º 7
0
        public LossStateCollection2 GetLossState()
        {
            LossStateCollection2 coverNodeLossState = new LossStateCollection2(1);

            return(coverNodeLossState);
        }