Пример #1
0
        public override HashSet <AtomicRITE> GetAtomicRites()
        {
            if (!IsDerived)
            {
                HashSet <CoverageAtomicRITE> ARITEs = new HashSet <CoverageAtomicRITE>();

                foreach (ExposureType expType in ExposureTypes)
                {
                    var RITChars = Schedule.RITChars.Where(RitChar => RitChar.ExpType == expType || ExposureTypeCollection.GetMappedType(RitChar.ExpType) == expType);
                    foreach (RITCharacteristic RITChar in RITChars)
                    {
                        HashSet <String> temp = CauseOfLossSet.GetSubperils();
                        foreach (string subperil in temp)
                        {
                            ExposureType       tempType = ExposureTypeCollection.GetMappedType(RITChar.ExpType);
                            CoverageAtomicRITE tempRite = new CoverageAtomicRITE(subperil, tempType, RITChar.ParentRITE, RITChar.ID);
                            ARITEs.Add(tempRite);
                            //IEnumerable<RITCharacteristic> RITChars;
                            //RITChars = rite.RiskCharacteristics.Where(RitChar => RitChar.ExpType == expType || ExposureTypeCollection.GetMappedType(RitChar.ExpType) == expType);
                            //foreach (RITCharacteristic RitChar in RITChars)
                            //{
                            //    ARITEs.Add(new CoverageAtomicRITE(subperil, ExposureTypeCollection.GetMappedType(RitChar.ExpType), rite, RitChar.ID));
                            //}
                        }
                    }
                }

                return(new HashSet <AtomicRITE>(ARITEs.Cast <AtomicRITE>()));
            }
            else
            {
                //    throw new InvalidOperationException("Cannot get Atomic Rites for derived subjects!");
                return(new HashSet <AtomicRITE>());
            }
        }
Пример #2
0
        //public override float GetFactor()
        //{
        //    return PrimarySubject.Schedule.Factor;
        //}

        public override long GetFirstRITEcharID()
        {
            CoverageAtomicRITE cRite = PrimarySubject.GetAtomicRites().First() as CoverageAtomicRITE;

            //return cRite.RITE.ExposureID;  //used to be GetFirstRITEID().
            return(cRite.RITCharacterisiticID);  //TODO: shouldreturn RiteID.
        }
Пример #3
0
        public void GetGUForCoverageRITE(CoverageAtomicRITE aRITE)
        {
            double[]          GULossArray;
            uint              timestamp;
            string            error;
            RITCharacteristic RIT = aRITE.RITE.RiskCharacteristics.Where(RITChar => RITChar.ID == aRITE.RITCharacterisiticID).FirstOrDefault();

            if (GetRITCharacteristicLoss(RIT, aRITE.SubPeril, out GULossArray, out timestamp, out error, aRITE.RITE.ActNumOfBldgs))
            {
                aRITE.SetSubjectLoss(new LossTimeSeries(timestamp, GULossArray));
            }
            else
            {
                throw new GUInputEngineException(error);
            }
        }
Пример #4
0
        public void GetGUForCoverageRITE(CoverageAtomicRITE aRITE)
        {
            double[] GULossArray;
            uint     timestamp;
            string   error;

            RITCharacteristic RIT = aRITE.RITE.RiskCharacteristics.Where(RITChar => RITChar.ID == aRITE.RITCharacterisiticID).FirstOrDefault();

            if (GetRITCharacteristicLoss(RIT, aRITE.SubPeril, out GULossArray, out timestamp, out error, aRITE.RITE.ActNumOfSampleBldgs))
            {
                DateTime ActualTimeStamp = new DateTime(ContractYear, 1, 1);
                ActualTimeStamp = ActualTimeStamp.AddDays((double)timestamp - 1);
                aRITE.SetSubjectLoss(new LossTimeSeries(ActualTimeStamp, GULossArray));
            }
            else
            {
                throw new GUInputEngineException(error);
            }
        }
Пример #5
0
 public int GetNumOfBuildingsActual()
 {
     //return PrimarySubject.Schedule.ActNumOfBldgs; //TODO: change to use factor
     if (Subject is PrimarySubject)
     {
         PrimarySubject ps    = Subject as PrimarySubject;
         AtomicRITE     aRite = Subject.GetAtomicRites().First();
         if (aRite is CoverageAtomicRITE)
         {
             CoverageAtomicRITE cRite = aRite as CoverageAtomicRITE;
             return(cRite.RITE.ActNumOfSampleBldgs);
         }
         else
         {
             return(1);
         }
     }
     else
     {
         return(1);
     }
 }
Пример #6
0
        private void ExecuteOverlappedGraph(GUInputEngine guLossesEngine)
        {
            List <int> levelList = new List <int>();

            foreach (int aLevel in graph.LevelNodeDict.Keys)
            {
                levelList.Add(aLevel);
            }


            for (int i = levelList.Max(); i > 0; i--)
            {
                HashSet <CoverageAtomicRITE> wholeList = new HashSet <CoverageAtomicRITE>();
                foreach (GraphNode currNode in graph.LevelNodeDict[i])
                {
                    //they should be all TermNode
                    TermNode currTermNode = currNode as TermNode;

                    //find its AtomicRITEs
                    HashSet <AtomicRITE> SubjectARITEs = currTermNode.AllAtomicRITEs; //currTermNode.GetAtomicRites();

                    //HashSet<CoverageAtomicRITE> SubjectCRITEs = currTermNode.AllAtomicRITEs;
                    HashSet <CoverageAtomicRITE> SubjectCRITEs = new HashSet <CoverageAtomicRITE>();

                    foreach (AtomicRITE aRite in SubjectARITEs)
                    {
                        CoverageAtomicRITE cRite = aRite as CoverageAtomicRITE;
                        if (cRite == null)
                        {
                            throw new InvalidOperationException("Overlap AtomicRite has to be all CoverageAtomicRite");
                        }

                        SubjectCRITEs.Add(cRite);
                    }
                    List <GraphNode> childrenNodes = new List <GraphNode>();
                    childrenNodes = graph.GetChildrenForNode(currTermNode);

                    ExecuteOverlappedTermNode(currTermNode, childrenNodes, guLossesEngine, SubjectCRITEs);
                    currTermNode.Executed = true;
                    AllocateOverlappedTermNode(currTermNode, SubjectCRITEs);  //allocate back to the AtomicRites
                    wholeList.UnionWith(SubjectCRITEs);
                }

                //when this level is done, for each child AtomicRite
                //then copy the Allocated value to Loss value for next iteration
                foreach (CoverageAtomicRITE childNode in wholeList)
                {
                    //first compare AllocationState, Per-Building or Summed Wins
                    //if (childNode.GetAllocState().GetTotalSum.R > childNode.GetAllocationStateSummed().R ||
                    //    (childNode.GetAllocState().GetTotalSum.R == childNode.GetAllocationStateSummed().R &&
                    //    childNode.GetAllocState().GetTotalSum.D > childNode.GetAllocationStateSummed().D))
                    //{
                    for (int j = 0; j < childNode.RITE.ActNumOfBldgs; j++)
                    {
                        //childNode.GetLossState().collection[j].S = childNode.GetAllocationState().collection[j].S;
                        childNode.GetLossState().collection[j].R = childNode.GetAllocState().collection[j].R;
                        childNode.GetLossState().collection[j].D = childNode.GetAllocState().collection[j].D;
                        childNode.GetLossState().collection[j].X = childNode.GetLossState().collection[j].S - childNode.GetLossState().collection[j].R - childNode.GetLossState().collection[j].D;

                        childNode.GetAllocState().collection[j].R = 0;            //refresh to be compared
                    }
                    //}
                    //else
                    //{
                    //    double loss = childNode.GetLossState().GetTotalSum.S;
                    //    childNode.ResetLossState(1);
                    //    childNode.GetLossState().collection[0].S = loss;
                    //    childNode.GetLossState().collection[0].R = childNode.GetAllocationStateSummed().R;
                    //    childNode.GetLossState().collection[0].D = childNode.GetAllocationStateSummed().D;
                    //    childNode.GetLossState().collection[0].X = childNode.GetLossState().collection[0].S - childNode.GetLossState().collection[0].R - childNode.GetLossState().collection[0].D;

                    //    //reset R for next level comparison
                    //    childNode.GetAllocationStateSummed().R = 0;
                    //}
                }
            }
            //then lelve i = 0, all are bottom CoverNode's which are connected to TermNode
            foreach (CoverNode currCoverNode in graph.LevelNodeDict[0])
            {                                                                              //simple sum up all children's R
                HashSet <AtomicRITE>         SubjectARITEs = currCoverNode.AllAtomicRITEs; //currCoverNode.AllAtomicRITEs;
                HashSet <CoverageAtomicRITE> SubjectCRITEs = new HashSet <CoverageAtomicRITE>();
                foreach (AtomicRITE aRite in SubjectARITEs)
                {
                    CoverageAtomicRITE cRite = aRite as CoverageAtomicRITE;
                    SubjectCRITEs.Add(cRite);
                }
                //HashSet<CoverageAtomicRITE> SubjectCRITEs = currCoverNode.Subject.GetAtomicRites();
                currCoverNode.Payout = SubjectCRITEs.Sum(item => item.GetLossState().GetTotalSum.R);
                CoverNodeFunctionalEngine coverNodeFuncEng = new CoverNodeFunctionalEngine(currCoverNode);
                coverNodeFuncEng.CoverNodeFunction();
                currCoverNode.Executed = true;
                AllocateOverlappedCoverNode(currCoverNode, SubjectCRITEs);
            }
        }