I have a database which has a table that stores medical conditions and another table which stores symptoms. Each condition has many symptoms. The user will select a number of symptoms from the database and the algorithm will find out how many symptoms match for each condition.
I want to return each matching condition and the number of matching symptoms e.g Cold 4/8
It’s quite a simple idea although I’m having difficulty working out the pseudocode/algorithm.
Thanks
If you have to code it from scratch (for example, in a homework assignment) then you might want to look at the Rete algorithm. It’s going to try and help you make the minimal number of tests to get to a given conclusion. If you just take the brute force solution of looking at a bunch of different medical conditions and a set of symptoms for each and roll through testing each symptom for each condition to assign it a score, you’ll end up testing the same symptoms many many times within different conditions. Runny nose, cough, etc. might show up in the symptoms list for hundreds of things. Rete attacks that and only tests each symptom once and then works its way to conclusions.
However, if you’re not having to build this from scratch then you probably want to look at an off-the-shelf solution like Drools or Jess which give you a rules engine to make building the kind of database you want easy. They also build in a Rete algorithm (or something like it) to optimize their performance in the face of potentially huge numbers of rules.