コード例 #1
0
        public CoverExecutionPosition(CoverExecutionPosition CopyFromThis)
        {
            int Count = CopyFromThis.S_vector.Length;

            S_vector = new double[Count];
            P_vector = new double[Count];

            for (int i = 0; i < Count; i++)
            {
                S_vector[i] = CopyFromThis.S_vector[i];
                P_vector[i] = CopyFromThis.P_vector[i];
            }

            Factor       = CopyFromThis.Factor;
            NumBuildings = CopyFromThis.NumBuildings;
        }
コード例 #2
0
        public CoverExecutionPosition Execute(CoverExecutionPosition _SubjectPosition,
                                              Dictionary <SimpleExpression <SymbolicValue>, double> Bindings,
                                              Dictionary <SimpleExpression <SymbolicValue>, double> AggregateStateBindings)
        {
            double[] P_vector = new double[_SubjectPosition.S_vector.Length];

            for (int i = 0; i < _SubjectPosition.S_vector.Length; i++)
            {
                double SubjectPosition = _SubjectPosition.S_vector[i];

                Bindings.Remove(new SymbolicExpression("Subject"));
                Bindings.Add(new SymbolicExpression("Subject"), SubjectPosition);

                double P = SubjectPosition;

                // does cover attach?
                var    Attachment      = GetContent().GetAttachment();
                double CodedAttachment = 0.0;
                if (Attachment != null)
                {
                    CodedAttachment = Attachment.GetEvaluatedExpression(Bindings);

                    if (SubjectPosition <= (CodedAttachment - AggregateStateBindings[new SymbolicExpression("AggregateAttachmentState")])) // it does not attach
                    {
                        P_vector[i] = 0.0;
                        if (Attachment.GetTimeBasis() == TimeBasis.Aggregate)
                        {
                            AggregateStateBindings[new SymbolicExpression("AggregateAttachmentState")]
                                = AggregateStateBindings[new SymbolicExpression("AggregateAttachmentState")] + SubjectPosition;
                        }
                        continue;
                    }

                    if (Attachment.GetTimeBasis() == TimeBasis.Aggregate)
                    {
                        AggregateStateBindings[new SymbolicExpression("AggregateAttachmentState")] = CodedAttachment;
                    }

                    // apply attachment
                    P = (Attachment.IsFranchise()) ? SubjectPosition : Math.Max(SubjectPosition - (CodedAttachment - AggregateStateBindings[new SymbolicExpression("AggregateAttachmentState")]), 0.0);
                }

                // apply payout (i.e. limit?) function
                var Limit = GetContent().GetLimit();
                if (Limit != null)
                {
                    double CodedLimit = Limit.GetEvaluatedExpression(Bindings);
                    if (Limit.IsPAY())
                    {
                        P = CodedLimit;
                    }
                    else
                    {
                        P = Math.Min(CodedLimit - AggregateStateBindings[new SymbolicExpression("AggregateLimitState")], P);

                        if (Limit.GetTimeBasis() == TimeBasis.Aggregate)
                        {
                            AggregateStateBindings[new SymbolicExpression("AggregateLimitState")]
                                = Math.Min(CodedLimit, AggregateStateBindings[new SymbolicExpression("AggregateLimitState")] + P);
                        }
                    }
                }

                // apply share
                double share = 100;
                var    Share = GetContent().GetParticipation();
                if (Share != null)
                {
                    share = GetContent().GetParticipation().GetEvaluatedValue(Bindings);
                }
                P          *= (share / 100.0);
                P_vector[i] = P;
            }

            return(new CoverExecutionPosition(_SubjectPosition.S_vector, P_vector, _SubjectPosition.FactorArray, _SubjectPosition.NumBuildings));
        }