Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Generating All Combinations of Array Data

Status
Not open for further replies.

f64

Technical User
May 23, 2003
24
US
I am writing a program that contains an array;

Data(x, y), x = 1 To 8, y = 1 To 24;

The program must generate and evaluate all combinations of y, taken 8 at a time, 1 from each x. What is the most efficient code to generate all the combinations?
 
Either:
For x = 1 To 8
For y = 1 To 24
...
Next y
Next x

Or:
For y = 1 To 24
For x = 1 To 8
...
Next x
Next y

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Have you actually worked out how many results you are going to get for this?

Cheers, Glenn.

Did you hear about the literalist show-jumper? He broke his nose jumping against the clock.
 
I'm not sure I'm explaining myself clearly.

PHV, what you described will iterate through the 8 x 24 = 192 individual entries, but the program must evaluate the entries in groups of 8, one from each x. Does iterating through the individual entries generate all possible combinations?

GlennUK - I think the total number of combinations of 192 items taken 8 at a time is 192! / ( 8!x(184)!) = REALLY BIG, but I'm not sure this equation applies because the population of 192 is divided into sub-groups of 24.
 
What is a group ? What is an evaluation ?
For each y you want all the x combinations ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 

For each x, there would be 735,471 ways to make combinations of 24 things taken 8 at a time. This makes it a grand total of 5,883,768 possible groupings.

Care to explain what it is exactly what you are doing?

If you are going to execute some process for each grouping, and you could generate a group and execute the process 10 times a second, it would only take 7 days to run the entire sequence.

 
sounds like he forgot the combination to his safe

Thanks and best regards,
-Lloyd
 
The program is being written to demonstrate to clinical lab managers how to schedule their diagnostic assays on a batch basis rather than on demand.

A “raw” schedule might look like this:

Assay Day 1 Day 2 Day 3 Day 4 …….. Day 24
1 40 90 100 100 25
2 50 50 50 50 50
3 0 75 0 75 0
4 25 50 0 0 60
…..
8 0 25 40 0 0

Daily 3 16 10 9 12
Turnaround
Time (hr)

The objective is to adjust the schedules of the individual assays, by moving them either forward or backward on the calendar, so that the projected total Daily Turnaround Time is less than the planned daily operating hours.

The “optimized” schedule would look like this:

Assay Day 1 Day 2 Day 3 Day 4 …….. Day 24
1 40 90 100 100 25
2 50 50 50 50 50
3 75 0 75 0 75
4 0 0 25 50 0
…..
8 25 40 0 0 0

Daily 6 8 8 7 8
Turnaround
Time (hr)

Each individual assay’s daily schedule would remain unchanged, only their relative alignment on the calendar would change. Assays with a fixed daily quantity ( 2 ) would be a constant and would be irrelevant to the analysis. The calculation of the daily Turnaround Time is straightforward. I don’t see how to arrive at the optimum alignment of the individual schedules except by generating all feasible combinations, while keeping track of the combination(s) that meet the daily turnaround time goal. I know this is inelegant brute force, but don’t know what else to do.

 

Let me see if I can put this in terms everyone can understand.

1. You have a total of 192 "assays" defined by an ID number from 1 to 8 along with a time value measured in minutes.

2. You need to fill an 8 by 24 matrix with the time values such that
2a. All "assays" with the same ID number must remain on the same row and
2b. The sum of all time values in each column is less than or equal to 480 minutes.

Seems like you could simply start with a random distribution and then "fix" the columns by swapping values, working from left to right. I.e., if the column total is too high (over 480), find smaller numbers and swap. If the column total is too low (under 420), find larger numbers and swap.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top