Exemplo n.º 1
0
 private Formulator.Formula GetFormula(StringBuilder sb)
 {
     sb.Length--;
     sb.Insert(0, '('); sb.Append(')'); sb.Append('/');
     sb.Append(Experts.Count());
     return(GetFormula(sb.ToString()));
 }
        public override ExpertOpinionSharp.Distributions.IDistribution Fit(string variableName)
        {
            var variable = Variables.Single(x => x.Name == variableName);
            var bounds   = GetBounds(variable);

            var w = new double[Experts.Count() + 1];
            var d = new QuantileDistribution[Experts.Count()];

            w [0]            = 0;
            w [w.Length - 1] = 1;

            var weights = UseOptimalAlpha ? GetOptimalWeights() : GetWeights(_alpha);

            int i = 0;

            foreach (var kv in weights)
            {
                var p = Estimates [kv.Item1, variable];
                var t = new [] { bounds.Item1, p [0], p [1], p [2], bounds.Item2 };
                d [i]     = new QuantileDistribution(QuantileVector, t);
                w [i + 1] = w [i] + kv.Item2;
                i++;
            }

            var dist = new MixtureDistribution(w, d);

            return(dist);
        }
        /// <summary>
        /// Gets the information scores for all experts, sorted by score.
        /// </summary>
        /// <returns>The information scores.</returns>
        public List <Tuple <Expert, double> > GetInformationScores()
        {
            var scores = Experts.Select(x => new Tuple <Expert, double> (x, GetInformationScore(x)))
                         .ToList();

            scores.Sort((x, y) => y.Item2.CompareTo(x.Item2));
            return(scores);
        }
        private void LoadExpert()
        {
            var x = App.LoadExpert(ExpertName);

            if (!Experts.Contains(x))
            {
                Experts.Add(App.LoadExpert(ExpertName));
            }
        }
        private void LoadExperts()
        {
            Experts.Clear();
            var x = App.LoadExperts();

            foreach (var exp in x)
            {
                Experts.Add(exp);
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// Gets the weights for all experts, sorted.
        /// </summary>
        /// <returns>The weights.</returns>
        public IEnumerable <Tuple <Expert, double> > GetWeights()
        {
            var scores = Experts.Select(x => new Tuple <Expert, double> (x, GetCalibrationScore(x) * GetInformationScore(x)))
                         .ToList();

            scores.Sort((x, y) => y.Item2.CompareTo(x.Item2));
            var scaling = scores.Sum(x => x.Item2);

            return(scores.Select(x => new Tuple <Expert, double> (x.Item1, x.Item2 / scaling)));
        }
        /// <summary>
        /// Gets the weights for all experts, sorted.
        /// </summary>
        /// <returns>The weights.</returns>
        public IEnumerable <Tuple <Expert, double> > GetWeights(double alpha = 0)
        {
            var scores = Experts.Select(x => {
                var c = GetCalibrationScore(x);
                var i = GetInformationScore(x);
                return(new Tuple <Expert, double> (x, ((c >= alpha) ? c : 0) * i));
            }).ToList();

            scores.Sort((x, y) => y.Item2.CompareTo(x.Item2));
            var scaling = scores.Sum(x => x.Item2);

            return(!(scaling > 0) ? scores : scores.Select(x => new Tuple <Expert, double> (x.Item1, x.Item2 / scaling)));
        }
Exemplo n.º 8
0
        public void OnExportHandler()
        {
            Expert[]    expertsToExport    = Experts.Where(e => e.IsChecked).Select(e => e.Expert).ToArray();
            EventTree[] eventTreesToExport = EventTrees.Where(e => e.IsChecked).Select(e => e.EventTree).ToArray();
            string      location           = ExportLocation;
            string      prefix             = Prefix;

            if (OnExport == null)
            {
                Log.Error("Er is iets onverwachts misgegaan tijdens het exporteren");
                return;
            }

            OnExport(location, prefix, expertsToExport, eventTreesToExport);
        }
        public void Export(StringBuilder sb)
        {
            var eDict = Experts.ToDictionary(x => x, x => new List <ExpertAnswer>());

            var maxLength = Experts.Max(x => x.Name.Length);

            foreach (var ea in base.ExpertAnswer)
            {
                eDict[ea.Expert].Add(ea);
            }

            const string qTitle = "Вопросы";

            string spaces;

            if (maxLength > qTitle.Length)
            {
                spaces = new string(' ', maxLength - qTitle.Length);
            }
            else
            {
                spaces = String.Empty;
            }

            sb.Append(spaces + qTitle);

            int number = 0;

            foreach (var q in Questions)
            {
                sb.Append('\t'); sb.Append(++number);
            }

            foreach (var e in eDict)
            {
                sb.AppendLine();

                sb.Append(e.Key.Name);

                var answers = e.Value.OrderBy(x => x.Question.Key).ToArray();

                foreach (var ea in answers)
                {
                    sb.Append('\t'); sb.Append(ea.Answer.Name);
                }
            }
            sb.AppendLine();
        }
        public IDistribution GetDistribution(string expertName, string variableName)
        {
            var variable = Variables.Single(x => x.Name == variableName);
            var bounds   = GetBounds(variable);
            var expert   = Experts.Single(x => x.Name == expertName);

            var p  = Estimates [expert, variable];
            var tt = new List <double> (p.Length + 2);

            tt.Add(bounds.Item1);
            tt.AddRange(p);
            tt.Add(bounds.Item2);
            var t = tt.ToArray();

            return(new QuantileDistribution(QuantileVector, t));
        }
Exemplo n.º 11
0
        void GetBounds(ExpertVariable var, out double vmin, out double vmax)
        {
            var min = Experts.Min(x => x.Estimates[var].GetQuantile(0));
            var max = Experts.Max(x => x.Estimates[var].GetQuantile(1));

            if (var is CalibrationVariable)
            {
                var cVar = (CalibrationVariable)var;
                min = Math.Min(min, cVar.TrueValue);
                max = Math.Max(max, cVar.TrueValue);
            }

            var overshoot = (max - min) * K / 100.0;

            vmin = min - overshoot;
            vmax = max + overshoot;
        }
Exemplo n.º 12
0
        private void Cancel_Click(object sender, RoutedEventArgs e)
        {
            Experts item = (Experts)DataGrid.SelectedItem;

            if (item != null)
            {
                dbEntities.Experts.Remove(item);
            }

            try
            {
                ClientServerController.SaveChangesExperts(list);
                dbEntities.SaveChanges();
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.Message);
            }
        }
Exemplo n.º 13
0
        /// <summary>
        /// Build the array <c>Pr</c>.
        /// </summary>
        protected void BuildPr()
        {
            Pr = new double[M];
            for (int h = 0; h < M; h++)
            {
                double product = 1;
                var    hashI   = h;
                for (int i = 0; i < Experts.Count(); i++)
                {
                    var index = hashI % (NbQuantiles + 1);
                    product *= ExpectedDensity[index];
                    hashI    = hashI / (NbQuantiles + 1);
                }

                Pr[h] = (S[h] + 1) / (Variables.Count(x => x.Calibration) + (1 / product));
            }

            Pr = Pr.Select(x => x / Pr.Sum()).ToArray();
        }
        private void RefreshAggregatedVectorMethod()
        {
            var norm    = Sqrt(Experts.Select(e => e.Weight).Sum(x => x * x));
            var vectors = Experts.Select(
                e => new Vector(
                    e.GlobalPriorityVector.GetColumn(0).Select(x => Pow(x, e.Weight / norm)).ToArray()
                    )
                ).ToList();

            var temp = new Matrix(vectors);

            var res = new Vector(temp.N);

            for (int i = 0; i < temp.N; ++i)
            {
                res[i] = Mult(temp.GetRow(i).X);
            }

            AggregatedVector = new Matrix(res);
            SelectedExpert.RefreshGlobalPriorityVector();
        }
Exemplo n.º 15
0
 public override System.Web.Mvc.ActionResult UserDefinedPriceForm(Experts.Web.Models.Forms.ThreadForm form)
 {
     var callInfo = new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.UserDefinedPriceForm);
     ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "form", form);
     return callInfo;
 }
Exemplo n.º 16
0
 public override System.Web.Mvc.ActionResult GiveUp(Experts.Web.Models.Forms.GiveUpForm model)
 {
     var callInfo = new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.GiveUp);
     ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "model", model);
     return callInfo;
 }
Exemplo n.º 17
0
 public override System.Web.Mvc.ActionResult ResendActivationEmail(Experts.Web.Models.Forms.EmailNotUniqueForm model)
 {
     var callInfo = new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.ResendActivationEmail);
     ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "model", model);
     return callInfo;
 }
Exemplo n.º 18
0
 public override System.Web.Mvc.ActionResult ThreadDetails(int threadId, Experts.Web.Models.Forms.PostForm postForm)
 {
     var callInfo = new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.ThreadDetails);
     ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "threadId", threadId);
     ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "postForm", postForm);
     return callInfo;
 }
Exemplo n.º 19
0
 public override System.Web.Mvc.ActionResult ChildCategoryAttributes(Experts.Web.Models.Shared.AttributeValueModel[] attributeValues, int attributeId)
 {
     var callInfo = new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.ChildCategoryAttributes);
     ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "ThreadForm.AttributeValues", attributeValues);
     ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "attributeId", attributeId);
     return callInfo;
 }
Exemplo n.º 20
0
 public override System.Web.Mvc.ActionResult StoreKeyword(Experts.Web.Models.Catalog.KeywordProcessForm form)
 {
     var callInfo = new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.StoreKeyword);
     ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "KeywordProcessForm", form);
     return callInfo;
 }
Exemplo n.º 21
0
 public override System.Web.Mvc.ActionResult PaymentForm(Experts.Web.Models.Payments.PaymentModel paymentModel, Experts.Web.Models.Payments.PaymentForm form)
 {
     var callInfo = new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.PaymentForm);
     ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "paymentModel", paymentModel);
     ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "form", form);
     return callInfo;
 }
Exemplo n.º 22
0
 public WSRContext()
 {
     //if (!(Database.GetService<IDatabaseCreator>() as RelationalDatabaseCreator).Exists())
     Database.EnsureDeleted();
     Database.EnsureCreated();
     if (!Participants.Any())
     {
         string DPath = Path.GetFullPath(Path.Combine(Directory.GetCurrentDirectory(), @"..\..\"));
         DPath += "\\CSV\\";
         Database.OpenConnection();
         using (var reader = new StreamReader(DPath + "Participants.csv"))
             using (var csv = new CsvReader(reader, CultureInfo.InvariantCulture))
             {
                 Participants.AddRange(csv.GetRecords <Participant>());
             }
         Database.ExecuteSqlRaw("SET IDENTITY_INSERT dbo.Participants ON;");
         SaveChanges();
         Database.ExecuteSqlRaw("SET IDENTITY_INSERT dbo.Participants OFF;");
         using (var reader = new StreamReader(DPath + "Experts.csv"))
             using (var csv = new CsvReader(reader, CultureInfo.InvariantCulture))
             {
                 Experts.AddRange(csv.GetRecords <Expert>());
             }
         Database.ExecuteSqlRaw("SET IDENTITY_INSERT dbo.Experts ON;");
         SaveChanges();
         Database.ExecuteSqlRaw("SET IDENTITY_INSERT dbo.Experts OFF;");
         using (var reader = new StreamReader(DPath + "Admins.csv"))
             using (var csv = new CsvReader(reader, CultureInfo.InvariantCulture))
             {
                 Administrators.AddRange(csv.GetRecords <Administrator>());
             }
         Database.ExecuteSqlRaw("SET IDENTITY_INSERT dbo.Administrators ON;");
         SaveChanges();
         Database.ExecuteSqlRaw("SET IDENTITY_INSERT dbo.Administrators OFF;");
         using (var reader = new StreamReader(DPath + "Coordinators.csv"))
             using (var csv = new CsvReader(reader, CultureInfo.InvariantCulture))
             {
                 Coordinators.AddRange(csv.GetRecords <Coordinator>());
             }
         Database.ExecuteSqlRaw("SET IDENTITY_INSERT dbo.Coordinators ON;");
         SaveChanges();
         Database.ExecuteSqlRaw("SET IDENTITY_INSERT dbo.Coordinators OFF;");
         List <Competention> temp = new List <Competention>();
         using (var reader = new StreamReader(DPath + "Competentions.csv"))
             using (var csv = new CsvReader(reader, CultureInfo.InvariantCulture))
             {
                 temp.AddRange(csv.GetRecords <Competention>());
             }
         using (var reader = new StreamReader(DPath + "CompetentionDesc.txt", Encoding.Default))
         {
             Competention CurrC;
             for (int Counter = 1; Counter <= temp.Count; Counter++)//relies on competencies being consequentioal from 1
             {
                 CurrC             = temp.FirstOrDefault(c => c.Id == Counter);
                 CurrC.Description = reader.ReadLine();
             }
         }
         Competentions.AddRange(temp);
         Database.ExecuteSqlRaw("SET IDENTITY_INSERT dbo.Competentions ON;");
         SaveChanges();
         Database.ExecuteSqlRaw("SET IDENTITY_INSERT dbo.Competentions OFF;");
         using (var reader = new StreamReader(DPath + "Championships.csv"))
             using (var csv = new CsvReader(reader, CultureInfo.InvariantCulture))
             {
                 Championships.AddRange(csv.GetRecords <Championship>());
             }
         Database.ExecuteSqlRaw("SET IDENTITY_INSERT dbo.Championships ON;");
         SaveChanges();
         Database.ExecuteSqlRaw("SET IDENTITY_INSERT dbo.Championships OFF;");
         using (var reader = new StreamReader(DPath + "Infrastructures.csv"))
             using (var csv = new CsvReader(reader, CultureInfo.InvariantCulture))
             {
                 Infrastructures.AddRange(csv.GetRecords <Infrastructure>());
             }
         Database.ExecuteSqlRaw("SET IDENTITY_INSERT dbo.Infrastructures ON;");
         SaveChanges();
         Database.ExecuteSqlRaw("SET IDENTITY_INSERT dbo.Infrastructures OFF;");
         using (var reader = new StreamReader(DPath + "SMPs.csv"))
             using (var csv = new CsvReader(reader, CultureInfo.InvariantCulture))
             {
                 SMPs.AddRange(csv.GetRecords <SMP>());
             }
         Database.ExecuteSqlRaw("SET IDENTITY_INSERT dbo.SMPs ON;");
         SaveChanges();
         Database.ExecuteSqlRaw("SET IDENTITY_INSERT dbo.SMPs OFF;");
         using (var reader = new StreamReader(DPath + "Results.csv"))
             using (var csv = new CsvReader(reader, CultureInfo.InvariantCulture))
             {
                 Results.AddRange(csv.GetRecords <Result>());
             }
         Database.ExecuteSqlRaw("SET IDENTITY_INSERT dbo.Results ON;");
         SaveChanges();
         Database.ExecuteSqlRaw("SET IDENTITY_INSERT dbo.Results OFF;");
         using (var reader = new StreamReader(DPath + "Sponsors.csv"))
             using (var csv = new CsvReader(reader, CultureInfo.InvariantCulture))
             {
                 Sponsors.AddRange(csv.GetRecords <Sponsor>());
             }
         Database.ExecuteSqlRaw("SET IDENTITY_INSERT dbo.Sponsors ON;");
         SaveChanges();
         Database.ExecuteSqlRaw("SET IDENTITY_INSERT dbo.Sponsors OFF;");
         using (var reader = new StreamReader(DPath + "Volunteers.csv"))
             using (var csv = new CsvReader(reader, CultureInfo.InvariantCulture))
             {
                 Volunteers.AddRange(csv.GetRecords <Volunteer>());
             }
         Database.ExecuteSqlRaw("SET IDENTITY_INSERT dbo.Volunteers ON;");
         SaveChanges();
         Database.ExecuteSqlRaw("SET IDENTITY_INSERT dbo.Volunteers OFF;");
         Database.CloseConnection();
     }
 }
 public override System.Web.Mvc.ActionResult BecomePartnerRequestReaction(Experts.Web.Models.Events.BecomePartnerRequestReactionModel model)
 {
     var callInfo = new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.BecomePartnerRequestReaction);
     ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "model", model);
     return callInfo;
 }
 public override System.Web.Mvc.ActionResult EditCategoryAttribute(Experts.Web.Models.Forms.CategoryAttributeForm form)
 {
     var callInfo = new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.EditCategoryAttribute);
     ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "form", form);
     return callInfo;
 }
 public override System.Web.Mvc.ActionResult UpdateCategoryAttributeOption(int categoryAttributeId, Experts.Core.Entities.CategoryAttributeOption updatedOption)
 {
     var callInfo = new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.UpdateCategoryAttributeOption);
     ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "categoryAttributeId", categoryAttributeId);
     ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "updatedOption", updatedOption);
     return callInfo;
 }
Exemplo n.º 26
0
 public override System.Web.Mvc.ActionResult ResetPassword(string resetKey, Experts.Web.Models.Forms.PasswordForm model)
 {
     var callInfo = new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.ResetPassword);
     ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "resetKey", resetKey);
     ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "model", model);
     return callInfo;
 }
Exemplo n.º 27
0
 public override System.Web.Mvc.ActionResult Error500(Experts.Web.Models.Forms.ApplicationErrorForm form)
 {
     var callInfo = new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.Error500);
     ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "form", form);
     return callInfo;
 }
Exemplo n.º 28
0
 public override System.Web.Mvc.ActionResult EditPhoneNumber(Experts.Web.Models.Forms.PhoneNumberForm form)
 {
     var callInfo = new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.EditPhoneNumber);
     ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "ExpertProfileFormModel.ExpertProfileForm.PhoneNumberForm", form);
     return callInfo;
 }
Exemplo n.º 29
0
        public override void Calculate()
        {
            var qCount = Questions.Count();
            var eCount = Experts.Count();

            var qDict      = Questions.ToDictionary(x => x, x => 0d);
            int index      = 0;
            var qIndexDict = Questions.ToDictionary(x => x, x => index++);

            index = 0;
            var eIndexDict = Experts.ToDictionary(x => x, x => index++);

            var matrix = new double[eCount, qCount];

            var coeffitient = (double)qCount / MaxNormalizedAnswer;

            //Нормализую ответы, относительно максимума, чтобы результат был меньше кол-ва вопросов
            foreach (var answer in ExpertAnswer)
            {
                var qIndex = qIndexDict[answer.Question];
                var eIndex = eIndexDict[answer.Expert];

                matrix[eIndex, qIndex] = answer.NormalizedAnswer * coeffitient;
            }

            //Нормализую ответы, убирая одинаковые ответы, не соотносящиеся с рангами
            Normalize(matrix);

            _normalizedMartix = matrix;

            //Сумма ответов по вопросам
            var totalSum = 0d;
            //Среднее значение ответов от сумм ответов по вопросам
            var middleSum = 0d;
            //Суммы ответов по вопросам
            var qSumm = new double[qCount]; QSumms = qSumm;
            //Отклонение от средней суммы ответов по вопросам
            var qDSumm = new double[qCount]; QDSumms = qDSumm;
            //Квадраты ответов по вопросам
            var qDoubleSumm = new double[qCount]; QDoubleSumms = qDoubleSumm;

            for (int q = 0; q < qCount; q++)
            {
                var qSum = 0d;

                for (int e = 0; e < eCount; e++)
                {
                    qSum += matrix[e, q];
                }

                totalSum += qSum;

                qSumm[q] = qSum;
            }

            middleSum = qSumm.Sum() / qSumm.Length;

            for (int q = 0; q < qDSumm.Length; q++)
            {
                qDSumm[q] = qSumm[q] - middleSum;
            }

            for (int q = 0; q < qDoubleSumm.Length; q++)
            {
                qDoubleSumm[q] = qDSumm[q] * qDSumm[q];
            }

            S = qDoubleSumm.Sum();

            const string sName   = "S";
            const string expName = "exp";
            const string queName = "que";

            CoefficientOfConcordance = GetFormula($"(12*{sName})/(({expName}*{expName})*({queName}*{queName}*{queName}-{queName}))");
            CoefficientOfConcordance.TrySetValue(sName, (decimal)S);
            CoefficientOfConcordance.TrySetValue(expName, eCount);
            CoefficientOfConcordance.TrySetValue(queName, qCount);
        }
Exemplo n.º 30
0
 public override System.Web.Mvc.ActionResult EditExpertMicroprofile(Experts.Web.Models.Forms.ExpertMicroprofileForm model)
 {
     var callInfo = new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.EditExpertMicroprofile);
     ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "ExpertProfileFormModel.ExpertProfileForm.ExpertMicroprofileForm", model);
     return callInfo;
 }
Exemplo n.º 31
0
 public override System.Web.Mvc.ActionResult PaymentConfirmation(int paymentId, Experts.Core.Entities.PaymentStatus providerStatus)
 {
     var callInfo = new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.PaymentConfirmation);
     ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "paymentId", paymentId);
     ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "providerStatus", providerStatus);
     return callInfo;
 }
Exemplo n.º 32
0
 public override System.Web.Mvc.ActionResult EditMailConfiguration(Experts.Web.Models.Forms.MailConfigurationForm model)
 {
     var callInfo = new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.EditMailConfiguration);
     ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "MailConfigurationForm", model);
     return callInfo;
 }
Exemplo n.º 33
0
 public override System.Web.Mvc.ActionResult CategoryAttributes(Experts.Web.Models.Forms.ThreadForm form, int? brokerId)
 {
     var callInfo = new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.CategoryAttributes);
     ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "ThreadForm", form);
     ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "brokerId", brokerId);
     return callInfo;
 }
Exemplo n.º 34
0
 public override System.Web.Mvc.ActionResult EditPublicSanitizedThreadTitle(Experts.Core.Entities.Thread model)
 {
     var callInfo = new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.EditPublicSanitizedThreadTitle);
     ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "Thread", model);
     return callInfo;
 }
Exemplo n.º 35
0
 public override System.Web.Mvc.ActionResult SanitizationQuestionList(Experts.Core.Entities.ThreadSanitizationStatus? sanitizationStatus, MvcContrib.UI.Grid.GridSortOptions sortOptions, int? page)
 {
     var callInfo = new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.SanitizationQuestionList);
     ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "sanitizationStatus", sanitizationStatus);
     ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "sortOptions", sortOptions);
     ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "page", page);
     return callInfo;
 }
Exemplo n.º 36
0
 public override System.Web.Mvc.ActionResult ShowPriceProposalNotification(Experts.Core.Entities.Thread thread)
 {
     var callInfo = new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.ShowPriceProposalNotification);
     ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "thread", thread);
     return callInfo;
 }
Exemplo n.º 37
0
 public override System.Web.Mvc.ActionResult ShowPost(Experts.Core.Entities.Post post, bool isCatalogMode, bool isSanitizationMode)
 {
     var callInfo = new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.ShowPost);
     ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "post", post);
     ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "isCatalogMode", isCatalogMode);
     ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "isSanitizationMode", isSanitizationMode);
     return callInfo;
 }
Exemplo n.º 38
0
 public override System.Web.Mvc.ActionResult SignIn(Experts.Web.Models.Forms.SignInForm model, string returnUrl)
 {
     var callInfo = new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.SignIn);
     ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "model", model);
     ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "returnUrl", returnUrl);
     return callInfo;
 }
Exemplo n.º 39
0
 public override System.Web.Mvc.ActionResult SanitizationUpdateThread(int threadId, Experts.Core.Entities.ThreadSanitizationStatus sanitizationStatus)
 {
     var callInfo = new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.SanitizationUpdateThread);
     ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "threadId", threadId);
     ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "sanitizationStatus", sanitizationStatus);
     return callInfo;
 }
Exemplo n.º 40
0
 public override System.Web.Mvc.ActionResult Fatal(Experts.Web.Logging.WebLogEntity webLogEntity)
 {
     var callInfo = new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.Fatal);
     ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "webLogEntity", webLogEntity);
     return callInfo;
 }
Exemplo n.º 41
0
 public override System.Web.Mvc.ActionResult ShowThreadDetailsMenu(Experts.Core.Entities.Thread thread, bool isModerator, Experts.Core.Entities.Post post)
 {
     var callInfo = new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.ShowThreadDetailsMenu);
     ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "thread", thread);
     ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "isModerator", isModerator);
     ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "post", post);
     return callInfo;
 }
Exemplo n.º 42
0
        public override IDistribution Fit(string variableName)
        {
            /* **** */

            orderedExpertNames = new string[Experts.Count()];
            int j = 0;

            foreach (var e in Experts)
            {
                orderedExpertNames [j] = e.Name;
                j++;
            }

            /* ---- */

            Buildz();
            BuildZ();
            BuildS();
            BuildPr();

            /* **** */

            var variable = Variables.Single(x => x.Name == variableName);

            var bounds = GetBounds(variable);
            var min    = bounds.Item1;
            var max    = bounds.Item2;

            var xx = Estimates.Get(variable);
            // var xx = expertEstimates.SelectMany(t => t);

            var xlist = new List <double> (xx);

            xlist.Add(min);
            xlist.Add(max);
            xlist.Sort();

            var probabilities = new double[xlist.Count - 1];

            for (int i = 0; i < xlist.Count - 1; i++)
            {
                var v = xlist[i];
                probabilities[i] = 1;
                var h = 0;

                // for getting the correct h, we need to compute it in the opposite
                // direction; as h = ((...) * (m + 1) + j ) * (m + 1) + k for [...,j,k]
                for (int l = Experts.Count() - 1; l >= 0; l--)
                {
                    var currentExpert = Experts.Single(x => x.Name == orderedExpertNames [l]);
                    var ll            = Estimates [currentExpert, variable].ToList();
                    // expertEstimates[l].ToList();
                    var index = ll.FindIndex(y => y > v);
                    if (index < 0)
                    {
                        index = NbQuantiles;
                    }

                    h = (h * (NbQuantiles + 1)) + index;
                }
                probabilities[i] *= Pr[h];
            }

            var sum = probabilities.Sum();

            probabilities = probabilities.Select(t => t / sum).ToArray();
            var stops = xlist.ToArray();

            var quantiles = new double [probabilities.Length + 1];

            quantiles [0] = 0;
            int ij;

            for (ij = 1; ij < probabilities.Length; ij++)
            {
                quantiles [ij] = quantiles[ij - 1] + probabilities[ij - 1];
            }

            quantiles [ij] = 1;

            var dist = new QuantileDistribution(quantiles, stops);

            return(dist);
        }
Exemplo n.º 43
0
 public override System.Web.Mvc.ActionResult CreateFeedbackForm(Experts.Web.Models.Forms.FeedbackForm form, int? threadId, bool skipAnswerFeedback)
 {
     var callInfo = new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.CreateFeedbackForm);
     ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "form", form);
     ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "threadId", threadId);
     ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "skipAnswerFeedback", skipAnswerFeedback);
     return callInfo;
 }
Exemplo n.º 44
0
 public override System.Web.Mvc.ActionResult ModeratorChatList(Experts.Web.Models.Chat.ChatsOverviewFilter filter, int page)
 {
     var callInfo = new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.ModeratorChatList);
     ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "filter", filter);
     ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "page", page);
     return callInfo;
 }
Exemplo n.º 45
0
 public override System.Web.Mvc.ActionResult ProposeAdditionalService(Experts.Web.Models.Forms.AdditionalServiceForm form)
 {
     var callInfo = new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.ProposeAdditionalService);
     ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "form", form);
     return callInfo;
 }
Exemplo n.º 46
0
 public override System.Web.Mvc.ActionResult SendMessage(Experts.Web.Models.Forms.ChatMessageForm form)
 {
     var callInfo = new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.SendMessage);
     ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "form", form);
     return callInfo;
 }
Exemplo n.º 47
0
 public override System.Web.Mvc.ActionResult OpinionSingle(Experts.Core.Entities.Feedback model)
 {
     var callInfo = new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.OpinionSingle);
     ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "model", model);
     return callInfo;
 }
Exemplo n.º 48
0
        private async Task LoadTSN(string tsn)
        {
            var hierarchy = await RequestManager.RequestFullHierarchy(tsn);

            var currentTaxonHierarchy = hierarchy.HierarchyList.Where(x => x.TSN.Equals(tsn)).FirstOrDefault();

            var currentTaxon = await RequestManager.RequestFullRecord(tsn);

            var image = await RequestManager.RequestWikispeciesImage(currentTaxonHierarchy.TaxonName);

            var imageSource = image.Query.Pages.FirstOrDefault().Value.Thumbnail?.Source;

            var children  = new List <HierarchyItem>();
            var ascending = new List <HierarchyItem>();

            children  = hierarchy.HierarchyList.Where(hierarchyItem => Rank.NumRankOf(currentTaxonHierarchy.RankName) < Rank.NumRankOf(hierarchyItem.RankName)).ToList();
            ascending = hierarchy.HierarchyList.Where(hierarchyItem => Rank.NumRankOf(currentTaxonHierarchy.RankName) >= Rank.NumRankOf(hierarchyItem.RankName)).ToList();

            await DispatcherUtil.Dispatch(() =>
            {
                TheList.SetBinding(ListView.ItemsSourceProperty, new Binding {
                    Source = children
                });
                if (!children.Any())
                {
                    DescendingGrid.Visibility = Visibility.Collapsed;
                }

                TaxonName.Text  = currentTaxonHierarchy.TaxonName;
                CommonName.Text = currentTaxon.GetCommonName();
                RankName.Text   = currentTaxonHierarchy.RankName;

                if (string.IsNullOrWhiteSpace(currentTaxon.Author.Authorship))
                {
                    AuthorshipLabel.Visibility = Visibility.Collapsed;
                    AuthorshipEntry.Visibility = Visibility.Collapsed;
                }
                else
                {
                    AuthorshipLabel.Visibility = Visibility.Visible;
                    AuthorshipEntry.Visibility = Visibility.Visible;
                    AuthorName.Text            = currentTaxon.Author.Authorship;
                }

                if (imageSource != null)
                {
                    TaxonImage.Source = new BitmapImage(new Uri(imageSource, UriKind.Absolute));
                }

                var synonyms = currentTaxon.SynonymList.Synonyms
                               .Where(x => x != null)
                               .Select(x => new SynonymItem(x));

                var synonymsCollection = new ObservableCollection <SynonymItem>(synonyms);

                if (synonymsCollection.Count == 0)
                {
                    SynonymsList.Visibility   = Visibility.Collapsed;
                    SynonymsButton.Visibility = Visibility.Collapsed;
                }
                else
                {
                    SynonymsList.Visibility   = Visibility.Visible;
                    SynonymsButton.Visibility = Visibility.Visible;
                    SynonymsList.SetBinding(ListBox.ItemsSourceProperty, new Binding {
                        Source = synonymsCollection
                    });
                }

                var pathItems = ascending.OrderBy(x => Rank.Ranks.ToList().IndexOf(x.RankName)).ToList();
                TaxonPath.SetBinding(ListView.ItemsSourceProperty, new Binding {
                    Source = pathItems
                });

                var expertsList = currentTaxon.ExpertList.Experts.Where(x => x != null).ToList();
                Experts.SetBinding(ListView.ItemsSourceProperty, new Binding {
                    Source = expertsList
                });
                if (expertsList.Any())
                {
                    ExpertsLabel.Visibility = Visibility.Visible;
                }

                var otherSourcesList = currentTaxon.OtherSourcesList.OtherSources.Where(x => x != null && !string.IsNullOrEmpty(x.SourceComment) && !string.IsNullOrEmpty(x.Source)).ToList();
                OtherSources.SetBinding(ListView.ItemsSourceProperty, new Binding {
                    Source = otherSourcesList
                });
                if (otherSourcesList.Any())
                {
                    OtherSourcesLabel.Visibility = Visibility.Visible;
                    OtherSources.Visibility      = Visibility.Visible;
                }
            });
        }