Decomposing a matrix into a sum of permutations

104 Views Asked by At

I have the following table where each row and column add to 100:

Position | A  | B  | C  |
---------+----+----+----+
1        | 20 | 50 | 30 |
2        | 30 | 20 | 50 |
3        | 50 | 30 | 20 |
---------+----+----+----+

I then need to create a value for each possible ordered combination of A,B,C (i.e. ABC, ACB, BAC, BCA, CAB, CBA) such that the above constraints are still met.

For example:

ABC relates to A in position 1, B in position 2 and C in position 3

and

ACB relates to A in position 1, C in position 2 and B in position 3

As these are the only two combinations that contain A in position 1 then the values for these two combinations should total 20 (position A1 in the table above).

But then ACB and BCA should total 50 as these are the only 2 combinations that contain C at position 2.

I'm not even sure if this is possible? I've tried simultaneous equations and think i'm finding more unknowns than equations which then means no solution right?

Anybody willing to take a stab at it and find a solution if ones exists?

3

There are 3 best solutions below

1
On BEST ANSWER

Suppose $ABC = x$. Then we have:

$ABC + ACB = 20 \Rightarrow ACB = 20-x \\ ABC + CBA = 20 \Rightarrow CBA = 20-x \\ ABC + BAC = 20 \Rightarrow BAC = 20-x \\ BAC + BCA = 50 \Rightarrow BCA = 50-(20-x)=30+x \\ CBA + CAB = 30 \Rightarrow CAB = 30-(20-x)=10+x$

Pick any value you like for $x$ and you have a solution. If you want all values to be strictly positive then $0 < x < 20$.

0
On

There is certainly more than one solution.

You can find one quite directly by considering the symmetries in the matrix. For instance, you need $20$ permutations where A is the first letter, $20$ where B is the second letter, and $20$ where C is the third letter, so $20$ ABC would cover that. In a similar fashion, $30$ CAB and $50$ BCA completely cover all $100$ words with no instances of the other three words.

0
On
a: ABC
b: ACB
c: BAC
d: BCA
e: CAB
f: CBA

import sympy as sy
a ,b, c, d, e, f, x, y, z = sy.symbols("a b c d e f x y z")

a = sy.solve(
    [
        (a+b)/(c+d) - 0.4,
        (e+f)/(c+d) - 0.6,
        (c+e)/(a+f) - 1.5,
        (b+d)/(a+f) - 2.5,
        (d+f)/(a+c) - 2.5,
        (b+e)/(a+c) - 1.5
    ],
    [a ,b, c, d, e, f])
print(a)