- ⚙️ Description of the problem
- 🛠️ Modelling ways
- 👀 Overlap constraints
- ⬛ Black cells limit
- 📝 Linking decision variables from the two modelling
Picross is a popular game of a similar nature to Sudoku.
It consists of a grid of square dimension
We will use the following notations:
-
$b_{i,j} \in {0, 1}$ represents a bit, indicating a column or a row where$i, j \in {1, ..., n}$ represents a column or row index; -
$m_i \in {1, ..., \lceil n/2 \rceil}$ represents the size of the list associated to row/column$i$ ; -
$a_{i,k} \in {1, ..., n}$ is the$k$ -th integer of the list associated to row/column$i$ .
The goal is to darken some cells of the grid, such that in each row/column
To popularize the notations, we can say:
-
$b_{i,j}$ : specific cell (row$i$ , column$j$ ) -
$m_i$ : number of cluster in row/column$i$ ; -
$a_{i,k}$ : in row$i$ , size of$k$ -th cluster
We introduce:
-
$s_{i,k}$ : in row$i$ , starting position of$k$ -th cluster
Each cell of the table is considered as a decision variables, with binary value as their domains (0 or 1)
On each row, one decision variable exist for the first position of every “cluster” of colored cell to be assigned (1 integer if there is only 1 cluster to assign, 2 integers if 2 clusters are to be assigned, ...).
Nota : the maximum number of “cluster” per row is limited to n/2 groups (since at least one blank cell need to exist between 2 clusters)
By using ‘Integer variable’ modelling (=(2)), we can state that the “no overlap constraint” correspond to constraint the
We state that by using following expression:
For each row
with:
-
$s_{i,k}$ : in row$i$ , starting position of$k$ -th cluster -
$a_{i,k}$ : in row$i$ , size of$k$ -th cluster
For each column
with:
-
$s_{j,k}$ : in column$j$ , starting position of$k$ -th cluster -
$a_{j,k}$ : in column$j$ , size of$k$ -th cluster
By using ‘binary variable’ modelling (=(1)), we can state that amount of s“colored black cells limit” correspond to the sum of 1 available on row/column i, and cannot be more than the sum of coefficients from the corresponding row/column i.
We state that by using following expression:
For each row
with:
-
$b_{i,j}$ : specific cell (row$i$ , column$j$ ) -
$a_{i,k}$ : in row$i$ , size of$k$ -th cluster -
$m_i$ : number of cluster in row$i$ ;
For each column
with:
-
$b_{i,j}$ : specific cell (row$i$ , column$j$ ) -
$a_{j,k}$ : in column$j$ , size of$k$ -th cluster -
$m_j$ : number of cluster in column$j$ ;
For each row i, for each cluster in that row i, the binary grid cell corresponding to the ‘integer model’ ‘starting point’ decision variables is equal to 1:
For each row i...
For the k-th cluster in that row i...
with:
-
$offset \in {[0, a_{i,k}[}$ -
$b_{i,j}$ : specific cell (row$i$ , column$j$ ) -
$a_{i,k}$ : in row$i$ , size of$k$ -th cluster -
$s_{i,k}$ : in row$i$ , starting position of$k$ -th cluster
And is it the similar logic with column.
Nota : We first started to think about this constraint defined as below, bumping into a coding problem since we used indexes slices with decision variables...We redefined the problem by using previously define concept in order to get around this coding problem.
The concept for this constraint is the following one : for one row i, for the k-th “cluster”, the sum of binary decision variables in this cluster have to be equal to the size of row i’s k-th cluster.
For each row i...
For each cluster in that row i...
with:
-
$b_{i,j}$ : specific cell (row$i$ , column$j$ ) -
$a_{i,k}$ : in row$i$ , size of$k$ -th cluster -
$s_{i,k}$ : in row$i$ , starting position of$k$ -th cluster
For each column j...
with:
-
$b_{i,j}$ : specific cell (row$i$ , column$j$ ) -
$a_{i,k}$ : in row$i$ , size of$k$ -th cluster -
$s_{j,k}$ : in column$j$ , starting position of$k$ -th cluster
Noémie Cohen
Mathieu Canto