예제 #1
0
        private HashSet <GraphInfo> BuildPosition(HashSet <long> conIDs)
        {
            HashSet <GraphInfo> position = new HashSet <GraphInfo>();

            foreach (long ID in conIDs)
            {
                GraphInfo contract;
                if (graphCache.GetGraphInfo(ID, out contract))
                {
                    position.Add(contract);
                }
                else
                {
                    GraphBuilder        builder = new GraphBuilder(graphCache);
                    ExposureDataAdaptor expData = graphCache.GetExposure(ID);
                    GraphType           type    = graphCache.GetSettings(ID).GraphType;
                    IRITEindexMapper    mapper  = GetMapper(expData);

                    contract = builder.MakeGraph(type, expData, mapper);
                    graphCache.Add(ID, contract);
                    position.Add(contract);
                }
            }

            return(position);
        }
예제 #2
0
 public void Add(long conID, IRITEindexMapper mapper)
 {
     if (!indexMappings.ContainsKey(conID))
     {
         indexMappings.Add(conID, mapper);
     }
 }
예제 #3
0
        public ReferenceResultOutput ExecutePeriod(long conID, GraphType type, List <Dictionary <string, Dictionary <int, Dictionary <long, Tuple <double, uint, List <float> > > > > > ListOfguLossDict)
        {
            ExposureDataAdaptor expData = PDataAdaptor.GetExposureAdaptor(conID);
            string error;

            // Gu Loss can be for many contracts for need Dictionary of Mapper as input..
            Dictionary <long, IRITEindexMapper> indexMappers = GetMappers(expData);

            //Need to get mapper for current executing contract to build graph..
            IRITEindexMapper mapperForContract = indexMappers[conID];

            GraphInfo graphInfo = GetGraph(type, expData, mapperForContract);
            Graph     graph     = graphInfo.Graph;

            //Output object
            ReferenceResultOutput ResultOutput = new ReferenceResultOutput(0, 0);

            foreach (Dictionary <string, Dictionary <int, Dictionary <long, Tuple <double, uint, List <float> > > > >
                     guLossDict in ListOfguLossDict)
            {
                //Execute each event
                graph.EventReset();

                GULossAdaptor guLossAdaptor = new GULossAdaptor(indexMappers, guLossDict, graph.DeclarationsForAssociatedContracts, true);

                GraphExecuterAdaptor MainExecuter = new GraphExecuterAdaptor(graphInfo);

                ResultOutput += MainExecuter.RunExecution(guLossAdaptor);
            }

            return(ResultOutput);
        }
예제 #4
0
        private void ConvertToGU(float[] drLossVector, IRITEindexMapper mapper)
        {
            int NumGuLoss = drLossVector.Length;

            float[] TIVarray = mapper.GetOrderedTIVArray();
            for (int i = 0; i < NumGuLoss; i++)
            {
                drLossVector[i] = drLossVector[i] * TIVarray[i];
            }
        }
예제 #5
0
 public bool GetIndexMapper(long conID, out IRITEindexMapper mapper)
 {
     if (indexMappings.TryGetValue(conID, out mapper))
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
예제 #6
0
        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");
        }
예제 #7
0
        private Dictionary <long, IRITEindexMapper> GetMappers(ExposureDataAdaptor expData)
        {
            Dictionary <long, IRITEindexMapper> indexMappers = new Dictionary <long, IRITEindexMapper>();

            if (expData.TreatyExposure)
            {
                foreach (long conID in expData.Positions.GetDependentContracts())
                {
                    ExposureDataAdaptor childContractData = PDataAdaptor.GetExposureAdaptor(conID);
                    IRITEindexMapper    childMapper       = GetMapperForContract(childContractData);
                    indexMappers.Add(childContractData.ContractID, childMapper);
                }
                indexMappers.Add(expData.ContractID, null);
            }
            else
            {
                IRITEindexMapper Mapper = GetMapperForContract(expData);
                indexMappers.Add(expData.ContractID, Mapper);
            }

            return(indexMappers);
        }
예제 #8
0
 public void PrepareContract(long ConID, GraphType type = GraphType.Auto)
 {
     ExposureDataAdaptor expData   = PDataAdaptor.GetExposureAdaptor(ConID);
     IRITEindexMapper    mapper    = GetMapperForContract(expData);
     GraphInfo           graphInfo = GetGraph(type, expData, mapper);
 }
예제 #9
0
        private GraphInfo GetGraph(GraphType type, ExposureDataAdaptor expData, IRITEindexMapper mapper)
        {
            GraphBuilder builder = new GraphBuilder(GraphCache);

            return(builder.MakeGraph(type, expData, mapper));
        }
예제 #10
0
 public AllocatedLossAdaptor(IRITEindexMapper _mapper)
 {
     Mapper = _mapper;
 }
예제 #11
0
        public GraphInfo MakeGraph(GraphType type, ExposureDataAdaptor expData, IRITEindexMapper indexMapper)
        {
            GraphInfo graphInfo;

            if (graphCache.GetGraphInfo(expData.ContractID, out graphInfo))
            {
                return(graphInfo);
            }

            Graph graph;

            switch (type)
            {
            case GraphType.Auto:
                ContractExtractor contract = GetContract(expData, graphCache);
                contract.Extract();

                AutoGraphStyle style = GetGraphStyle(contract);
                //AutoGraphStyle style = AutoGraphStyle.Matrix;
                //AutoGraphStyle style = AutoGraphStyle.Node;

                AutoGraphBuilder builder;

                if (style == AutoGraphStyle.Node)
                {
                    builder = new AutoGraphOfNodesBuilder(contract);
                }
                else
                {
                    builder = new AutoGraphOfMatrixBuilder(contract, indexMapper);
                }

                graph     = builder.Build();
                graphInfo = new GraphInfo(style, graph);
                break;

            case GraphType.FixedGraph1:
                graph     = new FixedGraph1(expData);
                graphInfo = new GraphInfo(AutoGraphStyle.Node, graph);
                break;

            case GraphType.FixedGraph2:
                graph     = new FixedGraph2(expData);
                graphInfo = new GraphInfo(AutoGraphStyle.Node, graph);
                break;

            case GraphType.FixedGraphOverlap:
                graph     = new FixedGraphOverlap(expData);
                graphInfo = new GraphInfo(AutoGraphStyle.Node, graph);
                break;

            case GraphType.FixedGraphOverlapSubperil:
                graph     = new FixedGraphOverlapSubperil(expData);
                graphInfo = new GraphInfo(AutoGraphStyle.Node, graph);
                break;

            case GraphType.FixedGraphOverlapSubperil2:
                graph     = new FixedGraphOverlapSubperil2(expData);
                graphInfo = new GraphInfo(AutoGraphStyle.Node, graph);
                break;

            case GraphType.FixedTreaty1:
                graph     = new FixedTreaty1(expData, graphCache);
                graphInfo = new GraphInfo(AutoGraphStyle.Node, graph);
                break;
            //case GraphType.FixedMatrixGraphJPTY:
            //    graph  = new FixedMatrixGraphJPTY(expData);
            //    graphInfo = new GraphInfo(AutoGraphStyle.Matrix, graph);
            //    //graph.Initialize();
            //    break;

            default:
                throw new NotSupportedException("Cannot currently support this treaty type");
            }


            graph.Initialize();

            if (graph is FixedPrimaryGraph || graph is FixedTreaty1)   ///need to remove FixedTreaty1 condition
            {
                GetTermsForGraph(expData, graph as GraphOfNodes);
            }

            graph.PeriodReset();

            graphCache.Add(graph.ContractID, graphInfo);
            return(graphInfo);
        }
예제 #12
0
 public VectorGUInputGenerator(GUInputGenerator inputGenerator, IRITEindexMapper _indexMapper)
 {
     GUgenerator = inputGenerator;
     indexMapper = _indexMapper;
 }
예제 #13
0
 public GULossTransformer(IRITEindexMapper _mapper)
 {
     mapper = _mapper;
     aggreagetRITEmapper = mapper.GetAggregateMapper();
 }
예제 #14
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;
                    }
                }
            }
        }