I am looking for a high speed solution to cycle a function with all combinations of different variables with start step stop scheme. Only at run-time is it known which variables are activated for the combination. (use = false/true).
A possible Solution can using recursion or back-tracking but that is too "slow" for the application.
For me the challenge is:
- High Performance! No use of recursion or back-tracking. Maybe a fast iterative solution?
- handle double and int datatypes.
- handle that only at run-time is it known which variables are activated for the combination. (use = false/true)
- handle that only at run-time is it known start/step/stop for the combination.
- The funktion use the normal values (e.g. i1_value). During the cycles, the values are changed through the combinations (if use = true).
How could a solution look like?
In this Example, the possible combinations of all active variables is 10*11*21 = 2310 In real there are more Variables and much more possible combinations, maybe up to several millions (the reason for need a high performance solution).
int i1_use = true;
int i1_value = 1; // the normal value that the function use
int i1_start_value = 1;
int i1_step_value = 2;
int i1_stop_value = 20;
// 1,3,5,7,9,11,13,15,17,19
// -> gives 10 different values
int i2_use = false;
int i2_value = 100; // the normal value that the function use
int i2_start_value = 1000;
int i2_step_value = 500;
int i2_stop_value = 3000;
// -> use = false! no combination!
double d1_use = true;
double d1_value = 1.234; // the normal value that the function use
double d1_start_value = 0;
double d1_step_value = 0.02;
double d1_stop_value = 0.2;
// 0,0.02,0.04,0.06,0.08,0.1,0.12,0.14,0.16,0.18,0.2
// -> gives 11 different values
double d2_use = true;
double d2_value = 10; // the normal value that the function use
double d2_start_value = 10;
double d2_step_value = 0.5;
double d2_stop_value = 20;
// 10,10.5,11,11.5,12,12.5,13,13.5,14,14.5,15,15.5,16,16.5,17,17.5,18,18.5,19,19.5,20
// -> gives 21 different values
// All combinations 10*11*21 = 2310