Exemple #1
0
        AggregateAndFilter(Dictionary <string, Dictionary <int, Dictionary <long, Tuple <double, uint, List <float> > > > > inputDict)
        {
            Dictionary <string, Dictionary <int, Dictionary <long, Tuple <List <double>, List <uint>, List <float> > > > > outputDict = new Dictionary <string, Dictionary <int, Dictionary <long, Tuple <List <double>, List <uint>, List <float> > > > >();
            AggregateRITEMapper aggregateRITEmapper = mapper.GetAggregateMapper();
            bool UseAggragatRITEs = aggregateRITEmapper.UseAggregateMapping;

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

                foreach (KeyValuePair <long, Tuple <double, uint, List <float> > > pair in LossesByRITE)
                {
                    long currentRITEId = pair.Key;

                    if (aggregateRITEmapper.RITEInContract(currentRITEId))
                    //if (true) // Sunny Hack remove Immeadiateley !!!!!!!!!!!
                    {
                        long originalAggregateRITEID = aggregateRITEmapper.OriginalAggregateID(currentRITEId);
                        int  NumOfSamples            = LossesByRITE[currentRITEId].Item3.Count;

                        if (AggregatedLossesByRITE.ContainsKey(originalAggregateRITEID))
                        {
                            //Set Factors
                            AggregatedLossesByRITE[originalAggregateRITEID].Item1.AddRange(Enumerable.Repeat(LossesByRITE[currentRITEId].Item1, NumOfSamples));
                            //Set Timestamps
                            AggregatedLossesByRITE[originalAggregateRITEID].Item2.AddRange(Enumerable.Repeat(LossesByRITE[currentRITEId].Item2, NumOfSamples));
                            //Set GULoss
                            AggregatedLossesByRITE[originalAggregateRITEID].Item3.AddRange(LossesByRITE[currentRITEId].Item3);
                        }
                        else
                        {
                            AggregatedLossesByRITE[originalAggregateRITEID] = new Tuple <List <double>, List <uint>, List <float> >(
                                Enumerable.Repeat(LossesByRITE[currentRITEId].Item1, NumOfSamples).ToList(),
                                Enumerable.Repeat(LossesByRITE[currentRITEId].Item2, NumOfSamples).ToList(),
                                new List <float>(LossesByRITE[currentRITEId].Item3));
                        }
                    }
                }

                outputDict.Add(subperil, new Dictionary <int, Dictionary <long, Tuple <List <double>, List <uint>, List <float> > > >
                {
                    { 0, AggregatedLossesByRITE }
                });
            }

            return(outputDict);
        }
Exemple #2
0
 public GULossTransformer(IRITEindexMapper _mapper)
 {
     mapper = _mapper;
     aggreagetRITEmapper = mapper.GetAggregateMapper();
 }