# Simple Program: Algorithm for Building Groups

This project received **16** bids from talented freelancers with an average bid price of **$118 USD**.

###### Skills Required

###### Project Budget

$30 - $250 USD###### Total Bids

16###### Project Description

I need a program which will create unique groups of elements subject to certain criteria. I need to be able to vary the inputs and run the program in a browser or Excel. If absolutely necessary I could use Matlab, Stata, or Access to run it too. (If you have another idea please let me know.) Program does not need to look too pretty but should be simple to use. It doesn't need to be very efficient in terms of speed either, if it takes a few seconds to run that will be fine. I can visualize how the algorithm might work but I don't have programming skills. Hopefully someone can program it up pretty quickly.

Here is the problem:

I have two groups (of people) A and B. Group A has N_a people and group B has N_b people (i.e. N = N_a + N_b). I want to randomly build G distinct groups of people, all of size N_g in round R=1. However, these groups must meet certain criteria: some groups will need n people from group A and m people from group B while other groups will need n' people from group A and m' people from group B, and so on. (Example: If I have 20 (N_a) people in A and 20 (N_b) people in B then I want to make 8 groups (G) of 5 people (N_g). I want the group compositions to be 1A/4B, 1A/4B, 2A/3B, 2A/3B, 3A/2B, 3A/2B, 4A/1B, 4A/1B. I would want to specify the group compositions, the number in each group (N_g), the number of groups (G).)

After round R=1, for round R=2, I want to then randomly assign everyone to a different group subject to the specified group compositions (same compositions for all rounds - these only need to be specified once). But, no one can be in a group with the the same person as before. (So, we randomly create 8 groups of 5 with the same specified group compositions but no two people should be in the same group with each other in both R=1 and R=-2).

Finally, in R=3 we do the same thing. Randomly make G groups all of size N_g but no one can be in a group with someone they were in a group with in R=1 or R=2.

I want the program to be flexible enough to specify any value of R.

I realize that there is a set of (N_a,N_b) pairs that will work once you specify R, G, N_g, and the compositions for each group. In each round some people will of course not be in one of the groups.

So, I want the program to deliver the following:

1. Given R, G, N_g, and the compositions A/B for each group, I want to be given a list of all (N_a,N_b) pairs for which it is possible to complete all the groupings as specified. This is of course for the minimum necessary N (call it minN) since an infinite number of pairs exists. Also you could include the pairings for minN + 1. (EX: For the example above, I know from brute force that 20A/23B will allow me to make 8 unique groups in all 3 rounds given the compositions 1A/4B, 1A/4B, 2A/3B, 2A/3B, 3A/2B, 3A/2B, 4A/1B, 4A/1B. List all the other pairings that will work, such as 21A/22B, i guess. Or, maybe you only need minN=42. Then list all the pairs that will work such that N_a+N_b = 42. Also then list all the pairs for minN+_1 = 43.).

2. By specifying R, G, N_g,the compositions for A/B for each group and (N_a,N_b), I want a list of randomly generated groups. I imagine it would show for each R the elements of A and B in each group. Important: In the event that the (N_a,N_b) pair I input cannot completely satisfy the constraints put in, the program needs to ask which group(s) of G to not fulfill. The output should then list the elements of A and B not assigned to a group as well. (EX: if I only had 20A/21B, I don't think it would be possible to create all the unique groups according to the combinations. So the program should ask which of the 8 groups to not fill. It would then still assign people to the remaining 7 groups. If it can only satisfy 6 groups then it should ask for 2 to be dropped. Elements not assigned to one of the 7 complete groups should also be listed. They can be in the "Sit Out" group.)

3. The output should also list for each element/person of A or B which group it is assigned to in each round. (EX: Person 5: Group 1 (R=1); Group 4 (R=2); Group 1 (R=3)). I don't care how, but every element needs a unique identifier. I must be able to tell whether an element came from A or B. So, giving elements in A odd number and elements in B even numbers will work. Or, A1, A2, etc. and B1, B2, etc. Groups should be uniquely labeled too by their round (R) and group within that round.

4. The output files need to be something I can print - a txt file or PDF, etc.

### Looking to make some money?

- Set your budget and the timeframe
- Outline your proposal
- Get paid for your work

## Hire Freelancers who also bid on this project

## Looking for work?

### Work on projects like this and make money from home!

Sign Up Now- Forbes
- The New York Times
- Time
- Wall Street Journal
- Times Online