I have been working on this similar problem for over a year now for an application for creating production costs. In the same way, it takes into account a lot of product design data and is based on design and other inventory considerations, such as quantity, bulk purchasing options, parts supplier, electrical ratings, etc. The result is a list of direct materials, costs and expenses.
I knew from the very beginning that I needed some kind of query language instead of a computational one, and it had to be written in a script, not compiled. But I have yet to find the perfect solution:
METHOD 1 - SQL I created tables that represent my objects and columns that represent properties, and then manually enter all the SQL SELECT statuses needed in the item_rules table. What I did was first store the object in the database and then I did
rules = SELECT * FROM item_rules foreach(rules as _rule) { count = SELECT COUNT(*) FROM (_rule[select_statement]) as T1 if(count > 1) itemlist.add(_rule[item_that_satisfy_rule]) }
What he does is each rule in the item_rules table and run it against my object, which is now in the tables. for example SELECT * FROM my_object WHERE A = 5 AND B> 10. If I pick it up successfully, I get a positive amount, and then I know that I must include the corresponding rule element in the list of my positions.
METHOD 2 - NCALC Instead of storing SQL queries, I found the NCALC open source expression parsing library. NCALC takes a string expression and an optional variable and evaluates the result. String expressions can be saved in text format in the file system.
METHOD 3 - EXCEL EXCEL is actually very good data retrieval software. You can create formulas in excel and then transfer data from your application to excel and then let excel run the formulas to give you the results. The advantage is that many people know how to use excel, so different people can support it.
But, as I said, none of this is perfect for me. I just share and hope that we can get the best recommendations.