I'm trying to solve the next problem:
Given symmetric matrix A (12x12) that shows grid of a competition.
A vector x (12) of rankings of the teams.
Their product gives a vector that represents total ranking of all teams with whom a team from A plays.
For example: you have 3 teams. Rankings x [1, 2, 3]. Matrix A:
0 2 1
2 0 4
1 4 0
Matrix A is fixed. We need to find permutation of x so that STD(Ax) is minimal.
My previous attempt was to try to check all permutations. But it works quite long since 12!.
import itertools
import numpy as np
A = np.matrix('0,3,1,2,2,2,2,2,2,1,2,2;3,0,3,1,2,3,1,1,2,2,1,2;1,3,0,2,2,2,2,2,2,1,2,2;2,1,2,0,2,1,2,2,2,2,3,2;2,2,2,2,0,2,1,2,2,3,2,1;2,3,2,1,2,0,3,2,1,2,1,2;2,1,2,2,1,3,0,2,1,1,3,3;2,1,2,2,2,2,2,0,3,2,2,1;2,2,2,2,2,1,1,3,0,3,1,2;1,2,1,2,3,2,1,2,3,0,2,2;2,1,2,3,2,1,3,2,1,2,0,2;2,2,2,2,1,2,3,1,2,2,2,0')
min = 1000000
for x in itertools.permutations([2433,2057,1935,1927,1870,1841,1818,1770,1680,1497,1435,1289]):
x = np.matrix(x).T
b = A.dot(x)
cur = np.std(b)
if cur < min:
min = cur
res = x
I know there is scipy minimize but I dont know weather it can cope with permutations of x instead of continuous optimization.
The question is how to solve this task as fast and precise as possible.
Thanks.