def weighted_sum(domain, weighted_fns, normalize=True):
    # Table of form:
    #   { domain1: [score1, score2, ..., scoreM]
    #     ...
    #     domainN: [score1, score2, ..., scoreM] }
    score_table = collections.defaultdict(list)
    for weight, fn in weighted_fns:
        scores = [fn(elem) for elem in domain]
        if normalize:
            norm_scores = normalize_list(scores)
        else:
            norm_scores = scores
        for idx, score in enumerate(norm_scores):
            weighted_score = score * weight
            score_table[idx].append(weighted_score)

    # Sum rows in table to compute score for each element in domain
    domain_scores = []
    for idx in sorted(score_table):
        elem_score = sum(score_table[idx])
        domain_scores.append(elem_score)
    return domain_scores
Use the weighted-sum method to compute a score for an array of objects.
dataset/ETHPy150Open nii-cloud/dodai-compute/nova/scheduler/least_cost.py/weighted_sum