Skip to content
This repository was archived by the owner on Jan 30, 2023. It is now read-only.

Commit e8c291f

Browse files
Release Managervbraun
authored andcommitted
Trac #15431: Transversal Design TD(6,12)
A construction for TD(6,12) (needed for the general construction of BIBD with k=5) URL: http://trac.sagemath.org/15431 Reported by: ncohen Ticket author(s): Nathann Cohen Reviewer(s): Vincent Delecroix
2 parents 85afa15 + a86b08e commit e8c291f

File tree

3 files changed

+105
-23
lines changed

3 files changed

+105
-23
lines changed

src/sage/combinat/combinat.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@
9696
.. TODO::
9797
9898
GUAVA commands:
99-
* MOLS returns a list of n Mutually Orthogonal Latin Squares (MOLS).
10099
* VandermondeMat
101100
* GrayMat returns a list of all different vectors of length n over
102101
the field F, using Gray ordering.

src/sage/combinat/designs/bibd.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ def BalancedIncompleteBlockDesign(v,k,use_LJCR=False):
4747
distinct elements `x,y\in V` there is a unique element `S\in \mathcal C`
4848
such that `x,y\in S`.
4949
50+
More general definitions sometimes involve a `\lambda` parameter, and we
51+
assume here that `\lambda=1`.
52+
5053
For more information on BIBD, see the
5154
:wikipedia:`corresponding Wikipedia entry <Block_design#Definition_of_a_BIBD_.28or_2-design.29>`.
5255

src/sage/combinat/designs/orthogonal_arrays.py

Lines changed: 102 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,32 +8,45 @@
88
---------
99
"""
1010

11-
def transversal_design(k,n,t=2,check=True):
11+
def transversal_design(k,n,check=True):
1212
r"""
1313
Return a transversal design of parameters `k,n`.
1414
15-
A transversal design of parameters `n, k` is a collection `\mathcal{S}`
16-
of `k`-subsets of `V = V_1 \sqcup \cdots \sqcup V_k`
17-
(where `|V_i| = n` for all `i`) such that:
15+
A transversal design of parameters `k, n` is a collection `\mathcal{S}` of
16+
subsets of `V = V_1 \cup \cdots \cup V_k` (where the *groups* `V_i` are
17+
disjoint and have cardinality `n`) such that:
1818
19-
* Any element `S \in \mathcal{S}` intersects each set `V_i` on exactly one
20-
element.
19+
* Any `S \in \mathcal{S}` has cardinality `k` and intersects each group on
20+
exactly one element.
2121
22-
* Any two elements `v_i \in V_i, v_j\in V_j` with `i \neq j` belong to
23-
exactly one element of `\mathcal{S}`.
22+
* Any two elements from distincts groups are contained in exactly one
23+
element of `\mathcal{S}`.
24+
25+
More general definitions sometimes involve a `\lambda` parameter, and we
26+
assume here that `\lambda=1`.
2427
2528
For more information on transversal designs, see
26-
http://mathworld.wolfram.com/TransversalDesign.html.
29+
`<http://mathworld.wolfram.com/TransversalDesign.html>`_.
2730
2831
INPUT:
2932
30-
- `n,k,t` -- integers
33+
- `n,k` -- integers.
3134
3235
- ``check`` -- (boolean) Whether to check that output is correct before
3336
returning it. As this is expected to be useless (but we are cautious
3437
guys), you may want to disable it whenever you want speed. Set to
3538
``True`` by default.
3639
40+
.. NOTE::
41+
42+
This function returns transversal designs with
43+
`V_1=\{0,\dots,n-1\},\dots,V_k=\{(k-1)n,\dots,kn-1\}`.
44+
45+
.. SEEALSO::
46+
47+
:func:`orthogonal_array` -- a tranversal design is an orthogonal array
48+
with `t=2`.
49+
3750
EXAMPLES::
3851
3952
sage: designs.transversal_design(5,5)
@@ -47,9 +60,12 @@ def transversal_design(k,n,t=2,check=True):
4760
[4, 5, 11, 17, 23], [4, 6, 13, 15, 22], [4, 7, 10, 18, 21],
4861
[4, 8, 12, 16, 20]]
4962
"""
50-
# Section 6.6
51-
OA = orthogonal_array(k,n)
52-
TD = [[i*n+c for i,c in enumerate(l)] for l in OA]
63+
if n == 12 and k <= 6:
64+
TD = [l[:k] for l in TD6_12()]
65+
else:
66+
# Section 6.6
67+
OA = orthogonal_array(k,n,t=2, check = False)
68+
TD = [[i*n+c for i,c in enumerate(l)] for l in OA]
5369

5470
if check:
5571
assert is_transversal_design(TD,k,n)
@@ -97,10 +113,60 @@ def is_transversal_design(B,k,n):
97113

98114
return g.is_clique()
99115

116+
def TD6_12():
117+
r"""
118+
Returns a `TD(6,12)` as build in [Hanani75]_.
119+
120+
This design is Lemma 3.21 from [Hanani75]_.
121+
122+
EXAMPLE::
123+
124+
sage: from sage.combinat.designs.orthogonal_arrays import TD6_12
125+
sage: _ = TD6_12()
126+
127+
REFERENCES:
128+
129+
.. [Hanani75] Haim Hanani,
130+
Balanced incomplete block designs and related designs,
131+
http://dx.doi.org/10.1016/0012-365X(75)90040-0,
132+
Discrete Mathematics, Volume 11, Issue 3, 1975, Pages 255-369.
133+
"""
134+
from sage.groups.additive_abelian.additive_abelian_group import AdditiveAbelianGroup
135+
G = AdditiveAbelianGroup([2,6])
136+
d = [[(0,0),(0,0),(0,0),(0,0),(0,0),(0,0)],
137+
[(0,0),(0,1),(1,0),(0,3),(1,2),(0,4)],
138+
[(0,0),(0,2),(1,2),(1,0),(0,1),(1,5)],
139+
[(0,0),(0,3),(0,2),(0,1),(1,5),(1,4)],
140+
[(0,0),(0,4),(1,1),(1,3),(0,5),(0,2)],
141+
[(0,0),(0,5),(0,1),(1,5),(1,3),(1,1)],
142+
[(0,0),(1,0),(1,3),(0,2),(0,3),(1,2)],
143+
[(0,0),(1,1),(1,5),(1,2),(1,4),(1,0)],
144+
[(0,0),(1,2),(0,4),(0,5),(0,2),(1,3)],
145+
[(0,0),(1,3),(1,4),(0,4),(1,1),(0,1)],
146+
[(0,0),(1,4),(0,5),(1,1),(1,0),(0,3)],
147+
[(0,0),(1,5),(0,3),(1,4),(0,4),(0,5)]]
148+
149+
r = lambda x : int(x[0])*6+int(x[1])
150+
TD = [[i*12+r(G(x)+g) for i,x in enumerate(X)] for X in d for g in G]
151+
for x in TD: x.sort()
152+
153+
return TD
154+
100155
def orthogonal_array(k,n,t=2,check=True):
101156
r"""
102157
Return an orthogonal array of parameters `k,n,t`.
103158
159+
An orthogonal array of parameters `k,n,t` is a matrix with `k` columns
160+
filled with integers from `[n]` in such a way that for any `t` columns, each
161+
of the `n^t` possible rows occurs exactly once. In
162+
particular, the matrix has `n^t` rows.
163+
164+
More general definitions sometimes involve a `\lambda` parameter, and we
165+
assume here that `\lambda=1`.
166+
167+
For more information on orthogonal arrays, see
168+
:wikipedia:`Orthogonal_array`.
169+
104170
INPUT:
105171
106172
- ``k`` -- (integer) number of columns
@@ -114,9 +180,6 @@ def orthogonal_array(k,n,t=2,check=True):
114180
guys), you may want to disable it whenever you want speed. Set to
115181
``True`` by default.
116182
117-
For more information on orthogonal arrays, see
118-
:wikipedia:`Orthogonal_array`.
119-
120183
.. NOTE::
121184
122185
This method implements theorems from [Stinson2004]_. See the code's
@@ -126,10 +189,14 @@ def orthogonal_array(k,n,t=2,check=True):
126189
127190
Implement Wilson's construction. See page 146 of [Stinson2004]_.
128191
192+
.. SEEALSO::
193+
194+
:func:`transversal_design` -- when `t=2` an orthogonal array is also
195+
called a transversal design.
196+
129197
EXAMPLES::
130198
131-
sage: from sage.combinat.designs.orthogonal_arrays import orthogonal_array
132-
sage: orthogonal_array(5,5)
199+
sage: designs.orthogonal_array(5,5)
133200
[[0, 0, 0, 0, 0], [0, 1, 2, 3, 4], [0, 2, 4, 1, 3], [0, 3, 1, 4, 2],
134201
[0, 4, 3, 2, 1], [1, 1, 1, 1, 1], [1, 2, 3, 4, 0], [1, 3, 0, 2, 4],
135202
[1, 4, 2, 0, 3], [1, 0, 4, 3, 2], [2, 2, 2, 2, 2], [2, 3, 4, 0, 1],
@@ -142,18 +209,30 @@ def orthogonal_array(k,n,t=2,check=True):
142209
143210
sage: designs.orthogonal_array(3,2)
144211
[[0, 1, 0], [0, 0, 1], [1, 0, 0], [1, 1, 1]]
212+
sage: designs.orthogonal_array(4,2)
213+
Traceback (most recent call last):
214+
...
215+
EmptySetError: No Orthogonal Array exists when k>=n+t
145216
"""
146217
from sage.rings.arith import is_prime_power
147218
from sage.rings.finite_rings.constructor import FiniteField
148219
OA = None
149220

150-
if t != 2:
151-
raise NotImplementedError("only implemented for t=2")
152-
153221
if k < 2:
154222
raise ValueError("undefined for k less than 2")
155223

156-
if k == t:
224+
elif k >= n+t:
225+
from sage.categories.sets_cat import EmptySetError
226+
# When t=2 then k<n+t as it is equivalent to the existence of n-1 MOLS.
227+
# When t>2 the submatrix defined by the rows whose first t-2 elements
228+
# are 0s yields a OA with t=2 and k-(t-2) columns. Thus k-(t-2) < n+2,
229+
# i.e. k<n+t.
230+
raise EmptySetError("No Orthogonal Array exists when k>=n+t")
231+
232+
elif t != 2:
233+
raise NotImplementedError("only implemented for t=2")
234+
235+
elif k == t:
157236
from itertools import product
158237
OA = map(list, product(range(n), repeat=k))
159238

@@ -192,6 +271,7 @@ def orthogonal_array(k,n,t=2,check=True):
192271

193272
if OA is None:
194273
raise NotImplementedError("I don't know how to build this orthogonal array!")
274+
195275
if check:
196276
assert is_orthogonal_array(OA,k,n,t)
197277

0 commit comments

Comments
 (0)