I’m working on a research problem out of curiosity, and I don’t know how to program the logic that I’ve in mind. Let me explain it to you:
I’ve four vectors, say for example,
v1 = 1 1 1 1
v2 = 2 2 2 2
v3 = 3 3 3 3
v4 = 4 4 4 4
I want to add them combination-wise. That is,
v12 = v1+v2
v13 = v1+v3
v14 = v1+v4
v23 = v2+v3
v24 = v2+v4
v34 = v3+v4
Till this step it is just fine. The problem/trick is now, at the end of each iteration I give the obtained vectors into a black box function, and it returns only a few of the vectors, say v12, v13 and v34. Now, I want to add each of these vectors one vector from v1, v2, v3, v4 which it hasn’t added before. For example, v3 and v4 hasn’t been added to v12, so I want to create v123 and v124. Similarly for all the vectors like,
v12 should become:
v123 = v12+v3
v124 = v12+v4
v13 should become:
v132 // This should not occur because I already have v123
v134 = v13+v4;
v14,v23 and v24 cannot be considered
because it was deleted in the black
box function so all we have in our
hands to work with is v12,v13 and v34.
v34 should become:
v341 // Cannot occur because we have 134
v342 = v34+v2
It is important that I do not do it all in one step at the start. Like for example, I can do (4 choose 3) 4C3 and finish it off, but I want to do it step by step at each iteration.
How do do it when the black box function is included?
Okay, here goes, this probably could be made more efficient, but I think this does what you need.
NOTES:
trimfunction models your black box which removes some entries from the main map with a given key size (same size as the most recently generated combinations)EDIT:
Okay now
baseis a vector which contains apairfor the key<->vector relationship – this is constant. Initially it is added to the map, and thegen_combfunction is skipped for the initial state,trimis still called to remove some entries. Next iteration uses the same search algorithm, but the combination is with the constant set ofbases.