Rudy’s OBTF Rudolf Adamkovič

Home / Computer science / Zebra puzzle / Computation


Decision variables

  • \(1 \leq h \leq l\) with \(l = 5\) attributes
  • \(1 \leq i \leq m\) with \(m = 5\) houses
  • \(1 \leq j \leq n\) with \(n = 5\) attribute values
l, m, n = 5, 5, 5
\begin{equation*} \underset{1 \leq h \leq \ell}{X_h} = \begin{pmatrix} x_{h11} & & \cdots & & x_{h1n} \\ & \ddots & & & \\ \vdots & & x_{hij} & & \vdots \\ & & & \ddots & \\ x_{hm1} & & \cdots & & x_{hmn} \end{pmatrix} \in {\{0, 1\}}^{m \times n} \end{equation*}
x = {
    (h, i, j): model.new_bool_var("x_{%d, %d, %d}" % (h + 1, i + 1, j + 1))
    for h in range(l)
    for i in range(m)
    for j in range(n)
}

© 2025 Rudolf Adamkovič under GNU General Public License version 3.
Made with Emacs and secret alien technologies of yesteryear.