/// <summary> /// Находит наилучшие решения по методу Електра. /// </summary> /// <param name="current">Варианты выбора и параметры каждого варианта.</param> /// <returns>Таблица с новыми значениями.</returns> public static TableOfResults ElectraMethod(TableOfExemplars current) { Dictionary <KeyValuePair <Exemplar, Exemplar>, ElementOfTable> values = new Dictionary <KeyValuePair <Exemplar, Exemplar>, ElementOfTable>(); foreach (var pair in current.Join()) { Exemplar first = pair.Key; Exemplar second = pair.Value; Dictionary <Exemplar, double> score = new Dictionary <Exemplar, double>(2) { [first] = 0, [second] = 0 }; foreach (Column difference in current.Columns) { if (first.IsBetter(difference, second)) { score[first] += difference.Weight; } else if (second.IsBetter(difference, first)) { score[second] += difference.Weight; } } values[pair] = score[first] / score[second]; } return(new TableOfResults(values)); }
public bool IsBetter(Column column, Exemplar another) => column.IsBetterMany ? (this[column] > another[column]) : (this[column] < another[column]);