Ejemplo n.º 1
0
        private object ConstructTerm(Dictionary <string, object> KeyValueData)
        {
            // label

            string Label = null;

            if (KeyValueData.ContainsKey("Label"))
            {
                Label = (string)KeyValueData["Label"];
            }

            // subject

            SubjectPosition _Subject = ConstructSubject(KeyValueData);

            TimeBasis _TimeBasis
                = (TimeBasis)System.Enum.Parse(typeof(TimeBasis), (string)KeyValueData["TimeBasis"]);

            object _Expression = ConstructExpression(KeyValueData);

            string _ValueType
                = (string)(KeyValueData["ValueType"]);

            object Term
                = Activator.CreateInstance(
                      GetType("Term<" + _ValueType + ">"),
                      _Expression, _Subject, _TimeBasis, Label);

            return(Term);
        }
Ejemplo n.º 2
0
 public Cover(Cover <ShareValue, LimitValue, AttachmentValue> CopyFrom, SymbolicExpression NewLabel)
 {
     this.Label          = NewLabel;
     this._Participation = CopyFrom._Participation;
     this._Limit         = CopyFrom._Limit;
     this._Attachment    = CopyFrom._Attachment;
     this._Subject       = new Subject((Subject)CopyFrom.GetSubject());
     this.DerivedSubject = CopyFrom.GetDerivedSubject();
 }
Ejemplo n.º 3
0
        private SubjectPosition ConstructSubject(Dictionary <string, object> KeyValueData)
        {
            object CausesOfLossObject;
            HashSet <SymbolicValue> CausesOfLoss = new HashSet <SymbolicValue>();

            if (KeyValueData.TryGetValue("CausesOfLoss", out CausesOfLossObject))
            {
                CausesOfLoss.UnionWith(ToHashSet(CausesOfLossObject.ToString()));
            }

            object ScheduleObject;
            HashSet <SymbolicValue> ScheduleSymbols = new HashSet <SymbolicValue>();

            if (KeyValueData.TryGetValue("Schedule", out ScheduleObject))
            {
                ScheduleSymbols.UnionWith(ToHashSet(ScheduleObject.ToString()));
            }
            Schedule _Schedule = new Schedule(ScheduleSymbols);

            object ExposureTypesObject;
            HashSet <SymbolicValue> ExposureTypes = new HashSet <SymbolicValue>();

            if (KeyValueData.TryGetValue("ExposureTypes", out ExposureTypesObject))
            {
                ExposureTypes.UnionWith(ToHashSet(ExposureTypesObject.ToString()));
            }

            bool Resolution = false;

            if (KeyValueData.ContainsKey("PerRisk"))
            {
                Resolution = bool.Parse((string)KeyValueData["PerRisk"]);
            }

            if ((CausesOfLoss.Count == 0) && (ScheduleSymbols.Count == 0) && (ExposureTypes.Count == 0))
            {
                SubjectPosition CoverSubjectPosition = new SubjectPosition();
                if (this.ContractSubject is Subject)
                {
                    CoverSubjectPosition = new Subject(this.ContractSubject as Subject);
                    ((Subject)CoverSubjectPosition).PerRisk = Resolution;
                }
                else if (this.ContractSubject is NetPosition)
                {
                    CoverSubjectPosition = new NetPosition(this.ContractSubject as NetPosition);
                }
                else if (this.ContractSubject is SubjectPosition)
                {
                    CoverSubjectPosition = new SubjectPosition(this.ContractSubject as SubjectPosition);
                }

                return(CoverSubjectPosition);
            }


            return(new Subject(UniversalSubject, _Schedule, CausesOfLoss, ExposureTypes, ResolvedSchedule, CoverageIdAttrMap, Resolution));
        }
Ejemplo n.º 4
0
 public Cover(Cover <ShareValue, LimitValue, AttachmentValue> CopyFrom, SymbolicExpression NewLabel,
              FunctionInvocation <IValue <AValue> > NewDerivedSubject)
 {
     this.Label          = NewLabel;
     this._Participation = CopyFrom._Participation;
     this._Limit         = CopyFrom._Limit;
     this._Attachment    = CopyFrom._Attachment;
     this._Subject       = CopyFrom.GetSubject(); // TODO : comment this later?
     this.DerivedSubject = NewDerivedSubject;
 }
Ejemplo n.º 5
0
 public Cover(Participation <ShareValue> share, Limit <LimitValue> limit, Attachment <AttachmentValue> attachment,
              SubjectPosition subject, FunctionInvocation <IValue <AValue> > DerivedSubject, string Label)
 {
     this.Label          = (Label == null) ? null : new SymbolicExpression(Label);
     this._Participation = share;
     this._Limit         = limit;
     this._Attachment    = attachment;
     this._Subject       = subject;
     this.DerivedSubject = DerivedSubject;
 }
Ejemplo n.º 6
0
 public SubjectPosition(SubjectPosition CopyFromSubjectPosition) :
     this(CopyFromSubjectPosition.GrossPosition, CopyFromSubjectPosition.CededPosition, CopyFromSubjectPosition.CausesOfLoss, CopyFromSubjectPosition.ExposureTypes)
 {
 }
Ejemplo n.º 7
0
 public Cover(Participation <ShareValue> share, SubjectPosition subject, FunctionInvocation <IValue <AValue> > DerivedSubject, string Label)
     : this(share, null, null, subject, DerivedSubject, Label)
 {
 }
Ejemplo n.º 8
0
 public Cover(Participation <ShareValue> share, SubjectPosition subject, string Label)
     : this(share, null, null, subject, null, Label)
 {
 }
Ejemplo n.º 9
0
 public Cover(Participation <ShareValue> share, Limit <LimitValue> limit, Attachment <AttachmentValue> attachment, SubjectPosition subject, string Label)
     : this(share, limit, attachment, subject, null, Label)
 {
 }
Ejemplo n.º 10
0
 public Cover(Participation <ShareValue> share, Limit <LimitValue> limit, Attachment <AttachmentValue> attachment, SubjectPosition subject, FunctionInvocation <IValue <AValue> > DerivedSubject)
     : this(share, limit, attachment, subject, DerivedSubject, null)
 {
 }
Ejemplo n.º 11
0
 public Cover(Participation <ShareValue> share, Attachment <AttachmentValue> attachment, SubjectPosition subject)
     : this(share, null, attachment, subject, null, null)
 {
 }
Ejemplo n.º 12
0
 public Cover(Participation <ShareValue> share, Limit <LimitValue> limit, SubjectPosition subject)
     : this(share, limit, null, subject, null, null)
 {
 }
Ejemplo n.º 13
0
        public Contract(Dictionary <string, object> IR,
                        Dictionary <string, HashSet <long> > resolvedSchedule,
                        Dictionary <long, RiskItemCharacteristicIDAttributes> CoverageIdAttrMap)
        {
            this.ResolvedSchedule  = resolvedSchedule;
            this.CoverageIdAttrMap = CoverageIdAttrMap;

            // Construct universal subject position
            HashSet <long> AllRITEIds = new HashSet <long>();

            if (resolvedSchedule != null)
            {
                AllRITEIds = resolvedSchedule.Aggregate(new HashSet <long>(), (a, b) => { a.UnionWith(b.Value); return(a); });
            }

            HashSet <long> AllRiskItemIds = new HashSet <long>();

            if (CoverageIdAttrMap != null)
            {
                AllRiskItemIds = new HashSet <long>(AllRITEIds.Where(x => CoverageIdAttrMap.ContainsKey(x)).Select(x => CoverageIdAttrMap[x].RITExposureId).Distinct());
            }

            UniversalSubject = new UniversalSubjectPosition(AllRITEIds, AllRiskItemIds);

            // Declarations
            Declarations = (Dictionary <string, object>)IR["Declarations"];

            // Claims Adjustment Settings
            if (!Declarations.ContainsKey("Claims Adjustment Options") ||
                Declarations["Claims Adjustment Options"] == null)
            {
                _AreSublimitsNetOfDeductible = false;
                _AreDeductiblesAbsorbable    = false;
            }
            else
            {
                if (!((Declarations["Claims Adjustment Options"] as Dictionary <string, object>).ContainsKey("Claims Adjustment Sublimits")) ||
                    (Declarations["Claims Adjustment Options"] as Dictionary <string, object>)["Claims Adjustment Sublimits"] == null)
                {
                    _AreSublimitsNetOfDeductible = false;
                }
                else
                {
                    _AreSublimitsNetOfDeductible = (Declarations["Claims Adjustment Options"] as Dictionary <string, object>)["Claims Adjustment Sublimits"].ToString().Equals("Net Of Deductible");
                }

                if (!((Declarations["Claims Adjustment Options"] as Dictionary <string, object>).ContainsKey("Claims Adjustment Deductibles")) ||
                    (Declarations["Claims Adjustment Options"] as Dictionary <string, object>)["Claims Adjustment Deductibles"] == null)
                {
                    _AreDeductiblesAbsorbable = false;
                }
                else
                {
                    _AreDeductiblesAbsorbable = (Declarations["Claims Adjustment Options"] as Dictionary <string, object>)["Claims Adjustment Deductibles"].ToString().Equals("Absorbable");
                }
            }


            object NameObject;

            if (Declarations.TryGetValue("Name", out NameObject))
            {
                this.Name = NameObject.ToString();
            }

            object CausesOfLossObject;

            Declarations.TryGetValue("CausesOfLoss", out CausesOfLossObject);

            object ScheduleObject;

            Declarations.TryGetValue("Schedule", out ScheduleObject);

            object ExposureTypesObject;

            Declarations.TryGetValue("ExposureTypes", out ExposureTypesObject);

            object GrossPositionObject;

            Declarations.TryGetValue("GrossPosition", out GrossPositionObject);

            object CededPositionObject;

            Declarations.TryGetValue("CededPosition", out CededPositionObject);

            if (GrossPositionObject != null)
            {
                if (CededPositionObject != null)
                {
                    this.ContractSubject = new NetPosition(ToHashSet(GrossPositionObject.ToString()), ToHashSet(CededPositionObject.ToString()));
                }
                else if (CausesOfLossObject != null)
                {
                    this.ContractSubject = new SubjectPosition(ToHashSet(GrossPositionObject.ToString()), ToHashSet(CausesOfLossObject.ToString()));
                }
                else
                {
                    this.ContractSubject = new SubjectPosition(ToHashSet(GrossPositionObject.ToString()));
                }
            }
            else if (CausesOfLossObject != null && ScheduleObject != null && ExposureTypesObject != null)
            {
                this.ContractSubject = new Subject(
                    UniversalSubject, new Schedule(ToHashSet(ScheduleObject.ToString())), ToHashSet(CausesOfLossObject.ToString()), ToHashSet(ExposureTypesObject.ToString()),
                    ResolvedSchedule, CoverageIdAttrMap);
            }

            // Covers

            object[] covers = (object[])IR["Covers"];

            Covers = new List <ICover <Value, Value, Value> >(covers.Length);

            foreach (object cover in covers)
            {
                Dictionary <string, object> coverData = (Dictionary <string, object>)cover;

                Covers.Add(ConstructCover(coverData));
            }

            // Sublimits

            object[] sublimits = (object[])IR["Sublimits"];

            Sublimits = new List <ITerm <Value> >(sublimits.Length);

            foreach (object sublimit in sublimits)
            {
                Sublimits.Add(ConstructSublimit((Dictionary <string, object>)sublimit, AreSublimitsNetOfDeductible()));
            }

            // Deductibles

            object[] deductibles = (object[])IR["Deductibles"];

            Deductibles = new List <ITerm <Value> >(deductibles.Length);

            foreach (object deductible in deductibles)
            {
                Deductibles.Add(ConstructDeductible((Dictionary <string, object>)deductible, AreDeductiblesAbsorbable()));
            }
        }
Ejemplo n.º 14
0
        private ICover <Value, Value, Value> ConstructCover(Dictionary <string, object> coverData)
        {
            // label

            string Label = null;

            if (coverData.ContainsKey("Label"))
            {
                Label = (string)coverData["Label"];
            }

            // participation

            string ParticipationValueType
                = (string)(((Dictionary <string, object>)coverData["Participation"])["ValueType"]);

            object Participation
                = ConstructParticipation(coverData);

            // _Limit

            object Limit = null;

            string LimitValueType = "Value";

            if (coverData.ContainsKey("LimitSpecification"))
            {
                Limit = ConstructLimit(coverData);

                LimitValueType
                    = (string)(((Dictionary <string, object>)coverData["LimitSpecification"])["ValueType"]);
            }

            // _Attachment

            object Attachment = null;

            string AttachmentValueType = "Value";

            if (coverData.ContainsKey("AttachmentSpecification"))
            {
                AttachmentValueType
                    = (string)(((Dictionary <string, object>)coverData["AttachmentSpecification"])["ValueType"]);

                Attachment = ConstructAttachment(coverData);
            }

            // Subject Constraint

            SubjectPosition _Subject = ConstructSubject(coverData);

            // Derived Subject, if any

            object DerivedSubject
                = null;

            if (coverData.ContainsKey("DerivedSubject"))
            {
                DerivedSubject = ConstructDerivedSubject((Dictionary <string, object>)coverData["DerivedSubject"]);
            }

            if (DerivedSubject != null)
            {
                _Subject.isNotConstrained = true;
                _Subject.isDerived        = true;
            }

            // build cover

            return((ICover <Value, Value, Value>)Activator.CreateInstance(
                       GetType("Cover<" + ParticipationValueType + "," + LimitValueType + "," + AttachmentValueType + ">"),
                       Participation, Limit, Attachment, _Subject, DerivedSubject, Label));
        }