PFAF companionship algorithm
Task is to implement algorithm that is given a set of plants as input and that calculates a companionship score based on combined information from the PFAF database and our current companionship database. Score of 0 indicates that the input set is not mutually compatible. Positive score indicates the goodness of the input set.
Companionship score is calculated in two steps. First the mutual compatibility (boolean) of the input set is determined. Then, if the plants are compatible, the goodness (positive integer) of the input set is calculated.
score = compatibility * goodness
PFAF categories that are used for determining compatibility are hardiness zone, soil type, pH, moisture and shade. These values must partially match between all pairs of the input set. Also all pairs must be neutral or positive in our current companionship database.
Goodness is the sum of diversity and preference values. Diversity correlates with the amount of different plant features that the input set spans. Preference correlates with the presence of specific plant features. Each diversity and preference value is also associated with an importance factor.
goodness = diversity + preference diversity = sum(diversity[i] * importance[i]) preference = sum(preference[i] * importance[i])
Each individual diversity value corresponds with a PFAF category. PFAF categories are treated as enum types. Individual diversity value is then the number of different enum values that the input set spans. This ensures that a diversity of edible uses (or medicinal uses, pollinators, physical dimensions, habits, etc.) is preferred over only single edible use.
The PFAF categories of edible rating and medicinal rating correspond to two preference values (calculated as sum of ratings of input plants). Another preference value is the number of positive pairs of the input set in our current companionship database.
#2 Updated by Petteri Pitkänen about 1 year ago
Moved to github: