Calculate family group factor based on matrix

Expand the generate_flush_factor function to calculate the family group
compatibility using information from the product matrix.