powerplant
powerplant copied to clipboard
Bed planner
In previous git versions we had a bed planner where it was possible to select a crop for the bed from only those crops that were companion plants with all the other crops that were already in the bed. This worked well for the relatively small dataset that we had back then, but now that we've moved to using the practicalplants.org data with over 8000 crops, we also need to redesign the bed planner.
In the new bed planner there could be a search field where one could find crops by name, and it'd open a dropdown list of the crops that match a given string (if no characters are given it'd show all crops). From this list those crops that are incompatible (cannot be grown in the same environment) with the other crops that are already in the bed, would be filtered out, and the list would be ordered by how good companion a crop would be. Then the user could select additional filters to further limit the list to only those crops that have specific properties.
The filtering function should be independent from the UI and tested separately, it should also use the companionship algorithm in shared/companionship.js
.
It turned out that the algorithm that was used in the previous bed planner has a serious performance problem, it doesn't scale at all to the size of the new dataset. The algorithm that's sketched here would have the time complexity NMK
(plus sorting and filtering), where N
is the number of crops (around 10000), M
is the number of compatibility/goodness values (around 30), and K
is the number of crops in the bed (around 5), so it should be usable, especially with some caching.
Added the filtering function in #59.