示例#1
0
        private void ConvertToGU(Dictionary <string, Dictionary <int, Dictionary <long, Tuple <double, uint, List <float> > > > > drLossDict, IRITEindexMapper mapper)
        {
            int[]   orderedNumOfBldgsList = mapper.GetOrderedNumBldgs();
            float[] TIVarray = mapper.GetOrderedTIVArray();

            foreach (string subperil in drLossDict.Keys)
            {
                Dictionary <long, Tuple <double, uint, List <float> > > LossesByRITE = drLossDict[subperil][0];

                foreach (KeyValuePair <long, Tuple <double, uint, List <float> > > pair in LossesByRITE)
                {
                    int          indexOfRITE = mapper.GetMappedIndex(pair.Key);
                    int          NumBldgs    = orderedNumOfBldgsList[indexOfRITE];
                    List <float> losses      = pair.Value.Item3;
                    for (int bldgID = 0; bldgID < NumBldgs; bldgID++)
                    {
                        float bldgTIV = TIVarray[mapper.GetMappedIndex(pair.Key, bldgID, subperil)];
                        losses[bldgID] = losses[bldgID] * bldgTIV; //TODO: raintest
                        //losses[bldgID] = 100;
                    }
                }
            }
        }
示例#2
0
        public IVectorEvent DictToVector(Dictionary <string, Dictionary <int, Dictionary <long, Tuple <double, uint, List <float> > > > > drLossDict)
        {
            //First filter losses by contract and group losses by aggregate RITEs
            Dictionary <string, Dictionary <int, Dictionary <long, Tuple <List <double>, List <uint>, List <float> > > > > PostAggregateDrDict;

            PostAggregateDrDict = AggregateAndFilter(drLossDict);

            float[] GULossVector     = new float[mapper.TotalNumIndexes];
            float[] FactorVector     = new float[mapper.TotalNumBldgs];
            uint[]  TimeStampsVector = new uint[mapper.TotalNumIndexes];

            int[] orderedNumOfBldgsList = mapper.GetOrderedNumBldgs();

            bool firstSubperil = true;

            foreach (string subperil in drLossDict.Keys)
            {
                Dictionary <long, Tuple <List <double>, List <uint>, List <float> > > LossesByRITE = PostAggregateDrDict[subperil][0];

                foreach (KeyValuePair <long, Tuple <List <double>, List <uint>, List <float> > > pair in LossesByRITE)
                {
                    int indexOfRITE = mapper.GetMappedIndex(pair.Key);
                    //int NumBldgs = orderedNumOfBldgsList[indexOfRITE];

                    List <float> losses          = pair.Value.Item3;
                    int          NumOfSubSamples = losses.Count;

                    //Get Factors and Gu Losses
                    if (firstSubperil)
                    {
                        for (int subSampleID = 0; subSampleID < NumOfSubSamples; subSampleID++)
                        {
                            //Get GU loss from dictionary
                            int IndexInGULossVector = mapper.GetMappedIndex(pair.Key, subSampleID, subperil);
                            GULossVector[IndexInGULossVector] = losses[subSampleID];

                            //Get factor from dictionary
                            int IndexInFactorVector = mapper.GetMappedFactorIndex(pair.Key, subSampleID);
                            FactorVector[IndexInFactorVector] = (float)pair.Value.Item1[subSampleID];

                            //Get Time Stamp from dictionary
                            //int IndexInTimeStampsVector = mapper.GetMappedIndex(pair.Key, subSampleID, subperil);
                            TimeStampsVector[IndexInGULossVector] = pair.Value.Item2[subSampleID];
                        }
                    }
                    else
                    {
                        for (int subSampleID = 0; subSampleID < NumOfSubSamples; subSampleID++)
                        {
                            //Get GU loss from dictionary
                            int IndexInGULossVector = mapper.GetMappedIndex(pair.Key, subSampleID, subperil);
                            GULossVector[IndexInGULossVector] = losses[subSampleID];

                            //Get Time Stamp from dictionary
                            //int IndexInTimeStampsVector = mapper.GetMappedIndex(pair.Key, subSampleID, subperil);
                            TimeStampsVector[IndexInGULossVector] = pair.Value.Item2[subSampleID];
                        }
                    }
                }

                firstSubperil = false;
            }

            return(new VectorLossEvent(GULossVector, FactorVector, TimeStampsVector));
        }