I need to develop algorithm for one task.
I have 500 types of object, each type is represented by a group of qualifiers (about 20 for each type, the same qualifier can be used for different types), where qualifier is a simple predicate (but calculation of the predicate can take some time, as you have to check data in data base). When all qualifiers for particular type return true then object has such type.
For now I just came up with idea to use cache and go through all types trying to do qualification. For each type firstly I go through predicates without calculation and check that no of them failed before if some failed I skip the type, otherwise I go through qualifiers and do calculations (for each predicate I take data from cache if I did the same qualifier before).
I think may be there are some data structures for such task, or common approaches how to do that better.
A small update to the question. The classification data I have, has special structure, like not all attributes of the object mentioned for each class.
For example Type European transaction:
- Country one of DE, FR, ES
- Color : Blue
- Serial type: 2
- Currency : EUR
Type UK transaction:
- Country: UK
- Serial type: 1
It just example out of my head, each object has much more attributes. The main point here that some attributes can present for some objects but not for others. So if we create data set on the objects to build qualification tree, the value of such attributes could be marked as ANY value, that way it's impossible to do qualification, since we can get to the branch where we have two ways to go.