Quantcast
Channel: User Rodrigo de Azevedo - MathOverflow
Viewing all articles
Browse latest Browse all 198

Answer by Rodrigo de Azevedo for Determining if some permutation of a vector satisfies a system of linear equations

$
0
0

Let $\mathbb P_n$ be the set of $n \times n$ permutation matrices. Given matrix $\mathrm A \in \mathbb R^{m \times n}$ and vector $\mathrm v \in \mathbb R^n$, we would like to find a permutation matrix $\mathrm P \in \mathbb P_n$ such that

$$\mathrm A \mathrm P \mathrm v = 0_m$$

The convex hull of $\mathbb P_n$ is the Birkhoff polytope$\mathbb B_n$ (the set of all $n \times n$ doubly stochastic matrices)

$$\mathbb B_n := \left\{ \mathrm X \in \mathbb R^{n \times n} \mid \mathrm X \mathrm 1_n = \mathrm 1_n, \mathrm 1_n^\top \mathrm X = 1_n^\top, \mathrm X \geq \mathrm O_n \right\}$$

Thus, a convex relaxation of the original discrete feasibility problem in $\mathrm P \in \mathbb P_n$ is the following continuous feasibility problem in $\mathrm X \in \mathbb B_n$

$$\begin{array}{ll} \text{minimize} & 0\\ \text{subject to} & \mathrm A \mathrm X \mathrm v = 0_m\\ & \mathrm X \mathrm 1_n = \mathrm 1_n\\ & \mathrm 1_n^\top \mathrm X = 1_n^\top\\ & \mathrm X \geq \mathrm O_n\end{array}$$

Let us look for a solution on the boundary of the feasible region. Hence, we generate a (nonzero) random matrix $\mathrm C \in \mathbb R^{n \times n}$ and minimize $\langle \mathrm C, \mathrm X \rangle$ instead. We have the following linear program (LP).

$$\begin{array}{ll} \text{minimize} & \langle \mathrm C, \mathrm X \rangle\\ \text{subject to} & \mathrm A \mathrm X \mathrm v = 0_m\\ & \mathrm X \mathrm 1_n = \mathrm 1_n\\ & \mathrm 1_n^\top \mathrm X = 1_n^\top\\ & \mathrm X \geq \mathrm O_n\end{array}$$

Although the vertices of the Birkhoff polytope are doubly stochastic matrices, the introduction of the equality constraints $\mathrm A \mathrm X \mathrm v = 0_m$ likely produces other vertices. We may have to generate several matrices $\rm C$ until we obtain an LP whose minimum is attained at a permutation matrix.


Numerical experiment

Suppose we are given

$$\rm A = \begin{bmatrix} 1 & 1 & 1 & 0 & 0\\ 0 & 1 & 1 & 1 & 0\\ 0 & 0 & 1 & 1 & 1\end{bmatrix}$$

$$\rm v = \begin{bmatrix} 1 & 1 & -1 & 0 & 0\end{bmatrix}^\top$$

Using NumPy to randomly generate matrix $\rm C$ and CVXPY to solve the LP:

from cvxpy import *import numpy as npA = np.array([[1,1,1,0,0],              [0,1,1,1,0],              [0,0,1,1,1]])v = np.array([1,1,-1,0,0])(m,n) = A.shapeC = np.random.rand(n,n)ones_n = np.ones((n,1))X = Variable(n,n)# define optimization problemprob = Problem( Minimize(trace(C.T * X)), [ A * X * v == np.zeros((m,1)), X * ones_n == ones_n, ones_n.T * X == ones_n.T, X >= 0 ])# solve optimization problemprint prob.solve()print prob.status# print resultsprint "X = \n", np.round(X.value,2)

which outputs the following permutation matrix that exchanges the 2nd and 4th entries:

0.669610896837optimalX = [[ 1.  0.  0.  0.  0.] [ 0.  0. -0.  1.  0.] [-0. -0.  1.  0. -0.] [ 0.  1.  0.  0.  0.] [ 0.  0.  0.  0.  1.]]

I ran the Python script a few (maybe $5$) times until I obtained a matrix $\rm X$ that is (close enough to) a permutation matrix. Unsurprisingly, the script does not produce such nice results for all choices of $\rm C$.

Running the script a few more times, I obtained another permutation matrix:

1.46656456314optimalX = [[ 0.  0.  0.  1.  0.] [ 1.  0.  0.  0.  0.] [-0. -0.  1.  0. -0.] [ 0.  0. -0.  0.  1.] [ 0.  1.  0.  0.  0.]]

Viewing all articles
Browse latest Browse all 198

Trending Articles