I would like to find the maximum of some objective function over all possible permutations
(* Memory inefficient solution *)
Max[obj/@Permutations[lst]]
(* Outout: SystemException["MemoryAllocationFailure"] *)
While this computation might be intractably slow $O(n!)$, it should have $O(n)$ space for lst
of size $n$.
Is there an efficient way to only cache the max seen so far? Thanks
Here is a standalone trivial example for the purposes of testing
n = 10;
l = Range[n];
Max[l . # & /@ Permutations[l]]
(* 385 *)
```
["MaximizeOverPermutations"]
$\endgroup$