public override LossStateCollection GetLossState() { LossStateCollection lossCol = new LossStateCollection(1); lossCol.SetSubjectLosses(subjectLoss.AllLoss()); lossCol.SetRecoverableLosses(subjectLoss.AllLoss()); return(lossCol); }
public CoverageAtomicRITE(string _subperil, ExposureType _expType, RITE _rite, long ID) { SubPeril = _subperil; ExpType = _expType; RITE = _rite; RITCharacterisiticID = ID; CurrentAllocationStateCollection = new AllocationStateCollection(RITE.ActNumOfBldgs); //CurrentAllocationStateSummed = new AllocationState(); CurrentLossStateCollection = new LossStateCollection(RITE.ActNumOfBldgs); }
public LossStateCollection CopyToLossState() { LossStateCollection lossCol = new LossStateCollection(NumBldgs); int i = 0; foreach (AllocationState allocState in collection) { lossCol.collection[i] = allocState.CopyToLossState(); i = i + 1; } return(lossCol); }
public void SumLossesFrom(LossStateCollection otherLosses) { if (this.NumBldgs == otherLosses.NumBldgs) { collection.Zip(otherLosses.collection, (a, b) => a + b); } else if (this.NumBldgs == 1) { collection[0] += otherLosses.GetTotalSum; } CalcTotalSum(); }
public override void Reset() { base.Reset(); if (IsPerRisk) { CurrentLossStateCollection = new LossStateCollection(PrimarySubject.Schedule.ActNumOfBldgs); } else { CurrentLossStateCollection = new LossStateCollection(1); } //CurrentLossState.Reset(); CurrentAllocationState.Reset(); }
private void RecursiveExecution(GraphNode currNode, GUInputEngine guLossesEngine) { Aggregation aggType = Aggregation.Summed; if (currNode is TermNode) { TermNode currTermNode = currNode as TermNode; //Execution for Term Node here... if (currTermNode.Executed == true) { return; } //execute child node first List <GraphNode> childrenNodes = graph.GetChildrenForNode(currTermNode); List <TermNode> childrenTermNodes = new List <TermNode>(); foreach (GraphNode childNode in childrenNodes) //Parallel.ForEach(childrenNodes, childNode => { TermNode childTermNode = childNode as TermNode; if (childTermNode == null) { throw new InvalidOperationException("Term node's children must be Term node."); } childrenTermNodes.Add(childTermNode); if (childNode.Executed == false) { RecursiveExecution(childTermNode, guLossesEngine); } } //); //has not executed, get the GU loss first double[] inputlosses; //inputlosses = graph.GetNodeSubjectLoss(currTermNode).AllLoss().Zip(currTermNode.PrimarySubject.Schedule.MultiplierArr, (d1, d2) => d1 * d2).ToArray(); inputlosses = graph.GetNodeSubjectLoss(currTermNode).AllLoss(); currTermNode.CurrentLossStateCollection.SetSubjectLosses(inputlosses); if (currTermNode.IsPerRisk == true && currTermNode.PrimarySubject.Schedule.ActNumOfBldgs > 1) { aggType = Aggregation.PerBuilding; } else { //need reset the lossState to act as only one building LossStateCollection tempLossStateCollection = new LossStateCollection(1); tempLossStateCollection.collection[0] = currTermNode.CurrentLossStateCollection.GetTotalSum; currTermNode.CurrentLossStateCollection = tempLossStateCollection; } //if no childrenNodes, nothing to do with the Interaction: the interaction terms are all zeros. if (childrenNodes.Count > 0) { //initialize InterObj InteractionObject[] InterObj = GetInterObj(currTermNode, aggType, childrenTermNodes); TermFunctionalEngine tFunEng = new TermFunctionalEngine(currTermNode, aggType); tFunEng.TermFunction(InterObj); //Interaction //InteractionEngine InterEng = new InteractionEngine(currTermNode, aggType, InterObj); //InterEng.Interaction(); } else { TermFunctionalEngine tFunEng = new TermFunctionalEngine(currTermNode, aggType); tFunEng.TermFunction(new InteractionObject[0]); //no interaction } //Final Adjustment for (int i = 0; i < currTermNode.CurrentLossStateCollection.NumBldgs; i++) { currTermNode.CurrentLossStateCollection.collection[i].AdjustR(); } currTermNode.CurrentLossStateCollection.CalcTotalSum(); currTermNode.Executed = true; } else //currNode is Cover Node { CoverNode currCoverNode = currNode as CoverNode; //Execution for Cover Node here... if (currCoverNode.Executed == true) { return; } foreach (AtomicRITE aRite in currCoverNode.ResidualAtomicRITEs) { currCoverNode.Payout += aRite.GetLossState().GetTotalSum.R; } // Parallel.ForEach(graph.GetChildrenForNode(currCoverNode), childNode => foreach (GraphNode childNode in graph.GetChildrenForNode(currCoverNode)) { RecursiveExecution(childNode, guLossesEngine); if (childNode is TermNode) { TermNode childTermNode = childNode as TermNode; //LossState currentLossState = new LossState(childTermNode.CurrentLossStateCollection.GetTotalSum); //currCoverNode.Payout += currentLossState.R; currCoverNode.Payout += childTermNode.CurrentLossStateCollection.GetTotalSum.R; } else { CoverNode childCoverNode = childNode as CoverNode; currCoverNode.Payout += childCoverNode.Payout; } } // ); CoverNodeFunctionalEngine coverNodeFuncEng = new CoverNodeFunctionalEngine(currCoverNode); coverNodeFuncEng.CoverNodeFunction(); currCoverNode.Executed = true; } //currNode is Cover Node }
public LossStateCollection GetLossState() { LossStateCollection coverNodeLossState = new LossStateCollection(1); return(coverNodeLossState); }