I have a MiniZinc app where I want to minimize the "cost" of something by finding a low-cost permutation of some input data. So I have:
array[1 .. n] of var 1 .. n: Seq;
...
constraint alldifferent( [ Seq[i] | i in 1 .. n ]);
And then I compute cost based on Seq. The app is starting to work but runs too long for n more than a very small number. Apparently the solver tries all n! possibilities. How do I scale this?
If alldifferent(Seq) is the only constraint then the solver will try all the permutations.
However, often there are symmetries in the permutation that might be possible to break, for example that the first element is 1 or that the first element always is less than the second element etc. These kind of symmetries are often very problem specific.
If there are other constraints in the model, then these can help to reduce the search space, perhaps by breaking symmetries etc.
How large are n in the normal case? As usual, more details of the model help to give a more specific help. Also, trying different solvers and search heuristics can speed things up.