|
-
Jun 29th, 2005, 08:30 AM
#1
Thread Starter
Member
Excel Help--Don't know exactly how to, worried about feasibility.
Hi,
Calling me a programmer of any sort would be a gross exaggeration.
After selecting a list of ten (or more or less, though I can put a lower and upper cap on the number in the list) numbers from an excel spreadsheet, I need to take EVERY possible combination of these numbers (choosing each number only once in each combination) and run through a program which then compares the sum of index values on the excel spreadsheet.
The issue I'm having is the actual generation of each combination of the numbers. I have a column of ten cells, and I need to generate each possible combination (yes, all ten factorial). I will be comparing the sums, and choosing the lowest total sum. Each transition has a value associated with it, so the transition 1->2 might be less than 3->4 or 1->4.
To be clear, I have a column of ten cells which correspond to a table in the spreadsheet.
As for the comparing the sums, I think that is simple:
VB Code:
ii = Factorial(Val(NumVals.Text))
LeastVal=1000000000
For ii = 1 to ii
CurrentVal = Function(...)
‘??? can't figure out how to generate each combination. I am thinking a whole new function which generates the sequence and the interrogates the spreadsheet.
If CurrentVal < LeastVal Then
LeastVal = CurrentVal
LeastNum1 = CurrentNumA ‘etc.
Next ii
Else
Next ii
End If
I know for a fact that the sums will be lower than, say, a billion, so I set the first least # to that so it will be instantly replaced. I store the information about the best combo so far in the 'Least' series variables, and replace it if I find a new best combination. Any ideas on what my function should look like?
(I have already coded in the simple factorial function that I call.)
Also, I am concerned that my program might take, say, forever to run. I don't have enough practical experience to know whether this is a valid concern or not, in this case, but 10! = 3.63 million or so. And if my list is longer, that number goes way up...
Thanks in advance for any advice,
Bartender
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|