コード例 #1
0
ファイル: MarginalDamage.cs プロジェクト: hbenveniste/fund
        public void WriteMarginalDamage(int RunId, Damage i_Damage, int WeightingschemeId, double Weight, WeightingCombination[] WeightingCombinations)
        {
            if (m_YearRegionSectorWeightingSchemeCsv != null)
            {
                int gas = Convert.ToInt32(_gas);

                m_YearRegionSectorWeightingSchemeCsv.WriteLine(
                    (OutputVerbal ? ScenarioName : ScenarioId.ToString()) +
                    ";" +
                    (OutputVerbal ? (RunId == 0 ? "Best guess" : RunId == -1 ? "Mean" : RunId.ToString()) : RunId.ToString()) +
                    ";" +
                    (OutputVerbal ? (gas == 0 ? "C" : gas == 1 ? "CH4" : gas == 2 ? "N2O" : gas == 3 ? "SF6" : "ERROR") : ((int)_gas).ToString()) +
                    ";" +
                    _emissionyear.ToString() +
                    ";" +
                    (i_Damage.Year + 1950).ToString() +
                    ";" +
                    (OutputVerbal ? i_Damage.Region.ToString() : i_Damage.Region.ToString()) +
                    ";" +
                    (OutputVerbal ? Enum.GetName(typeof(Sector), i_Damage.Sector) : ((int)i_Damage.Sector).ToString()) +
                    ";" +
                    (OutputVerbal ? WeightingCombinations[WeightingschemeId].Name : WeightingschemeId.ToString()) +
                    ";" +
                    (i_Damage.DamageValue * Weight).ToString("f15")
                    );
            }
        }
コード例 #2
0
ファイル: MarginalDamage.cs プロジェクト: hbenveniste/fund
        public void WriteAggregateDamage(int RunId, int WeightingschemeId, double Damage, WeightingCombination[] WeightingCombinations)
        {
            if (!CalculateMeanForMonteCarlo && (RunId == -1))
            {
                return;
            }
            else if (!OutputAllMonteCarloRuns && (RunId > 0))
            {
                return;
            }

            if (m_AggregateDamageCsv != null)
            {
                int gas = (int)_gas;

                m_AggregateDamageCsv.WriteLine(
                    (OutputVerbal ? ScenarioName : ScenarioId.ToString()) +
                    ";" +
                    (OutputVerbal ? (gas == 0 ? "C" : gas == 1 ? "CH4" : gas == 2 ? "N2O" : gas == 3 ? "SF6" : "ERROR") : ((int)_gas).ToString()) +
                    ";" +
                    _emissionyear.ToString() +
                    ";" +
                    (OutputVerbal ? (RunId == 0 ? "Best guess" : RunId == -1 ? "Mean" : RunId.ToString()) : RunId.ToString()) +
                    ";" +
                    (OutputVerbal ? WeightingCombinations[WeightingschemeId].Name : WeightingschemeId.ToString()) +
                    ";" +
                    Damage.ToString("f15")
                    );
            }
        }
コード例 #3
0
ファイル: MarginalDamage.cs プロジェクト: hbenveniste/fund
        public void WriteSummaryDamage(int WeightingschemeId, double bgDamage, IEnumerable <double> damages, WeightingCombination[] WeightingCombinations)
        {
            if (SummaryCsv != null)
            {
                int gas = (int)_gas;

                var stats = new DescriptiveStatistics(damages);

                var sortedDamages = damages.OrderBy(i => i).ToArray();

                double count = sortedDamages.Length;

                int skiptake0_001 = (int)(count * 0.001 / 2.0);
                int skiptake0_01  = (int)(count * 0.01 / 2.0);
                int skiptake0_05  = (int)(count * 0.05 / 2.0);

                var trimmedMean0_001 = sortedDamages.Skip(skiptake0_001).Take(sortedDamages.Length - 2 * skiptake0_001).Mean();

                var trimmedMean0_01 = sortedDamages.Skip(skiptake0_01).Take(sortedDamages.Length - 2 * skiptake0_01).Mean();

                var trimmedMean0_05 = sortedDamages.Skip(skiptake0_05).Take(sortedDamages.Length - 2 * skiptake0_05).Mean();


                SummaryCsv.WriteLine("{0};{1};{2};{3};{4:f15};{5:f15};{6:f15};{7:f15};{8:f15};{9:f15};{10:f15};{11:f15};{12:f15};{13:f15};{14:f15};{15:f15};{16:f15}",
                                     OutputVerbal ? ScenarioName : ScenarioId.ToString(),
                                     OutputVerbal ? (gas == 0 ? "C" : gas == 1 ? "CH4" : gas == 2 ? "N2O" : gas == 3 ? "SF6" : "ERROR") : ((int)_gas).ToString(),
                                     _emissionyear,
                                     OutputVerbal ? WeightingCombinations[WeightingschemeId].Name : WeightingschemeId.ToString(),
                                     bgDamage,
                                     stats.Mean,
                                     trimmedMean0_001,
                                     trimmedMean0_01,
                                     trimmedMean0_05,
                                     stats.Median,
                                     stats.StandardDeviation,
                                     stats.Variance,
                                     stats.Skewness,
                                     stats.Kurtosis,
                                     stats.Minimum,
                                     stats.Maximum,
                                     Math.Sqrt(stats.Variance) / Math.Sqrt(stats.Count)
                                     );
            }
        }
コード例 #4
0
        public ClientVisitSaveDataModel(User user, ClientVisit clientVisit)
            : this(user)
        {
            VisitId                       = clientVisit.Id;
            ClientId                      = clientVisit.ClientId;
            VisitGroupId                  = clientVisit.VisitGroupId;
            SignatureFileName             = clientVisit.SignatureFileName ?? Guid.NewGuid().ToString();
            PhotoFileName                 = clientVisit.PhotoFileName ?? Guid.NewGuid().ToString();
            DeliveryCenterId              = clientVisit.DeliveryCenter.Id;
            ScenarioId                    = clientVisit.Scenario != null ? clientVisit.Scenario.Id : new long?();
            TemporaryPolicyDate           = clientVisit.TemporaryPolicyDate;
            TemporaryPolicyNumber         = clientVisit.TemporaryPolicyNumber;
            TemporaryPolicyExpirationDate = clientVisit.TemporaryPolicyExpirationDate;
            StatusId                      = clientVisit.Status.Id;
            StatusDate                    = clientVisit.StatusDate;
            StatusEnabled                 = user.Roles.Contains(Role.Administrator) || user.Roles.Contains(Role.OperatorSG);
            DisableAll                    = clientVisit.Status.Id == ClientVisitStatuses.AnswerPending.Id &&
                                            !(user.Roles.Contains(Role.Administrator) || user.Roles.Contains(Role.OperatorSG));
            OldClientInfo           = new ClientVersionEditModel(clientVisit.OldClientInfo, EntityType.Old);
            NewClientInfo           = new ClientVersionEditModel(clientVisit.NewClientInfo, EntityType.New);
            OldDocument             = new DocumentModel(clientVisit.OldDocument, DocumentType.Old);
            NewDocument             = new DocumentModel(clientVisit.NewDocument, DocumentType.New);
            NewForeignDocument      = new DocumentModel(clientVisit.NewForeignDocument, DocumentType.NewForeign);
            OldForeignDocument      = new DocumentModel(clientVisit.OldForeignDocument, DocumentType.OldForeign);
            LivingAddress           = new AddressModel(clientVisit.LivingAddress, AddressType.Living);
            RegistrationAddress     = new AddressModel(clientVisit.RegistrationAddress, AddressType.Registration);
            RegistrationAddressDate = clientVisit.RegistrationAddressDate;
            OldPolicy                 = new PolicyInfoClientVisitSaveModel(clientVisit.OldPolicy, EntityType.Old);
            NewPolicy                 = new PolicyInfoClientVisitSaveModel(clientVisit.NewPolicy, EntityType.New);
            Registrator               = new UserModel(clientVisit.Registrator);
            Representative            = new RepresentativeEditModel(clientVisit.Representative);
            CarrierId                 = clientVisit.CarrierId;
            ApplicationMethodId       = clientVisit.ApplicationMethodId;
            Comment                   = clientVisit.Comment;
            GOZNAKDate                = clientVisit.GOZNAKDate;
            GOZNAKTypeId              = clientVisit.GOZNAKType != null ? clientVisit.GOZNAKType.Id : default(long?);
            ClientCategoryId          = clientVisit.ClientCategoryId == 0 ? new long() : clientVisit.ClientCategoryId;
            DeliveryPointId           = clientVisit.DeliveryPointId == 0 ? new long() : clientVisit.DeliveryPointId;
            ClientAcquisitionEmployee = clientVisit.ClientAcquisitionEmployee;
            ClientContacts            = clientVisit.ClientContacts;
            Phone          = clientVisit.Phone;
            Email          = clientVisit.Email;
            IssueDate      = clientVisit.IssueDate;
            UralsibCard    = clientVisit.UralsibCard;
            IsActual       = clientVisit.IsActual;
            Scenaries      = ReferencesProvider.GetReferences(Constants.ScenarioRef, user.Roles, DateTime.Now, null, true);
            DeliveryPoints = ReferencesProvider.GetReferences(Constants.DeliveryPointRef, user.Roles, DateTime.Now, null, true);
            ListClientAcquisitionEmployee = ReferencesProvider.GetListClientAcquisitionEmployee(null, true);
            PolicyBlanc = clientVisit.PolicyBlanc;

            if (ScenarioId != 0 && !Scenaries.Exists(item => item.Value == ScenarioId.ToString()))
            {
                Scenaries.Add(ReferencesProvider.GetReferences(Constants.ScenarioRef).FirstOrDefault(item => item.Value == ScenarioId.ToString()));
            }
            if (DeliveryPointId.HasValue && !DeliveryPoints.Exists(item => item.Value == DeliveryPointId.Value.ToString()))
            {
                DeliveryPoints.Add(ReferencesProvider.GetReferences(Constants.DeliveryPointRef).FirstOrDefault(item => item.Value == DeliveryPointId.Value.ToString()));
            }
            if (ClientCategoryId.HasValue && !UralsibClientCategories.Exists(item => item.Value == ClientCategoryId.Value.ToString()))
            {
                UralsibClientCategories.Add(ReferencesProvider.GetReferences(Constants.UralsibClientCategoryRef).FirstOrDefault(item => item.Value == ClientCategoryId.Value.ToString()));
            }
            IssueDateEnabled = (user.Roles.Contains(Role.Administrator) || user.Roles.Contains(Role.OperatorSG)) ||
                               (StatusId == ClientVisitStatuses.PolicyReadyForClient.Id && user.Roles.Contains(Role.Registrator));
            IsReadyToFundSubmitRequestEnabled = user.Roles.Contains(Role.Administrator) || user.Roles.Contains(Role.OperatorSG);
            PolicyPartyNumber           = clientVisit.PolicyPartyNumber;
            FundResponseApplyingMessage = clientVisit.FundResponseApplyingMessage;
            IsReadyToFundSubmitRequest  = clientVisit.IsReadyToFundSubmitRequest;
            CreateDate       = clientVisit.CreateDate;
            UpdateDate       = clientVisit.UpdateDate;
            IsDifficultCase  = clientVisit.IsDifficultCase;
            AttachmentDate   = clientVisit.AttachmentDate;
            AttachmentTypeId = clientVisit.AttachmentType != null ? clientVisit.AttachmentType.Id : new long?();
            MedicalCentreId  = clientVisit.MedicalCentre != null ? clientVisit.MedicalCentre.Id : new long?();
        }