Injector grouping, the exhaustive search
As you saw in the previous post, the way we grouped injectors was very simple, we simply sorted them by flow and picked 'top 4' and 'bottom 4' and that was it. It seemed to work well, but how do we know there isn't a better method.
Last night I realized that there are 8 injectors, so there's factorial(8)=40320 ways of organizing the injectors. Seems like a lot, but I figured there'd be a lot of repetition within each bank as we don't care if we get [A B C D] or [D C B A] or any other related permutations. Thus I figured this would be problem small enough that I could calculate the flow spreads for every possible permutation (exhaustive search, by the way of brute force).
Matlab of course has a function that can generate permutations of any set of numbers, so I let it generate the 40320-entry long list. Then I split the resulting lists into bank1 and bank2, and then executed all the calculations presented in the previous post. An additional step at the end was summing up the two AFRdifference results, in order to come up with one final number describing the 'goodness' of the combination. Then I found which flow permutations came up with the best (lowest spread) number. I pick one of them, and that's my 'best' injector grouping.
So how did the exhaustive search results compare to our 'sort and split down the middle' approach? Pretty good actually! I ran the optimization for 3 sets of injectors and 2 of the 3 permutations we came up were actually optimal, according to this script. The third permutation was different only in placement of 2 swapped injectors, and even then the resulting difference from what we picked was minuscule. Why does the simplistic approach work so well then? I think it happens because if you pick a group that isn't a 'bottom half ' or 'top half' of flows, then you end up with one group that's very closely matched, but the other group ends up inherently with flows that are from two ends of the spread, negating the positive effect of the extra close group.
I have some other ideas on how to generate the final 'goodness' number. For right now it's just a sum of the AFRdifferences, but it could be something completely different, I could go with standard deviation of the flows within the bank multiplied out with the range of the means between the means of two banks for example. It's just something to play with, and now that I have an infrastructure set up for it, it should be easy.
I put the quotes around the 'best' when talking about finding optimal grouping, because there are many other permutations that generate different, but effectively identical permutations. So once you get results, you still can rearrange the numbers within the bank, to match that particularly high or low flowing cylinder.
When I originally came up with this, I figured I'm going to have to figure out how to eliminate all the 'duplicate permutations' of numbers that are reorganized within the bank, to speed up the process. There was no need for it. The entire script, with setup, calculations, and display of results, took a grand total of 0.03 seconds on a 2yr old 2.4GHz CPU. Right now this is just a Matlab script, which I know is not particularly popular with gearheads due to cost ($2000!!! unless you get the $100 student version). I will try to figure out how to make a standalone program from this script, so you have optimal flow groupings every time you redo your injectors.