All Questions
Tagged with permutation performance-tuning
24
questions
1
vote
1
answer
207
views
Arrange 1-n^2 in n×n grid satisfy products of rows equal to products columns
For which $n\in\mathbb{N}$ is it possible to arrange $\{1,…,n^2\}$ in an $n\times n$ grid so that the set of products of columns equals the set of products of rows?
I can find solution for $3\times 3$ ...
1
vote
2
answers
140
views
How to get all necklaces without the full permutations' set?
There are previous posts, such as Delete duplicates from list of lists as if on a necklace,
that give a way to find all necklaces from a set of lists. The methods presented there work well for a small ...
4
votes
3
answers
343
views
Find all sets whose index is divisible by the elements
Suppose I have such a set $S=\{3,4,5,...n+2\}, n\in \mathbb{Z}_{>\, 0} $, $a_n$ is any permutation of $S$ such that $n|a_n$, I want to know how many such $a_n$. The easy but inefficient way to do ...
2
votes
1
answer
130
views
Accelerating sum over permutations of matrix elements
I am trying to short-cut the use of a CoefficientArrays call by manually calculating the resulting matrix of coefficients myself (this avoids using symbolic arrays ...
1
vote
0
answers
88
views
Find Max Instance Over Permutations
I would like to find the maximum of some objective function over all possible permutations
...
5
votes
1
answer
491
views
Generating a list of integers that sums to zero
Given a pair of integers n and k, I want to generate all lists of integers of length n, ...
3
votes
5
answers
830
views
Finding all Latin Squares of order 5
A Latin Square is a square of size n × n containing numbers 1 to n inclusive. Each number occurs once in each row and column.
An example of a 3 × 3 Latin Square is:
$$
\left(
\begin{array}{ccc}
1 &...
2
votes
1
answer
112
views
Splitting balls over sized bins
This is strongly related to Splitting a set of integers over a set of bins, but a much simpler case.
If we have $N$ indistinguishable balls and $k$ arbitrarily large distinguishable bins, we know the ...
5
votes
2
answers
72
views
Pair-wise equality over large sets of large vectors
I've got an interesting performance tuning/algorithmic problem that I'm running into in an optimization context.
I've got a set of ~16-50 lists of integers (usually in ...
2
votes
4
answers
157
views
How to use function `GeneratingFunction ` to solve this combinatorial problem efficiently?
Divide the 14 elements {A, B, C, C, C, C, D, D, D, D, E, E, E, E} into 7 groups (one group all have two elements), and I want to find out how many kinds of methods ...
5
votes
1
answer
138
views
Why is NextPermutation slow?
<< Combinatorica`
Permutations[Range[0, 9]][[1000000]] // AbsoluteTiming
Nest[NextPermutation, Range[0, 9], 1*^6 - 1] // AbsoluteTiming
I want to save memory,...
4
votes
1
answer
410
views
Efficiently removing elements from list of permutations
I'm looking for an efficient way to remove entries from a list of permutations.
I have a list of variables from which I calculate all possible permutations. I then want to remove those permutations ...
1
vote
2
answers
96
views
Optimize certain list over permutations, perhaps using recursions?
I am trying to improve my code for computing products of monomial symmetric functions.
It boils down to the following. Let lam and ...
6
votes
4
answers
261
views
Faster way to find longest chain of inequalities
I have a list of algebraic expression, all variables are positive, some of them have a specific size relationship.
Such as:
$\frac{(a b+a c+b c)^2}{a+b+c}\leq \frac{1}{3} (a+b+c) (a b+a c+b c)\leq \...
16
votes
1
answer
527
views
ls Ordering[Ordering[list]] optimal?
Given a list list with unique elements, the task is to replace each element by its position in Sort[list]. For example,
...