# Question

How is the Reltio rating/ranking done?

Here is the algorithm of the consolidated rating calculation:

Assume you have a relation. It has several crosswalks, also it has several votes.

1. Walkthrough all Crosswalks and collect information about the Source System of each crosswalk and the update date of the Crosswalk. If several Crosswalks have the same Source System then the crosswalk with a bigger update date will be taken into account.
2. For each Source System we should find weights configuration in the following way:
• Get configuration by the source System from rating configuration/source mapping - it will be a list of weight configurations.
• Walk through the list of configurations and find that one which contains URI of the relation type in the "URIs" attribute. If such configuration will not be found then the configuration without the "URIs" attribute will be used.
• If the rating configuration/sources do not contain mappings for the Source System. Or the list of configuration from the mapping does not have appropriate configuration - then such crosswalk will be ignored in the calculation.
3. If the configuration of the weight for a Source System was found then we calculate agedSourceWeight by minVoteWeight, maxVoteWeight, monthsToMinVote from the configuration and by updateDate of the crosswalk (the formula will be below).
4. Then we sum all these agedSourceWeight and get the sum(agedSourceWeight)
5. After that, we walk through all votes of the relation. For each vote, we walk through all user roles of the vote. For each user role, we take weights configuration from rating configuration/user roles (the algorithm is similar to source systems, except if the weight configuration is not defined to a role then the weight has defaulted to 1.0). And then for each role, we calculate agedRoleWeight by minVoteWeight, maxVoteWeight, monthsToMinVote from the configuration and by the timestamp of the vote. And then we take the biggest (from all roles of the vote) value - agedRoleWeightMax.
6. After the agedRoleWeightMax was calculated for the vote, we calculate agedVoteWeight=value*agedRoleWeightMax, where the value is the value of the vote.
7. Then we calculate sum of all agedRoleWeightMax and agedVoteWeight and thus get the sum(agedRoleWeight) and sum(agedVoteWeight).
8. The consolidatedRating is (sum(agedVoteWeight) + sum(5*agedSourceWeight)) / (sum(agedRoleWeight) + sum(agedSourceWeight))

Algorithm of the aged weight calculation:
So, we have min, max, monthsToMin and time here. Also, we get the current time.
• If time is not defined (for example, a Crosswalk has no updateDate attribute) then the result (final value for aged weight) is 0.
• If some other value is not defined (min, max, monthsToMin) then it will be substituted with 0.
• If monthsToMin <= 0 then the final result is min.
• monthsAmount = amount of months between currentTime and time
• monthsDelta = monthsToMin - monthsAmount
• if monthsDelta <= 0 then the final result is min
• else the final result is min + (max - min) * monthsDelta / monthsToMin

# References

https://docs.reltio.com/ratingapi/ratingsapi.html?hl=rating%2Capi%2Cconfiguration