//Filter TimeStamp based on Inception Date and Expiration Date & Find the earliest TimeStamp for the Event private void FilterGULoss(IVectorEvent output, long ContractID) { float[] LossVector = output.LossVector; uint[] TimeStamps = output.TimeStamps; int Length = LossVector.Length; DateTime inception = ContractDeclarationsSet[ContractID].Inception; DateTime expiration = ContractDeclarationsSet[ContractID].Expiration; uint MinTimeStamp = uint.MaxValue; for (int i = 0; i < Length; i++) { //Find earliest TimeStamp for the Event; if (TimeStamps[i] > 0 && TimeStamps[i] < MinTimeStamp) { MinTimeStamp = TimeStamps[i]; } DateTime AriteExpiration = inception.AddDays((double)TimeStamps[i]); if (AriteExpiration > expiration) { LossVector[i] = 0; } } DateTime EventStartTime = new DateTime(inception.Year, 1, 1); EventStartTime = EventStartTime.AddDays((double)MinTimeStamp - 1); EventStartDate.Add(ContractID, EventStartTime); }
public GULossAdaptor(IRITEindexMapper _mapper, IVectorEvent _guLossVector, Dictionary <long, Declarations> _declarationsSet, bool _convertToGU = true) { //mapper = _mapper; //ContractDeclarations = _contractDeclarations; //AllocationHelper = new AllocatedLossAdaptor(_mapper, ContractDeclarations); //drLossEvent = _guLossVector; //lossType = GULossType.Vector; //transformer = new GULossTransformer(mapper); //convertToGU = _convertToGU; throw new NotSupportedException("Losses of Vector type input is no longer supported"); }
public ReferenceResultOutput Execute(long conID, GraphType type, IVectorEvent guLossEvent) { //ExposureDataAdaptor expData = PDataAdaptor.GetExposureAdaptor(conID); //string error; //IRITEindexMapper indexMapper = GetMapper(expData); //GraphInfo graphInfo = GetGraph(type, expData, indexMapper); //Graph graph = graphInfo.Graph; //GULossAdaptor guLossAdaptor = new GULossAdaptor(indexMapper, guLossEvent, graph.Declarations, true); //GraphExecuterAdaptor MainExecuter = new GraphExecuterAdaptor(graphInfo); //return MainExecuter.RunExecution(guLossAdaptor); throw new NotSupportedException("Reference Prototype no longer supports Vector type input!"); }
public IVectorEvent GenerateRITELoss(int eventID) { Dictionary <string, Dictionary <int, Dictionary <long, Tuple <double, uint, List <float> > > > > IntialGULoss; if (GUgenerator.GenerateRITELoss(eventID)) { IntialGULoss = GUgenerator.GULosses; } else { throw new InvalidOperationException("Cannot get ground-up loss for event: " + eventID); } GULossTransformer transformer = new GULossTransformer(indexMapper); IVectorEvent VectorGU = transformer.DictToVector(IntialGULoss); return(VectorGU); }
private static void TestGULossVector(PartitionData pd, long conID) { //Default SubSampling Settings SubSamplingAnalysisSetting subSamplingSettings = new SubSamplingAnalysisSetting(false, 1, 0, 250, "", ""); PartitionDataAdpator PDataAdap = new PartitionDataAdpator(pd, subSamplingSettings); ExposureDataAdaptor expData = PDataAdap.GetExposureAdaptor(conID); ISubPerilConfig subperilInfo = new RMSSubPerilConfig(); IRITEindexMapper mapper = new RITEmapper1(expData, new RAPSettings(new HashSet <string> { "EQ" }), subperilInfo); HashSet <String> subperils = new HashSet <string> { "EQ", "WS" }; VectorGUInputGeneratorFactory vectorgeneratorFactory = new VectorGUInputGeneratorFactory(pd, new HashSet <string> { "EQ" }, TimeStyle.ConstantTimeStamps, LossStyle.GroundUp, true, subSamplingSettings); VectorGUInputGenerator ReferenceEventGen = vectorgeneratorFactory.GetGeneratorForContract(conID); IVectorEvent Event = ReferenceEventGen.GenerateRITELoss(1); }
public GULossInputEngine(IGraphState _graphstate, IExecutableMatrixGraph _graph, IVectorEvent _event) { graphstate = _graphstate; graph = _graph; Event = _event; }
public static void TestReferenceSpeed(GraphType type, PartitionData PD, int conIndex, COLCollection COLSet) { RAPSettings settings = new RAPSettings(COLSet.GetSubperils()); //Default SubSampling Settings SubSamplingAnalysisSetting subSamplingSettings = new SubSamplingAnalysisSetting(false, 1, 0, 250, "", ""); //NGFMPrototype NGFM = new NGFMPrototype(PD); ReferencePrototype Reference = new ReferencePrototype(PD, settings, subSamplingSettings); Reference.ReferencePrepare(GraphType.Auto); NGFMPrototype NGFM = new NGFMPrototype(); NGFM.Prepare(PD); //NGFM result is cached, so create another object for each event double MicroSecondTicks = Stopwatch.Frequency / 1000000.0; Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); NGFM.Prepare(PD); //NGFM result is cached, so create another object for each event stopwatch.Stop(); double NGFMGraphTime = Convert.ToDouble(stopwatch.ElapsedTicks) / MicroSecondTicks; PartitionDataAdpator PDataAdap = new PartitionDataAdpator(PD, subSamplingSettings); ExposureDataAdaptor expData = PDataAdap.GetExposureAdaptor(conIndex); GUInputGeneratorFactory generatorFactory = new GUInputGeneratorFactory(PD, COLSet, subSamplingSettings, TimeStyle.ConstantTimeStamps, LossStyle.DamagaeRatio); GUInputGenerator NGFMEventGen = generatorFactory.GetGeneratorForContract(conIndex); VectorGUInputGeneratorFactory vectorgeneratorFactory = new VectorGUInputGeneratorFactory(PD, COLSet.GetSubperils(), TimeStyle.ConstantTimeStamps, LossStyle.GroundUp, true, subSamplingSettings); VectorGUInputGenerator ReferenceEventGen = vectorgeneratorFactory.GetGeneratorForContract(conIndex); int counter = 0; int total = 0; Console.WriteLine("State at: " + DateTime.Now.ToString("h:mm:ss tt")); //NGFMPrototype NGFM = new NGFMPrototype(PD); for (int i = 1; i < 100; i += 1) { Dictionary <string, Dictionary <int, Dictionary <long, Tuple <double, uint, List <float> > > > > NGFMguLoss; //Dictionary<string, Dictionary<int, Dictionary<long, Tuple<double, uint, List<float>>>>> RefguLoss; if (NGFMEventGen.GenerateRITELoss(i)) { NGFMguLoss = NGFMEventGen.GULosses; } else { throw new InvalidOperationException("Cannot get ground-up loss for event: " + i); } IVectorEvent RefguLoss = ReferenceEventGen.GenerateRITELoss(i); stopwatch = new Stopwatch(); stopwatch.Start(); double ReferencePayout = Reference.Execute(conIndex, type, RefguLoss).TotalPayout; stopwatch.Stop(); double ReferenceTime = Convert.ToDouble(stopwatch.ElapsedTicks) / MicroSecondTicks; stopwatch.Reset(); stopwatch.Start(); double NGFMpayout = 0; //double NGFMpayout = NGFM.ExecuteFM(NGFMguLoss)[conIndex]; RMS.ContractObjectModel.ResultPosition result = NGFM.ProcessEvent(i, NGFMguLoss, true, 1, new long[] { conIndex })[conIndex]; NGFMpayout = result.PayOut; stopwatch.Stop(); double NGFMTime = Convert.ToDouble(stopwatch.ElapsedTicks) / MicroSecondTicks; double diff = NGFMTime - ReferenceTime; Console.WriteLine("Event ID: " + i + " || " + "NGFM: " + NGFMTime + " || " + "Reference: " + ReferenceTime + " || " + diff); } Console.WriteLine("total event = " + total); Console.WriteLine("NGFM Graph Building Time = " + NGFMGraphTime); Console.WriteLine("End at: " + DateTime.Now.ToString("h:mm:ss tt")); Console.ReadLine(); }
private static void TestMatrixHDFM(PartitionData pd, long conID) { Stopwatch sw = new Stopwatch(); //Default SubSampling Settings SubSamplingAnalysisSetting subSamplingSettings = new SubSamplingAnalysisSetting(false, 1, 0, 250, "", ""); PartitionDataAdpator PDataAdap = new PartitionDataAdpator(pd, subSamplingSettings); ExposureDataAdaptor expData = PDataAdap.GetExposureAdaptor(conID); ISubPerilConfig subperilInfo = new RMSSubPerilConfig(); HashSet <String> subperils = new HashSet <string> { "WI" }; IRITEindexMapper mapper = new RITEmapper1(expData, new RAPSettings(subperils), subperilInfo); VectorGUInputGeneratorFactory vectorgeneratorFactory = new VectorGUInputGeneratorFactory(pd, subperils, TimeStyle.ConstantTimeStamps, LossStyle.GroundUp, true, subSamplingSettings); VectorGUInputGenerator vectorGenerator = vectorgeneratorFactory.GetGeneratorForContract(conID); FixedMatrixGraphJPTY JPTYGraph = new FixedMatrixGraphJPTY(expData); JPTYGraph.Initialize(); MatrixGraphExecuter executer = new MatrixGraphExecuter(JPTYGraph); int NumOfEvents = 100; double totalTime = 0; for (int eventId = 6; eventId < NumOfEvents; eventId++) { IVectorEvent Event = vectorGenerator.GenerateRITELoss(eventId); sw.Start(); float payout = (float)(executer.Run(Event).TotalPayOut); sw.Stop(); long test = sw.ElapsedMilliseconds; //totalTime += sw.Elapsed.TotalMilliseconds; } double avgTime = sw.Elapsed.TotalMilliseconds / NumOfEvents; double avgGraphState = executer.IniGraphState.Elapsed.TotalMilliseconds / NumOfEvents; double avgAggregation = executer.Aggregation.Elapsed.TotalMilliseconds / NumOfEvents; double avgInteraction = executer.Interaction.Elapsed.TotalMilliseconds / NumOfEvents; double avgFillARite = executer.AssignGUtoARite.Elapsed.TotalMilliseconds / NumOfEvents; double avgSumByPattern = executer.Aggregation1.Elapsed.TotalMilliseconds / NumOfEvents; double avgAllocation = executer.Allocationtimer.Elapsed.TotalMilliseconds / NumOfEvents; Console.WriteLine("For " + NumOfEvents + " Events avg execution time is " + avgTime + " Milliseconds"); Console.WriteLine("For" + NumOfEvents + "avg GraphState Instantiation is " + avgGraphState + "Milliseconds"); Console.WriteLine("For" + NumOfEvents + "avg Aggregation is " + avgAggregation + "Milliseconds"); Console.WriteLine("For" + NumOfEvents + "avg Interaction is " + avgInteraction + "Milliseconds"); Console.WriteLine("For" + NumOfEvents + "avg Assigning GU to Arites is " + avgFillARite + "Milliseconds"); Console.WriteLine("For" + NumOfEvents + "avg SumArrayByPattern is " + avgSumByPattern + "Milliseconds"); Console.WriteLine("For" + NumOfEvents + "avg allocation time is " + avgAllocation + "Milliseconds"); Console.ReadLine(); }
//public float Execute_For(int eventID, IVectorEvent Event) //{ // ILossState lossState = new LossState(Graph); // GULossInputEngine inputEngine = new GULossInputEngine(lossState, Graph, Event); // inputEngine.Run(); // //lowest level, no children // int i = Graph.NumOfLevels - 1; // ILevelFinancialInfo thisLevelInfo = Graph.GetTermLevelInfo(i); // int lowestlevelsize = Graph.GetAggLevelInfo(i).LevelSize; // float[] codeDed = thisLevelInfo.GetCodedMinDeds().ToArray(); // float[] codeLim = thisLevelInfo.GetCodedLimits().ToArray(); // //allLevelState[i] = new LevelState(thisLevelInfo.LevelSize); // //int currSeed = 31 + eventID; // //var RandGen = new Random(currSeed); // if (!thisLevelInfo.HasMaxDed && !thisLevelInfo.HasPercentDed) // { // for (int j = 0; j < lowestlevelsize; j++) // { // allLevelState[i].SubjectLoss[j] = guloss; // allLevelState[i].Excess[j] = Math.Max(0, guloss - codeLim[j]); // allLevelState[i].Deductible[j] = Math.Min(guloss, codeDed[j]); // allLevelState[i].Recoverable[j] = allLevelState[i].SubjectLoss[j] - allLevelState[i].Excess[j] - allLevelState[i].Deductible[j]; // } // } // //upper levels // for (i = Graph.NumOfLevels - 2; i >= 0; i--) // { // thisLevelInfo = Graph.GetTermLevelInfo(i); // ILevelInfo childLevelInfo = Graph.GetTermLevelInfo(i + 1); // float[] dedFromBelow; // float[] excessFromBelow; // float[] subjectLossFromBelow; // float[] recovFromBelow; // bool SimplyCopy = false; // if (SimplyCopy) // { // dedFromBelow = allLevelState[i + 1].Deductible; // excessFromBelow = allLevelState[i + 1].Excess; // subjectLossFromBelow = allLevelState[i + 1].SubjectLoss; // recovFromBelow = allLevelState[i + 1].Recoverable; // } // else // { // dedFromBelow = Utilities.SumArrayByPartitionUsingFor(allLevelState[i + 1].Deductible, childLevelInfo.GetAggregationPartitions()); // excessFromBelow = Utilities.SumArrayByPartitionUsingFor(allLevelState[i + 1].Excess, childLevelInfo.GetAggregationPartitions()); // subjectLossFromBelow = Utilities.SumArrayByPartitionUsingFor(allLevelState[i + 1].SubjectLoss, childLevelInfo.GetAggregationPartitions()); // recovFromBelow = Utilities.SumArrayByPartitionUsingFor(allLevelState[i + 1].Recoverable, childLevelInfo.GetAggregationPartitions()); // } // codeDed = thisLevelInfo.GetCodedMinDeds().ToArray(); // codeLim = thisLevelInfo.GetCodedLimits().ToArray(); // allLevelState[i] = new LevelState(thisLevelInfo.LevelSize); // if (!thisLevelInfo.HasMaxDed && !thisLevelInfo.HasPercentDed) // { // for (int j = 0; j < thisLevelInfo.LevelSize; j++) // { // allLevelState[i].SubjectLoss[j] = subjectLossFromBelow[j]; // allLevelState[i].Excess[j] = Math.Max(excessFromBelow[j], Math.Max(0, subjectLossFromBelow[j] - codeLim[j])); // allLevelState[i].Deductible[j] = Math.Max(dedFromBelow[j], Math.Min(subjectLossFromBelow[j], codeDed[j])); // allLevelState[i].Recoverable[j] = allLevelState[i].SubjectLoss[j] - allLevelState[i].Excess[j] - allLevelState[i].Deductible[j]; // float deltaD = allLevelState[i].Deductible[j] - dedFromBelow[j]; // if (deltaD >= 0) // { // allLevelState[i].AllocateRatioR[j] = 1 - deltaD / recovFromBelow[j]; // allLevelState[i].AllocateRatioD[j] = 1; // } // else // { // allLevelState[i].AllocateRatioR[j] = 1; // allLevelState[i].AllocateRatioD[j] = 1 - deltaD / dedFromBelow[j]; // } // } // } // } // Graph.AllLevelState = allLevelState; // return allLevelState[0].Recoverable[0]; //} //test:delete later //public float Run(IVectorEvent Event) public MatrixResultOutput Run(IVectorEvent Event) { MatrixResultOutput output = new MatrixResultOutput(); //this is to store (utlitmately output) the total GU loss for all top Term Level SubjectLoss + LowestCoverLevel's ResidualRites SubjectLoss //the loss is accumulated throught each term level and the lowest cover level float TotalGULoss = 0; IniGraphState.Start(); IGraphState graphState = new GraphState(Graph); IniGraphState.Stop(); //Get GU AssignGUtoARite.Start(); GULossInputEngine inputEngine = new GULossInputEngine(graphState, Graph, Event); inputEngine.Run(); AssignGUtoARite.Stop(); //Get Factors FactorInputEngine factorEngine = new FactorInputEngine(graphState, Graph, Event); factorEngine.Run(); float[] FactorVector = Event.Factors; //this is for TotalCoverState, only used to aggregate Cover Levels //If there is no term, only covers, we get lowest atomic rites, then return; //float topLevelPayout =0; if (Graph.NumOfLevels > 1) { //Check Contract level Ded and Sublimit Type (Absorbabel or Net of Deductible), and choose the correct Term Engine //which will have diff method to apply interaction bool NetOfDeductible = Graph.ContractInfo.SublimitIsNetOfDeductible; bool DedIsAbsorbable = Graph.ContractInfo.DedIsAbsorbable; ITermEngine TermEngine; if (NetOfDeductible && DedIsAbsorbable) { TermEngine = new TermEngine1(); } else if (!NetOfDeductible && !DedIsAbsorbable) { TermEngine = new TermEngine4(); } else if (NetOfDeductible && !DedIsAbsorbable) { TermEngine = new TermEngine3(); } else { TermEngine = new TermEngine2(); } #region Sunny Test max possible speed//// delete/comment out now! Or ask Sunny !!!!!!! //double[] covA_Alloc = ConverterForTestRun(graphState.GetARITELevelState(2).GetSubjectLoss()); //double[] covC_Alloc = ConverterForTestRun(graphState.GetARITELevelState(3).GetSubjectLoss()); //SunnyTesttimer.Start(); ////double payout = TestRunDouble(covA_Alloc, covC_Alloc); //double payout = TestRun(graphState); //SunnyTesttimer.Stop(); #endregion //Loop through all levels in Graph IAggregator Aggregator = new Aggregator1(); int lowestlevel = Graph.LowestLevel; for (int i = lowestlevel; i > 0; i--) { Aggregation.Start(); ILevelState parentTermLevelState = graphState.GetTermLevelState(i - 1); ILevelAtomicRITEInfo childaRITEInfo = Graph.GetAtomicRITEInfo(i); ISimpleLevelState childaRITELevelState = graphState.GetARITELevelState(i); //Aggregate level to parents if (i == lowestlevel) { Aggregator.AggregateLevel(childaRITELevelState, parentTermLevelState, childaRITEInfo); //TotalGULoss += childaRITELevelState.GetSubjectLoss().Zip(childaRITELevelState.GetFactors(), (x1, x2) => x1*x2).Sum(); } else { ILevelNodeAggInfo childNodeAggInfo = Graph.GetNodeAggInfo(i); ILevelState childTermLevelState = graphState.GetTermLevelState(i); Aggregator.AggregateLevel(childTermLevelState, childaRITELevelState, parentTermLevelState, childNodeAggInfo, childaRITEInfo, aggregation1); //TotalGULoss += childaRITELevelState.GetSubjectLoss().Zip(childaRITELevelState.GetFactors(), (x1, x2) => x1 * x2).Sum(); } Aggregation.Stop(); //Do GULoss if (i == 1) { TotalGULoss += parentTermLevelState.GetSubjectLoss().Zip(parentTermLevelState.GetFactors(), (x1, x2) => x1 * x2).Sum(); } //Apply finacial terms to level Interaction.Start(); ILevelFinancialInfo parentlevelFinInfo = Graph.GetTermLevelInfo(i - 1); ILevelNodeAggInfo parentlevelaggInfo = Graph.GetNodeAggInfo(i - 1); bool HasMaxDed = Graph.GetTermLevelInfo(i - 1).HasMaxDed; bool HasFranchise = Graph.GetTermLevelInfo(i - 1).HasFranchiseDed; if (i == lowestlevel) { TermEngine.InteractionOnLowestTermLevel(parentTermLevelState, parentlevelFinInfo, parentlevelaggInfo.NumOfNodes); } else { TermEngine.ApplyInteraction(parentTermLevelState, parentlevelFinInfo, parentlevelaggInfo.NumOfNodes); } Interaction.Stop(); } //float topLevelPayout = graphState.GetTermLevelState(0).GetRecoverable()[0]; //topLevelPayout = graphState.GetTermLevelState(0).GetRecoverable().Sum(); //Allocate & loop through each level to get AriteR MatrixGraphAllocation Allocator = new MatrixGraphAllocation(Graph, graphState); allocationtimer.Start(); Allocator.Run(); allocationtimer.Stop(); //float AllocatedFinalPayout = 0; //for (int i = 0; i <= lowestlevel; i++) //{ // float[] AriteR = graphState.GetARITELevelState(i).GetRecoverable(); // AllocatedFinalPayout += AriteR.Sum(); //} //topLevelPayout = AllocatedFinalPayout; } //else //{ // ISimpleLevelState childaRITELevelState = graphState.GetARITELevelState(0); // topLevelPayout = childaRITELevelState.GetSubjectLoss().Sum(); //} //Execute covers after terms: int lowestCoverLevel = Graph.LowestCoverLevel; int NumOfCoverLevels = Graph.NumOfCoverLevels; ICoverLevelResiduleInfo ResiduleInfo = Graph.GetCoverResiduleInfo(); ICoverLevelTermAriteInfo AriteInfo = Graph.GetCoverAriteInfo(); ICoverState ResiduleState = graphState.GetLowestCoverLevelResiduleState(); ICoverState AriteState = graphState.GetLowestCoverLevelAriteState(); ICoverState TotalCoverState = graphState.GetTotalCoverState(); ICoverAggregator CoverAggregator = new CoverAggregator(); //int StartPosition=0; //int EndPosition = Graph.GetCoverNodeAggInfo(Graph.LowestCoverLevel).NumOfNodes; int CalculationStartPosition = 0; int ParentStartPosition = Graph.GetCoverNodeAggInfo(Graph.LowestCoverLevel + 1).NumOfNodes; int TopCoverLevel = lowestCoverLevel + NumOfCoverLevels; float TotalPayout = 0; //Get Subject Loss for the lowest cover level (GU & Recoverable) CoverInputEngine CoverinputEngine = new CoverInputEngine(graphState, Graph, Event); CoverinputEngine.Run(); for (int i = lowestCoverLevel; i < TopCoverLevel; i++) { //Aggregation: if (i == lowestCoverLevel) { CoverAggregator.AggregateLowestLevel(ResiduleInfo, AriteInfo, ResiduleState, AriteState, TotalCoverState, graphState.GetLowestCoverLevelAriteAllocationRatio(), graphState.GetLowestCoverLevelResidualAllocationRatio()); TotalGULoss += ResiduleState.GetSubjectLoss().Zip(ResiduleState.GetFactors(), (x1, x2) => x1 * x2).Sum(); } else { ICoverAllocationState currLevelAllocationRatio = graphState.GetCoverLevelAllocationRatioState(i); ICoverLevelNodeAggInfo ChildrenLevelAggInfo = Graph.GetCoverNodeAggInfo(i); IDerivedCoverLevelNodeAggInfo DerivedInfo = Graph.GetDerivedCoverNodeAggInfo(i + 1); CoverAggregator.AggregateLevel(ParentStartPosition, TotalCoverState, ChildrenLevelAggInfo, DerivedInfo, currLevelAllocationRatio, FactorVector); ParentStartPosition += Graph.GetCoverNodeAggInfo(i + 1).NumOfNodes; } //Apply Financial Terms to parent level ICoverLevelFinancialInfo ParentLevelFinInfo = Graph.GetCoverLevelInfo(i + 1); ICoverEngine CoverEngine = new CoverEngine(); int[] LeafTopCoverList = Graph.GetCoverNodeAggInfo(lowestCoverLevel + 1).GetLeafTopCoverList(); if (i != TopCoverLevel - 1) { CoverEngine.ApplyCoverLayer(ParentLevelFinInfo, CalculationStartPosition, TotalCoverState); } else { TotalPayout = CoverEngine.ApplyTopCoverLayer(ParentLevelFinInfo, CalculationStartPosition, TotalCoverState, LeafTopCoverList, FactorVector); } //Reset Position for next loop CalculationStartPosition = ParentStartPosition; } //Allocate cover graph payout coverAllocationtimer.Start(); MatrixCoverGraphAllocation CoverAllocator = new MatrixCoverGraphAllocation(Graph, graphState); CoverAllocator.Run(); coverAllocationtimer.Stop(); output.TotalGULoss = TotalGULoss; output.TotalPayOut = TotalPayout; //combine allocated Residual loss&indicies and Arite loss&indicies for output output.RiteGULossIndicies = (Graph.GetCoverAriteInfo().GetAriteGULossIndicies()).Concat(Graph.GetCoverResiduleInfo().GetGULossIndicies()).ToArray(); output.AllocatedRitePayout = (graphState.GetLowestCoverLevelAriteState().GetAllocatedPayout()).Concat(graphState.GetLowestCoverLevelResiduleState().GetAllocatedPayout()).ToArray(); return(output); //return TotalPayout; //return topLevelPayout; //Need to get Final Payout for cover.... #region Delete Later //allLevelState[i] = new LevelState(thisLevelInfo.LevelSize); //int currSeed = 31 + eventID; //var RandGen = new Random(currSeed); //float[] subjectloss = new float[thisLevelSize]; //Array.Copy(Graph.AllLevelState[lowestlevel].SubjectLoss, subjectloss, thisLevelSize); //float[] excess = new float[thisLevelSize]; //float[] ded = new float[thisLevelSize]; //float[] recov = new float[thisLevelSize]; //if (!thisLevelInfo.HasMaxDed && !thisLevelInfo.HasPercentDed) //{ // for (int j = 0; j < thisLevelSize; j++) // { // //float guloss = (float)(RandGen.NextDouble()); // //guloss = guloss * 1000000; // //float guloss = Event.LossVector[thisLevelInfo.GetAtomicRITEIndicies().ToArray()[j]]; // float guloss = subjectloss[j]; // excess[j] = Math.Max(0, guloss - codeLim[j]); // ded[j] = Math.Min(guloss, codeDed[j]); // recov[j] = subjectloss[j] - excess[j] - ded[j]; // //allLevelState[i].SubjectLoss[j] = guloss; // //allLevelState[i].Excess[j] = Math.Max(0, guloss - codeLim[j]); // //allLevelState[i].Deductible[j] = Math.Min(guloss, codeDed[j]); // //allLevelState[i].Recoverable[j] = allLevelState[i].SubjectLoss[j] - allLevelState[i].Excess[j] - allLevelState[i].Deductible[j]; // } // Array.Copy(subjectloss, allLevelState[lowestlevel].SubjectLoss, thisLevelSize); // Array.Copy(excess, allLevelState[lowestlevel].Excess, thisLevelSize); // Array.Copy(ded, allLevelState[lowestlevel].Deductible, thisLevelSize); // Array.Copy(recov, allLevelState[lowestlevel].Recoverable, thisLevelSize); //} // thisLevelInfo = Graph.GetTermLevelInfo(i); // ILevelInfo childLevelInfo = Graph.GetTermLevelInfo(i + 1); // thisLevelSize = thisLevelInfo.LevelSize; // float[] dedFromBelow; // float[] excessFromBelow; // float[] subjectLossFromBelow; // float[] recovFromBelow; // float[] rRatio = new float[thisLevelSize]; // float[] dRatio = new float[thisLevelSize]; // subjectloss = new float[thisLevelSize]; // excess = new float[thisLevelSize]; // ded = new float[thisLevelSize]; // recov = new float[thisLevelSize]; // bool SimplyCopy = true; // if (SimplyCopy) // { // dedFromBelow = allLevelState[i + 1].Deductible; // excessFromBelow = allLevelState[i + 1].Excess; // subjectLossFromBelow = allLevelState[i + 1].SubjectLoss; // recovFromBelow = allLevelState[i + 1].Recoverable; // } // else // { // dedFromBelow = SumArrayByPartition(allLevelState[i + 1].Deductible, childLevelInfo.GetAggregationPartitions()); // excessFromBelow = SumArrayByPartition(allLevelState[i + 1].Excess, childLevelInfo.GetAggregationPartitions()); // subjectLossFromBelow = SumArrayByPartition(allLevelState[i + 1].SubjectLoss, childLevelInfo.GetAggregationPartitions()); // recovFromBelow = SumArrayByPartition(allLevelState[i + 1].Recoverable, childLevelInfo.GetAggregationPartitions()); // } // codeDed = thisLevelInfo.GetCodedMinDeds().ToArray(); // codeLim = thisLevelInfo.GetCodedLimits().ToArray(); // allLevelState[i] = new LevelState(thisLevelInfo.LevelSize); // if (!thisLevelInfo.HasMaxDed && !thisLevelInfo.HasPercentDed) // { // for (int j = 0; j < thisLevelSize; j++) // { // subjectloss[j] = subjectLossFromBelow[j]; // excess[j] = Math.Max(excessFromBelow[j], Math.Max(0, subjectLossFromBelow[j] - codeLim[j])); // ded[j] = Math.Max(dedFromBelow[j], Math.Min(subjectLossFromBelow[j], codeDed[j])); // recov[j] = subjectloss[j] - excess[j] - ded[j]; // float deltaD = allLevelState[i].Deductible[j] - dedFromBelow[j]; // if (deltaD >= 0) // { // rRatio[j] = 1 - deltaD / recovFromBelow[j]; // dRatio[j] = 1; // } // else // { // rRatio[j] = 1; // dRatio[j] = 1 - deltaD / dedFromBelow[j]; // } // } // Array.Copy(subjectloss, allLevelState[i].SubjectLoss, thisLevelSize); // Array.Copy(excess, allLevelState[i].Excess, thisLevelSize); // Array.Copy(ded, allLevelState[i].Deductible, thisLevelSize); // Array.Copy(recov, allLevelState[i].Recoverable, thisLevelSize); // Array.Copy(rRatio, allLevelState[i].AllocateRatioR, thisLevelSize); // Array.Copy(dRatio, allLevelState[i].AllocateRatioD, thisLevelSize); // } //} //Array.Copy(allLevelState, Graph.AllLevelState, Graph.NumOfLevels); #endregion }
public Dictionary <string, Dictionary <int, Dictionary <long, Tuple <double, uint, List <float> > > > > VectorToDict(IVectorEvent drLossEvent) { Dictionary <string, Dictionary <int, Dictionary <long, Tuple <double, uint, List <float> > > > > guLossDict = new Dictionary <string, Dictionary <int, Dictionary <long, Tuple <double, uint, List <float> > > > >(); throw new NotImplementedException(); }