# How the Score is calculated when ranking instances in Clarity Portfolio Waterlines

**Document ID :**KB000100774

**Last Modified Date :**11/06/2018

The score is calculated by normalizing each optimization parameter on each instance to a value between 0 and 10. The formula to normalize is as follows:

((value - min) / (max - min)) * 10

where value = the optimization parameter value on the instance

min = the minimum value of the optimization parameter of all instances in the set to be ranked.

max = the maximum value of the optimization parameter of all instances in the set to be ranked.

Once the optimization parameter value on the instance has been normalized the weight and the high/low optimization is applied to get the final score of that parameter on the instance. This is done using the following calculation:

weight * (optimizeHigh ? normalizedValue : (10 - normalizedValue))

The final score for the instance is the sum of all the calculated optimization parameter scores.

There are few fence-post cases that need to be called out in this scoring:

- If the min = max then the optimization parameter's score will just be the weight.
- If there is only one optimization parameter and it is optimized high then the value of that parameter is the score for the optimization parameter.
- Lookups are supported, however, the user must set up a numeric enumeration on the lookup codes. This is done in the UI using the Lookup weighting values link. If no enumeration is set up, the score for the lookup will be 0.
- Date attributes are supported. The value of the date attribute is the Julian day value as calculated by Clarity's NkDate Java class. The routine creates the Julian day using this algorithm, where the year, month and day are standard numbers from a Java calendar instance:

The RankSelector will write the scores of the RankedItems along with their primary keys to the log if you enable the following category in your logger.xml file:

<category additivity="false" name="com.ca.clarity.ranking.RankSelector">

<priority value="debug"/>

<appender-ref ref="STDOUT"/>

</category>