Beispiel #1
0
        public override void SetAllocState(AllocationStateCollection allocState)
        {
            double ratio = allocState.Loss / subjectLoss.TotalLoss;

            AllocatedLossSeries = subjectLoss;
            AllocatedLossSeries.AllocateRatio(ratio);
        }
Beispiel #2
0
 public TermNode(PrimarySubject _subject) : base(_subject)
 {
     if (_subject.IsDerived)
     {
         throw new ArgumentOutOfRangeException("Terms Nodes cannot have a derivied subject!");
     }
     CurrentAllocationState = new AllocationStateCollection(_subject.Schedule.ActNumOfBldgs);
     Deductibles            = new DeductibleCollection();
     Limits = new LimitCollection();
 }
Beispiel #3
0
 public CoverageAtomicRITE(string _subperil, ExposureType _expType, RITE _rite, long ID)
 {
     SubPeril                         = _subperil;
     ExpType                          = _expType;
     RITE                             = _rite;
     RITCharacterisiticID             = ID;
     CurrentAllocationStateCollection = new AllocationStateCollection(RITE.ActNumOfBldgs);
     //CurrentAllocationStateSummed = new AllocationState();
     CurrentLossStateCollection = new LossStateCollection(RITE.ActNumOfBldgs);
 }
Beispiel #4
0
 public CoverNode(Subject _subject, string _coverName)
     : base(_subject)
 {
     Payout    = 0;
     CoverName = _coverName;
     CurrentAllocationState = new AllocationStateCollection(1);
     //CurrentAggState = new AggState(Cover.AggDedAmount, Cover.AggLimitAmount, Cover.DedOfAggDedLayer.Amount, Cover.LimitOfAggDedLayer.Amount);
     CurrentAggState = new AggState();
     keystring       = keystring + "-Cov: " + _coverName;
 }
Beispiel #5
0
 public void SumLossesFrom(AllocationStateCollection otherLosses)
 {
     if (this.NumBldgs == otherLosses.NumBldgs)
     {
         collection.Zip(otherLosses.collection, (a, b) => a + b);
     }
     else if (this.NumBldgs == 1)
     {
         collection[0] += otherLosses.GetTotalSum;
     }
 }
Beispiel #6
0
        public override void SetAllocState(AllocationStateCollection allocstate)
        {
            CurrentAllocationStateCollection = allocstate;
            AllocatedLossSeries = subjectLoss.Clone();
            double ratio;

            if (subjectLoss.TotalLoss > 0)
            {
                ratio = allocstate.GetPayout() / subjectLoss.TotalLoss;
                AllocatedLossSeries.AllocateRatio(ratio);
            }
        }
Beispiel #7
0
        public ContractAtomicRITE(Graph _contractGraph, string _subPeril, ExposureType _expType)
        {
            contractGraph = _contractGraph;
            SubPeril      = _subPeril;
            ExpType       = _expType;

            CurrentAllocationStateCollection = new AllocationStateCollection(1);

            if (_contractGraph.IsExecuted)
            {
                subjectLoss = _contractGraph.exResults.GetFilteredTimeSeries(_subPeril, _expType);
            }
        }
Beispiel #8
0
        private void AllocateOverlappedTermNode(TermNode currTermNode, HashSet <CoverageAtomicRITE> SubjectARITEs)
        {
            //find its AtomicRITEs
            //HashSet<AtomicRITE> SubjectARITEs = currTermNode.Subject.GetAtomicRites();
            Aggregation aggType = Aggregation.Summed;

            if (currTermNode.IsPerRisk && currTermNode.PrimarySubject.Schedule.ActNumOfBldgs > 1)
            {
                aggType = Aggregation.PerBuilding;
            }

            int numOfChildren = SubjectARITEs.Count;

            AllocationStateCollection[] MidAllocationStateCollection = new AllocationStateCollection[numOfChildren];

            int j = 0;

            foreach (CoverageAtomicRITE childNode in SubjectARITEs)
            {
                MidAllocationStateCollection[j] = new AllocationStateCollection(childNode.GetAllocState().NumBldgs);
                j++;
            }

            //Allocation has to co-op with multi-building
            //always allocate to per-building
            if (aggType == Aggregation.PerBuilding)
            {   // do it per-building
                foreach (CoverageAtomicRITE cRite in SubjectARITEs)
                {
                    if (cRite.GetLossState().NumBldgs != currTermNode.CurrentLossStateCollection.NumBldgs)
                    {
                        throw new InvalidOperationException("AtomicRite NumOfBuilding must be equal to its parent's numOfBuilding");
                    }
                }

                for (int i = 0; i < currTermNode.CurrentLossStateCollection.NumBldgs; i++)
                {
                    Double childrenDSum = SubjectARITEs.Sum(item => item.GetLossState().collection[i].D);
                    Double childrenRSum = SubjectARITEs.Sum(item => item.GetLossState().collection[i].R);
                    Double childrenSSum = SubjectARITEs.Sum(item => item.GetLossState().collection[i].S);
                    Double diffD        = currTermNode.CurrentLossStateCollection.collection[i].D - childrenDSum;

                    if (childrenRSum == 0)
                    {
                        j = 0;
                        foreach (AtomicRITE childNode in SubjectARITEs)
                        {
                            MidAllocationStateCollection[j].collection[i].R = currTermNode.CurrentLossStateCollection.collection[i].R * childNode.GetLossState().collection[i].S / childrenSSum;
                            j++;
                        }
                    }
                    else if (diffD >= 0)
                    {
                        j = 0;
                        foreach (AtomicRITE childNode in SubjectARITEs)
                        {
                            MidAllocationStateCollection[j].collection[i].R = childNode.GetLossState().collection[i].R * (1 - diffD / childrenRSum);
                            MidAllocationStateCollection[j].collection[i].D = childNode.GetLossState().collection[i].S - childNode.GetLossState().collection[i].X - MidAllocationStateCollection[j].collection[i].R;
                            j++;
                        }
                    }
                    else
                    {
                        j = 0;
                        foreach (AtomicRITE childNode in SubjectARITEs)
                        {
                            MidAllocationStateCollection[j].collection[i].D = childNode.GetLossState().collection[i].D * (1 + diffD / childrenDSum);
                            MidAllocationStateCollection[j].collection[i].R = childNode.GetLossState().collection[i].S - childNode.GetLossState().collection[i].X - MidAllocationStateCollection[j].collection[i].D;
                            j++;
                        }
                    }

                    Double childrenRaSum = MidAllocationStateCollection.Sum(item => item.collection[i].R);
                    int    jj            = 0;
                    if (diffD >= 0 && childrenRaSum == 0)
                    {
                        foreach (CoverageAtomicRITE childNode in SubjectARITEs)
                        {
                            MidAllocationStateCollection[jj].collection[i].R = childNode.GetLossState().collection[i].R;
                            jj++;
                        }
                        childrenRaSum = MidAllocationStateCollection.Sum(item => item.collection[i].R);
                    }

                    jj = 0;
                    foreach (CoverageAtomicRITE childNode in SubjectARITEs)
                    {
                        if (currTermNode.CurrentLossStateCollection.collection[i].R == 0)
                        {
                            MidAllocationStateCollection[jj].collection[i].R = 0;
                        }
                        else if (childrenRaSum > 0)
                        {
                            MidAllocationStateCollection[jj].collection[i].R = currTermNode.CurrentLossStateCollection.collection[i].R * MidAllocationStateCollection[jj].collection[i].R / childrenRaSum;
                        }

                        MidAllocationStateCollection[jj].collection[i].S = childNode.GetAllocState().collection[i].S;
                        //if (MidAllocationStateCollection[jj].collection[i].R > childNode.GetAllocState().collection[i].R ||
                        //      (MidAllocationStateCollection[jj].collection[i].R == childNode.GetAllocState().collection[i].R
                        //          && MidAllocationStateCollection[jj].collection[i].D > childNode.GetAllocState().collection[i].D))
                        //{
                        //    childNode.SetAllocState(MidAllocationStateCollection[jj]);
                        //    //childNode.GetAllocState().collection[i].R = MidAllocationStateCollection[jj].collection[i].R;
                        //    //childNode.GetAllocState().collection[i].D = MidAllocationStateCollection[jj].collection[i].D;
                        //}
                        jj++;
                    }
                }  //end of building i
                   //compare,always compare the summed, then pick the winner

                int ii = 0;
                foreach (CoverageAtomicRITE childNode in SubjectARITEs)
                {
                    if (MidAllocationStateCollection[ii].GetTotalSum.R > childNode.GetAllocState().GetTotalSum.R ||
                        (MidAllocationStateCollection[ii].GetTotalSum.R == childNode.GetAllocState().GetTotalSum.R &&
                         MidAllocationStateCollection[ii].GetTotalSum.D > childNode.GetAllocState().GetTotalSum.D))
                    {
                        childNode.SetAllocState(MidAllocationStateCollection[ii]);
                    }
                    ii++;
                }
            }
            else //not per-risk, but still allocate to per-building
            {
                AllocationStateCollection[] tempMid = new AllocationStateCollection[numOfChildren];
                j = 0;
                foreach (CoverageAtomicRITE childNode in SubjectARITEs)
                {
                    tempMid[j] = new AllocationStateCollection(1);
                    j++;
                }

                Double childrenDSum = SubjectARITEs.Sum(item => item.GetLossState().GetTotalSum.D);
                Double childrenRSum = SubjectARITEs.Sum(item => item.GetLossState().GetTotalSum.R);
                Double childrenSSum = SubjectARITEs.Sum(item => item.GetLossState().GetTotalSum.S);
                Double diffD        = currTermNode.GetLossState().GetTotalSum.D - childrenDSum;

                if (childrenRSum == 0)
                {
                    j = 0;
                    foreach (AtomicRITE childNode in SubjectARITEs)
                    {
                        tempMid[j].collection[0].R = currTermNode.GetLossState().GetTotalSum.R *childNode.GetLossState().GetTotalSum.S / childrenSSum;
                        j++;
                    }
                }
                else if (diffD >= 0)
                {
                    j = 0;
                    foreach (AtomicRITE childNode in SubjectARITEs)
                    {
                        tempMid[j].collection[0].R = childNode.GetLossState().GetTotalSum.R *(1 - diffD / childrenRSum);
                        tempMid[j].collection[0].D = childNode.GetLossState().GetTotalSum.S - childNode.GetLossState().GetTotalSum.X - tempMid[j].collection[0].R;
                        j++;
                    }
                }
                else
                {
                    j = 0;
                    foreach (AtomicRITE childNode in SubjectARITEs)
                    {
                        tempMid[j].collection[0].D = childNode.GetLossState().GetTotalSum.D *(1 + diffD / childrenDSum);
                        tempMid[j].collection[0].R = childNode.GetLossState().GetTotalSum.S - childNode.GetLossState().GetTotalSum.X - tempMid[j].collection[0].D;
                        j++;
                    }
                }

                Double childrenRaSum = tempMid.Sum(item => item.collection[0].R);
                int    k             = 0;

                if (diffD >= 0 && childrenRaSum == 0)
                {
                    foreach (CoverageAtomicRITE childNode in SubjectARITEs)
                    {
                        tempMid[k].collection[0].R = childNode.GetLossState().GetTotalSum.R;
                        k++;
                    }
                    childrenRaSum = tempMid.Sum(item => item.collection[0].R);
                }

                k = 0;
                foreach (CoverageAtomicRITE childNode in SubjectARITEs)
                {
                    if (currTermNode.GetLossState().GetTotalSum.R == 0)
                    {
                        tempMid[k].collection[0].R = 0;
                    }
                    else if (childrenRaSum > 0)
                    {
                        tempMid[k].collection[0].R = currTermNode.GetLossState().GetTotalSum.R *tempMid[k].collection[0].R / childrenRaSum;
                    }

                    if (tempMid[k].collection[0].R > childNode.GetAllocState().GetTotalSum.R ||
                        (tempMid[k].collection[0].R == childNode.GetAllocState().GetTotalSum.R&&
                         tempMid[k].collection[0].D > childNode.GetAllocState().GetTotalSum.D))
                    {
                        for (int i = 0; i < childNode.GetAllocState().NumBldgs; i++)
                        {
                            MidAllocationStateCollection[k].collection[i].D = tempMid[k].collection[0].D * childNode.GetAllocState().collection[i].S / childNode.GetAllocState().GetTotalSum.S;
                            MidAllocationStateCollection[k].collection[i].R = tempMid[k].collection[0].R * childNode.GetAllocState().collection[i].S / childNode.GetAllocState().GetTotalSum.S;
                            MidAllocationStateCollection[k].collection[i].S = childNode.GetAllocState().collection[i].S;
                        }
                        childNode.SetAllocState(MidAllocationStateCollection[k]);
                    }
                    k++;
                }
            }
        }
Beispiel #9
0
        private void AllocateOverlappedCoverNode(CoverNode currCoverNode, HashSet <CoverageAtomicRITE> SubjectARITEs)
        {
            int numOfChildren = SubjectARITEs.Count;

            //for cover node, always allocate as summed
            Double childrenRSum = SubjectARITEs.Sum(item => item.GetLossState().GetTotalSum.R);
            Double childrenSSum = SubjectARITEs.Sum(item => item.GetLossState().GetTotalSum.S);

            AllocationStateCollection[] MidAllocationStateCollection = new AllocationStateCollection[numOfChildren];

            int j = 0;

            foreach (CoverageAtomicRITE childNode in SubjectARITEs)
            {
                MidAllocationStateCollection[j] = new AllocationStateCollection(childNode.GetAllocState().NumBldgs);
                j++;
            }

            if (childrenRSum != 0)
            {
                j = 0;  //child
                foreach (CoverageAtomicRITE childNode in SubjectARITEs)
                {
                    //devided among children
                    double temp = currCoverNode.GetPayout() * childNode.GetLossState().GetTotalSum.R / childrenRSum;
                    for (int jj = 0; jj < childNode.GetAllocState().NumBldgs; jj++)
                    {
                        //divided among building
                        if (childNode.GetLossState().GetTotalSum.S > 0)
                        {
                            MidAllocationStateCollection[j].collection[jj].P = temp * childNode.GetLossState().collection[jj].S / childNode.GetLossState().GetTotalSum.S;
                        }
                        else
                        {
                            MidAllocationStateCollection[j].collection[jj].P = temp / childNode.GetAllocState().NumBldgs;
                        }
                    }
                    j++;
                }
            }
            else
            {
                j = 0;  //child
                foreach (CoverageAtomicRITE childNode in SubjectARITEs)
                {
                    //devided among children
                    double temp = currCoverNode.GetPayout() * childNode.GetLossState().GetTotalSum.S / childrenSSum;
                    for (int jj = 0; jj < childNode.GetAllocState().NumBldgs; jj++)
                    {
                        //divided among building
                        if (childNode.GetLossState().GetTotalSum.S > 0)
                        {
                            MidAllocationStateCollection[j].collection[jj].P = temp * childNode.GetLossState().collection[jj].S / childNode.GetLossState().GetTotalSum.S;
                        }
                        else
                        {
                            MidAllocationStateCollection[j].collection[jj].P = temp / childNode.GetAllocState().NumBldgs;
                        }
                    }
                    j++;
                }
            }

            j = 0;
            foreach (CoverageAtomicRITE childNode in SubjectARITEs)
            {
                for (int jj = 0; jj < childNode.GetAllocState().NumBldgs; jj++)
                {
                    MidAllocationStateCollection[j].collection[jj].P += childNode.GetAllocState().collection[jj].P;
                    MidAllocationStateCollection[j].collection[jj].S  = childNode.GetAllocState().collection[jj].S;
                }
                childNode.SetAllocState(MidAllocationStateCollection[j]);
                j++;
            }
        }
Beispiel #10
0
 public void SetAllocState(AllocationStateCollection allocState)
 {
     CurrentAllocationState = allocState;
 }
Beispiel #11
0
 public abstract void SetAllocState(AllocationStateCollection state);