Exemplo n.º 1
0
        public List <dtoAlgorithmAlternativeFuzzy> CalculateOwa(dtoAlgorithmInputFuzzy input)
        {
            List <dtoAlgorithmAlternativeFuzzy> results = input.Alternatives;

            LM.MathLibrary.Algorithms.TriangularFuzzyOWA tp = new LM.MathLibrary.Algorithms.TriangularFuzzyOWA(input.Alternatives.Select(a => a.Values.ToArray()), input.Weights.ToArray());
            TriangularFuzzyNumber[] values = tp.Elaborate();
            if (values != null && values.Any())
            {
                //values = (values.SumToOne()) ? values ; values.NormalizeTo1().ToArray();
                long index = 0;
                foreach (dtoAlgorithmAlternativeFuzzy alternative in results)
                {
                    if (values[index] != null)
                    {
                        alternative.Ranking         = values[index].Ranking();
                        alternative.FinalValue      = values[index].ToCrispy();
                        alternative.FinalValueFuzzy = values[index].ToString();
                        alternative.IsFuzzyValue    = true;
                    }
                    else
                    {
                        alternative.FinalValue      = 0;
                        alternative.Ranking         = 0;
                        alternative.FinalValueFuzzy = alternative.FinalValue.ToFuzzy().ToString();
                        alternative.IsFuzzyValue    = true;
                    }
                    index++;
                }
            }
            return(results);
        }
Exemplo n.º 2
0
        public List <dtoAlgorithmAlternative> CalculateOwa(dtoAlgorithmInput input)
        {
            List <dtoAlgorithmAlternative> results = input.Alternatives;

            double[] weights = input.Weights.ToArray();
            //switch (input.NormalizeTo)
            //{
            //    case NormalizeTo.simple:
            //        weights = weights.SimpleNormalize().ToArray();
            //        break;
            //    case NormalizeTo.standard:
            weights = weights.Normalize().ToArray();
            //        break;
            //    case NormalizeTo.toOne:
            //        weights = weights.NormalizeTo1().ToArray();
            //        break;
            //}

            LM.MathLibrary.Algorithms.TriangularFuzzyOWA tp = new LM.MathLibrary.Algorithms.TriangularFuzzyOWA(input.Alternatives.Select(a => a.Values.ToArray()), weights);
            TriangularFuzzyNumber[] values = tp.Elaborate();
            if (values != null && values.Any())
            {
                long index = 0;
                foreach (dtoAlgorithmAlternative alternative in results)
                {
                    if (values[index] != null)
                    {
                        alternative.Ranking         = values[index].Ranking();
                        alternative.FinalValue      = values[index].ToCrispy();
                        alternative.FinalValueFuzzy = values[index].ToString();
                        alternative.IsFuzzyValue    = true;
                    }
                    else
                    {
                        alternative.Ranking         = 0;
                        alternative.FinalValue      = 0;
                        alternative.FinalValueFuzzy = alternative.FinalValue.ToFuzzy().ToString();
                        alternative.IsFuzzyValue    = true;
                    }
                    index++;
                }
            }
            return(results);
        }