# Integer programming bi-indexed variables.

Many integer programming programs as the following needed for Kemeny ranking

$$ \begin{array}{c} \text{minimiser} \sum_{i,j \in \mathcal{A}}\omega_{i,j} x_{i,j}+\omega_{j,i} x_{j,i}\\ \text{sous les contraintes} \\ x_{i,j}+ x_{j,i} = 1, \forall i \not=j\\ x_{i,j}+ x_{j,k}+ x_{k,i}\geq 1, \forall i \not=j\not=k\not=i \end{array} $$

I want to construct a function wich takes the vector or the list $\omega$ and return the solution. But to construct such a function iot will be safer for me not to be obliged to assign on variable with a index to all two indexed variables.

Is there a way ? My problem is in the enumeration of the constraints for high indexes.

Why not represent $\omega$ as a dict, where tuples $(i,j)$ are mapped to the corresponding values? Or did I misunderstand your question?

You probably understand my question better than I. But I do not know how to do. A second possibility would be to create the matrices of zero and one associated with the constraints. But I do not know (even if I have a little idea how to construct them).

Can you give a specific toy example of what you want to achieve?

Hello, @Cyrille! What I understand that you want to achieve is to create a Sage function that will receive the constants $\omega$ and return the corresponding solution to the MILP you wrote above. Am I correct? What I didn't understand was the final part of your question where you talk about two-index variables. Could you clarify that? Perhaps I can help you with this problem.