# Generate all combinations from two data-sets [closed]

I have a large number of expressions which I am trying to solve.

• List 1 contains formulas like `A = B + C`.
• List 2 contains additional equations for those variables, like `C = D*3`, `C = B/2`, `B = D*50`, etc.
• List 3 contains values for those variables B, D, etc.

I then need to compute all possible results for the List 1 formulas when expanding the formula by using different equations from List 2. Since these lists are large, the number of possible combinations can be huge!

I planning to break down the problem as follows:

1. For each expression in List-1 look up all possible values for each variable in List-2 and generate all possible expression as List-4. List-4 can be huge, maybe in GB or TB!
2. Create a tree for each expression from first generated list Find the each variable values in List-3.
3. Replace constant in the expression to get the result.

Step 1 and 3 are the core problems which needs lot of memory and CPU, any guidance would be highly appreciated.

Example:

• List1 (Expressions): `A = x + y`, `y = u + v`
• List2 (extensions): `v = 20 + u`, `v = 30*u`
• List3 (constant values): `x = 20`, `u = 10`

Expanding with `v = 20 + u`:
`A = x + y`, `y = u + 20 + u`, `x = 20`, `u = 10`
=> y = 40, A = 60

Expanding with `v = 30*u`:
`A = x + y`, `y = u + 30*u`, `x = 20`, `u = 10`
=> y = 310, A = 330

## closed as unclear what you're asking by gnat, amon, Bart van Ingen Schenau, BobDalgleish, MetaFightDec 13 '17 at 17:14

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

• please don't cross-post: stackoverflow.com/questions/47566167/… – gnat Nov 30 '17 at 5:53
• It's not clear to me the relationship between List-1, List-2, and List-3. Is List-1 and List-2 one to one or many to one? Same question for List2 and List3. – Neil Nov 30 '17 at 8:46
• For me it's not clear either. Am I correctly assuming that list 2 just contains variable names, that list 3 contains tuples of values for he variables in list 2, and that expressions in list 1 are considered independent from each other ? – Christophe Nov 30 '17 at 9:14
• What's the difference between: "formulas" in list 1 written as assignments (or equalities?) involving variables -- vs. -- "values" written in list 2, also as assignments (or equalities?) involving variables? – Erik Eidt Nov 30 '17 at 18:06
• Also we need to be clear on when/whether the elements in the various lists (not to mention all the lists as a whole) are taken in conjunction or disjunction. – Erik Eidt Nov 30 '17 at 18:07