| New Reply |
Determining Combinations with Restraints |
Share Thread | Thread Tools |
| Jul16-12, 07:04 PM | #1 |
|
|
Determining Combinations with Restraints
I'm loosely familiar with the formulas for combinations and permutations. However, I don't know how to use the formula with restraints.
Here is the specific issue I am having:
I know that for the first and last 8 both have 2^8 permutations, so there is a minimum of 512 permutations. |
| Jul16-12, 09:08 PM | #2 |
|
|
I'm sorry, I don't understand the question.
|
| Jul16-12, 11:00 PM | #3 |
|
|
Hey Altermeris and welcome to the forums.
Your question is unclear but one recommendation to make it clearer is to write the scenarios and then write how many states per scenario. For example 2 states per object for 16 objects is 32 states, or 2 states per combination of every pair of objects selected without replacemet is 2*16*15 = 480 or 512 if with replacement. This kind of thing would be a lot more informative and cause less confusion. |
| Jul16-12, 11:33 PM | #4 |
|
|
Determining Combinations with Restraints
I wrote a brute force program to solve the problem. By punching in the output of the brute forcing algorithm into WolframAlpha, I was able to find the sequence formula to solve this problem.
An=C(2n,n) Code:
public class BruteForcePermutation {
public static boolean countUniqueChar(int num, char symb, String text){
int count = 0;
int textLength = text.length();
char[] charArray = new char[textLength];
charArray = text.toCharArray();
for(int i = 0; i<textLength; i++)
if(charArray[i]==symb)count++;
if(count==num) return true;
else return false;
}
public static String intToBinary(int num, int size){
String result = "";
while(num!=0){
result = (num%2) + result;
num /= 2;
size--;
}
while(size>0){
result = "0" + result;
size--;
}
return result;
}
public static void main(String[] args){
String currentBin = "";
int permutations;
int terms = 10;
for(int size = 2; size<=terms*2;size+=2){
permutations = 0;
for(int i = 0; i<Math.pow(2,size) ;i++){
currentBin = intToBinary(i,size);
if(countUniqueChar((size/2),'1',currentBin)){
//System.out.println(currentBin);
permutations++;
}
}
System.out.print(permutations + " ");
}
}
}
|
| Jul17-12, 05:58 AM | #5 |
|
|
OK, so have you solved the problem to your satisfaction? If not, then could you please post a better description of your problem, because I don't want to read through Java to try to figure out what you mean.
|
| Jul17-12, 02:02 PM | #6 |
|
|
I'll try describing the problem differently. If you have a bag of n-Coins that contain (n/2) black coins and (n/2) white coins, how many ways can you place the white and black coins in a line of n? |
| Jul17-12, 04:47 PM | #7 |
|
|
the number of combinations of n objects taken n/2 at a time. |
| New Reply |
| Thread Tools | |
Similar Threads for: Determining Combinations with Restraints
|
||||
| Thread | Forum | Replies | ||
| Determining Cheapest Food Combinations (Seems like ILP problem, but also not) | General Math | 4 | ||
| Rigging Restraints & Force Required to Restrain an object | General Engineering | 2 | ||
| effect of thermal expansion on restraints | General Engineering | 7 | ||
| determining probability using combinations/permutations (i think) | Precalculus Mathematics Homework | 1 | ||
| Logical Restraints | General Discussion | 1 | ||