So, I have an algorithm, composed of parameters A, B, C and D, and operations X, Y and Z. The objective is to write code that will test all combinations (within a certain range) of A, B, C and D, and possibly change the operations X, Y or Z.
This would be simple if it was just a matter of placing variables within a certain range. But since I want to also change operators, it is not as simple.
My idea is to write the code that would cover all combinations. For example, lets consider that there are only two parameters (A and B) and that the range is the same for both: [1,2], integers. The code would build (and if possible, execute) 4 different executables, corresponding to use the algorithm with:
A = 1, B = 1
A = 1, B = 2
A = 2, B = 1
A = 2, B = 2
Now adding the operators. For example, we pick the previous example and add operation X, where it can be [+,-]. The resulting set is:
A = 1, B = 1, X = +
A = 1, B = 2, X = -
A = 2, B = 1, X = +
A = 2, B = 2, X = -
A = 1, B = 1, X = -
A = 1, B = 2, X = +
A = 2, B = 1, X = -
A = 2, B = 2, X = +
(I hope I wrote all combinations)
Anyway, I believe it is possible to build such structure using a makefile, where it attributes values to constants of a code written in C. I am not sure that is possible to change the operators in such way. I was thinking of using a makefile for simplicity. It is always possible to write code that generates code, but seems quite exaggerated for the case.
Perhaps it would create a tree structure? I'm not sure if it is beneficial to have (and picking the first example):
|--Makefile
|--A1
| |--B1
| | |--a.out
| |--B2
| |--a.out
|--A2
|--B1
| |--a.out
|--B2
|--a.out
Using make I believe I can add extra variables/operators to the code and rebuild all the tests easily. Also, does this structure allow the use of the jobs functionality of make in order to have multiple threads running?
Thanks