So I have a set of data which is similar to this:
index |Parameter A| Parameter B
1|1|3
2|1|5
3|1|1
4|2|12
5|2|15
6|2|41
7|3|22
8|3|14
9|3|9
I need to calculate all the possible combinations of parameters B with a different parameter A i.e. (1)3-(2)12-(3)9 and obtain the indices of said combinations, in this case 1-4-9. The way I solved this was defining the index at which parameter A changes (in this case 3 and 6, I should point out it is not periodic) and use the combvec function in a loop:
- combvec(combvec(1:3,4:6),6:9);
An then obtain a matrix which has all the combination indices in each column, which I can then use to obtain combinations of parameter B. The thing is the list is too big now hence the Out of memory problem.
The objective here is to calculate for each sequence of parameters B obtain a certain result - X - and then choose the combination that minimises said result.
I thought I could divide the list in two but the problem is since X is dependent on all A parameters the minimum of both groups will not necessarily be the global minimum, so I am not so sure.
The other alternative I thought was try obtain each combination in a loop and immediately calculate X and only store X if it was smaller than the previous iteration. This solution would solve my problem of storage but I am not so sure how to do this without a lot of nested loops because I would not be able to use combvec.
I would appreciate if you guys had any ideas on how to solve this or how to come about my suggestions avoiding the problems I mentioned.
My thanks in advance.