In [1] an intriguing problem is posted:
There are 8 soldiers, gathering and lining up every morning for their military service. The commander at the head of these soldiers demands that the morning lineup of these soldiers be arranged differently for every next day according to the following rule:
Any three soldiers cannot be lined up next to each other in the same order for others days.
For example; If ABCDEFGH is the first arrangement for day 1, on the other days, ABC,BCD, CDE, DEF, EFG and FGH cannot be lined up next to each other in the same order any more, but ACB arrangement is okay for other days until used once since they are not in the same order.
What is the maximum number of days can this happen?
Let's first make the problem a bit smaller. Say we have just 4 soldiers. This gives us \(4!=24\) permutations or line-ups. Let's have a look at the following sets:
- \(p\) is the set of permutations
- \(t\) is the set of substrings of length 3 that we can form from \(p\)
- \(\color{darkblue}pt(p,t)\) is the mapping between \(p\) and \(t\)
---- 53 SET p permutations or line ups
ABCD, ABDC, ACBD, ACDB, ADBC, ADCB, BACD, BADC, BCAD, BCDA, BDAC, BDCA, CABD
CADB, CBAD, CBDA, CDAB, CDBA, DABC, DACB, DBAC, DBCA, DCAB, DCBA
---- 53 SET t substrings of length 3
ABC, BCD, ABD, BDC, ACB, CBD, ACD, CDB, ADB, DBC, ADC, DCB, BAC, BAD, BCA
CAD, CDA, BDA, DAC, DCA, CAB, CBA, DAB, DBA
---- 55 SET pt mapping (computed in Python)
ABCD.ABC, ABCD.BCD, ABDC.ABD, ABDC.BDC, ACBD.ACB, ACBD.CBD, ACDB.ACD
ACDB.CDB, ADBC.ADB, ADBC.DBC, ADCB.ADC, ADCB.DCB, BACD.ACD, BACD.BAC
BADC.ADC, BADC.BAD, BCAD.BCA, BCAD.CAD, BCDA.BCD, BCDA.CDA, BDAC.BDA
BDAC.DAC, BDCA.BDC, BDCA.DCA, CABD.ABD, CABD.CAB, CADB.ADB, CADB.CAD
CBAD.BAD, CBAD.CBA, CBDA.CBD, CBDA.BDA, CDAB.CDA, CDAB.DAB, CDBA.CDB
CDBA.DBA, DABC.ABC, DABC.DAB, DACB.ACB, DACB.DAC, DBAC.BAC, DBAC.DBA
DBCA.DBC, DBCA.BCA, DCAB.DCA, DCAB.CAB, DCBA.DCB, DCBA.CBA
---- 66 PARAMETER np = 24 card(p)
PARAMETER nt = 24 card(t)
PARAMETER npt = 48 card(pt)
In [1], Rob Pratt proposes a MIP model for this:
| Model A |
| \[\begin{align}\max\> & \color{darkred}z = \sum_p \color{darkred}x_p \\ &\sum_{p|\color{darkblue}{pt}(p,t)} \color{darkred}x_p \le 1&& \forall t \\ & \color{darkred}x_p \in \{0,1\}\end{align} \] |