I want to solve the following integer programming problem using AMPL. The problem is the following (It was already asked on mathstackexchange.com, but I need to know how to solve it using AMPL):
Let $N=\{1,…,22\}$ be the nodes, and let $P=\{i\in N,j\in N:i<j\}$ be the set of node pairs. For $(i,j)\in P$, let binary decision variable $x_{i,j}$ indicate whether $(i,j)$ is an edge. For $(i,j)∈P$ and $k \in N \setminus \{i,j\}$, let binary decision variable $y_{i,j,k}$ indicate whether k is a common neighbor of i and j.
Optimization Model: Minimize $\sum_{k \in N \setminus \{i,j\}} y_{i,j,k}$
subject to:
\begin{align} \sum_{(i,j)\in P:\ k \in \{i,j\}} x_{i,j} &= 5 &&\text{for $k\in N$} \tag1\\ x_{i,j} + \sum_{k \in N \setminus \{i,j\}} y_{i,j,k} &\ge 1 &&\text{for $(i,j)\in P$} \tag2\\ y_{i,j,k} &\le [i<k]x_{i,k} + [k<i]x_{k,i} &&\text{for $(i,j)\in P$ and $k \in N \setminus \{i,j\}$} \tag3\\ y_{i,j,k} &\le [j<k]x_{j,k} + [k<j]x_{k,j} &&\text{for $(i,j)\in P$ and $k \in N \setminus \{i,j\}$} \tag4 \end{align}
so far I have tried the following in AMPL, but the result has error (Please I need help):
example1.mod:
set N:={1..22};
set P:={i in N, j in N: i<j};
set K:={i in N, j in N, k in N: k!=i,k!=j};
var x{i in P, j in P} binary; #for x_{ij}
var y{i in P, j in P, k in K} binary; #for y_{ijk}
var x{j in P,k in K: j<k} binary; #for x_{jk}
var x{i in P,k in K: i<k} binary; #for x_{ik}
var x{k in K,j in P: k<j} binary; #for x_{kj}
var x{k in K,i in P: k<i} binary; #for x_{ki}
minimize z: sum{k in K} y[i,j,k];
subject to Constraint1{i in P, j in P}: sum{k in N}x[i,j]=5;
subject to Constraint2{i in P, j in P}: sum{k in K}y[i,j,k]>=1-x[i,j] ;
subject to constraint3{i in P, j in P, k in K}: y[i,j,k]<=x[i,k]+x[k,i];
subject to constraint4{i in P, j in P, k in K}:y[i,j,k]<=x[j,k]+x[k,j];
example2.run:
reset;
model example1.mod;
option solver cplex;
solve;
display x, z;
Thanks!
set K:={i in N, j in N, k in N: k!=i and k!=j};
i.e. replace the comma with theand
operator on the logical condition. Section 5.5 of the AMPL reference contains more examples of conditioning on indexing expressions. $\endgroup$