Coverage for moptipy / operators / permutations / __init__.py: 100%
0 statements
« prev ^ index » next coverage.py v7.12.0, created at 2025-11-24 08:49 +0000
« prev ^ index » next coverage.py v7.12.0, created at 2025-11-24 08:49 +0000
1"""
2Search operators for permutations with repetitions.
4These operators can be used in conjunction with the space
5:class:`~moptipy.spaces.permutations.Permutations`.
7- Module :mod:`~moptipy.operators.permutations.op0_shuffle` provides a nullary
8 operator sampling an entirely random permutation.
9- Module :mod:`~moptipy.operators.permutations.op1_insert1` provides a unary
10 operator that extracts one element and inserts it elsewhere.
11- Module :mod:`~moptipy.operators.permutations.op1_swap2` provides a unary
12 operator which swaps exactly two different elements of a permutation.
13- Module :mod:`~moptipy.operators.permutations.op1_swapn` provides a unary
14 operator which tries to find a cyclic move whose length would be
15 approximately binomially distributed, i.e., which may swap two elements with
16 probability 0.5, three elements with probability 0.25, 4 elements with
17 probability 0.125, and so on. It does so by performing a sequence of swaps
18 but does not check whether one swap undoes a previous one.
19- Module :mod:`~moptipy.operators.permutations.op1_swap_exactly_n` offers a
20 unary operator with a step size (see
21 :class:`~moptipy.api.operators.Op1WithStepSize`). A step size of `0.0` means
22 that it will swap two elements, a step size of `1.0` means that it tries to
23 perform the largest-possible modification. If it is applied to permutations
24 where each element occurs once, this means that all elements change their
25 position. If applied to permutations with repetitions, things are more
26 complex and some moves may be impossible, in which case a best effort is
27 attempted.
28- Module :mod:`~moptipy.operators.permutations.op1_swap_try_n` is similar to
29 the operator from :mod:`~moptipy.operators.permutations.op1_swap_exactly_n`,
30 but invests less effort into reaching the prescribed number of modifications
31 exactly. Instead, it will accept making only fewer swaps more easily.
32- Module :mod:`~moptipy.operators.permutations.op2_gap` offers an operator
33 that tries to build a new permutation by appending not-yet-appended elements
34 from both input permutations, alternating between them randomly.
35- Module :mod:`~moptipy.operators.permutations.op2_ox2` implements a slightly
36 modified version of the order-based crossover operator for permutations.
37"""