combinatorics - Combining a set of fractions

Consider the set {1, 1/2, 1/3, 1/4, 1/5, ..., 1/n}Choose any two numbers x and y and replace them with x + y + xyFor example, if we choose the numbers 1 and 1/2 , we will replace them by 1 + 1/2 + 1/2 = 2.If we keep repeating this process until only number remains, what is the final number?So far I understand that this will result in all possible combinations of the terms for example:{a, b, c, d} = a+b+c+d+ab+ac+ad+bc+bd+cd+abc+abd+acd+bcd+abcdHow do we compute this sum effectively though?...Read more

combinatorics - Seeking a solution or a heursitic approxmation for the 3-partition combinatorial situation

How do I distribute 48 items each with its own dollar value to each of 3 inheritors so that the value given to each is equal or nearly equal?This is a form of partitioning problem with is NP-complete (or some such) and therefore impossible to perfectly answer with 48 items. I'm looking for a practical and generally acknowledged approximate algorithm to do this. It's a problem faced by many in resolving wills and estates. Answer must be out there somewhere! The answer could be a computer script or just a manual method.A heuristic that is "Genera...Read more

combinatorics - Product partitions

I am looking for information about "Product Partitions" (I don't know the official name)In the "classic" partition we search the decompositions of a positive integer as sums: Partition(5) 5 1 4 2 3 1 1 3 1 2 2 1 1 1 2 1 1 1 1 1 I want to find all the decompositions as products: ProductPartition(36) 36 2 18 3 12 4 9 6 6 2 2 9 2 3 6 3 3 4 2 2 3 3 I have a recursive solution, but it is not efficient enough.Thank you very much in advance for any information.P...Read more

combinatorics - Find rank of lottery combinations

I need to find the rank/index of a lottery combination and be able to reverse the process (Find the lottery combination given its rank).Consider a lottery game with 5 balls from 1 to 45 and 1 powerball from 1 to 20. Duplication is not allowed and the order does not matter. The number of combinations is:(45 * 44 * 43 * 42 * 41 / 5!) * 20 = 24,435,180The first combination (index 0) is:1, 2, 3, 4, 5, 1The last combination (index 24,435,179) is:41, 42, 43, 44, 45, 20How can I convert a combination into its index and vice versa without exhaustivel...Read more

combinatorics - Iterating over distinct permutations of a vector in Pari/GP

I want to iterate over all distinct permutations of a vector. I have tried doing this by using vecextract() in combination with numtoperm() to create a vector of permutations, and vecsort(,,,8) to remove equivalent permutations. Unfortunately, this doesn't scale well: the maximum size of a vector within my current stack size of 4GB is less than 12!, and my machine only has 16GB. Is there a way to do this without running out of memory, maybe by generating the k-th distinct permutation directly?...Read more

combinatorics - does OptaPlanner take care of TSPTW (or VRPTW ) with optional nodes?

let's say my traveling salesman is allowed to ignore some nodes, as long as he finishes visiting the nodes he chose , within a time range. his goal is to maximize the gain from the nodes visited (such as the total sales amount from these nodes). I guess we don't need a total time window constraint, since we already have the availability window for each ndoe. so basically the question boils down to TSPTW with possibility to ignore nodes. it's referred to as Generic TSP (GTSP ) in literature, does OptaPlanner have some knobs to model this?thanksY...Read more

combinatorics - bin packing with overlapping objects

I have some bins with different capacities and some objects with specified size. The goal is to pack these objects in the bins. Until now it is similar to the bin-packing problem. But the twist is that each object has a partial overlap with another. So while object 1 and 2 has sizes s1 and s2, when I put them in the same bin the filled space is less than s1+s2. Supposing that I know this overlapping value for each pair of objects, is there any approximation algorithm like the ones for original bin-packing for this problem too?...Read more

combinatorics - Number of distinct arrangements of elements of a list

Suppose a list is {1,2,2,3,2,4}.For one query, suppose the given range is [2,5]. So cnt[2] = 3, cnt[3] = 1 and PRODUCT = 3! * 1! = 6Then I want (num/PRODUCT) mod p, where 'num' is (R-L+1)! and p is 1e9+7, where [L, R] is the given range.Query contains different ranges each time.How do I solve it?I was thinking somewhat on the lines of Fermat's Little Theorem, but couldnt actually workout a proper method. How do I code it?I was trying like preprocessing all ranges possible, but that goes upto 10^10, i need an algo inside 10^8. It is given in my ...Read more

combinatorics - Distributing k distinct items among r distinct groups without ordering

Calculate the number of ways of distributing k distinct items among r distinct groups such that each group receives at least a and at most b items and internal arrangement of items within groups doesn't matter.For example suppose there are 2 groups and 3 items A, B, C. The distributions (AB, C) and (BA, C) must not be counted twice.Or in other words find the number of ways of distributing k distinct candies to r distinct kids. Each kid wants atleast a and atmost b candies. The order in which the kids receive candies doesn't matter.I've read a...Read more