public List <dtoAlgorithmAlternativeFuzzy> CalculateWeightedAverage(dtoAlgorithmInputFuzzy input) { List <dtoAlgorithmAlternativeFuzzy> results = input.Alternatives; LM.MathLibrary.Algorithms.TriangularFuzzyWeightedAverage tp = new LM.MathLibrary.Algorithms.TriangularFuzzyWeightedAverage(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.Ranking = 0; alternative.FinalValue = 0; alternative.FinalValueFuzzy = alternative.FinalValue.ToFuzzy().ToString(); alternative.IsFuzzyValue = true; } index++; } } return(results); }
public List <dtoAlgorithmAlternativeFuzzy> CalculateTopsis(dtoAlgorithmInputFuzzy input, IEnumerable <int> benefits = null, IEnumerable <int> costs = null) { List <dtoAlgorithmAlternativeFuzzy> results = input.Alternatives; LM.MathLibrary.Algorithms.FuzzyTopsis tp = new LM.MathLibrary.Algorithms.FuzzyTopsis(input.Alternatives.Select(a => a.Values.ToArray()), input.Weights.ToArray(), benefits, costs); double[] values = tp.Elaborate(); if (values != null && values.Any()) { //values = (values.SumToOne()) ? values ; values.NormalizeTo1().ToArray(); long index = 0; foreach (dtoAlgorithmAlternativeFuzzy alternative in results) { alternative.Ranking = values[index]; alternative.FinalValue = values[index]; alternative.FinalValueFuzzy = new TriangularFuzzyNumber(alternative.FinalValue).ToString(); alternative.IsFuzzyValue = false; index++; } } return(results); }
public List <dtoAlgorithmAlternativeFuzzy> Calculate(dtoAlgorithmInputFuzzy input) { List <dtoAlgorithmAlternativeFuzzy> results = input.Alternatives; switch (input.Type) { case AlgorithmType.ahp: break; case AlgorithmType.owa: results = CalculateOwa(input); break; case AlgorithmType.topsis: results = CalculateTopsis(input); break; case AlgorithmType.weightedAverage: results = CalculateWeightedAverage(input); break; } return(results); }