moptipy.examples.bitstrings package

Example for bit-string based objective functions.

The problems noted here are mainly well-known benchmark problems from the discrete optimization community. For these problems, we designed the dedicated base class BitStringProblem.

The following benchmark problems are provided:

  1. The onemax problem, where the goal is to find a bit string with the maximum number of ones.

  2. The leadingones problem, where the goal is to find a bit string with the maximum number of leading ones.

  3. The linearharmonic problem, where the goal is to find a bit string with the all ones, like in onemax, but this time all bits have a different weight (namely their index, starting at 1).

  4. The binint problem, is again similar to onemax, but the bits have exponential weight. Basically, we just decode the bit string into an integer.

  5. The trap problem, which is like OneMax, but with the optimum and worst-possible solution swapped. This problem is therefore highly deceptive.

  6. The twomax problem has the global optimum at the string of all 1 bits and a local optimum at the string of all 0 bits. Both have basins of attraction of about the same size.

  7. ising1d, the one-dimensional Ising model, where the goal is that all bits should have the same value as their neighbors in a ring.

  8. ising2d, the two-dimensional Ising model, where the goal is that all bits should have the same value as their neighbors on a torus.

  9. The jump problem is equivalent to onemax, but has a deceptive region right before the optimum.

  10. The plateau problem similar to the jump problem, but this time the optimum is surrounded by a region of neutrality.

  11. The nqueens, where the goal is to place k queens on a k * k-sized chess board such that no queen can beat any other queen.

  12. The labs, where the goal is to find a sequence with low autocorrelation and, thus, high merit factor. This problem is different from the others, because here, only for low values of n, the optimal solutions are actually known.

  13. The w_model, a benchmark problem with tunable epistasis, uniform neutrality, and ruggedness/deceptiveness.

  14. The zeromax problem, where the goal is to find a bit string with the maximum number of zeros. This is the opposite of the OneMax problem.

Parts of the code here are related to the research work of Mr. Jiazheng ZENG (曾嘉政), a Master’s student at the Institute of Applied Optimization (应用优化研究所, http://iao.hfuu.edu.cn) of the School of Artificial Intelligence and Big Data (人工智能与大数据学院) at Hefei University (合肥大学) in Hefei, Anhui, China (中国安徽省合肥市) under the supervision of Prof. Dr. Thomas Weise (汤卫思教授).

moptipy.examples.bitstrings.default_instances(class_scales=<function <lambda>>)[source]

Get the default bit-string based benchmark instances.

Parameters:

class_scales (Callable[[type], Iterator[int]], default: <function <lambda> at 0x7f6684fa6fc0>) – a function that can override the minimum and maximimum problem scales on a per-benchmark-function-class basis. If this function returns an empty iterator, then the default scales are used.

Return type:

Iterator[Callable[[], BitStringProblem]]

Returns:

an Iterator with the default bit-string benchmark instances

>>> len(list(default_instances()))
1009

Submodules

moptipy.examples.bitstrings.binint module

The BinInt problem maximizes the binary value of a bit string.

The BinInt problem is similar to the OneMax and LinearHarmonic in that it tries to maximize the number of True bits in a string. Different from these problems, however, it assigns exponentially increasing weights to the bits. The bit at index 1 has weight 2 ** (n - 1). The bit at the last position has weight 1. The upper bound for the objective function, reached when all bits are False, therefore is 2 ** n - 1. The lower bound, reached when all bits are True, is 0.

  1. William Michael Rudnick. Genetic Algorithms and Fitness Variance with an Application to the Automated Design of Artificial Neural Networks. PhD thesis, Oregon Graduate Institute of Science & Technology: Beaverton, OR, USA, 1992. UMI Order No.: GAX92-22642.

  2. Dirk Thierens, David Edward Goldberg, and Ângela Guimarães Pereira. Domino Convergence, Drift, and the Temporal-Salience Structure of Problems. In CEC’98, pages 535-540, 1998. doi: https://doi.org/10.1109/ICEC.1998.700085.

  3. Kumara Sastry and David Edward Goldberg. Let’s Get Ready to Rumble Redux: Crossover versus Mutation Head to Head on Exponentially Scaled Problems. In GECCO’07-I, pages 1380-1387, 2007. doi: https://doi.org10.1145/1276958.1277215.

  4. Kumara Sastry and David Edward Goldberg. Let’s Get Ready to Rumble Redux: Crossover versus Mutation Head to Head on Exponentially Scaled Problems. IlliGAL Report 2007005, Illinois Genetic Algorithms Laboratory (IlliGAL), Department of Computer Science, Department of General Engineering, University of Illinois at Urbana-Champaign: Urbana-Champaign, IL, USA, February 11, 2007.

class moptipy.examples.bitstrings.binint.BinInt(n)[source]

Bases: BitStringProblem

Maximize the binary value of a bit string.

classmethod default_instances(scale_min=2, scale_max=30)[source]

Get the 29 default instances of the BinInt problem.

Parameters:
  • scale_min (int, default: 2) – the minimum permitted scale, by default 2

  • scale_max (int, default: 30) – the maximum permitted scale, by default 32

Return type:

Iterator[Callable[[], BinInt]]

Returns:

a sequence of default BinInt instances

>>> len(list(BinInt.default_instances()))
29
>>> [x() for x in BinInt.default_instances()]
[binint_2, binint_3, binint_4, binint_5, binint_6, binint_7, binint_8, binint_9, binint_10, binint_11, binint_12, binint_13, binint_14, binint_15, binint_16, binint_17, binint_18, binint_19, binint_20, binint_21, binint_22, binint_23, binint_24, binint_25, binint_26, binint_27, binint_28, binint_29, binint_30]
upper_bound()[source]

Get the upper bound of the BinInt problem.

Return type:

int

Returns:

(1 << n) - 1

>>> BinInt(4).upper_bound()
15
>>> BinInt(4).evaluate(np.array([0, 0, 0, 0]))
15
moptipy.examples.bitstrings.binint.binint(x)[source]

Get the binint objective value: decode the inverted bit string as integer.

Parameters:

x (ndarray) – the np array

Return type:

int

Returns:

the inverted bit string represented as integer

>>> binint(np.array([0]))
1
>>> binint(np.array([1]))
0
>>> binint(np.array([0, 0]))
3
>>> binint(np.array([0, 1]))
2
>>> binint(np.array([1, 0]))
1
>>> binint(np.array([1, 1]))
0
>>> binint(np.array([0, 0, 0]))
7
>>> binint(np.array([0, 0, 1]))
6
>>> binint(np.array([0, 1, 0]))
5
>>> binint(np.array([0, 1, 1]))
4
>>> binint(np.array([1, 0, 0]))
3
>>> binint(np.array([1, 0, 1]))
2
>>> binint(np.array([1, 1, 0]))
1
>>> binint(np.array([1, 1, 1]))
0

moptipy.examples.bitstrings.bitstring_problem module

A base class for bitstring-based problems.

Many benchmark problems from discrete optimization are simple functions defined over bit strings. We here offer the class BitStringProblem, which provides reasonable default behavior and several utilities for implementing such problems.

class moptipy.examples.bitstrings.bitstring_problem.BitStringNKProblem(n, k)[source]

Bases: BitStringProblem

A bit string problem with a second parameter k with 1 < k < n/2.

>>> sb = BitStringNKProblem(9, 3)
>>> sb.n
9
>>> sb.k
3
>>> try:
...     bs = BitStringNKProblem(0, 3)
... except ValueError as ve:
...     print(ve)
n=0 is invalid, must be in 6..1000000000.
>>> try:
...     bs = BitStringNKProblem(5, 2)
... except ValueError as ve:
...     print(ve)
n=5 is invalid, must be in 6..1000000000.
>>> try:
...     bs = BitStringNKProblem(21, 20)
... except ValueError as ve:
...     print(ve)
k=20 is invalid, must be in 2..9.
>>> try:
...     bs = BitStringNKProblem("a", 3)
... except TypeError as te:
...     print(te)
n should be an instance of int but is str, namely 'a'.
>>> try:
...     bs = BitStringNKProblem(13, "x")
... except TypeError as te:
...     print(te)
k should be an instance of int but is str, namely 'x'.
classmethod default_instances(scale_min=6, scale_max=32)[source]

Get the default instances of this problem type.

Return type:

Iterator[Callable[[], BitStringNKProblem]]

Returns:

an Iterator with the instances

k: Final[int]

the second parameter, with 1 < k < n/2

log_parameters_to(logger)[source]

Log all parameters of this component as key-value pairs.

Parameters:

logger (KeyValueLogSection) – the logger for the parameters

Return type:

None

>>> from moptipy.utils.logger import InMemoryLogger
>>> with InMemoryLogger() as l:
...     with l.key_values("C") as kv:
...         BitStringNKProblem(23, 7).log_parameters_to(kv)
...     text = l.get_log()
>>> text[1]
'name: bitstringnkproblem_23_7'
>>> text[3]
'lowerBound: 0'
>>> text[4]
'upperBound: 23'
>>> text[5]
'n: 23'
>>> text[6]
'k: 7'
>>> len(text)
8
class moptipy.examples.bitstrings.bitstring_problem.BitStringProblem(n)[source]

Bases: Objective

A base class for problems defined over bit strings.

This base class has a set of default behaviors. It has an attribute n denoting the lengths of the accepted bit strings. Its lower_bound() returns 0 and its upper_bound() returns n. is_always_integer() returns True. If also offers the method space() which returns an instance of BitStrings for bit strings of length n.

>>> bs = BitStringProblem(1)
>>> bs.n
1
>>> try:
...     bs = BitStringProblem(0)
... except ValueError as ve:
...     print(ve)
n=0 is invalid, must be in 1..1000000000.
>>> try:
...     bs = BitStringProblem("a")
... except TypeError as te:
...     print(te)
n should be an instance of int but is str, namely 'a'.
classmethod default_instances(scale_min=2, scale_max=3333)[source]

Get the default instances of this problem type.

Parameters:
  • scale_min (int, default: 2) – the minimum scale

  • scale_max (int, default: 3333) – the maximum scale

Return type:

Iterator[Callable[[], BitStringProblem]]

Returns:

an Iterator with the instances

is_always_integer()[source]

Return True if the evaluate function always returns an int.

This pre-defined function for bit-string based problems will always return True. Problems where this is not the case should overwrite this method.

Retval True:

always

Return type:

bool

log_parameters_to(logger)[source]

Log all parameters of this component as key-value pairs.

Parameters:

logger (KeyValueLogSection) – the logger for the parameters

Return type:

None

>>> from moptipy.utils.logger import InMemoryLogger
>>> with InMemoryLogger() as l:
...     with l.key_values("C") as kv:
...         BitStringProblem(5).log_parameters_to(kv)
...     text = l.get_log()
>>> text[1]
'name: bitstringproblem_5'
>>> text[3]
'lowerBound: 0'
>>> text[4]
'upperBound: 5'
>>> text[5]
'n: 5'
>>> len(text)
7
lower_bound()[source]

Get the lower bound of the bit string based problem.

By default, this method returns 0. Problems where the lower bound differs should override this method.

Return type:

int

Returns:

0

>>> print(BitStringProblem(10).lower_bound())
0
n: Final[int]

the length of the bit strings

space()[source]

Create a proper search space for this problem.

Return type:

BitStrings

Returns:

an instance of BitStrings for bit strings of length n

upper_bound()[source]

Get the upper bound of the bit string based problem.

The default value is the length of the bit string. Problems where the upper bound differs should overrrite this method.

Return type:

int

Returns:

by default, this is the length of the bit string

>>> print(BitStringProblem(7).upper_bound())
7
class moptipy.examples.bitstrings.bitstring_problem.SquareBitStringProblem(n)[source]

Bases: BitStringProblem

A bitstring problem which requires that the string length is square.

>>> sb = SquareBitStringProblem(9)
>>> sb.n
9
>>> sb.k
3
>>> try:
...     bs = SquareBitStringProblem(0)
... except ValueError as ve:
...     print(ve)
n=0 is invalid, must be in 4..1000000000.
>>> try:
...     bs = SquareBitStringProblem(3)
... except ValueError as ve:
...     print(ve)
n=3 is invalid, must be in 4..1000000000.
>>> try:
...     bs = SquareBitStringProblem(21)
... except ValueError as ve:
...     print(ve)
n=21 must be a square number, but isqrt(n)=4 does not satisfy n = k*k.
>>> try:
...     bs = SquareBitStringProblem("a")
... except TypeError as te:
...     print(te)
n should be an instance of int but is str, namely 'a'.
classmethod default_instances(scale_min=4, scale_max=3333)[source]

Get the default instances of this problem type.

Return type:

Iterator[Callable[[], SquareBitStringProblem]]

Returns:

an Iterator with the instances

k: Final[int]

the k value, i.e., the number of bits per row and column of the square

log_parameters_to(logger)[source]

Log all parameters of this component as key-value pairs.

Parameters:

logger (KeyValueLogSection) – the logger for the parameters

Return type:

None

>>> from moptipy.utils.logger import InMemoryLogger
>>> with InMemoryLogger() as l:
...     with l.key_values("C") as kv:
...         SquareBitStringProblem(49).log_parameters_to(kv)
...     text = l.get_log()
>>> text[1]
'name: squarebitstringproblem_49'
>>> text[3]
'lowerBound: 0'
>>> text[4]
'upperBound: 49'
>>> text[5]
'n: 49'
>>> text[6]
'k: 7'
>>> len(text)
8
moptipy.examples.bitstrings.bitstring_problem.default_nk_k_sequence(n)[source]

Get the default values of k for a BitStringNKProblem.

Parameters:

n (int) – the n value for the BitStringNKProblem.

Return type:

Iterator[int]

Returns:

a sequence of appropriate k values

>>> list(default_nk_k_sequence(6))
[2]
>>> list(default_nk_k_sequence(7))
[2]
>>> list(default_nk_k_sequence(8))
[2, 3]
>>> list(default_nk_k_sequence(10))
[2, 3, 4]
>>> list(default_nk_k_sequence(20))
[2, 3, 4, 5, 7, 9]
>>> list(default_nk_k_sequence(32))
[2, 4, 5, 8, 11, 15]
>>> try:
...     default_nk_k_sequence(3)
... except ValueError as ve:
...     print(ve)
n=3 is invalid, must be in 6..1000000000.
>>> try:
...     default_nk_k_sequence("6")
... except TypeError as te:
...     print(te)
n should be an instance of int but is str, namely '6'.
moptipy.examples.bitstrings.bitstring_problem.default_scale_sequence(minimum=2, maximum=3333)[source]

Get the default scales for investigating discrete optimization.

Parameters:
  • minimum (int, default: 2) – the smallest permitted value, by default 2

  • maximum (int, default: 3333) – the largest permitted value, by default 3333

Return type:

Iterator[int]

>>> list(default_scale_sequence())
[2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 36, 40, 41, 42, 44, 48, 49, 50, 55, 59, 60, 64, 66, 70, 77, 79, 80, 81, 85, 88, 90, 96, 99, 100, 107, 111, 121, 125, 128, 144, 149, 169, 170, 192, 196, 199, 200, 222, 225, 243, 256, 269, 289, 300, 324, 333, 341, 343, 359, 361, 384, 400, 441, 444, 479, 484, 500, 512, 529, 555, 576, 600, 625, 641, 666, 676, 682, 700, 729, 768, 777, 784, 800, 841, 857, 888, 900, 961, 999, 1000, 1024, 1089, 1111, 1151, 1156, 1225, 1296, 1365, 1369, 1444, 1521, 1536, 1543, 1600, 1681, 1764, 1849, 1936, 2000, 2025, 2048, 2063, 2116, 2187, 2209, 2222, 2304, 2401, 2500, 2601, 2704, 2730, 2753, 2809, 2916, 3000, 3025, 3072, 3125, 3136, 3249, 3333]
>>> list(default_scale_sequence(10, 100))
[10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 36, 40, 41, 42, 44, 48, 49, 50, 55, 59, 60, 64, 66, 70, 77, 79, 80, 81, 85, 88, 90, 96, 99, 100]
>>> list(default_scale_sequence(maximum=100))
[2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 36, 40, 41, 42, 44, 48, 49, 50, 55, 59, 60, 64, 66, 70, 77, 79, 80, 81, 85, 88, 90, 96, 99, 100]
>>> list(default_scale_sequence(9000, 10000))
[9000, 9025, 9216, 9409, 9604, 9801, 9999, 10000]
>>> try:
...     default_scale_sequence(-1)
... except ValueError as ve:
...     print(ve)
minimum=-1 is invalid, must be in 1..1000000000.
>>> try:
...     default_scale_sequence("2")
... except TypeError as te:
...     print(te)
minimum should be an instance of int but is str, namely '2'.
>>> try:
...     default_scale_sequence(10, 10)
... except ValueError as ve:
...     print(ve)
maximum=10 is invalid, must be in 11..1000000000.
>>> try:
...     default_scale_sequence(2, "2")
... except TypeError as te:
...     print(te)
maximum should be an instance of int but is str, namely '2'.
moptipy.examples.bitstrings.bitstring_problem.default_square_scale_sequence(minimum=2, maximum=3333)[source]

Get the default sequence of square numbers.

Parameters:
  • minimum (int, default: 2) – the smallest permitted value, by default 2

  • maximum (int, default: 3333) – the largest permitted value, by default 3333

Return type:

Iterator[int]

>>> list(default_square_scale_sequence())
[4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225, 256, 289, 324, 361, 400, 441, 484, 529, 576, 625, 676, 729, 784, 841, 900, 961, 1024, 1089, 1156, 1225, 1296, 1369, 1444, 1521, 1600, 1681, 1764, 1849, 1936, 2025, 2116, 2209, 2304, 2401, 2500, 2601, 2704, 2809, 2916, 3025, 3136, 3249]
>>> list(default_square_scale_sequence(100, 1000))
[100, 121, 144, 169, 196, 225, 256, 289, 324, 361, 400, 441, 484, 529, 576, 625, 676, 729, 784, 841, 900, 961]
>>> try:
...     default_square_scale_sequence(-1)
... except ValueError as ve:
...     print(ve)
minimum=-1 is invalid, must be in 1..1000000000.
>>> try:
...     default_square_scale_sequence("2")
... except TypeError as te:
...     print(te)
minimum should be an instance of int but is str, namely '2'.
>>> try:
...     default_square_scale_sequence(10, 10)
... except ValueError as ve:
...     print(ve)
maximum=10 is invalid, must be in 11..1000000000.
>>> try:
...     default_square_scale_sequence(2, "2")
... except TypeError as te:
...     print(te)
maximum should be an instance of int but is str, namely '2'.

moptipy.examples.bitstrings.ising1d module

The one-dimensional Ising problem.

The one-dimensional Ising problem describes a ring. For each bit that differs from its (right-side) neighboring bit, a penalty of 1 is incurred. The optimum is a bit string of either all ones or all zeros. The optimal objective value is 0, the worst-possible one is n.

  1. Simon Fischer and Ingo Wegener. The one-dimensional Ising model: Mutation versus recombination. Theoretical Computer Science. 344(2-3):208-225. November 2005. doi: https://doi.org/10.1016/j.tcs.2005.04.002

  2. Carola Doerr and Furong Ye and Naama Horesh and Hao Wang and Ofer M. Shir and Thomas Bäck. Benchmarking Discrete Optimization Heuristics with IOHprofiler. Applied Soft Computing 88:106027, March 2020, doi: https://doi.org/10.1016/j.asoc.2019.106027.

  3. Clarissa Van Hoyweghen, David Edward Goldberg, and Bart Naudts. From Twomax To The Ising Model: Easy And Hard Symmetrical Problems. In Proceedings of the Genetic and Evolutionary Computation Conference (GECCO’02), July 9-13, 2002, New York, NY, USA, pages 626-633. Morgan Kaufmann. http://gpbib.cs.ucl.ac.uk/gecco2002/GA013.pdf

  4. Thomas Weise, Zhize Wu, Xinlu Li, Yan Chen, and Jörg Lässig. Frequency Fitness Assignment: Optimization without Bias for Good Solutions can be Efficient. IEEE Transactions on Evolutionary Computation (TEVC). 27(4):980-992. August 2023. doi: https://doi.org/10.1109/TEVC.2022.3191698

class moptipy.examples.bitstrings.ising1d.Ising1d(n)[source]

Bases: BitStringProblem

The one-dimensional Ising problem.

classmethod default_instances(scale_min=2, scale_max=100)[source]

Get the 56 default instances of the Ising1d problem.

Parameters:
  • scale_min (int, default: 2) – the minimum permitted scale, by default 2

  • scale_max (int, default: 100) – the maximum permitted scale, by default 100

Return type:

Iterator[Callable[[], Ising1d]]

Returns:

a sequence of default Ising1d instances

>>> len(list(Ising1d.default_instances()))
56
>>> [x() for x in Ising1d.default_instances()]
[ising1d_2, ising1d_3, ising1d_4, ising1d_5, ising1d_6, ising1d_7, ising1d_8, ising1d_9, ising1d_10, ising1d_11, ising1d_12, ising1d_13, ising1d_14, ising1d_15, ising1d_16, ising1d_17, ising1d_18, ising1d_19, ising1d_20, ising1d_21, ising1d_22, ising1d_23, ising1d_24, ising1d_25, ising1d_26, ising1d_27, ising1d_28, ising1d_29, ising1d_30, ising1d_31, ising1d_32, ising1d_33, ising1d_36, ising1d_40, ising1d_41, ising1d_42, ising1d_44, ising1d_48, ising1d_49, ising1d_50, ising1d_55, ising1d_59, ising1d_60, ising1d_64, ising1d_66, ising1d_70, ising1d_77, ising1d_79, ising1d_80, ising1d_81, ising1d_85, ising1d_88, ising1d_90, ising1d_96, ising1d_99, ising1d_100]
moptipy.examples.bitstrings.ising1d.ising1d(x)[source]

Compute the objective value of the 1-dimensional Ising problem.

Parameters:

x (ndarray) – the np array

Return type:

int

Returns:

the ising1d function value

>>> ising1d(np.array([True, True, True, True, True]))
0
>>> ising1d(np.array([False, False, False, False, False]))
0
>>> ising1d(np.array([False, False, False, True, False]))
2
>>> ising1d(np.array([True, False, False, False, False]))
2
>>> ising1d(np.array([False, False, False, False, True]))
2
>>> ising1d(np.array([True, False, False, False, True]))
2
>>> ising1d(np.array([True, False, True, False, False]))
4
>>> ising1d(np.array([True, False, True, False, True, False]))
6

# n = 1 and 0 true bits >>> ising1d(np.array([0])) 0

# n = 1 and 1 true bit >>> ising1d(np.array([1])) 0

# n = 2 and 0 true bits >>> ising1d(np.array([0, 0])) 0

# n = 2 and 1 true bit >>> ising1d(np.array([1, 0])) 2

# n = 2 and 1 true bit >>> ising1d(np.array([0, 1])) 2

# n = 2 and 1 true bit >>> ising1d(np.array([0, 1])) 2

# n = 2 and 2 true bits >>> ising1d(np.array([1, 1])) 0

# n = 3 and 0 true bits >>> ising1d(np.array([0, 0, 0])) 0

# n = 3 and 1 true bit >>> ising1d(np.array([1, 0, 0])) 2

# n = 3 and 1 true bit >>> ising1d(np.array([0, 0, 1])) 2

# n = 3 and 1 true bit >>> ising1d(np.array([1, 0, 0])) 2

# n = 3 and 2 true bits >>> ising1d(np.array([1, 0, 1])) 2

# n = 3 and 2 true bits >>> ising1d(np.array([1, 0, 1])) 2

# n = 3 and 2 true bits >>> ising1d(np.array([1, 1, 0])) 2

# n = 3 and 3 true bits >>> ising1d(np.array([1, 1, 1])) 0

# n = 4 and 0 true bits >>> ising1d(np.array([0, 0, 0, 0])) 0

# n = 4 and 1 true bit >>> ising1d(np.array([1, 0, 0, 0])) 2

# n = 4 and 1 true bit >>> ising1d(np.array([0, 0, 1, 0])) 2

# n = 4 and 1 true bit >>> ising1d(np.array([1, 0, 0, 0])) 2

# n = 4 and 2 true bits >>> ising1d(np.array([1, 0, 0, 1])) 2

# n = 4 and 2 true bits >>> ising1d(np.array([1, 1, 0, 0])) 2

# n = 4 and 2 true bits >>> ising1d(np.array([0, 1, 1, 0])) 2

# n = 4 and 3 true bits >>> ising1d(np.array([0, 1, 1, 1])) 2

# n = 4 and 3 true bits >>> ising1d(np.array([1, 1, 0, 1])) 2

# n = 4 and 3 true bits >>> ising1d(np.array([0, 1, 1, 1])) 2

# n = 4 and 4 true bits >>> ising1d(np.array([1, 1, 1, 1])) 0

# n = 5 and 0 true bits >>> ising1d(np.array([0, 0, 0, 0, 0])) 0

# n = 5 and 1 true bit >>> ising1d(np.array([0, 0, 0, 0, 1])) 2

# n = 5 and 1 true bit >>> ising1d(np.array([0, 0, 0, 0, 1])) 2

# n = 5 and 1 true bit >>> ising1d(np.array([0, 1, 0, 0, 0])) 2

# n = 5 and 2 true bits >>> ising1d(np.array([0, 1, 0, 0, 1])) 4

# n = 5 and 2 true bits >>> ising1d(np.array([0, 1, 0, 0, 1])) 4

# n = 5 and 2 true bits >>> ising1d(np.array([0, 1, 1, 0, 0])) 2

# n = 5 and 3 true bits >>> ising1d(np.array([1, 1, 0, 1, 0])) 4

# n = 5 and 3 true bits >>> ising1d(np.array([1, 1, 1, 0, 0])) 2

# n = 5 and 3 true bits >>> ising1d(np.array([1, 0, 1, 0, 1])) 4

# n = 5 and 4 true bits >>> ising1d(np.array([1, 1, 1, 1, 0])) 2

# n = 5 and 4 true bits >>> ising1d(np.array([1, 1, 0, 1, 1])) 2

# n = 5 and 4 true bits >>> ising1d(np.array([1, 1, 0, 1, 1])) 2

# n = 5 and 5 true bits >>> ising1d(np.array([1, 1, 1, 1, 1])) 0

# n = 6 and 0 true bits >>> ising1d(np.array([0, 0, 0, 0, 0, 0])) 0

# n = 6 and 1 true bit >>> ising1d(np.array([0, 0, 0, 0, 0, 1])) 2

# n = 6 and 1 true bit >>> ising1d(np.array([0, 0, 0, 0, 1, 0])) 2

# n = 6 and 1 true bit >>> ising1d(np.array([0, 1, 0, 0, 0, 0])) 2

# n = 6 and 2 true bits >>> ising1d(np.array([1, 1, 0, 0, 0, 0])) 2

# n = 6 and 2 true bits >>> ising1d(np.array([1, 1, 0, 0, 0, 0])) 2

# n = 6 and 2 true bits >>> ising1d(np.array([0, 0, 0, 1, 1, 0])) 2

# n = 6 and 3 true bits >>> ising1d(np.array([1, 0, 0, 1, 0, 1])) 4

# n = 6 and 3 true bits >>> ising1d(np.array([1, 0, 0, 0, 1, 1])) 2

# n = 6 and 3 true bits >>> ising1d(np.array([1, 1, 0, 0, 1, 0])) 4

# n = 6 and 4 true bits >>> ising1d(np.array([1, 0, 1, 1, 1, 0])) 4

# n = 6 and 4 true bits >>> ising1d(np.array([1, 1, 1, 1, 0, 0])) 2

# n = 6 and 4 true bits >>> ising1d(np.array([1, 1, 0, 1, 0, 1])) 4

# n = 6 and 5 true bits >>> ising1d(np.array([1, 1, 1, 1, 0, 1])) 2

# n = 6 and 5 true bits >>> ising1d(np.array([1, 0, 1, 1, 1, 1])) 2

# n = 6 and 5 true bits >>> ising1d(np.array([0, 1, 1, 1, 1, 1])) 2

# n = 6 and 6 true bits >>> ising1d(np.array([1, 1, 1, 1, 1, 1])) 0

# n = 7 and 0 true bits >>> ising1d(np.array([0, 0, 0, 0, 0, 0, 0])) 0

# n = 7 and 1 true bit >>> ising1d(np.array([0, 0, 0, 1, 0, 0, 0])) 2

# n = 7 and 1 true bit >>> ising1d(np.array([0, 0, 0, 0, 0, 1, 0])) 2

# n = 7 and 1 true bit >>> ising1d(np.array([0, 0, 0, 0, 0, 1, 0])) 2

# n = 7 and 2 true bits >>> ising1d(np.array([0, 1, 1, 0, 0, 0, 0])) 2

# n = 7 and 2 true bits >>> ising1d(np.array([1, 0, 0, 0, 0, 1, 0])) 4

# n = 7 and 2 true bits >>> ising1d(np.array([1, 0, 0, 0, 0, 0, 1])) 2

# n = 7 and 3 true bits >>> ising1d(np.array([1, 0, 0, 0, 0, 1, 1])) 2

# n = 7 and 3 true bits >>> ising1d(np.array([1, 0, 1, 0, 0, 1, 0])) 6

# n = 7 and 3 true bits >>> ising1d(np.array([1, 0, 0, 1, 0, 1, 0])) 6

# n = 7 and 4 true bits >>> ising1d(np.array([0, 1, 1, 0, 1, 1, 0])) 4

# n = 7 and 4 true bits >>> ising1d(np.array([0, 1, 0, 1, 1, 0, 1])) 6

# n = 7 and 4 true bits >>> ising1d(np.array([1, 1, 1, 0, 1, 0, 0])) 4

# n = 7 and 5 true bits >>> ising1d(np.array([1, 0, 1, 1, 1, 0, 1])) 4

# n = 7 and 5 true bits >>> ising1d(np.array([0, 1, 1, 1, 0, 1, 1])) 4

# n = 7 and 5 true bits >>> ising1d(np.array([1, 1, 1, 0, 1, 1, 0])) 4

# n = 7 and 6 true bits >>> ising1d(np.array([1, 1, 1, 0, 1, 1, 1])) 2

# n = 7 and 6 true bits >>> ising1d(np.array([1, 1, 1, 1, 1, 1, 0])) 2

# n = 7 and 6 true bits >>> ising1d(np.array([0, 1, 1, 1, 1, 1, 1])) 2

# n = 7 and 7 true bits >>> ising1d(np.array([1, 1, 1, 1, 1, 1, 1])) 0

# n = 8 and 0 true bits >>> ising1d(np.array([0, 0, 0, 0, 0, 0, 0, 0])) 0

# n = 8 and 1 true bit >>> ising1d(np.array([0, 0, 1, 0, 0, 0, 0, 0])) 2

# n = 8 and 1 true bit >>> ising1d(np.array([0, 0, 1, 0, 0, 0, 0, 0])) 2

# n = 8 and 1 true bit >>> ising1d(np.array([0, 0, 0, 0, 0, 1, 0, 0])) 2

# n = 8 and 2 true bits >>> ising1d(np.array([1, 0, 1, 0, 0, 0, 0, 0])) 4

# n = 8 and 2 true bits >>> ising1d(np.array([0, 0, 0, 0, 1, 1, 0, 0])) 2

# n = 8 and 2 true bits >>> ising1d(np.array([0, 0, 0, 1, 0, 0, 0, 1])) 4

# n = 8 and 3 true bits >>> ising1d(np.array([0, 0, 1, 1, 1, 0, 0, 0])) 2

# n = 8 and 3 true bits >>> ising1d(np.array([1, 0, 1, 0, 0, 0, 1, 0])) 6

# n = 8 and 3 true bits >>> ising1d(np.array([0, 1, 0, 1, 0, 0, 1, 0])) 6

# n = 8 and 4 true bits >>> ising1d(np.array([0, 1, 0, 1, 1, 0, 0, 1])) 6

# n = 8 and 4 true bits >>> ising1d(np.array([1, 0, 1, 0, 1, 0, 1, 0])) 8

# n = 8 and 4 true bits >>> ising1d(np.array([1, 0, 1, 0, 1, 0, 0, 1])) 6

# n = 8 and 5 true bits >>> ising1d(np.array([1, 0, 1, 0, 0, 1, 1, 1])) 4

# n = 8 and 5 true bits >>> ising1d(np.array([1, 1, 0, 1, 0, 0, 1, 1])) 4

# n = 8 and 5 true bits >>> ising1d(np.array([1, 0, 0, 1, 0, 1, 1, 1])) 4

# n = 8 and 6 true bits >>> ising1d(np.array([0, 1, 1, 1, 0, 1, 1, 1])) 4

# n = 8 and 6 true bits >>> ising1d(np.array([0, 0, 1, 1, 1, 1, 1, 1])) 2

# n = 8 and 6 true bits >>> ising1d(np.array([1, 1, 1, 1, 1, 1, 0, 0])) 2

# n = 8 and 7 true bits >>> ising1d(np.array([1, 1, 1, 0, 1, 1, 1, 1])) 2

# n = 8 and 7 true bits >>> ising1d(np.array([1, 1, 1, 1, 1, 1, 0, 1])) 2

# n = 8 and 7 true bits >>> ising1d(np.array([1, 1, 1, 1, 1, 1, 0, 1])) 2

# n = 8 and 8 true bits >>> ising1d(np.array([1, 1, 1, 1, 1, 1, 1, 1])) 0

# n = 9 and 0 true bits >>> ising1d(np.array([0, 0, 0, 0, 0, 0, 0, 0, 0])) 0

# n = 9 and 1 true bit >>> ising1d(np.array([0, 0, 0, 0, 0, 0, 0, 1, 0])) 2

# n = 9 and 1 true bit >>> ising1d(np.array([0, 0, 0, 0, 0, 1, 0, 0, 0])) 2

# n = 9 and 1 true bit >>> ising1d(np.array([0, 1, 0, 0, 0, 0, 0, 0, 0])) 2

# n = 9 and 2 true bits >>> ising1d(np.array([0, 1, 0, 1, 0, 0, 0, 0, 0])) 4

# n = 9 and 2 true bits >>> ising1d(np.array([0, 1, 0, 0, 1, 0, 0, 0, 0])) 4

# n = 9 and 2 true bits >>> ising1d(np.array([0, 1, 0, 1, 0, 0, 0, 0, 0])) 4

# n = 9 and 3 true bits >>> ising1d(np.array([0, 0, 1, 0, 0, 1, 0, 1, 0])) 6

# n = 9 and 3 true bits >>> ising1d(np.array([0, 0, 0, 1, 1, 0, 0, 1, 0])) 4

# n = 9 and 3 true bits >>> ising1d(np.array([0, 0, 0, 1, 0, 0, 0, 1, 1])) 4

# n = 9 and 4 true bits >>> ising1d(np.array([1, 0, 1, 1, 1, 0, 0, 0, 0])) 4

# n = 9 and 4 true bits >>> ising1d(np.array([1, 1, 1, 0, 1, 0, 0, 0, 0])) 4

# n = 9 and 4 true bits >>> ising1d(np.array([0, 1, 0, 0, 0, 1, 1, 0, 1])) 6

# n = 9 and 5 true bits >>> ising1d(np.array([0, 0, 1, 1, 0, 0, 1, 1, 1])) 4

# n = 9 and 5 true bits >>> ising1d(np.array([0, 1, 0, 1, 1, 0, 1, 0, 1])) 8

# n = 9 and 5 true bits >>> ising1d(np.array([1, 0, 1, 1, 1, 0, 0, 1, 0])) 6

# n = 9 and 6 true bits >>> ising1d(np.array([1, 0, 1, 1, 1, 1, 1, 0, 0])) 4

# n = 9 and 6 true bits >>> ising1d(np.array([0, 0, 1, 1, 1, 1, 1, 1, 0])) 2

# n = 9 and 6 true bits >>> ising1d(np.array([1, 1, 1, 1, 0, 1, 0, 0, 1])) 4

# n = 9 and 7 true bits >>> ising1d(np.array([1, 1, 0, 1, 1, 0, 1, 1, 1])) 4

# n = 9 and 7 true bits >>> ising1d(np.array([1, 1, 0, 1, 1, 1, 1, 1, 0])) 4

# n = 9 and 7 true bits >>> ising1d(np.array([1, 0, 1, 0, 1, 1, 1, 1, 1])) 4

# n = 9 and 8 true bits >>> ising1d(np.array([1, 0, 1, 1, 1, 1, 1, 1, 1])) 2

# n = 9 and 8 true bits >>> ising1d(np.array([1, 1, 1, 1, 1, 1, 0, 1, 1])) 2

# n = 9 and 8 true bits >>> ising1d(np.array([1, 1, 1, 1, 1, 0, 1, 1, 1])) 2

# n = 9 and 9 true bits >>> ising1d(np.array([1, 1, 1, 1, 1, 1, 1, 1, 1])) 0

# n = 10 and 0 true bits >>> ising1d(np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0])) 0

# n = 10 and 1 true bit >>> ising1d(np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 1])) 2

# n = 10 and 1 true bit >>> ising1d(np.array([0, 0, 0, 1, 0, 0, 0, 0, 0, 0])) 2

# n = 10 and 1 true bit >>> ising1d(np.array([1, 0, 0, 0, 0, 0, 0, 0, 0, 0])) 2

# n = 10 and 2 true bits >>> ising1d(np.array([0, 1, 0, 0, 0, 0, 0, 0, 1, 0])) 4

# n = 10 and 2 true bits >>> ising1d(np.array([1, 0, 0, 0, 0, 0, 0, 0, 0, 1])) 2

# n = 10 and 2 true bits >>> ising1d(np.array([0, 0, 0, 0, 1, 0, 0, 0, 0, 1])) 4

# n = 10 and 3 true bits >>> ising1d(np.array([1, 1, 1, 0, 0, 0, 0, 0, 0, 0])) 2

# n = 10 and 3 true bits >>> ising1d(np.array([0, 0, 1, 0, 0, 0, 1, 0, 1, 0])) 6

# n = 10 and 3 true bits >>> ising1d(np.array([0, 1, 0, 0, 0, 0, 1, 0, 0, 1])) 6

# n = 10 and 4 true bits >>> ising1d(np.array([1, 0, 0, 1, 1, 0, 0, 0, 1, 0])) 6

# n = 10 and 4 true bits >>> ising1d(np.array([0, 0, 0, 1, 1, 0, 1, 0, 0, 1])) 6

# n = 10 and 4 true bits >>> ising1d(np.array([1, 1, 0, 0, 0, 0, 0, 1, 0, 1])) 4

# n = 10 and 5 true bits >>> ising1d(np.array([1, 0, 0, 0, 1, 1, 1, 0, 1, 0])) 6

# n = 10 and 5 true bits >>> ising1d(np.array([1, 1, 0, 0, 1, 0, 1, 0, 1, 0])) 8

# n = 10 and 5 true bits >>> ising1d(np.array([0, 0, 1, 0, 0, 1, 0, 1, 1, 1])) 6

# n = 10 and 6 true bits >>> ising1d(np.array([1, 1, 1, 0, 0, 1, 1, 0, 0, 1])) 4

# n = 10 and 6 true bits >>> ising1d(np.array([1, 1, 0, 1, 0, 0, 1, 1, 1, 0])) 6

# n = 10 and 6 true bits >>> ising1d(np.array([1, 0, 0, 0, 1, 1, 1, 0, 1, 1])) 4

# n = 10 and 7 true bits >>> ising1d(np.array([1, 0, 0, 0, 1, 1, 1, 1, 1, 1])) 2

# n = 10 and 7 true bits >>> ising1d(np.array([1, 0, 0, 1, 1, 1, 1, 1, 1, 0])) 4

# n = 10 and 7 true bits >>> ising1d(np.array([0, 1, 1, 1, 0, 1, 0, 1, 1, 1])) 6

# n = 10 and 8 true bits >>> ising1d(np.array([1, 0, 1, 1, 0, 1, 1, 1, 1, 1])) 4

# n = 10 and 8 true bits >>> ising1d(np.array([1, 1, 1, 1, 1, 1, 1, 0, 1, 0])) 4

# n = 10 and 8 true bits >>> ising1d(np.array([0, 1, 1, 1, 1, 1, 1, 0, 1, 1])) 4

# n = 10 and 9 true bits >>> ising1d(np.array([1, 1, 1, 1, 1, 1, 1, 1, 0, 1])) 2

# n = 10 and 9 true bits >>> ising1d(np.array([1, 1, 1, 1, 1, 0, 1, 1, 1, 1])) 2

# n = 10 and 9 true bits >>> ising1d(np.array([1, 0, 1, 1, 1, 1, 1, 1, 1, 1])) 2

# n = 10 and 10 true bits >>> ising1d(np.array([1, 1, 1, 1, 1, 1, 1, 1, 1, 1])) 0

moptipy.examples.bitstrings.ising2d module

The two-dimensional Ising problem.

The two-dimensional Ising problem describes a torus. For each bit that differs from its right-side neighboring bit, a penalty of 1 is incurred. For each bit differing from its above neighbor, another penalty of 1 is added. The optimum is a bit string of either all ones or all zeros. The optimal objective value is 0. The worst possible objective value is 2*n.

  1. Simon Fischer. A Polynomial Upper Bound for a Mutation-Based Algorithm on the Two-Dimensional Ising Model. In Kalyanmoy Deb, editor, Genetic and Evolutionary Computation Conference, June 26-30, 2004, Seattle, WA, USA, Proceedings, Part I, Lecture Notes in Computer Science (LNCS), volume 3102, Springer Berlin, Heidelberg. pages 1100-1112. doi: https://doi.org/10.1007/978-3-540-24854-5_108.

  2. Carola Doerr and Furong Ye and Naama Horesh and Hao Wang and Ofer M. Shir and Thomas Bäck. Benchmarking Discrete Optimization Heuristics with IOHprofiler. Applied Soft Computing 88:106027, March 2020, doi: https://doi.org/10.1016/j.asoc.2019.106027.

  3. Thomas Weise, Zhize Wu, Xinlu Li, Yan Chen, and Jörg Lässig. Frequency Fitness Assignment: Optimization without Bias for Good Solutions can be Efficient. IEEE Transactions on Evolutionary Computation (TEVC). 27(4):980-992. August 2023. doi: https://doi.org/10.1109/TEVC.2022.3191698

This is code is part of the research work of Mr. Jiazheng ZENG (曾嘉政), a Master’s student at the Institute of Applied Optimization (应用优化研究所, http://iao.hfuu.edu.cn) of the School of Artificial Intelligence and Big Data (人工智能与大数据学院) at Hefei University (合肥大学) in Hefei, Anhui, China (中国安徽省合肥市) under the supervision of Prof. Dr. Thomas Weise (汤卫思教授).

class moptipy.examples.bitstrings.ising2d.Ising2d(n)[source]

Bases: SquareBitStringProblem

The two-dimensional Ising model.

>>> ising = Ising2d(16)
>>> ising.n
16
>>> ising.k
4
>>> ising.evaluate(np.array([False, False, False, False,
...                          False, False, False, False,
...                          False, False, False, False,
...                          False, False, False, False]))
0
>>> ising.evaluate(np.array([False, False, False, False,
...                          False,  True, False, False,
...                          False, False, False, False,
...                          False, False, False, False]))
4
>>> ising.evaluate(np.array([False, False, False, False,
...                           True,  True,  True,  True,
...                          False, False, False, False,
...                          False, False, False, False]))
8
>>> ising.evaluate(np.array([False,  True, False, False,
...                           True,  True,  True,  True,
...                          False,  True, False, False,
...                          False,  True, False, False]))
12
>>> ising.evaluate(np.array([False,  True, False, False,
...                           True,  True,  True,  True,
...                          False,  True, False, False,
...                          False,  True, False,  True]))
16
>>> ising.evaluate(np.array([False,  True, False, False,
...                           True,  True,  True,  True,
...                          False,  True, False, False,
...                           True,  True,  True,  True]))
16
classmethod default_instances(scale_min=2, scale_max=100)[source]

Get the 56 default instances of the Ising2d problem.

Parameters:
  • scale_min (int, default: 2) – the minimum permitted scale, by default 2

  • scale_max (int, default: 100) – the maximum permitted scale, by default 100

Return type:

Iterator[Callable[[], Ising2d]]

Returns:

a sequence of default Ising2d instances

>>> len(list(Ising2d.default_instances()))
9
>>> [x() for x in Ising2d.default_instances()]
[ising2d_4, ising2d_9, ising2d_16, ising2d_25, ising2d_36, ising2d_49, ising2d_64, ising2d_81, ising2d_100]
evaluate(x)[source]

Evaluate a solution to the 2D Ising problem.

Parameters:

x (ndarray) – the bit string to evaluate

Return type:

int

Returns:

the value of the 2D Ising Model for the string

upper_bound()[source]

Get the upper bound of the two-dimensional Ising model.

Return type:

int

Returns:

twice the length of the bit string

>>> Ising2d(49).upper_bound()
98
moptipy.examples.bitstrings.ising2d.ising2d(x, k)[source]

Calculate the two-dimensional Ising model.

Parameters:
  • x (ndarray) – the flat numpy array representing the bitstring

  • k (int) – the side length of the square grid (i.e., sqrt(len(x)))

Return type:

int

Returns:

the two-dimensional Ising objective

>>> test_k = 2
>>> y = np.array([False] * test_k * test_k)
>>> ising2d(y, test_k)
0
>>> y.fill(True)
>>> ising2d(y, test_k)
0
>>> y[2] = not y[2]
>>> ising2d(y, test_k)
4
>>> ising2d(np.array([True, False, False, True]), 2)
8
>>> test_k = 3
>>> y = np.array([False] * test_k * test_k)
>>> ising2d(y, test_k)
0
>>> y.fill(True)
>>> ising2d(y, test_k)
0
>>> y[4] = not y[4]
>>> ising2d(y, test_k)
4
>>> y[5] = not y[5]
>>> ising2d(y, test_k)
6
>>> y[3] = not y[3]
>>> ising2d(y, test_k)
6
>>> test_k = 5
>>> y = np.array([False] * test_k * test_k)
>>> ising2d(y, test_k)
0
>>> y.fill(True)
>>> ising2d(y, test_k)
0
>>> y[5] = not y[5]
>>> ising2d(y, test_k)
4
>>> y[6] = not y[6]
>>> ising2d(y, test_k)
6
>>> y[7] = not y[7]
>>> ising2d(y, test_k)
8
>>> y[6] = not y[6]
>>> ising2d(y, test_k)
8
>>> y[10] = not y[10]
>>> ising2d(y, test_k)
10
>>> y[12] = not y[12]
>>> ising2d(y, test_k)
12
>>> y[11] = not y[11]
>>> ising2d(y, test_k)
12
>>> y[6] = not y[6]
>>> ising2d(y, test_k)
10

# 16 bits, torus width = 4, and 2 true bits >>> ising2d(np.array([0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0]), 4) 8

# 16 bits, torus width = 4, and 3 true bits >>> ising2d(np.array([0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0]), 4) 12

# 16 bits, torus width = 4, and 3 true bits >>> ising2d(np.array([0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0]), 4) 10

# 16 bits, torus width = 4, and 1 true bit >>> ising2d(np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0]), 4) 4

# 16 bits, torus width = 4, and 4 true bits >>> ising2d(np.array([0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0]), 4) 10

# 16 bits, torus width = 4, and 4 true bits >>> ising2d(np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1]), 4) 10

# 16 bits, torus width = 4, and 4 true bits >>> ising2d(np.array([0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0]), 4) 12

# 16 bits, torus width = 4, and 4 true bits >>> ising2d(np.array([0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0]), 4) 12

# 16 bits, torus width = 4, and 10 true bits >>> ising2d(np.array([0, 1, 1, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1]), 4) 14

# 16 bits, torus width = 4, and 8 true bits >>> ising2d(np.array([1, 0, 1, 0, 1, 1, 0, 0, 0, 1, 0, 1, 1, 0, 1, 0]), 4) 22

# 16 bits, torus width = 4, and 12 true bits >>> ising2d(np.array([1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 0]), 4) 12

# 16 bits, torus width = 4, and 13 true bits >>> ising2d(np.array([0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1]), 4) 12

# 16 bits, torus width = 4, and 0 true bits >>> ising2d(np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), 4) 0

# 16 bits, torus width = 4, and 16 true bits >>> ising2d(np.array([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]), 4) 0

# 25 bits, torus width = 5, and 1 true bit >>> ising2d(np.array([0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0]), 5) 4

# 25 bits, torus width = 5, and 1 true bit >>> ising2d(np.array([0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0]), 5) 4

# 25 bits, torus width = 5, and 1 true bit >>> ising2d(np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0]), 5) 4

# 25 bits, torus width = 5, and 4 true bits >>> ising2d(np.array([1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, … 0, 1, 0, 1, 0, 0, 0, 0]), 5) 12

# 25 bits, torus width = 5, and 5 true bits >>> ising2d(np.array([0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, … 1, 0, 1, 0, 0, 1, 0, 0]), 5) 16

# 25 bits, torus width = 5, and 5 true bits >>> ising2d(np.array([0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, … 1, 0, 0, 0, 0, 0, 0, 1]), 5) 16

# 25 bits, torus width = 5, and 5 true bits >>> ising2d(np.array([0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 1]), 5) 18

# 25 bits, torus width = 5, and 5 true bits >>> ising2d(np.array([0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 1]), 5) 20

# 25 bits, torus width = 5, and 13 true bits >>> ising2d(np.array([1, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, … 1, 0, 1, 0, 1, 0, 0, 1]), 5) 26

# 25 bits, torus width = 5, and 21 true bits >>> ising2d(np.array([1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 0, 1, … 1, 1, 1, 1, 1, 1, 1, 1]), 5) 12

# 25 bits, torus width = 5, and 24 true bits >>> ising2d(np.array([1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, … 1, 1, 1, 1, 1, 1, 1, 1]), 5) 4

# 25 bits, torus width = 5, and 12 true bits >>> ising2d(np.array([1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 0, 0, … 0, 1, 0, 0, 1, 0, 1, 0]), 5) 24

# 25 bits, torus width = 5, and 0 true bits >>> ising2d(np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0]), 5) 0

# 25 bits, torus width = 5, and 25 true bits >>> ising2d(np.array([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, … 1, 1, 1, 1, 1, 1, 1, 1]), 5) 0

# 36 bits, torus width = 6, and 3 true bits >>> ising2d(np.array([0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, … 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), 6) 12

# 36 bits, torus width = 6, and 4 true bits >>> ising2d(np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0]), 6) 12

# 36 bits, torus width = 6, and 2 true bits >>> ising2d(np.array([0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), 6) 8

# 36 bits, torus width = 6, and 1 true bit >>> ising2d(np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), 6) 4

# 36 bits, torus width = 6, and 6 true bits >>> ising2d(np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, … 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0]), 6) 18

# 36 bits, torus width = 6, and 6 true bits >>> ising2d(np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0]), 6) 18

# 36 bits, torus width = 6, and 6 true bits >>> ising2d(np.array([0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, … 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0]), 6) 18

# 36 bits, torus width = 6, and 6 true bits >>> ising2d(np.array([0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0]), 6) 18

# 36 bits, torus width = 6, and 12 true bits >>> ising2d(np.array([0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 0]), 6) 28

# 36 bits, torus width = 6, and 15 true bits >>> ising2d(np.array([1, 1, 1, 0, 1, 0, 1, 1, 0, 0, 1, 0, 0, 1, 1, 1, 0, … 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1]), 6) 34

# 36 bits, torus width = 6, and 26 true bits >>> ising2d(np.array([1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, … 1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 1, 0, 0, 0, 1, 1, 1, 1, 1]), 6) 30

# 36 bits, torus width = 6, and 20 true bits >>> ising2d(np.array([0, 1, 1, 1, 0, 0, 0, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1, … 1, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0]), 6) 32

# 36 bits, torus width = 6, and 0 true bits >>> ising2d(np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), 6) 0

# 36 bits, torus width = 6, and 36 true bits >>> ising2d(np.array([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, … 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]), 6) 0

# 49 bits, torus width = 7, and 6 true bits >>> ising2d(np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, … 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 1, 0, 0, 0, 1, 0]), 7) 24

# 49 bits, torus width = 7, and 4 true bits >>> ising2d(np.array([0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), 7) 16

# 49 bits, torus width = 7, and 2 true bits >>> ising2d(np.array([0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), 7) 8

# 49 bits, torus width = 7, and 1 true bit >>> ising2d(np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 1, 0, 0, 0]), 7) 4

# 49 bits, torus width = 7, and 7 true bits >>> ising2d(np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, … 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, … 0, 1, 0, 0, 0, 0, 0, 1, 0, 0]), 7) 24

# 49 bits, torus width = 7, and 7 true bits >>> ising2d(np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, … 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, … 1, 0, 0, 0, 0, 1, 0, 0, 0, 0]), 7) 26

# 49 bits, torus width = 7, and 7 true bits >>> ising2d(np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, … 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, … 0, 0, 1, 0, 1, 0, 0, 0, 1, 0]), 7) 28

# 49 bits, torus width = 7, and 7 true bits >>> ising2d(np.array([0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, … 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, … 0, 0, 1, 0, 0, 0, 0, 0, 0, 0]), 7) 26

# 49 bits, torus width = 7, and 14 true bits >>> ising2d(np.array([0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, … 0, 1, 1, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, … 0, 0, 0, 0, 0, 1, 0, 0, 0, 0]), 7) 36

# 49 bits, torus width = 7, and 12 true bits >>> ising2d(np.array([0, 0, 1, 1, 0, 1, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, … 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, … 1, 0, 0, 1, 0, 0, 1, 0, 0, 0]), 7) 38

# 49 bits, torus width = 7, and 15 true bits >>> ising2d(np.array([0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, … 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, … 1, 1, 1, 0, 0, 1, 0, 0, 1, 0]), 7) 42

# 49 bits, torus width = 7, and 29 true bits >>> ising2d(np.array([1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, … 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 1, 1, 1, 1, 0, 0, 1, 0, 0, … 0, 1, 1, 1, 1, 0, 1, 1, 1, 1]), 7) 48

# 49 bits, torus width = 7, and 0 true bits >>> ising2d(np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), 7) 0

# 49 bits, torus width = 7, and 49 true bits >>> ising2d(np.array([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, … 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, … 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]), 7) 0

# 64 bits, torus width = 8, and 5 true bits >>> ising2d(np.array([0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, … 0, 0, 0]), 8) 20

# 64 bits, torus width = 8, and 7 true bits >>> ising2d(np.array([0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, … 0, 0, 0]), 8) 26

# 64 bits, torus width = 8, and 2 true bits >>> ising2d(np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0]), 8) 8

# 64 bits, torus width = 8, and 4 true bits >>> ising2d(np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, … 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0]), 8) 14

# 64 bits, torus width = 8, and 8 true bits >>> ising2d(np.array([0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, … 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, … 1, 0, 0]), 8) 30

# 64 bits, torus width = 8, and 8 true bits >>> ising2d(np.array([0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0]), 8) 28

# 64 bits, torus width = 8, and 8 true bits >>> ising2d(np.array([0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, … 0, 1, 0]), 8) 30

# 64 bits, torus width = 8, and 8 true bits >>> ising2d(np.array([0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, … 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, … 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0]), 8) 26

# 64 bits, torus width = 8, and 37 true bits >>> ising2d(np.array([0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 0, 1, … 1, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, … 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, … 1, 1, 0]), 8) 58

# 64 bits, torus width = 8, and 36 true bits >>> ising2d(np.array([0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 1, … 1, 0, 1, 0, 1, 1, 0, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, … 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 1, 1, 0, 1, … 1, 1, 1]), 8) 62

# 64 bits, torus width = 8, and 55 true bits >>> ising2d(np.array([1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, … 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, … 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, … 1, 1, 1]), 8) 32

# 64 bits, torus width = 8, and 38 true bits >>> ising2d(np.array([0, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, … 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 1, 0, 1, … 1, 1, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 1, … 1, 0, 1]), 8) 68

# 64 bits, torus width = 8, and 0 true bits >>> ising2d(np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0]), 8) 0

# 64 bits, torus width = 8, and 64 true bits >>> ising2d(np.array([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, … 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, … 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, … 1, 1, 1]), 8) 0

# 81 bits, torus width = 9, and 1 true bit >>> ising2d(np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), 9) 4

# 81 bits, torus width = 9, and 5 true bits >>> ising2d(np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, … 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), 9) 20

# 81 bits, torus width = 9, and 1 true bit >>> ising2d(np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), 9) 4

# 81 bits, torus width = 9, and 3 true bits >>> ising2d(np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, … 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), 9) 12

# 81 bits, torus width = 9, and 9 true bits >>> ising2d(np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, … 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, … 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0]), 9) 30

# 81 bits, torus width = 9, and 9 true bits >>> ising2d(np.array([0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, … 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), 9) 32

# 81 bits, torus width = 9, and 9 true bits >>> ising2d(np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, … 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0]), 9) 32

# 81 bits, torus width = 9, and 9 true bits >>> ising2d(np.array([0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0]), 9) 36

# 81 bits, torus width = 9, and 11 true bits >>> ising2d(np.array([0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, … 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]), 9) 40

# 81 bits, torus width = 9, and 40 true bits >>> ising2d(np.array([1, 0, 1, 1, 0, 1, 1, 0, 0, 0, 1, 1, 1, 0, 1, 1, 0, … 0, 0, 0, 1, 1, 0, 1, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 1, … 1, 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 1, … 1, 0, 1, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 1, 1, 0, 1, 0]), 9) 88

# 81 bits, torus width = 9, and 35 true bits >>> ising2d(np.array([0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 1, 1, 1, 0, 1, 0, 0, … 1, 0, 0, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 0, 1, 1, 1, 0, … 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, … 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1]), 9) 70

# 81 bits, torus width = 9, and 79 true bits >>> ising2d(np.array([1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, … 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, … 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, … 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]), 9) 8

# 81 bits, torus width = 9, and 0 true bits >>> ising2d(np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), 9) 0

# 81 bits, torus width = 9, and 81 true bits >>> ising2d(np.array([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, … 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, … 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, … 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]), 9) 0

# 100 bits, torus width = 10, and 3 true bits >>> ising2d(np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0]), 10) 12

# 100 bits, torus width = 10, and 5 true bits >>> ising2d(np.array([0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), 10) 20

# 100 bits, torus width = 10, and 2 true bits >>> ising2d(np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), 10) 8

# 100 bits, torus width = 10, and 1 true bit >>> ising2d(np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), 10) 4

# 100 bits, torus width = 10, and 10 true bits >>> ising2d(np.array([0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, … 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, … 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0]), 10) 40

# 100 bits, torus width = 10, and 10 true bits >>> ising2d(np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, … 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0]), 10) 38

# 100 bits, torus width = 10, and 10 true bits >>> ising2d(np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, … 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 1, … 1, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), 10) 28

# 100 bits, torus width = 10, and 10 true bits >>> ising2d(np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, … 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0]), 10) 36

# 100 bits, torus width = 10, and 91 true bits >>> ising2d(np.array([1, 0, 1, 1, 1, 1, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, … 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, … 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, … 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, … 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]), 10) 32

# 100 bits, torus width = 10, and 32 true bits >>> ising2d(np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, … 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, … 0, 1, 0, 0, 0, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 1, 0, 0, 0, 1, 0, … 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, … 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 1, 1, 1, 0, 0]), 10) 68

# 100 bits, torus width = 10, and 89 true bits >>> ising2d(np.array([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, … 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, … 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, … 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, … 1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 0]), 10) 42

# 100 bits, torus width = 10, and 92 true bits >>> ising2d(np.array([0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, … 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 0, 1, 1, 1, 1, … 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, … 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, … 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]), 10) 30

# 100 bits, torus width = 10, and 0 true bits >>> ising2d(np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), 10) 0

# 100 bits, torus width = 10, and 100 true bits >>> ising2d(np.array([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, … 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, … 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, … 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, … 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]), 10) 0

moptipy.examples.bitstrings.jump module

The Jump problem.

The Jump problem is basically OneMax, but with a deceptive region of k bit flips before the optimum. The optimal objective value is 0, which is reached if all bits are True. The worst objective value is n + k - 1, which is reached if exactly one bit is False.

  1. Stefan Droste, Thomas Jansen, and Ingo Wegener. On the Analysis of the (1+1) Evolutionary Algorithm. Theoretical Computer Science. 276(1-2):51-81. April 2002. doi: https://doi.org/10.1016/S0304-3975(01)00182-7

  2. Tobias Friedrich, Francesco Quinzan, and Markus Wagner. Escaping Large Deceptive Basins of Attraction with Heavy-Tailed Mutation Operators. In Hernán E. Aguirre and Keiki Takadama, editors, Proceedings of the Genetic and Evolutionary Computation Conference (GECCO’18), July 15-19, 2018. Kyoto, Japan. ACM. doi: https://doi.org/10.1145/3205455.3205515}

  3. Francesco Quinzan, Andreas Göbel, Markus Wagner, and Tobias Friedrich. Evolutionary algorithms and submodular functions: benefits of heavy-tailed mutations. Natural Computing. 20(3):561-575. September 2021. doi: https://doi.org/10.1007/s11047-021-09841-7. Also: arXiv:1805.10902v2 [cs.DS] 21 Nov 2018. https://arxiv.org/abs/1805.10902

  4. Thomas Weise, Zhize Wu, Xinlu Li, and Yan Chen. Frequency Fitness Assignment: Making Optimization Algorithms Invariant under Bijective Transformations of the Objective Function Value. IEEE Transactions on Evolutionary Computation 25(2):307-319. April 2021. Preprint available at arXiv:2001.01416v5 [cs.NE] 15 Oct 2020. https://dx.doi.org/10.1109/TEVC.2020.3032090

  5. Thomas Weise, Zhize Wu, Xinlu Li, Yan Chen, and Jörg Lässig. Frequency Fitness Assignment: Optimization without Bias for Good Solutions can be Efficient. IEEE Transactions on Evolutionary Computation (TEVC). 27(4):980-992. August 2023. doi: https://doi.org/10.1109/TEVC.2022.3191698

>>> len(list(Jump.default_instances()))
122
>>> [x() for x in Jump.default_instances()]
[jump_6_2, jump_7_2, jump_8_2, jump_8_3, jump_9_2, jump_9_3, jump_10_2, jump_10_3, jump_10_4, jump_11_2, jump_11_3, jump_11_4, jump_12_2, jump_12_3, jump_12_4, jump_12_5, jump_13_2, jump_13_3, jump_13_4, jump_13_5, jump_14_2, jump_14_3, jump_14_4, jump_14_6, jump_15_2, jump_15_3, jump_15_4, jump_15_6, jump_16_2, jump_16_4, jump_16_5, jump_16_7, jump_17_2, jump_17_4, jump_17_5, jump_17_7, jump_18_2, jump_18_4, jump_18_6, jump_18_8, jump_19_2, jump_19_4, jump_19_6, jump_19_8, jump_20_2, jump_20_3, jump_20_4, jump_20_5, jump_20_7, jump_20_9, jump_21_2, jump_21_3, jump_21_4, jump_21_5, jump_21_7, jump_21_9, jump_22_2, jump_22_3, jump_22_4, jump_22_5, jump_22_7, jump_22_10, jump_23_2, jump_23_3, jump_23_4, jump_23_5, jump_23_7, jump_23_10, jump_24_2, jump_24_3, jump_24_4, jump_24_6, jump_24_8, jump_24_11, jump_25_2, jump_25_3, jump_25_5, jump_25_6, jump_25_8, jump_25_11, jump_26_2, jump_26_3, jump_26_5, jump_26_6, jump_26_9, jump_26_12, jump_27_2, jump_27_3, jump_27_5, jump_27_6, jump_27_9, jump_27_12, jump_28_2, jump_28_4, jump_28_5, jump_28_7, jump_28_10, jump_28_13, jump_29_2, jump_29_4, jump_29_5, jump_29_7, jump_29_10, jump_29_13, jump_30_2, jump_30_4, jump_30_5, jump_30_7, jump_30_10, jump_30_14, jump_31_2, jump_31_4, jump_31_5, jump_31_7, jump_31_10, jump_31_14, jump_32_2, jump_32_4, jump_32_5, jump_32_8, jump_32_11, jump_32_15]
class moptipy.examples.bitstrings.jump.Jump(n, k)[source]

Bases: BitStringNKProblem

Compute the Jump problem.

evaluate(x)[source]

Evaluate a solution to the jump problem.

Parameters:

x (ndarray) – the bit string to evaluate

Return type:

int

Returns:

the value of the jump problem for the string

upper_bound()[source]

Get the upper bound of the jump problem.

Return type:

int

Returns:

the length of the bit string + the length of the jump - 1

>>> Jump(15, 4).upper_bound()
18
moptipy.examples.bitstrings.jump.jump(x, k)[source]

Compute the jump value.

Parameters:
  • x (ndarray) – the np array

  • k (int) – the k parameter

Return type:

int

Returns:

jump value

>>> jump(np.array([False, False, False, False, False, False]), 2)
6
>>> jump(np.array([False, False, False, False, True, False]), 2)
5
>>> jump(np.array([False, True, True, False, False, False]), 2)
4
>>> jump(np.array([True, False, True, False, True, False]), 2)
3
>>> jump(np.array([True, False, True, False, True, True]), 2)
2
>>> jump(np.array([True, True, True, True, True, False]), 2)
7
>>> jump(np.array([True, True, True, True, True, True]), 2)
0

# n = 6, k = 2, and 0 true bits >>> jump(np.array([0, 0, 0, 0, 0, 0]), 2) 6

# n = 6, k = 2, and 1 true bit >>> jump(np.array([0, 0, 0, 1, 0, 0]), 2) 5

# n = 6, k = 2, and 2 true bits >>> jump(np.array([0, 0, 1, 0, 0, 1]), 2) 4

# n = 6, k = 2, and 3 true bits >>> jump(np.array([1, 1, 1, 0, 0, 0]), 2) 3

# n = 6, k = 2, and 4 true bits >>> jump(np.array([1, 0, 0, 1, 1, 1]), 2) 2

# n = 6, k = 2, and 5 true bits >>> jump(np.array([1, 1, 1, 1, 0, 1]), 2) 7

# n = 6, k = 2, and 6 true bits >>> jump(np.array([1, 1, 1, 1, 1, 1]), 2) 0

# n = 7, k = 2, and 0 true bits >>> jump(np.array([0, 0, 0, 0, 0, 0, 0]), 2) 7

# n = 7, k = 2, and 1 true bit >>> jump(np.array([0, 0, 0, 1, 0, 0, 0]), 2) 6

# n = 7, k = 2, and 2 true bits >>> jump(np.array([0, 0, 1, 0, 1, 0, 0]), 2) 5

# n = 7, k = 2, and 3 true bits >>> jump(np.array([1, 1, 0, 1, 0, 0, 0]), 2) 4

# n = 7, k = 2, and 4 true bits >>> jump(np.array([0, 1, 0, 1, 1, 1, 0]), 2) 3

# n = 7, k = 2, and 5 true bits >>> jump(np.array([1, 0, 1, 1, 0, 1, 1]), 2) 2

# n = 7, k = 2, and 6 true bits >>> jump(np.array([1, 1, 1, 1, 0, 1, 1]), 2) 8

# n = 7, k = 2, and 7 true bits >>> jump(np.array([1, 1, 1, 1, 1, 1, 1]), 2) 0

# n = 8, k = 2, and 0 true bits >>> jump(np.array([0, 0, 0, 0, 0, 0, 0, 0]), 2) 8

# n = 8, k = 2, and 1 true bit >>> jump(np.array([0, 0, 0, 0, 0, 0, 1, 0]), 2) 7

# n = 8, k = 2, and 2 true bits >>> jump(np.array([0, 0, 0, 0, 0, 0, 1, 1]), 2) 6

# n = 8, k = 2, and 3 true bits >>> jump(np.array([0, 0, 1, 0, 0, 0, 1, 1]), 2) 5

# n = 8, k = 2, and 4 true bits >>> jump(np.array([0, 0, 0, 1, 1, 1, 0, 1]), 2) 4

# n = 8, k = 2, and 5 true bits >>> jump(np.array([0, 1, 1, 1, 1, 1, 0, 0]), 2) 3

# n = 8, k = 2, and 6 true bits >>> jump(np.array([1, 1, 1, 0, 1, 1, 1, 0]), 2) 2

# n = 8, k = 2, and 7 true bits >>> jump(np.array([1, 1, 1, 1, 0, 1, 1, 1]), 2) 9

# n = 8, k = 2, and 8 true bits >>> jump(np.array([1, 1, 1, 1, 1, 1, 1, 1]), 2) 0

# n = 8, k = 3, and 0 true bits >>> jump(np.array([0, 0, 0, 0, 0, 0, 0, 0]), 3) 8

# n = 8, k = 3, and 1 true bit >>> jump(np.array([0, 1, 0, 0, 0, 0, 0, 0]), 3) 7

# n = 8, k = 3, and 2 true bits >>> jump(np.array([0, 0, 0, 0, 1, 0, 0, 1]), 3) 6

# n = 8, k = 3, and 3 true bits >>> jump(np.array([0, 0, 0, 1, 1, 1, 0, 0]), 3) 5

# n = 8, k = 3, and 4 true bits >>> jump(np.array([0, 1, 0, 0, 1, 1, 1, 0]), 3) 4

# n = 8, k = 3, and 5 true bits >>> jump(np.array([1, 0, 1, 1, 1, 0, 0, 1]), 3) 3

# n = 8, k = 3, and 6 true bits >>> jump(np.array([1, 0, 1, 0, 1, 1, 1, 1]), 3) 9

# n = 8, k = 3, and 7 true bits >>> jump(np.array([1, 0, 1, 1, 1, 1, 1, 1]), 3) 10

# n = 8, k = 3, and 8 true bits >>> jump(np.array([1, 1, 1, 1, 1, 1, 1, 1]), 3) 0

# n = 9, k = 2, and 0 true bits >>> jump(np.array([0, 0, 0, 0, 0, 0, 0, 0, 0]), 2) 9

# n = 9, k = 2, and 1 true bit >>> jump(np.array([0, 0, 0, 0, 0, 0, 0, 0, 1]), 2) 8

# n = 9, k = 2, and 2 true bits >>> jump(np.array([0, 0, 1, 0, 0, 0, 0, 0, 1]), 2) 7

# n = 9, k = 2, and 3 true bits >>> jump(np.array([0, 0, 0, 1, 0, 0, 1, 0, 1]), 2) 6

# n = 9, k = 2, and 4 true bits >>> jump(np.array([1, 0, 0, 0, 1, 0, 0, 1, 1]), 2) 5

# n = 9, k = 2, and 5 true bits >>> jump(np.array([0, 0, 0, 1, 1, 0, 1, 1, 1]), 2) 4

# n = 9, k = 2, and 6 true bits >>> jump(np.array([1, 1, 0, 1, 0, 1, 1, 1, 0]), 2) 3

# n = 9, k = 2, and 7 true bits >>> jump(np.array([1, 0, 1, 1, 1, 1, 0, 1, 1]), 2) 2

# n = 9, k = 2, and 8 true bits >>> jump(np.array([1, 1, 1, 1, 1, 0, 1, 1, 1]), 2) 10

# n = 9, k = 2, and 9 true bits >>> jump(np.array([1, 1, 1, 1, 1, 1, 1, 1, 1]), 2) 0

# n = 9, k = 3, and 0 true bits >>> jump(np.array([0, 0, 0, 0, 0, 0, 0, 0, 0]), 3) 9

# n = 9, k = 3, and 1 true bit >>> jump(np.array([0, 0, 0, 0, 0, 0, 0, 0, 1]), 3) 8

# n = 9, k = 3, and 2 true bits >>> jump(np.array([0, 0, 1, 0, 1, 0, 0, 0, 0]), 3) 7

# n = 9, k = 3, and 3 true bits >>> jump(np.array([0, 1, 0, 1, 1, 0, 0, 0, 0]), 3) 6

# n = 9, k = 3, and 4 true bits >>> jump(np.array([0, 1, 1, 0, 1, 0, 0, 1, 0]), 3) 5

# n = 9, k = 3, and 5 true bits >>> jump(np.array([1, 1, 1, 1, 0, 0, 0, 0, 1]), 3) 4

# n = 9, k = 3, and 6 true bits >>> jump(np.array([0, 0, 1, 1, 1, 1, 1, 0, 1]), 3) 3

# n = 9, k = 3, and 7 true bits >>> jump(np.array([0, 1, 1, 1, 1, 1, 1, 1, 0]), 3) 10

# n = 9, k = 3, and 8 true bits >>> jump(np.array([0, 1, 1, 1, 1, 1, 1, 1, 1]), 3) 11

# n = 9, k = 3, and 9 true bits >>> jump(np.array([1, 1, 1, 1, 1, 1, 1, 1, 1]), 3) 0

# n = 10, k = 2, and 0 true bits >>> jump(np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), 2) 10

# n = 10, k = 2, and 1 true bit >>> jump(np.array([0, 0, 0, 0, 0, 1, 0, 0, 0, 0]), 2) 9

# n = 10, k = 2, and 2 true bits >>> jump(np.array([0, 0, 1, 0, 0, 0, 0, 0, 0, 1]), 2) 8

# n = 10, k = 2, and 3 true bits >>> jump(np.array([0, 1, 0, 0, 1, 0, 0, 0, 0, 1]), 2) 7

# n = 10, k = 2, and 4 true bits >>> jump(np.array([0, 0, 1, 0, 1, 0, 1, 0, 0, 1]), 2) 6

# n = 10, k = 2, and 5 true bits >>> jump(np.array([1, 0, 1, 1, 0, 1, 1, 0, 0, 0]), 2) 5

# n = 10, k = 2, and 6 true bits >>> jump(np.array([1, 1, 0, 1, 1, 0, 0, 0, 1, 1]), 2) 4

# n = 10, k = 2, and 7 true bits >>> jump(np.array([1, 0, 1, 0, 1, 0, 1, 1, 1, 1]), 2) 3

# n = 10, k = 2, and 8 true bits >>> jump(np.array([1, 0, 1, 1, 1, 1, 1, 0, 1, 1]), 2) 2

# n = 10, k = 2, and 9 true bits >>> jump(np.array([1, 0, 1, 1, 1, 1, 1, 1, 1, 1]), 2) 11

# n = 10, k = 2, and 10 true bits >>> jump(np.array([1, 1, 1, 1, 1, 1, 1, 1, 1, 1]), 2) 0

# n = 10, k = 3, and 0 true bits >>> jump(np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), 3) 10

# n = 10, k = 3, and 1 true bit >>> jump(np.array([0, 0, 0, 0, 0, 0, 0, 0, 1, 0]), 3) 9

# n = 10, k = 3, and 2 true bits >>> jump(np.array([1, 0, 0, 0, 0, 0, 1, 0, 0, 0]), 3) 8

# n = 10, k = 3, and 3 true bits >>> jump(np.array([0, 1, 0, 1, 0, 0, 1, 0, 0, 0]), 3) 7

# n = 10, k = 3, and 4 true bits >>> jump(np.array([0, 0, 1, 0, 1, 1, 0, 0, 1, 0]), 3) 6

# n = 10, k = 3, and 5 true bits >>> jump(np.array([0, 0, 1, 1, 0, 0, 1, 1, 0, 1]), 3) 5

# n = 10, k = 3, and 6 true bits >>> jump(np.array([1, 0, 0, 1, 1, 1, 0, 1, 0, 1]), 3) 4

# n = 10, k = 3, and 7 true bits >>> jump(np.array([0, 1, 1, 1, 1, 1, 0, 0, 1, 1]), 3) 3

# n = 10, k = 3, and 8 true bits >>> jump(np.array([0, 1, 1, 1, 1, 1, 1, 0, 1, 1]), 3) 11

# n = 10, k = 3, and 9 true bits >>> jump(np.array([1, 1, 0, 1, 1, 1, 1, 1, 1, 1]), 3) 12

# n = 10, k = 3, and 10 true bits >>> jump(np.array([1, 1, 1, 1, 1, 1, 1, 1, 1, 1]), 3) 0

# n = 10, k = 4, and 0 true bits >>> jump(np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), 4) 10

# n = 10, k = 4, and 1 true bit >>> jump(np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 1]), 4) 9

# n = 10, k = 4, and 2 true bits >>> jump(np.array([0, 1, 0, 0, 0, 0, 0, 0, 1, 0]), 4) 8

# n = 10, k = 4, and 3 true bits >>> jump(np.array([1, 0, 1, 0, 0, 1, 0, 0, 0, 0]), 4) 7

# n = 10, k = 4, and 4 true bits >>> jump(np.array([0, 0, 0, 0, 0, 1, 1, 0, 1, 1]), 4) 6

# n = 10, k = 4, and 5 true bits >>> jump(np.array([0, 1, 1, 0, 1, 0, 1, 0, 1, 0]), 4) 5

# n = 10, k = 4, and 6 true bits >>> jump(np.array([1, 1, 1, 1, 0, 1, 0, 0, 1, 0]), 4) 4

# n = 10, k = 4, and 7 true bits >>> jump(np.array([0, 1, 1, 1, 0, 1, 1, 1, 1, 0]), 4) 11

# n = 10, k = 4, and 8 true bits >>> jump(np.array([1, 0, 1, 1, 1, 0, 1, 1, 1, 1]), 4) 12

# n = 10, k = 4, and 9 true bits >>> jump(np.array([1, 1, 1, 1, 1, 1, 1, 0, 1, 1]), 4) 13

# n = 10, k = 4, and 10 true bits >>> jump(np.array([1, 1, 1, 1, 1, 1, 1, 1, 1, 1]), 4) 0

# n = 11, k = 2, and 0 true bits >>> jump(np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), 2) 11

# n = 11, k = 2, and 1 true bit >>> jump(np.array([0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0]), 2) 10

# n = 11, k = 2, and 2 true bits >>> jump(np.array([0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0]), 2) 9

# n = 11, k = 2, and 3 true bits >>> jump(np.array([0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0]), 2) 8

# n = 11, k = 2, and 4 true bits >>> jump(np.array([1, 1, 0, 0, 1, 0, 1, 0, 0, 0, 0]), 2) 7

# n = 11, k = 2, and 5 true bits >>> jump(np.array([1, 1, 0, 0, 0, 1, 0, 0, 0, 1, 1]), 2) 6

# n = 11, k = 2, and 6 true bits >>> jump(np.array([1, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0]), 2) 5

# n = 11, k = 2, and 7 true bits >>> jump(np.array([1, 0, 1, 1, 1, 0, 1, 0, 1, 1, 0]), 2) 4

# n = 11, k = 2, and 8 true bits >>> jump(np.array([1, 1, 0, 1, 1, 1, 1, 1, 1, 0, 0]), 2) 3

# n = 11, k = 2, and 9 true bits >>> jump(np.array([0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1]), 2) 2

# n = 11, k = 2, and 10 true bits >>> jump(np.array([1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1]), 2) 12

# n = 11, k = 2, and 11 true bits >>> jump(np.array([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]), 2) 0

# n = 11, k = 3, and 0 true bits >>> jump(np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), 3) 11

# n = 11, k = 3, and 1 true bit >>> jump(np.array([0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0]), 3) 10

# n = 11, k = 3, and 2 true bits >>> jump(np.array([0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1]), 3) 9

# n = 11, k = 3, and 3 true bits >>> jump(np.array([0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0]), 3) 8

# n = 11, k = 3, and 4 true bits >>> jump(np.array([1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1]), 3) 7

# n = 11, k = 3, and 5 true bits >>> jump(np.array([1, 1, 1, 0, 0, 0, 1, 0, 1, 0, 0]), 3) 6

# n = 11, k = 3, and 6 true bits >>> jump(np.array([0, 1, 0, 1, 0, 0, 1, 1, 0, 1, 1]), 3) 5

# n = 11, k = 3, and 7 true bits >>> jump(np.array([0, 0, 1, 1, 1, 0, 1, 1, 1, 1, 0]), 3) 4

# n = 11, k = 3, and 8 true bits >>> jump(np.array([0, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1]), 3) 3

# n = 11, k = 3, and 9 true bits >>> jump(np.array([1, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1]), 3) 12

# n = 11, k = 3, and 10 true bits >>> jump(np.array([0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]), 3) 13

# n = 11, k = 3, and 11 true bits >>> jump(np.array([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]), 3) 0

# n = 11, k = 4, and 0 true bits >>> jump(np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), 4) 11

# n = 11, k = 4, and 1 true bit >>> jump(np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]), 4) 10

# n = 11, k = 4, and 2 true bits >>> jump(np.array([0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1]), 4) 9

# n = 11, k = 4, and 3 true bits >>> jump(np.array([0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1]), 4) 8

# n = 11, k = 4, and 4 true bits >>> jump(np.array([1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1]), 4) 7

# n = 11, k = 4, and 5 true bits >>> jump(np.array([1, 0, 0, 1, 1, 1, 0, 1, 0, 0, 0]), 4) 6

# n = 11, k = 4, and 6 true bits >>> jump(np.array([0, 1, 0, 0, 0, 1, 1, 1, 0, 1, 1]), 4) 5

# n = 11, k = 4, and 7 true bits >>> jump(np.array([1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1]), 4) 4

# n = 11, k = 4, and 8 true bits >>> jump(np.array([1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 1]), 4) 12

# n = 11, k = 4, and 9 true bits >>> jump(np.array([1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0]), 4) 13

# n = 11, k = 4, and 10 true bits >>> jump(np.array([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]), 4) 14

# n = 11, k = 4, and 11 true bits >>> jump(np.array([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]), 4) 0

# n = 12, k = 2, and 0 true bits >>> jump(np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), 2) 12

# n = 12, k = 2, and 1 true bit >>> jump(np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]), 2) 11

# n = 12, k = 2, and 2 true bits >>> jump(np.array([0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0]), 2) 10

# n = 12, k = 2, and 3 true bits >>> jump(np.array([0, 1, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0]), 2) 9

# n = 12, k = 2, and 4 true bits >>> jump(np.array([1, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0]), 2) 8

# n = 12, k = 2, and 5 true bits >>> jump(np.array([1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1]), 2) 7

# n = 12, k = 2, and 6 true bits >>> jump(np.array([1, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0]), 2) 6

# n = 12, k = 2, and 7 true bits >>> jump(np.array([1, 0, 1, 1, 1, 0, 1, 0, 1, 1, 0, 0]), 2) 5

# n = 12, k = 2, and 8 true bits >>> jump(np.array([1, 1, 0, 0, 1, 1, 0, 1, 1, 0, 1, 1]), 2) 4

# n = 12, k = 2, and 9 true bits >>> jump(np.array([1, 0, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1]), 2) 3

# n = 12, k = 2, and 10 true bits >>> jump(np.array([0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1]), 2) 2

# n = 12, k = 2, and 11 true bits >>> jump(np.array([0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]), 2) 13

# n = 12, k = 2, and 12 true bits >>> jump(np.array([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]), 2) 0

# n = 12, k = 3, and 0 true bits >>> jump(np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), 3) 12

# n = 12, k = 3, and 1 true bit >>> jump(np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0]), 3) 11

# n = 12, k = 3, and 2 true bits >>> jump(np.array([0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0]), 3) 10

# n = 12, k = 3, and 3 true bits >>> jump(np.array([1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1]), 3) 9

# n = 12, k = 3, and 4 true bits >>> jump(np.array([0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0]), 3) 8

# n = 12, k = 3, and 5 true bits >>> jump(np.array([0, 1, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0]), 3) 7

# n = 12, k = 3, and 6 true bits >>> jump(np.array([0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1]), 3) 6

# n = 12, k = 3, and 7 true bits >>> jump(np.array([1, 0, 0, 1, 1, 1, 0, 1, 0, 1, 0, 1]), 3) 5

# n = 12, k = 3, and 8 true bits >>> jump(np.array([1, 1, 1, 1, 0, 1, 1, 1, 0, 0, 0, 1]), 3) 4

# n = 12, k = 3, and 9 true bits >>> jump(np.array([1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0]), 3) 3

# n = 12, k = 3, and 10 true bits >>> jump(np.array([1, 1, 1, 1, 1, 1, 0, 1, 1, 0, 1, 1]), 3) 13

# n = 12, k = 3, and 11 true bits >>> jump(np.array([1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1]), 3) 14

# n = 12, k = 3, and 12 true bits >>> jump(np.array([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]), 3) 0

# n = 12, k = 4, and 0 true bits >>> jump(np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), 4) 12

# n = 12, k = 4, and 1 true bit >>> jump(np.array([0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0]), 4) 11

# n = 12, k = 4, and 2 true bits >>> jump(np.array([1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0]), 4) 10

# n = 12, k = 4, and 3 true bits >>> jump(np.array([1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0]), 4) 9

# n = 12, k = 4, and 4 true bits >>> jump(np.array([1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0]), 4) 8

# n = 12, k = 4, and 5 true bits >>> jump(np.array([0, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 0]), 4) 7

# n = 12, k = 4, and 6 true bits >>> jump(np.array([0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 1, 0]), 4) 6

# n = 12, k = 4, and 7 true bits >>> jump(np.array([1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 1]), 4) 5

# n = 12, k = 4, and 8 true bits >>> jump(np.array([0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 0, 1]), 4) 4

# n = 12, k = 4, and 9 true bits >>> jump(np.array([1, 1, 1, 1, 1, 0, 1, 1, 0, 0, 1, 1]), 4) 13

# n = 12, k = 4, and 10 true bits >>> jump(np.array([1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 0]), 4) 14

# n = 12, k = 4, and 11 true bits >>> jump(np.array([1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1]), 4) 15

# n = 12, k = 4, and 12 true bits >>> jump(np.array([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]), 4) 0

# n = 12, k = 5, and 0 true bits >>> jump(np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), 5) 12

# n = 12, k = 5, and 1 true bit >>> jump(np.array([1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), 5) 11

# n = 12, k = 5, and 2 true bits >>> jump(np.array([0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0]), 5) 10

# n = 12, k = 5, and 3 true bits >>> jump(np.array([0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0]), 5) 9

# n = 12, k = 5, and 4 true bits >>> jump(np.array([0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 1]), 5) 8

# n = 12, k = 5, and 5 true bits >>> jump(np.array([1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0]), 5) 7

# n = 12, k = 5, and 6 true bits >>> jump(np.array([0, 0, 1, 1, 1, 0, 0, 1, 0, 1, 1, 0]), 5) 6

# n = 12, k = 5, and 7 true bits >>> jump(np.array([1, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0]), 5) 5

# n = 12, k = 5, and 8 true bits >>> jump(np.array([0, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1]), 5) 13

# n = 12, k = 5, and 9 true bits >>> jump(np.array([1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1]), 5) 14

# n = 12, k = 5, and 10 true bits >>> jump(np.array([1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1]), 5) 15

# n = 12, k = 5, and 11 true bits >>> jump(np.array([1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1]), 5) 16

# n = 12, k = 5, and 12 true bits >>> jump(np.array([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]), 5) 0

moptipy.examples.bitstrings.labs module

The ow Autocorrelation Binary Sequence problem.

The autocorrelations of a bit string x are defined as

C_k(x) = sum(i = 0, n - k - 1, 1 if x[i] == x[i + k] else -1)

The energy of the bit string, which is equivalent to the objective value of this benchmark problem, is then:

E(x) = sum(k = 1, n - 1, C_k(x) ** 2)

The low-autocorrelation binary sequence (LABS) problem is to find a minimum autocorrelated bit string is equivalent to minimizing E. We use the energy directly as objective function. Others who define LABS as a maximization problem try to maximize the merit factor F instead, which is equivalent to minimizing the energy:

F(x) = n² / (n * E(X))

This problem is different than the other bit-string based problems, because we only know the optimal solutions for few, smaller instances. For larger instances, we only have lower bounds of the energy.

  1. Carola Doerr and Furong Ye and Naama Horesh and Hao Wang and Ofer M. Shir and Thomas Bäck. Benchmarking Discrete Optimization Heuristics with IOHprofiler. Applied Soft Computing 88:106027, March 2020, doi: https://doi.org/10.1016/j.asoc.2019.106027.

  2. Tom Packebusch and Stephan Mertens. Low Autocorrelation Binary Sequences. arXiv:1512.02475v2 [cond-mat.stat-mech] 24 Mar 2016 https://arxiv.org/pdf/1512.02475

  3. Burkhard Militzer, Michele Zamparelli, and Dieter Beule. Evolutionary Search for Low Autocorrelated Binary Sequences. IEEE Transactions on Evolutionary Computation. 2(1):34-39}. 1998. doi: https://doi.org/10.1109/4235.728212

  4. Wai Ho Mow and Ke-Lin Du. New Evolutionary Search for Long Low Autocorrelation Binary Sequences. IEEE Transactions on Aerospace and Electronic Systems. 51(1):290-303. January 2015. doi: https://doi.org/10.1109/TAES.2014.130518

  5. Borko Bošković, Franc Brglez, and Janez Brest. Low-Autocorrelation Binary Sequences: On Improved Merit Factors and Runtime Predictions to Achieve Them. arXiv:1406.5301v6 [cs.DS] 6 May 2017. See [6] below. https://arxiv.org/pdf/1406.5301

  6. Borko Bošković, Franc Brglez, and Janez Brest. Low-Autocorrelation Binary Sequences: On Improved Merit Factors and Runtime Predictions to Achieve Them. Applied Soft Computing. 56:262-285, July 2017. doi: https://doi.org/10.1016/j.asoc.2017.02.024

This is code is part of the research work of Mr. Jiazheng ZENG (曾嘉政), a Master’s student at the Institute of Applied Optimization (应用优化研究所, http://iao.hfuu.edu.cn) of the School of Artificial Intelligence and Big Data (人工智能与大数据学院) at Hefei University (合肥大学) in Hefei, Anhui, China (中国安徽省合肥市) under the supervision of Prof. Dr. Thomas Weise (汤卫思教授).

class moptipy.examples.bitstrings.labs.LABS(n)[source]

Bases: BitStringProblem

The Low-Autocorrelation Sequence Problem.

classmethod default_instances(scale_min=3, scale_max=625)[source]

Get the default instances of the LABS problem.

Parameters:
  • scale_min (int, default: 3) – the minimum permitted scale, by default 3

  • scale_max (int, default: 625) – the maximum permitted scale, by default 625

Return type:

Iterator[Callable[[], LABS]]

Returns:

a sequence of default LABS instances

>>> len(list(LABS.default_instances()))
46
>>> [x() for x in LABS.default_instances()]
[labs_3, labs_4, labs_5, labs_6, labs_7, labs_8, labs_9, labs_10, labs_11, labs_12, labs_13, labs_14, labs_15, labs_16, labs_17, labs_18, labs_19, labs_20, labs_21, labs_22, labs_23, labs_24, labs_25, labs_26, labs_27, labs_28, labs_29, labs_30, labs_31, labs_32, labs_33, labs_36, labs_40, labs_41, labs_42, labs_44, labs_48, labs_49, labs_50, labs_55, labs_59, labs_60, labs_64, labs_66, labs_100, labs_625]
lower_bound()[source]

Get the lower bound of the LABS problem.

The minimum amount of energy that a sequence could possibly have. For each correlation length k, this is (n - k) % 2. In total, this is just equivalent to n // 2.

For some instances of LABS, the global optima are known. For these instances, we return the objective values of these optima, which obviously are >= n // 2.

Return type:

int

Returns:

the lower bound of the LABS problem

>>> LABS(16).lower_bound()
24
>>> LABS(61).lower_bound()
226
>>> LABS(200).lower_bound()
100
>>> LABS(124200).lower_bound()
62100
upper_bound()[source]

Get the upper bound of the LABS problem.

The energy of a sequence where all bits are the same is the highest. This means that each correlation basically produces its length to the square as contribution to the result. The upper bound then is the sum of all of these squares from 1..(n-1).

Return type:

int

Returns:

the upper bound of LABS

>>> LABS(16).upper_bound()
1240
>>> LABS(63).upper_bound()
81375
>>> LABS(200).upper_bound()
2646700
>>> LABS(12316).upper_bound()
622636950290
moptipy.examples.bitstrings.labs.is_labs_objective_value_optimal(n, f)[source]

Check whether a given objective value is optimal on the LABS problem.

We use the lower and upper bound of the LABS problem to check whether a given objective value can be optimal. We also use the objective values of the known global optima from

Tom Packebusch and Stephan Mertens. Low Autocorrelation Binary Sequences. arXiv:1512.02475v2 [cond-mat.stat-mech] 24 Mar 2016 https://arxiv.org/pdf/1512.02475

Parameters:
  • n (int) – the scale of the problem

  • f (int) – the objective value

Return type:

bool | None

Returns:

True if the objective value f is optimal, False if it cannot be optimal, and None if the situation is unclear

Raises:
>>> print(is_labs_objective_value_optimal(49, 136))
True
>>> print(is_labs_objective_value_optimal(49, 137))
False
>>> print(is_labs_objective_value_optimal(100, 50))
True
>>> print(is_labs_objective_value_optimal(100, 51))
None
>>> try:
...     is_labs_objective_value_optimal("x", 3)
... except TypeError as te:
...     print(te)
n should be an instance of int but is str, namely 'x'.
>>> try:
...     is_labs_objective_value_optimal(7, "3")
... except TypeError as te:
...     print(te)
f should be an instance of int but is str, namely '3'.
>>> try:
...     is_labs_objective_value_optimal(0, 0)
... except ValueError as ve:
...     print(ve)
n=0 is invalid, must be in 3..1000000000.
>>> try:
...     is_labs_objective_value_optimal(3, 0)
... except ValueError as ve:
...     print(ve)
f=0 is invalid, must be in 1..5.
>>> try:
...     is_labs_objective_value_optimal(3, 234240)
... except ValueError as ve:
...     print(ve)
f=234240 is invalid, must be in 1..5.
moptipy.examples.bitstrings.labs.labs(x)[source]

Calculate the objective value of the LABS problem.

Parameters:

x (ndarray) – the flat numpy array representing the bitstring

Return type:

int

Returns:

the LABS objective

# N = 3, E = 1, FN = 4.50000 >>> labs(np.array([0, 0, 1])) 1

# N = 3, E = 1, FN = 4.50000 >>> labs(np.array([1, 1, 0])) 1

# N = 4, E = 2, FN = 4.00000 >>> labs(np.array([0, 1, 0, 0])) 2

# N = 4, E = 2, FN = 4.00000 >>> labs(np.array([1, 0, 1, 1])) 2

# N = 5, E = 2, FN = 6.25000 >>> labs(np.array([0, 0, 0, 1, 0])) 2

# N = 5, E = 2, FN = 6.25000 >>> labs(np.array([1, 1, 1, 0, 1])) 2

# N = 6, E = 7, FN = 2.57143 >>> labs(np.array([0, 1, 1, 1, 1, 0])) 7

# N = 6, E = 7, FN = 2.57143 >>> labs(np.array([1, 0, 0, 0, 0, 1])) 7

# N = 6, E = 7, FN = 2.57143 >>> labs(np.array([0, 1, 1, 0, 0, 0])) 7

# N = 6, E = 7, FN = 2.57143 >>> labs(np.array([1, 0, 0, 1, 1, 1])) 7

# N = 6, E = 7, FN = 2.57143 >>> labs(np.array([0, 0, 0, 1, 0, 0])) 7

# N = 6, E = 7, FN = 2.57143 >>> labs(np.array([1, 1, 1, 0, 1, 1])) 7

# N = 6, E = 7, FN = 2.57143 >>> labs(np.array([0, 1, 0, 1, 1, 1])) 7

# N = 6, E = 7, FN = 2.57143 >>> labs(np.array([1, 0, 1, 0, 0, 0])) 7

# N = 7, E = 3, FN = 8.16667 >>> labs(np.array([0, 1, 0, 0, 1, 1, 1])) 3

# N = 7, E = 3, FN = 8.16667 >>> labs(np.array([1, 0, 1, 1, 0, 0, 0])) 3

# N = 8, E = 8, FN = 4.00000 >>> labs(np.array([0, 0, 0, 1, 1, 0, 1, 0])) 8

# N = 8, E = 8, FN = 4.00000 >>> labs(np.array([1, 1, 1, 0, 0, 1, 0, 1])) 8

# N = 8, E = 8, FN = 4.00000 >>> labs(np.array([0, 0, 0, 1, 0, 1, 1, 0])) 8

# N = 8, E = 8, FN = 4.00000 >>> labs(np.array([1, 1, 1, 0, 1, 0, 0, 1])) 8

# N = 9, E = 12, FN = 3.37500 >>> labs(np.array([0, 0, 0, 1, 0, 1, 0, 0, 1])) 12

# N = 9, E = 12, FN = 3.37500 >>> labs(np.array([1, 1, 1, 0, 1, 0, 1, 1, 0])) 12

# N = 9, E = 12, FN = 3.37500 >>> labs(np.array([0, 0, 0, 0, 1, 1, 0, 1, 0])) 12

# N = 9, E = 12, FN = 3.37500 >>> labs(np.array([1, 1, 1, 1, 0, 0, 1, 0, 1])) 12

# N = 9, E = 12, FN = 3.37500 >>> labs(np.array([0, 0, 0, 1, 1, 0, 0, 1, 0])) 12

# N = 9, E = 12, FN = 3.37500 >>> labs(np.array([1, 1, 1, 0, 0, 1, 1, 0, 1])) 12

# N = 9, E = 12, FN = 3.37500 >>> labs(np.array([0, 0, 0, 1, 0, 1, 1, 0, 0])) 12

# N = 9, E = 12, FN = 3.37500 >>> labs(np.array([1, 1, 1, 0, 1, 0, 0, 1, 1])) 12

# N = 10, E = 13, FN = 3.84615 >>> labs(np.array([0, 0, 0, 0, 1, 1, 0, 0, 1, 0])) 13

# N = 10, E = 13, FN = 3.84615 >>> labs(np.array([1, 1, 1, 1, 0, 0, 1, 1, 0, 1])) 13

# N = 10, E = 13, FN = 3.84615 >>> labs(np.array([0, 0, 0, 0, 0, 1, 1, 0, 1, 0])) 13

# N = 10, E = 13, FN = 3.84615 >>> labs(np.array([1, 1, 1, 1, 1, 0, 0, 1, 0, 1])) 13

# N = 10, E = 13, FN = 3.84615 >>> labs(np.array([0, 0, 0, 1, 0, 1, 0, 0, 1, 1])) 13

# N = 10, E = 13, FN = 3.84615 >>> labs(np.array([1, 1, 1, 0, 1, 0, 1, 1, 0, 0])) 13

# N = 10, E = 13, FN = 3.84615 >>> labs(np.array([0, 0, 0, 0, 1, 0, 1, 1, 0, 0])) 13

# N = 10, E = 13, FN = 3.84615 >>> labs(np.array([1, 1, 1, 1, 0, 1, 0, 0, 1, 1])) 13

# N = 10, E = 13, FN = 3.84615 >>> labs(np.array([0, 0, 0, 1, 1, 1, 0, 1, 1, 0])) 13

# N = 10, E = 13, FN = 3.84615 >>> labs(np.array([1, 1, 1, 0, 0, 0, 1, 0, 0, 1])) 13

# N = 11, E = 5, FN = 12.10000 >>> labs(np.array([0, 1, 0, 0, 1, 0, 0, 0, 1, 1, 1])) 5

# N = 11, E = 5, FN = 12.10000 >>> labs(np.array([1, 0, 1, 1, 0, 1, 1, 1, 0, 0, 0])) 5

# N = 12, E = 10, FN = 7.20000 >>> labs(np.array([0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 1, 0])) 10

# N = 12, E = 10, FN = 7.20000 >>> labs(np.array([1, 1, 1, 1, 0, 0, 1, 1, 0, 1, 0, 1])) 10

# N = 12, E = 10, FN = 7.20000 >>> labs(np.array([0, 0, 0, 0, 1, 0, 1, 0, 0, 1, 1, 0])) 10

# N = 12, E = 10, FN = 7.20000 >>> labs(np.array([1, 1, 1, 1, 0, 1, 0, 1, 1, 0, 0, 1])) 10

# N = 13, E = 6, FN = 14.08333 >>> labs(np.array([0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 1, 0])) 6

# N = 13, E = 6, FN = 14.08333 >>> labs(np.array([1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1, 0, 1])) 6

# N = 14, E = 19, FN = 5.15789 >>> labs(np.array([0, 0, 0, 0, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1])) 19

# N = 14, E = 19, FN = 5.15789 >>> labs(np.array([1, 1, 1, 1, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0])) 19

# N = 14, E = 19, FN = 5.15789 >>> labs(np.array([0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 1, 0])) 19

# N = 14, E = 19, FN = 5.15789 >>> labs(np.array([1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1, 0, 1])) 19

# N = 14, E = 19, FN = 5.15789 >>> labs(np.array([0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0])) 19

# N = 14, E = 19, FN = 5.15789 >>> labs(np.array([1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1])) 19

# N = 14, E = 19, FN = 5.15789 >>> labs(np.array([0, 0, 0, 1, 1, 1, 0, 1, 0, 1, 1, 0, 1, 1])) 19

# N = 14, E = 19, FN = 5.15789 >>> labs(np.array([1, 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0])) 19

# N = 14, E = 19, FN = 5.15789 >>> labs(np.array([0, 0, 0, 0, 1, 0, 1, 0, 1, 1, 0, 0, 1, 1])) 19

# N = 14, E = 19, FN = 5.15789 >>> labs(np.array([1, 1, 1, 1, 0, 1, 0, 1, 0, 0, 1, 1, 0, 0])) 19

# N = 14, E = 19, FN = 5.15789 >>> labs(np.array([0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 1])) 19

# N = 14, E = 19, FN = 5.15789 >>> labs(np.array([1, 1, 1, 1, 0, 0, 1, 1, 0, 1, 0, 1, 0, 0])) 19

# N = 14, E = 19, FN = 5.15789 >>> labs(np.array([0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 1, 0, 0])) 19

# N = 14, E = 19, FN = 5.15789 >>> labs(np.array([1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1, 0, 1, 1])) 19

# N = 14, E = 19, FN = 5.15789 >>> labs(np.array([0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 1, 1, 0])) 19

# N = 14, E = 19, FN = 5.15789 >>> labs(np.array([1, 1, 1, 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1])) 19

# N = 15, E = 15, FN = 7.50000 >>> labs(np.array([0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 1])) 15

# N = 15, E = 15, FN = 7.50000 >>> labs(np.array([1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 0])) 15

# N = 15, E = 15, FN = 7.50000 >>> labs(np.array([0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1])) 15

# N = 15, E = 15, FN = 7.50000 >>> labs(np.array([1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0])) 15

# N = 16, E = 24, FN = 5.33333 >>> labs(np.array([0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 1, 0])) 24

# N = 16, E = 24, FN = 5.33333 >>> labs(np.array([1, 1, 0, 0, 1, 1, 1, 1, 1, 0, 1, 0, 1, 0, 0, 1])) 24

# N = 16, E = 24, FN = 5.33333 >>> labs(np.array([0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 0, 1, 0])) 24

# N = 16, E = 24, FN = 5.33333 >>> labs(np.array([1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, 0, 1])) 24

# N = 16, E = 24, FN = 5.33333 >>> labs(np.array([0, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 1, 0])) 24

# N = 16, E = 24, FN = 5.33333 >>> labs(np.array([1, 1, 1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 1, 1, 0, 1])) 24

# N = 16, E = 24, FN = 5.33333 >>> labs(np.array([0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0])) 24

# N = 16, E = 24, FN = 5.33333 >>> labs(np.array([1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1])) 24

# N = 17, E = 32, FN = 4.51562 >>> labs(np.array([0, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1, 0, 1, 1, 0])) 32

# N = 17, E = 32, FN = 4.51562 >>> labs(np.array([1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 1, 0, 0, 1])) 32

# N = 17, E = 32, FN = 4.51562 >>> labs(np.array([0, 0, 0, 0, 1, 1, 1, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1])) 32

# N = 17, E = 32, FN = 4.51562 >>> labs(np.array([1, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0])) 32

# N = 17, E = 32, FN = 4.51562 >>> labs(np.array([0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1])) 32

# N = 17, E = 32, FN = 4.51562 >>> labs(np.array([1, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 0])) 32

# N = 17, E = 32, FN = 4.51562 >>> labs(np.array([0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 0, 0, 1])) 32

# N = 17, E = 32, FN = 4.51562 >>> labs(np.array([1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 1, 1, 0])) 32

# N = 17, E = 32, FN = 4.51562 >>> labs(np.array([0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 1, 0, 1, 1])) 32

# N = 17, E = 32, FN = 4.51562 >>> labs(np.array([1, 1, 0, 1, 1, 0, 0, 1, 1, 1, 1, 0, 1, 0, 1, 0, 0])) 32

# N = 17, E = 32, FN = 4.51562 >>> labs(np.array([0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 1])) 32

# N = 17, E = 32, FN = 4.51562 >>> labs(np.array([1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0])) 32

# N = 18, E = 25, FN = 6.48000 >>> labs(np.array([0, 0, 0, 0, 1, 1, 1, 1, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0])) 25

# N = 18, E = 25, FN = 6.48000 >>> labs(np.array([1, 1, 1, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1])) 25

# N = 18, E = 25, FN = 6.48000 >>> labs(np.array([0, 0, 0, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 0, 1, 1, 0, 0])) 25

# N = 18, E = 25, FN = 6.48000 >>> labs(np.array([1, 1, 1, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 1, 0, 0, 1, 1])) 25

# N = 19, E = 29, FN = 6.22414 >>> labs(np.array([0, 0, 0, 0, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1, … 1])) 29

# N = 19, E = 29, FN = 6.22414 >>> labs(np.array([1, 1, 1, 1, 0, 1, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, … 0])) 29

# N = 20, E = 26, FN = 7.69231 >>> labs(np.array([0, 0, 0, 0, 0, 1, 0, 1, 1, 1, 0, 1, 0, 0, 1, 1, 1, 0, … 0, 1])) 26

# N = 20, E = 26, FN = 7.69231 >>> labs(np.array([1, 1, 1, 1, 1, 0, 1, 0, 0, 0, 1, 0, 1, 1, 0, 0, 0, 1, … 1, 0])) 26

# N = 21, E = 26, FN = 8.48077 >>> labs(np.array([0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1, 0, 1, 0, … 1, 1, 0])) 26

# N = 21, E = 26, FN = 8.48077 >>> labs(np.array([1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, … 0, 0, 1])) 26

# N = 22, E = 39, FN = 6.20513 >>> labs(np.array([0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 1, 0, 1, 0, 0, 1, 1, … 1, 0, 0, 0])) 39

# N = 22, E = 39, FN = 6.20513 >>> labs(np.array([1, 1, 1, 1, 1, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0, 0, … 0, 1, 1, 1])) 39

# N = 22, E = 39, FN = 6.20513 >>> labs(np.array([0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0, 1, 0, 0, … 1, 1, 0, 1])) 39

# N = 22, E = 39, FN = 6.20513 >>> labs(np.array([1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 1, 0, 1, 0, 1, 1, … 0, 0, 1, 0])) 39

# N = 22, E = 39, FN = 6.20513 >>> labs(np.array([0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, … 0, 0, 1, 1])) 39

# N = 22, E = 39, FN = 6.20513 >>> labs(np.array([1, 1, 1, 1, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 1, 0, 0, 1, … 1, 1, 0, 0])) 39

# N = 23, E = 47, FN = 5.62766 >>> labs(np.array([0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, … 0, 0, 0, 1, 1])) 47

# N = 23, E = 47, FN = 5.62766 >>> labs(np.array([1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, … 1, 1, 1, 0, 0])) 47

# N = 23, E = 47, FN = 5.62766 >>> labs(np.array([0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0, 1, … 1, 0, 0, 1, 0])) 47

# N = 23, E = 47, FN = 5.62766 >>> labs(np.array([1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 1, 0, 1, 0, … 0, 1, 1, 0, 1])) 47

# N = 23, E = 47, FN = 5.62766 >>> labs(np.array([0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 0, 1, … 0, 0, 0, 1, 1])) 47

# N = 23, E = 47, FN = 5.62766 >>> labs(np.array([1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 0, 1, 0, 0, 0, 1, 0, … 1, 1, 1, 0, 0])) 47

# N = 24, E = 36, FN = 8.00000 >>> labs(np.array([0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 0, … 1, 1, 0, 1, 1, 0])) 36

# N = 24, E = 36, FN = 8.00000 >>> labs(np.array([1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, … 0, 0, 1, 0, 0, 1])) 36

# N = 25, E = 36, FN = 8.68056 >>> labs(np.array([0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, … 1, 0, 1, 1, 0, 0, 1])) 36

# N = 25, E = 36, FN = 8.68056 >>> labs(np.array([1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 0, … 0, 1, 0, 0, 1, 1, 0])) 36

# N = 26, E = 45, FN = 7.51111 >>> labs(np.array([0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, … 0, 1, 1, 1, 0, 0, 1, 1])) 45

# N = 26, E = 45, FN = 7.51111 >>> labs(np.array([1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, … 1, 0, 0, 0, 1, 1, 0, 0])) 45

# N = 26, E = 45, FN = 7.51111 >>> labs(np.array([0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 1, 0, 1, … 0, 1, 1, 0, 1, 1, 0, 1])) 45

# N = 26, E = 45, FN = 7.51111 >>> labs(np.array([1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 1, 0, … 1, 0, 0, 1, 0, 0, 1, 0])) 45

# N = 26, E = 45, FN = 7.51111 >>> labs(np.array([0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, … 0, 1, 1, 0, 1, 1, 0, 1])) 45

# N = 26, E = 45, FN = 7.51111 >>> labs(np.array([1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, … 1, 0, 0, 1, 0, 0, 1, 0])) 45

# N = 27, E = 37, FN = 9.85135 >>> labs(np.array([0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, … 1, 0, 0, 1, 0, 1, 1, 0, 1])) 37

# N = 27, E = 37, FN = 9.85135 >>> labs(np.array([1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, … 0, 1, 1, 0, 1, 0, 0, 1, 0])) 37

# N = 28, E = 50, FN = 7.84000 >>> labs(np.array([0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, … 1, 0, 0, 1, 0, 1, 1, 0, 1, 1])) 50

# N = 28, E = 50, FN = 7.84000 >>> labs(np.array([1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, … 0, 1, 1, 0, 1, 0, 0, 1, 0, 0])) 50

# N = 29, E = 62, FN = 6.78226 >>> labs(np.array([0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, … 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 0])) 62

# N = 29, E = 62, FN = 6.78226 >>> labs(np.array([1, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, … 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1])) 62

# N = 29, E = 62, FN = 6.78226 >>> labs(np.array([0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, … 1, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0])) 62

# N = 29, E = 62, FN = 6.78226 >>> labs(np.array([1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, … 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1])) 62

# N = 30, E = 59, FN = 7.62712 >>> labs(np.array([0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, … 0, 1, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0])) 59

# N = 30, E = 59, FN = 7.62712 >>> labs(np.array([1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, … 1, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1])) 59

# N = 30, E = 59, FN = 7.62712 >>> labs(np.array([0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, … 0, 1, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0])) 59

# N = 30, E = 59, FN = 7.62712 >>> labs(np.array([1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, … 1, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1])) 59

# N = 31, E = 67, FN = 7.17164 >>> labs(np.array([0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, … 0, 0, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1])) 67

# N = 31, E = 67, FN = 7.17164 >>> labs(np.array([1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 0, … 1, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0])) 67

# N = 32, E = 64, FN = 8.00000 >>> labs(np.array([0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, … 1, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 1, 0])) 64

# N = 32, E = 64, FN = 8.00000 >>> labs(np.array([1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 0, … 0, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 0, 0, 1])) 64

# N = 33, E = 64, FN = 8.50781 >>> labs(np.array([0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 1, 0, 1, 1, 0, … 1, 0, 1, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1])) 64

# N = 33, E = 64, FN = 8.50781 >>> labs(np.array([1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 1, 0, 0, 1, … 0, 1, 0, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0])) 64

# N = 34, E = 65, FN = 8.89231 >>> labs(np.array([0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 1, 0, 1, 1, … 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1])) 65

# N = 34, E = 65, FN = 8.89231 >>> labs(np.array([1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 1, 0, 0, … 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0])) 65

# N = 35, E = 73, FN = 8.39041 >>> labs(np.array([0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 1, 1, 0, 0, 1, … 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0])) 73

# N = 35, E = 73, FN = 8.39041 >>> labs(np.array([1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 0, 0, 1, 0, 0, 1, 1, 0, … 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 1])) 73

# N = 36, E = 82, FN = 7.90244 >>> labs(np.array([0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, … 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0])) 82

# N = 36, E = 82, FN = 7.90244 >>> labs(np.array([1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, … 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1])) 82

# N = 37, E = 86, FN = 7.95930 >>> labs(np.array([0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, … 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1])) 86

# N = 37, E = 86, FN = 7.95930 >>> labs(np.array([1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, … 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0])) 86

# N = 38, E = 87, FN = 8.29885 >>> labs(np.array([0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, … 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0])) 87

# N = 38, E = 87, FN = 8.29885 >>> labs(np.array([1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, … 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1])) 87

# N = 39, E = 99, FN = 7.68182 >>> labs(np.array([0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 0, 1, 0, 0, 1, … 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1])) 99

# N = 39, E = 99, FN = 7.68182 >>> labs(np.array([1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 0, … 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0])) 99

# N = 39, E = 99, FN = 7.68182 >>> labs(np.array([0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0, 1, 0, 0, 0, 0, 0, … 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 1, 0, 1, 1, 0, 0, 1, 0, 0, 1])) 99

# N = 39, E = 99, FN = 7.68182 >>> labs(np.array([1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 1, 1, 1, 1, 1, … 1, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 0, 1, 0, 0, 1, 1, 0, 1, 1, 0])) 99

# N = 40, E = 108, FN = 7.40741 >>> labs(np.array([0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1, … 1, 0, 1, 1, 1, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, … 1])) 108

# N = 40, E = 108, FN = 7.40741 >>> labs(np.array([1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 1, 1, 0, 1, 0, … 0, 1, 0, 0, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, … 0])) 108

# N = 41, E = 108, FN = 7.78241 >>> labs(np.array([0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, … 0, 0, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 0, 1, 0, 0, … 1, 0])) 108

# N = 41, E = 108, FN = 7.78241 >>> labs(np.array([1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 0, 0, … 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1, … 0, 1])) 108

# N = 42, E = 101, FN = 8.73267 >>> labs(np.array([0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, … 1, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, … 1, 0, 0])) 101

# N = 42, E = 101, FN = 8.73267 >>> labs(np.array([1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 0, … 0, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, … 0, 1, 1])) 101

# N = 43, E = 109, FN = 8.48165 >>> labs(np.array([0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 0, … 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 0, 1, 0, 0, 1, 1, … 0, 1, 1, 1])) 109

# N = 43, E = 109, FN = 8.48165 >>> labs(np.array([1, 0, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 1, … 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 0, … 1, 0, 0, 0])) 109

# N = 44, E = 122, FN = 7.93443 >>> labs(np.array([0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, … 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 0, 0, 1, … 0, 1, 0, 0, 1])) 122

# N = 44, E = 122, FN = 7.93443 >>> labs(np.array([1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, … 0, 1, 0, 1, 1, 1, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 1, 1, 0, … 1, 0, 1, 1, 0])) 122

# N = 45, E = 118, FN = 8.58051 >>> labs(np.array([0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 0, 1, 0, 0, 1, … 0, 0, 1, 1, 1, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, … 1, 0, 1, 0, 1, 0])) 118

# N = 45, E = 118, FN = 8.58051 >>> labs(np.array([1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 0, … 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1, … 0, 1, 0, 1, 0, 1])) 118

# N = 46, E = 131, FN = 8.07634 >>> labs(np.array([0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, … 0, 0, 1, 0, 0, 1, 1, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, … 1, 0, 1, 0, 1, 0, 1])) 131

# N = 46, E = 131, FN = 8.07634 >>> labs(np.array([1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, … 1, 1, 0, 1, 1, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 0, 0, 1, … 0, 1, 0, 1, 0, 1, 0])) 131

# N = 46, E = 131, FN = 8.07634 >>> labs(np.array([0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 0, 1, 0, 0, 1, … 0, 0, 1, 1, 1, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, … 1, 0, 1, 0, 1, 0, 1])) 131

# N = 46, E = 131, FN = 8.07634 >>> labs(np.array([1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 0, … 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1, … 0, 1, 0, 1, 0, 1, 0])) 131

# N = 46, E = 131, FN = 8.07634 >>> labs(np.array([0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, … 0, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 1, … 0, 1, 1, 0, 1, 1, 0])) 131

# N = 46, E = 131, FN = 8.07634 >>> labs(np.array([1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, … 1, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 0, 1, 0, 0, 1, 1, 0, … 1, 0, 0, 1, 0, 0, 1])) 131

# N = 47, E = 135, FN = 8.18148 >>> labs(np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, … 0, 0, 0, 1, 0, 0, 1, 1, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, … 0, 1, 0, 1, 0, 1, 0, 1])) 135

# N = 47, E = 135, FN = 8.18148 >>> labs(np.array([1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, … 1, 1, 1, 0, 1, 1, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 0, 0, … 1, 0, 1, 0, 1, 0, 1, 0])) 135

# N = 47, E = 135, FN = 8.18148 >>> labs(np.array([0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, … 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, … 0, 1, 1, 0, 0, 1, 0, 1])) 135

# N = 47, E = 135, FN = 8.18148 >>> labs(np.array([1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, … 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, … 1, 0, 0, 1, 1, 0, 1, 0])) 135

# N = 47, E = 135, FN = 8.18148 >>> labs(np.array([0, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 0, 1, 0, … 0, 0, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 0, 0, 0, 0, 1, 1, 0, … 1, 1, 0, 0, 0, 0, 1, 1])) 135

# N = 47, E = 135, FN = 8.18148 >>> labs(np.array([1, 1, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 1, 1, 1, 0, 1, … 1, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 1, 1, 1, 0, 0, 1, … 0, 0, 1, 1, 1, 1, 0, 0])) 135

# N = 47, E = 135, FN = 8.18148 >>> labs(np.array([0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, … 0, 0, 1, 1, 0, 1, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, … 1, 0, 1, 0, 1, 1, 0, 1])) 135

# N = 47, E = 135, FN = 8.18148 >>> labs(np.array([1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, … 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 0, 1, … 0, 1, 0, 1, 0, 0, 1, 0])) 135

# N = 47, E = 135, FN = 8.18148 >>> labs(np.array([0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, … 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, … 0, 1, 0, 0, 1, 0, 0, 1])) 135

# N = 47, E = 135, FN = 8.18148 >>> labs(np.array([1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, … 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, … 1, 0, 1, 1, 0, 1, 1, 0])) 135

# N = 47, E = 135, FN = 8.18148 >>> labs(np.array([0, 0, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, … 0, 1, 1, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0, 1, 0, 1, 0, 1, 0, … 1, 0, 1, 1, 0, 0, 0, 1])) 135

# N = 47, E = 135, FN = 8.18148 >>> labs(np.array([1, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, … 1, 0, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 0, 1, … 0, 1, 0, 0, 1, 1, 1, 0])) 135

# N = 48, E = 140, FN = 8.22857 >>> labs(np.array([0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, … 0, 0, 1, 1, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 1, 1, … 0, 1, 0, 0, 1, 0, 1, 1, 0])) 140

# N = 48, E = 140, FN = 8.22857 >>> labs(np.array([1, 1, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, … 1, 1, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 1, 1, 0, 0, … 1, 0, 1, 1, 0, 1, 0, 0, 1])) 140

# N = 49, E = 136, FN = 8.82721 >>> labs(np.array([0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, … 1, 1, 0, 0, 1, 1, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 1, … 1, 1, 1, 0, 1, 0, 0, 0, 0, 1])) 136

# N = 49, E = 136, FN = 8.82721 >>> labs(np.array([1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, … 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 1, 1, 0, 1, 0, … 0, 0, 0, 1, 0, 1, 1, 1, 1, 0])) 136

# N = 49, E = 136, FN = 8.82721 >>> labs(np.array([0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, … 0, 1, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 1, 0, 1, … 0, 0, 1, 0, 0, 1, 0, 0, 1, 0])) 136

# N = 49, E = 136, FN = 8.82721 >>> labs(np.array([1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, … 1, 0, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, … 1, 1, 0, 1, 1, 0, 1, 1, 0, 1])) 136

# N = 50, E = 153, FN = 8.16993 >>> labs(np.array([0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, … 1, 1, 0, 0, 1, 1, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 1, … 1, 1, 1, 0, 1, 0, 0, 0, 0, 1, 1])) 153

# N = 50, E = 153, FN = 8.16993 >>> labs(np.array([1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, … 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 1, 1, 0, 1, 0, … 0, 0, 0, 1, 0, 1, 1, 1, 1, 0, 0])) 153

# N = 50, E = 153, FN = 8.16993 >>> labs(np.array([0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, … 0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, … 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1])) 153

# N = 50, E = 153, FN = 8.16993 >>> labs(np.array([1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, … 1, 1, 0, 0, 1, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 1, … 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0])) 153

# N = 50, E = 153, FN = 8.16993 >>> labs(np.array([0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, … 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 1, 0, … 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0])) 153

# N = 50, E = 153, FN = 8.16993 >>> labs(np.array([1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, … 1, 1, 0, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 0, 1, … 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1])) 153

# N = 51, E = 153, FN = 8.50000 >>> labs(np.array([0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0, … 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1, … 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1])) 153

# N = 51, E = 153, FN = 8.50000 >>> labs(np.array([1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 1, 0, 1, … 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 0, … 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 0])) 153

# N = 52, E = 166, FN = 8.14458 >>> labs(np.array([0, 0, 0, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 0, 1, … 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 0, 0, 1, 1, 1, 0, … 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1])) 166

# N = 52, E = 166, FN = 8.14458 >>> labs(np.array([1, 1, 1, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, … 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 1, … 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0])) 166

# N = 53, E = 170, FN = 8.26176 >>> labs(np.array([0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, … 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 0, 0, … 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 0, 1])) 170

# N = 53, E = 170, FN = 8.26176 >>> labs(np.array([1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 0, 1, 1, 1, 0, 1, 0, 1, … 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 1, … 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0])) 170

# N = 53, E = 170, FN = 8.26176 >>> labs(np.array([0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, … 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, … 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 1, 0])) 170

# N = 53, E = 170, FN = 8.26176 >>> labs(np.array([1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, … 0, 1, 1, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, … 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 0, 1])) 170

# N = 54, E = 175, FN = 8.33143 >>> labs(np.array([0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, … 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 0, 1, … 1, 0, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0])) 175

# N = 54, E = 175, FN = 8.33143 >>> labs(np.array([1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, … 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 0, … 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1])) 175

# N = 55, E = 171, FN = 8.84503 >>> labs(np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, … 0, 0, 1, 1, 0, 1, 1, 0, 1, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, … 1, 1, 1, 0, 0, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1])) 171

# N = 55, E = 171, FN = 8.84503 >>> labs(np.array([1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, … 1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, … 0, 0, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0])) 171

# N = 55, E = 171, FN = 8.84503 >>> labs(np.array([0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 1, 1, 1, 1, 0, 1, 0, 0, 1, 1, 1, 1, 0, 1, 0, 0, 1, 0, 1, … 0, 1, 0, 1, 0, 1, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1])) 171

# N = 55, E = 171, FN = 8.84503 >>> labs(np.array([1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, … 1, 1, 0, 0, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 1, 0, 1, 1, 0, 1, 0, … 1, 0, 1, 0, 1, 0, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0])) 171

# N = 56, E = 192, FN = 8.16667 >>> labs(np.array([0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 0, 0, … 1, 1, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0, 1, 0, 1, 0, … 1, 1, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 1])) 192

# N = 56, E = 192, FN = 8.16667 >>> labs(np.array([1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, … 0, 0, 0, 1, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 1, 0, 1, … 0, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 0])) 192

# N = 57, E = 188, FN = 8.64096 >>> labs(np.array([0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, … 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, … 0, 1, 0, 1, 0, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0])) 188

# N = 57, E = 188, FN = 8.64096 >>> labs(np.array([1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, … 0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, … 1, 0, 1, 0, 1, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 1, 0, 1])) 188

# N = 58, E = 197, FN = 8.53807 >>> labs(np.array([0, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 0, 0, 0, 1, 1, 0, 1, … 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 1, 1, 0, … 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 0, 1, 1])) 197

# N = 58, E = 197, FN = 8.53807 >>> labs(np.array([1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, … 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 0, 1, 0, 0, 1, … 0, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 1, 0, 0])) 197

# N = 59, E = 205, FN = 8.49024 >>> labs(np.array([0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, … 1, 1, 0, 1, 1, 0, 0, 1, 1, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, … 1, 0, 1, 0, 0, 1, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1])) 205

# N = 59, E = 205, FN = 8.49024 >>> labs(np.array([1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, … 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, … 0, 1, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0])) 205

# N = 59, E = 205, FN = 8.49024 >>> labs(np.array([0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, … 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0, … 0, 0, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 1, 1, 0, 0])) 205

# N = 59, E = 205, FN = 8.49024 >>> labs(np.array([1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 0, 0, 1, 1, 1, … 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 1, 0, 0, 0, 1, 1, … 1, 1, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 0, 0, 0, 0, 1, 1])) 205

# N = 60, E = 218, FN = 8.25688 >>> labs(np.array([0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, … 0, 1, 1, 1, 1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 1, 0, 0, 1, 1, 1, 1, … 0, 0, 1, 0, 1, 1, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1])) 218

# N = 60, E = 218, FN = 8.25688 >>> labs(np.array([1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, … 1, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, … 1, 1, 0, 1, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0])) 218

# N = 60, E = 218, FN = 8.25688 >>> labs(np.array([0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 1, 1, 1, … 0, 1, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 1, 1, … 1, 1, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 0, 1, 0, 0, 1])) 218

# N = 60, E = 218, FN = 8.25688 >>> labs(np.array([1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 0, 0, 0, … 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, … 0, 0, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 0])) 218

# N = 61, E = 226, FN = 8.23230 >>> labs(np.array([0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, … 0, 0, 1, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, … 0, 1, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 0, … 1])) 226

# N = 61, E = 226, FN = 8.23230 >>> labs(np.array([1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 0, 0, 1, … 1, 1, 0, 0, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 1, 0, 1, … 1, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 0, 1, … 0])) 226

# N = 62, E = 235, FN = 8.17872 >>> labs(np.array([0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 1, 0, … 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, … 1, 0, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 0, … 1, 1])) 235

# N = 62, E = 235, FN = 8.17872 >>> labs(np.array([1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 1, … 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, … 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 1, … 0, 0])) 235

# N = 62, E = 235, FN = 8.17872 >>> labs(np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, … 0, 1, 1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, … 1, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 0, 0, 1, 0, … 1, 1])) 235

# N = 62, E = 235, FN = 8.17872 >>> labs(np.array([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, … 1, 0, 0, 0, 1, 1, 0, 1, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, … 0, 1, 0, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 1, 1, 0, 1, … 0, 0])) 235

# N = 63, E = 207, FN = 9.58696 >>> labs(np.array([0, 0, 1, 0, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 0, 1, 1, 1, … 1, 1, 1, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 0, 1, … 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 1, 1, 0, 0, 0, … 1, 1, 0])) 207

# N = 63, E = 207, FN = 9.58696 >>> labs(np.array([1, 1, 0, 1, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, … 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0, … 1, 1, 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 1, … 0, 0, 1])) 207

# N = 64, E = 208, FN = 9.84615 >>> labs(np.array([0, 0, 1, 0, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 0, 1, 1, 1, … 1, 1, 1, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 0, 1, … 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 1, 1, 0, 0, 0, … 1, 1, 0, 0])) 208

# N = 64, E = 208, FN = 9.84615 >>> labs(np.array([1, 1, 0, 1, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, … 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0, … 1, 1, 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 1, … 0, 0, 1, 1])) 208

# N = 65, E = 240, FN = 8.80208 >>> labs(np.array([0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, 1, 1, 1, 0, 1, … 0, 1, 1, 1, 0, 0, 0, 0, 1, 0, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, … 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 1, … 0, 0, 1, 0, 0])) 240

# N = 65, E = 240, FN = 8.80208 >>> labs(np.array([1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, … 1, 0, 0, 0, 1, 1, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, … 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 0, … 1, 1, 0, 1, 1])) 240

# N = 66, E = 257, FN = 8.47471 >>> labs(np.array([0, 0, 1, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, … 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, … 0, 1, 0, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, … 1, 1, 1, 1, 0, 0])) 257

# N = 66, E = 257, FN = 8.47471 >>> labs(np.array([1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, … 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, … 1, 0, 1, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, … 0, 0, 0, 0, 1, 1])) 257

# N = 3, all bits are True >>> labs(np.array([1, 1, 1])) 5

# N = 4, all bits are True >>> labs(np.array([1, 1, 1, 1])) 14

# N = 5, all bits are True >>> labs(np.array([1, 1, 1, 1, 1])) 30

# N = 6, all bits are True >>> labs(np.array([1, 1, 1, 1, 1, 1])) 55

# N = 7, all bits are True >>> labs(np.array([1, 1, 1, 1, 1, 1, 1])) 91

# N = 8, all bits are False >>> labs(np.array([0, 0, 0, 0, 0, 0, 0, 0])) 140

# N = 9, all bits are False >>> labs(np.array([0, 0, 0, 0, 0, 0, 0, 0, 0])) 204

# N = 10, all bits are True >>> labs(np.array([1, 1, 1, 1, 1, 1, 1, 1, 1, 1])) 285

# N = 11, all bits are True >>> labs(np.array([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1])) 385

# N = 12, all bits are True >>> labs(np.array([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1])) 506

# N = 13, all bits are False >>> labs(np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])) 650

# N = 14, all bits are False >>> labs(np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])) 819

# N = 15, all bits are False >>> labs(np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])) 1015

# N = 16, all bits are False >>> labs(np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])) 1240

# N = 17, all bits are True >>> labs(np.array([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1])) 1496

# N = 18, all bits are True >>> labs(np.array([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1])) 1785

# N = 19, all bits are False >>> labs(np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0])) 2109

# N = 20, all bits are False >>> labs(np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0])) 2470

# N = 21, all bits are True >>> labs(np.array([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, … 1, 1, 1])) 2870

# N = 22, all bits are True >>> labs(np.array([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, … 1, 1, 1, 1])) 3311

# N = 23, all bits are True >>> labs(np.array([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, … 1, 1, 1, 1, 1])) 3795

# N = 24, all bits are False >>> labs(np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0])) 4324

# N = 25, all bits are True >>> labs(np.array([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, … 1, 1, 1, 1, 1, 1, 1])) 4900

# N = 26, all bits are True >>> labs(np.array([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, … 1, 1, 1, 1, 1, 1, 1, 1])) 5525

# N = 27, all bits are True >>> labs(np.array([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, … 1, 1, 1, 1, 1, 1, 1, 1, 1])) 6201

# N = 28, all bits are True >>> labs(np.array([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, … 1, 1, 1, 1, 1, 1, 1, 1, 1, 1])) 6930

# N = 29, all bits are False >>> labs(np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])) 7714

# N = 30, all bits are False >>> labs(np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])) 8555

# N = 31, all bits are True >>> labs(np.array([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, … 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1])) 9455

# N = 32, all bits are False >>> labs(np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])) 10416

# N = 33, all bits are True >>> labs(np.array([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, … 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1])) 11440

# N = 34, all bits are False >>> labs(np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])) 12529

# N = 35, all bits are False >>> labs(np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])) 13685

# N = 36, all bits are True >>> labs(np.array([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, … 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1])) 14910

# N = 37, all bits are False >>> labs(np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])) 16206

# N = 38, all bits are True >>> labs(np.array([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, … 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1])) 17575

# N = 39, all bits are True >>> labs(np.array([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, … 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1])) 19019

# N = 40, all bits are False >>> labs(np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0])) 20540

# N = 41, all bits are False >>> labs(np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0])) 22140

# N = 42, all bits are True >>> labs(np.array([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, … 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, … 1, 1, 1])) 23821

# N = 43, all bits are True >>> labs(np.array([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, … 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, … 1, 1, 1, 1])) 25585

# N = 44, all bits are False >>> labs(np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0])) 27434

# N = 45, all bits are False >>> labs(np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0])) 29370

# N = 46, all bits are True >>> labs(np.array([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, … 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, … 1, 1, 1, 1, 1, 1, 1])) 31395

# N = 47, all bits are True >>> labs(np.array([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, … 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, … 1, 1, 1, 1, 1, 1, 1, 1])) 33511

# N = 48, all bits are True >>> labs(np.array([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, … 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, … 1, 1, 1, 1, 1, 1, 1, 1, 1])) 35720

# N = 49, all bits are False >>> labs(np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])) 38024

# N = 50, all bits are False >>> labs(np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])) 40425

# N = 51, all bits are True >>> labs(np.array([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, … 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, … 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1])) 42925

# N = 52, all bits are True >>> labs(np.array([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, … 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, … 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1])) 45526

# N = 53, all bits are True >>> labs(np.array([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, … 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, … 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1])) 48230

# N = 54, all bits are True >>> labs(np.array([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, … 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, … 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1])) 51039

# N = 55, all bits are True >>> labs(np.array([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, … 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, … 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1])) 53955

# N = 56, all bits are False >>> labs(np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])) 56980

# N = 57, all bits are False >>> labs(np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])) 60116

# N = 58, all bits are True >>> labs(np.array([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, … 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, … 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1])) 63365

# N = 59, all bits are True >>> labs(np.array([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, … 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, … 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1])) 66729

# N = 60, all bits are True >>> labs(np.array([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, … 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, … 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1])) 70210

# N = 61, all bits are False >>> labs(np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0])) 73810

# N = 62, all bits are True >>> labs(np.array([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, … 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, … 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, … 1, 1])) 77531

# N = 63, all bits are True >>> labs(np.array([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, … 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, … 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, … 1, 1, 1])) 81375

# N = 64, all bits are True >>> labs(np.array([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, … 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, … 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, … 1, 1, 1, 1])) 85344

# N = 65, all bits are True >>> labs(np.array([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, … 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, … 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, … 1, 1, 1, 1, 1])) 89440

# N = 66, all bits are True >>> labs(np.array([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, … 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, … 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, … 1, 1, 1, 1, 1, 1])) 93665

# N = 67, all bits are False >>> labs(np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0])) 98021

# N = 68, all bits are False >>> labs(np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0])) 102510

# N = 69, all bits are False >>> labs(np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0])) 107134

# N = 70, all bits are False >>> labs(np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])) 111895

# N = 71, all bits are False >>> labs(np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])) 116795

# N = 72, all bits are False >>> labs(np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])) 121836

# N = 73, all bits are True >>> labs(np.array([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, … 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, … 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, … 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1])) 127020

# N = 74, all bits are False >>> labs(np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])) 132349

# N = 75, all bits are True >>> labs(np.array([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, … 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, … 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, … 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1])) 137825

# N = 76, all bits are True >>> labs(np.array([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, … 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, … 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, … 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1])) 143450

# N = 77, all bits are False >>> labs(np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])) 149226

# N = 78, all bits are False >>> labs(np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])) 155155

# N = 79, all bits are False >>> labs(np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])) 161239

# N = 80, all bits are False >>> labs(np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])) 167480

# N = 81, all bits are True >>> labs(np.array([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, … 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, … 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, … 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1])) 173880

# N = 82, all bits are False >>> labs(np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0])) 180441

# N = 83, all bits are False >>> labs(np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0])) 187165

# N = 84, all bits are False >>> labs(np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0])) 194054

# N = 85, all bits are False >>> labs(np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0])) 201110

# N = 86, all bits are True >>> labs(np.array([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, … 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, … 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, … 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, … 1, 1, 1, 1, 1])) 208335

# N = 87, all bits are False >>> labs(np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0])) 215731

# N = 88, all bits are True >>> labs(np.array([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, … 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, … 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, … 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, … 1, 1, 1, 1, 1, 1, 1])) 223300

# N = 89, all bits are False >>> labs(np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0])) 231044

# N = 90, all bits are False >>> labs(np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0])) 238965

# N = 91, all bits are True >>> labs(np.array([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, … 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, … 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, … 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, … 1, 1, 1, 1, 1, 1, 1, 1, 1, 1])) 247065

# N = 92, all bits are True >>> labs(np.array([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, … 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, … 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, … 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, … 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1])) 255346

# N = 93, all bits are True >>> labs(np.array([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, … 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, … 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, … 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, … 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1])) 263810

# N = 94, all bits are True >>> labs(np.array([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, … 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, … 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, … 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, … 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1])) 272459

# N = 95, all bits are True >>> labs(np.array([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, … 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, … 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, … 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, … 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1])) 281295

# N = 96, all bits are False >>> labs(np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])) 290320

# N = 97, all bits are False >>> labs(np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])) 299536

# N = 98, all bits are False >>> labs(np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])) 308945

# N = 99, all bits are True >>> labs(np.array([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, … 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, … 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, … 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, … 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1])) 318549

moptipy.examples.bitstrings.leadingones module

An objective function counting the leading ones in a bit string.

LeadingOnes is a standard benchmark problem in evolutionary computation. It attempts to maximize the number of consecutive True bits at the beginning of a bit string. Its best possible objective value is 0, the worst possible is n.

  1. L. Darrell Whitley. The GENITOR Algorithm and Selection Pressure: Why Rank-Based Allocation of Reproductive Trials is Best. In J. David Schaffer, ed., Proceedings of the 3rd International Conference on Genetic Algorithms (ICGA’89), June 4-7, 1989, Fairfax, VA, USA, pages 116-121. San Francisco, CA, USA: Morgan Kaufmann Publishers Inc. ISBN: 1-55860-066-3 https://www.researchgate.net/publication/2527551

  2. Günter Rudolph, Convergence Properties of Evolutionary Algorithms. Hamburg, Germany: Verlag Dr. Kovač, 1997.

  3. Peyman Afshani, Manindra Agrawal, Benjamin Doerr, Kasper Green Larsen, Kurt Mehlhorn, and Carola Winzen. The Query Complexity of Finding a Hidden Permutation. Space-Efficient Data Structures, Streams, and Algorithms. pp. 1-11. Springer. 2013. doi: https://doi.org/10.1007/978-3-642-40273-9_1

  4. Peyman Afshani, Manindra Agrawal, Benjamin Doerr, Carola Doerr, Kasper Green Larsen, Kurt Mehlhorn. The Query Complexity of a Permutation-Based Variant of Mastermind. Discrete Applied Mathematics. 260:28-50. 2019. doi: https://doi.org/10.1016/j.dam.2019.01.007

  5. Stefan Droste, Thomas Jansen, and Ingo Wegener. On the Analysis of the (1+1) Evolutionary Algorithm. Theoretical Computer Science. 276(1-2):51-81. 2002. doi: https://doi.org/10.1016/S0304-3975(01)00182-7.

  6. Denis Antipov, Benjamin Doerr, and Vitalii Karavaev. A Tight Runtime Analysis for the (1+(λ,λ)) GA on LeadingOnes. FOGA 2019, pp. 169-182. ACM. doi: https://doi.org/10.1145/3299904.3340317.

  7. Vitalii Karavaev, Denis Antipov, and Benjamin Doerr. Theoretical and Empirical Study of the (1+(λ,λ)) EA on the LeadingOnes Problem. GECCO (Companion) 2019. pp 2036-2039. ACM. doi: https://doi.org/10.1145/3319619.3326910.

  8. Thomas Weise, Zhize Wu, Xinlu Li, and Yan Chen. Frequency Fitness Assignment: Making Optimization Algorithms Invariant under Bijective Transformations of the Objective Function Value. IEEE Transactions on Evolutionary Computation 25(2):307-319. April 2021. Preprint available at arXiv:2001.01416v5 [cs.NE] 15 Oct 2020. https://dx.doi.org/10.1109/TEVC.2020.3032090

  9. Thomas Weise, Zhize Wu, Xinlu Li, Yan Chen, and Jörg Lässig. Frequency Fitness Assignment: Optimization without Bias for Good Solutions can be Efficient. IEEE Transactions on Evolutionary Computation (TEVC). 27(4):980-992. August 2023. doi: https://doi.org/10.1109/TEVC.2022.3191698

class moptipy.examples.bitstrings.leadingones.LeadingOnes(n)[source]

Bases: BitStringProblem

Maximize the number of leading ones in a bit string.

classmethod default_instances(scale_min=2, scale_max=4096)[source]

Get the 163 default instances of the LeadingOnes problem.

Parameters:
  • scale_min (int, default: 2) – the minimum permitted scale, by default 2

  • scale_max (int, default: 4096) – the maximum permitted scale, by default 4096

Return type:

Iterator[Callable[[], LeadingOnes]]

Returns:

a sequence of default LeadingOnes instances

>>> len(list(LeadingOnes.default_instances()))
163
>>> [x() for x in LeadingOnes.default_instances()]
[leadingones_2, leadingones_3, leadingones_4, leadingones_5, leadingones_6, leadingones_7, leadingones_8, leadingones_9, leadingones_10, leadingones_11, leadingones_12, leadingones_13, leadingones_14, leadingones_15, leadingones_16, leadingones_17, leadingones_18, leadingones_19, leadingones_20, leadingones_21, leadingones_22, leadingones_23, leadingones_24, leadingones_25, leadingones_26, leadingones_27, leadingones_28, leadingones_29, leadingones_30, leadingones_31, leadingones_32, leadingones_33, leadingones_36, leadingones_40, leadingones_41, leadingones_42, leadingones_44, leadingones_48, leadingones_49, leadingones_50, leadingones_55, leadingones_59, leadingones_60, leadingones_64, leadingones_66, leadingones_70, leadingones_77, leadingones_79, leadingones_80, leadingones_81, leadingones_85, leadingones_88, leadingones_90, leadingones_96, leadingones_99, leadingones_100, leadingones_107, leadingones_111, leadingones_121, leadingones_125, leadingones_128, leadingones_144, leadingones_149, leadingones_169, leadingones_170, leadingones_192, leadingones_196, leadingones_199, leadingones_200, leadingones_222, leadingones_225, leadingones_243, leadingones_256, leadingones_269, leadingones_289, leadingones_300, leadingones_324, leadingones_333, leadingones_341, leadingones_343, leadingones_359, leadingones_361, leadingones_384, leadingones_400, leadingones_441, leadingones_444, leadingones_479, leadingones_484, leadingones_500, leadingones_512, leadingones_529, leadingones_555, leadingones_576, leadingones_600, leadingones_625, leadingones_641, leadingones_666, leadingones_676, leadingones_682, leadingones_700, leadingones_729, leadingones_768, leadingones_777, leadingones_784, leadingones_800, leadingones_841, leadingones_857, leadingones_888, leadingones_900, leadingones_961, leadingones_999, leadingones_1000, leadingones_1024, leadingones_1089, leadingones_1111, leadingones_1151, leadingones_1156, leadingones_1225, leadingones_1296, leadingones_1365, leadingones_1369, leadingones_1444, leadingones_1521, leadingones_1536, leadingones_1543, leadingones_1600, leadingones_1681, leadingones_1764, leadingones_1849, leadingones_1936, leadingones_2000, leadingones_2025, leadingones_2048, leadingones_2063, leadingones_2116, leadingones_2187, leadingones_2209, leadingones_2222, leadingones_2304, leadingones_2401, leadingones_2500, leadingones_2601, leadingones_2704, leadingones_2730, leadingones_2753, leadingones_2809, leadingones_2916, leadingones_3000, leadingones_3025, leadingones_3072, leadingones_3125, leadingones_3136, leadingones_3249, leadingones_3333, leadingones_3364, leadingones_3481, leadingones_3600, leadingones_3671, leadingones_3721, leadingones_3844, leadingones_3969, leadingones_4000, leadingones_4096]
moptipy.examples.bitstrings.leadingones.leadingones(x)[source]

Get the length of the string minus the number of leading ones.

Parameters:

x (ndarray) – the np array

Return type:

int

Returns:

the number of leading ones

>>> leadingones(np.array([False, False, True, False, False]))
5
>>> leadingones(np.array([True, False, False, True, True]))
4
>>> leadingones(np.array([True, True, False, False, False]))
3
>>> leadingones(np.array([True, True, True, False, True]))
2
>>> leadingones(np.array([True, True, True, True, False]))
1
>>> leadingones(np.array([True, True, True, True, True]))
0

# n = 1 and 0 true bits >>> leadingones(np.array([0])) 1

# n = 1 and 1 true bit >>> leadingones(np.array([1])) 0

# n = 2 and 0 true bits >>> leadingones(np.array([0, 0])) 2

# n = 2 and 1 true bit >>> leadingones(np.array([1, 0])) 1

# n = 2 and 1 true bit >>> leadingones(np.array([0, 1])) 2

# n = 2 and 1 true bit >>> leadingones(np.array([1, 0])) 1

# n = 2 and 2 true bits >>> leadingones(np.array([1, 1])) 0

# n = 3 and 0 true bits >>> leadingones(np.array([0, 0, 0])) 3

# n = 3 and 1 true bit >>> leadingones(np.array([0, 1, 0])) 3

# n = 3 and 1 true bit >>> leadingones(np.array([0, 0, 1])) 3

# n = 3 and 1 true bit >>> leadingones(np.array([0, 1, 0])) 3

# n = 3 and 2 true bits >>> leadingones(np.array([1, 1, 0])) 1

# n = 3 and 2 true bits >>> leadingones(np.array([1, 0, 1])) 2

# n = 3 and 2 true bits >>> leadingones(np.array([1, 1, 0])) 1

# n = 3 and 3 true bits >>> leadingones(np.array([1, 1, 1])) 0

# n = 4 and 0 true bits >>> leadingones(np.array([0, 0, 0, 0])) 4

# n = 4 and 1 true bit >>> leadingones(np.array([1, 0, 0, 0])) 3

# n = 4 and 1 true bit >>> leadingones(np.array([0, 0, 1, 0])) 4

# n = 4 and 1 true bit >>> leadingones(np.array([1, 0, 0, 0])) 3

# n = 4 and 2 true bits >>> leadingones(np.array([1, 0, 0, 1])) 3

# n = 4 and 2 true bits >>> leadingones(np.array([0, 1, 0, 1])) 4

# n = 4 and 2 true bits >>> leadingones(np.array([0, 1, 1, 0])) 4

# n = 4 and 3 true bits >>> leadingones(np.array([1, 1, 1, 0])) 1

# n = 4 and 3 true bits >>> leadingones(np.array([1, 1, 1, 0])) 1

# n = 4 and 3 true bits >>> leadingones(np.array([0, 1, 1, 1])) 4

# n = 4 and 4 true bits >>> leadingones(np.array([1, 1, 1, 1])) 0

# n = 5 and 0 true bits >>> leadingones(np.array([0, 0, 0, 0, 0])) 5

# n = 5 and 1 true bit >>> leadingones(np.array([0, 1, 0, 0, 0])) 5

# n = 5 and 1 true bit >>> leadingones(np.array([0, 1, 0, 0, 0])) 5

# n = 5 and 1 true bit >>> leadingones(np.array([0, 1, 0, 0, 0])) 5

# n = 5 and 2 true bits >>> leadingones(np.array([1, 1, 0, 0, 0])) 3

# n = 5 and 2 true bits >>> leadingones(np.array([1, 0, 0, 1, 0])) 4

# n = 5 and 2 true bits >>> leadingones(np.array([0, 0, 1, 1, 0])) 5

# n = 5 and 3 true bits >>> leadingones(np.array([1, 0, 0, 1, 1])) 4

# n = 5 and 3 true bits >>> leadingones(np.array([1, 1, 1, 0, 0])) 2

# n = 5 and 3 true bits >>> leadingones(np.array([0, 0, 1, 1, 1])) 5

# n = 5 and 4 true bits >>> leadingones(np.array([1, 1, 0, 1, 1])) 3

# n = 5 and 4 true bits >>> leadingones(np.array([1, 1, 0, 1, 1])) 3

# n = 5 and 4 true bits >>> leadingones(np.array([1, 1, 1, 1, 0])) 1

# n = 5 and 5 true bits >>> leadingones(np.array([1, 1, 1, 1, 1])) 0

# n = 6 and 0 true bits >>> leadingones(np.array([0, 0, 0, 0, 0, 0])) 6

# n = 6 and 1 true bit >>> leadingones(np.array([0, 0, 1, 0, 0, 0])) 6

# n = 6 and 1 true bit >>> leadingones(np.array([0, 1, 0, 0, 0, 0])) 6

# n = 6 and 1 true bit >>> leadingones(np.array([1, 0, 0, 0, 0, 0])) 5

# n = 6 and 2 true bits >>> leadingones(np.array([0, 1, 0, 0, 0, 1])) 6

# n = 6 and 2 true bits >>> leadingones(np.array([0, 0, 1, 0, 0, 1])) 6

# n = 6 and 2 true bits >>> leadingones(np.array([0, 0, 1, 0, 1, 0])) 6

# n = 6 and 3 true bits >>> leadingones(np.array([0, 1, 0, 1, 1, 0])) 6

# n = 6 and 3 true bits >>> leadingones(np.array([1, 0, 0, 0, 1, 1])) 5

# n = 6 and 3 true bits >>> leadingones(np.array([0, 0, 1, 1, 1, 0])) 6

# n = 6 and 4 true bits >>> leadingones(np.array([0, 1, 0, 1, 1, 1])) 6

# n = 6 and 4 true bits >>> leadingones(np.array([0, 1, 1, 1, 1, 0])) 6

# n = 6 and 4 true bits >>> leadingones(np.array([0, 1, 1, 0, 1, 1])) 6

# n = 6 and 5 true bits >>> leadingones(np.array([1, 0, 1, 1, 1, 1])) 5

# n = 6 and 5 true bits >>> leadingones(np.array([1, 1, 1, 1, 1, 0])) 1

# n = 6 and 5 true bits >>> leadingones(np.array([1, 0, 1, 1, 1, 1])) 5

# n = 6 and 6 true bits >>> leadingones(np.array([1, 1, 1, 1, 1, 1])) 0

# n = 7 and 0 true bits >>> leadingones(np.array([0, 0, 0, 0, 0, 0, 0])) 7

# n = 7 and 1 true bit >>> leadingones(np.array([0, 0, 0, 0, 0, 0, 1])) 7

# n = 7 and 1 true bit >>> leadingones(np.array([0, 0, 0, 0, 1, 0, 0])) 7

# n = 7 and 1 true bit >>> leadingones(np.array([0, 0, 1, 0, 0, 0, 0])) 7

# n = 7 and 2 true bits >>> leadingones(np.array([0, 1, 0, 0, 0, 1, 0])) 7

# n = 7 and 2 true bits >>> leadingones(np.array([0, 0, 1, 0, 0, 1, 0])) 7

# n = 7 and 2 true bits >>> leadingones(np.array([0, 0, 0, 1, 0, 1, 0])) 7

# n = 7 and 3 true bits >>> leadingones(np.array([1, 0, 0, 0, 0, 1, 1])) 6

# n = 7 and 3 true bits >>> leadingones(np.array([1, 0, 1, 0, 0, 1, 0])) 6

# n = 7 and 3 true bits >>> leadingones(np.array([1, 0, 0, 1, 1, 0, 0])) 6

# n = 7 and 4 true bits >>> leadingones(np.array([1, 0, 0, 1, 1, 1, 0])) 6

# n = 7 and 4 true bits >>> leadingones(np.array([1, 0, 1, 1, 0, 1, 0])) 6

# n = 7 and 4 true bits >>> leadingones(np.array([1, 1, 1, 0, 1, 0, 0])) 4

# n = 7 and 5 true bits >>> leadingones(np.array([0, 1, 1, 1, 0, 1, 1])) 7

# n = 7 and 5 true bits >>> leadingones(np.array([1, 1, 0, 0, 1, 1, 1])) 5

# n = 7 and 5 true bits >>> leadingones(np.array([0, 1, 1, 1, 1, 0, 1])) 7

# n = 7 and 6 true bits >>> leadingones(np.array([1, 1, 0, 1, 1, 1, 1])) 5

# n = 7 and 6 true bits >>> leadingones(np.array([1, 1, 1, 1, 0, 1, 1])) 3

# n = 7 and 6 true bits >>> leadingones(np.array([1, 1, 0, 1, 1, 1, 1])) 5

# n = 7 and 7 true bits >>> leadingones(np.array([1, 1, 1, 1, 1, 1, 1])) 0

# n = 8 and 0 true bits >>> leadingones(np.array([0, 0, 0, 0, 0, 0, 0, 0])) 8

# n = 8 and 1 true bit >>> leadingones(np.array([0, 0, 0, 0, 0, 1, 0, 0])) 8

# n = 8 and 1 true bit >>> leadingones(np.array([0, 0, 0, 0, 1, 0, 0, 0])) 8

# n = 8 and 1 true bit >>> leadingones(np.array([1, 0, 0, 0, 0, 0, 0, 0])) 7

# n = 8 and 2 true bits >>> leadingones(np.array([0, 0, 0, 1, 0, 0, 0, 1])) 8

# n = 8 and 2 true bits >>> leadingones(np.array([0, 1, 0, 0, 0, 0, 0, 1])) 8

# n = 8 and 2 true bits >>> leadingones(np.array([0, 1, 0, 1, 0, 0, 0, 0])) 8

# n = 8 and 3 true bits >>> leadingones(np.array([1, 0, 0, 0, 1, 0, 1, 0])) 7

# n = 8 and 3 true bits >>> leadingones(np.array([1, 0, 1, 0, 1, 0, 0, 0])) 7

# n = 8 and 3 true bits >>> leadingones(np.array([0, 0, 0, 1, 0, 0, 1, 1])) 8

# n = 8 and 4 true bits >>> leadingones(np.array([1, 1, 0, 0, 0, 0, 1, 1])) 6

# n = 8 and 4 true bits >>> leadingones(np.array([1, 1, 0, 1, 0, 1, 0, 0])) 6

# n = 8 and 4 true bits >>> leadingones(np.array([0, 0, 1, 0, 1, 1, 1, 0])) 8

# n = 8 and 5 true bits >>> leadingones(np.array([1, 1, 1, 1, 0, 0, 1, 0])) 4

# n = 8 and 5 true bits >>> leadingones(np.array([1, 0, 1, 1, 0, 0, 1, 1])) 7

# n = 8 and 5 true bits >>> leadingones(np.array([0, 1, 0, 1, 1, 1, 0, 1])) 8

# n = 8 and 6 true bits >>> leadingones(np.array([1, 1, 1, 1, 0, 1, 0, 1])) 4

# n = 8 and 6 true bits >>> leadingones(np.array([1, 1, 0, 1, 1, 1, 0, 1])) 6

# n = 8 and 6 true bits >>> leadingones(np.array([1, 1, 0, 1, 1, 1, 0, 1])) 6

# n = 8 and 7 true bits >>> leadingones(np.array([0, 1, 1, 1, 1, 1, 1, 1])) 8

# n = 8 and 7 true bits >>> leadingones(np.array([1, 1, 0, 1, 1, 1, 1, 1])) 6

# n = 8 and 7 true bits >>> leadingones(np.array([1, 1, 1, 1, 1, 0, 1, 1])) 3

# n = 8 and 8 true bits >>> leadingones(np.array([1, 1, 1, 1, 1, 1, 1, 1])) 0

# n = 9 and 0 true bits >>> leadingones(np.array([0, 0, 0, 0, 0, 0, 0, 0, 0])) 9

# n = 9 and 1 true bit >>> leadingones(np.array([0, 0, 0, 0, 0, 1, 0, 0, 0])) 9

# n = 9 and 1 true bit >>> leadingones(np.array([0, 0, 0, 0, 1, 0, 0, 0, 0])) 9

# n = 9 and 1 true bit >>> leadingones(np.array([0, 0, 1, 0, 0, 0, 0, 0, 0])) 9

# n = 9 and 2 true bits >>> leadingones(np.array([0, 0, 0, 0, 0, 1, 0, 0, 1])) 9

# n = 9 and 2 true bits >>> leadingones(np.array([0, 0, 0, 0, 1, 1, 0, 0, 0])) 9

# n = 9 and 2 true bits >>> leadingones(np.array([1, 0, 0, 0, 0, 0, 1, 0, 0])) 8

# n = 9 and 3 true bits >>> leadingones(np.array([0, 1, 0, 0, 1, 0, 0, 0, 1])) 9

# n = 9 and 3 true bits >>> leadingones(np.array([0, 1, 1, 0, 0, 1, 0, 0, 0])) 9

# n = 9 and 3 true bits >>> leadingones(np.array([0, 1, 1, 0, 0, 0, 0, 0, 1])) 9

# n = 9 and 4 true bits >>> leadingones(np.array([0, 1, 0, 0, 1, 0, 0, 1, 1])) 9

# n = 9 and 4 true bits >>> leadingones(np.array([1, 1, 0, 0, 1, 0, 0, 1, 0])) 7

# n = 9 and 4 true bits >>> leadingones(np.array([0, 1, 1, 1, 0, 0, 1, 0, 0])) 9

# n = 9 and 5 true bits >>> leadingones(np.array([0, 0, 1, 1, 1, 1, 0, 1, 0])) 9

# n = 9 and 5 true bits >>> leadingones(np.array([0, 0, 1, 1, 1, 0, 0, 1, 1])) 9

# n = 9 and 5 true bits >>> leadingones(np.array([1, 0, 0, 1, 1, 0, 0, 1, 1])) 8

# n = 9 and 6 true bits >>> leadingones(np.array([1, 1, 1, 0, 1, 1, 0, 0, 1])) 6

# n = 9 and 6 true bits >>> leadingones(np.array([1, 0, 1, 1, 1, 1, 1, 0, 0])) 8

# n = 9 and 6 true bits >>> leadingones(np.array([1, 1, 0, 1, 1, 1, 0, 0, 1])) 7

# n = 9 and 7 true bits >>> leadingones(np.array([1, 1, 0, 1, 0, 1, 1, 1, 1])) 7

# n = 9 and 7 true bits >>> leadingones(np.array([1, 0, 1, 1, 1, 1, 0, 1, 1])) 8

# n = 9 and 7 true bits >>> leadingones(np.array([1, 0, 1, 1, 1, 0, 1, 1, 1])) 8

# n = 9 and 8 true bits >>> leadingones(np.array([1, 1, 1, 0, 1, 1, 1, 1, 1])) 6

# n = 9 and 8 true bits >>> leadingones(np.array([1, 0, 1, 1, 1, 1, 1, 1, 1])) 8

# n = 9 and 8 true bits >>> leadingones(np.array([1, 0, 1, 1, 1, 1, 1, 1, 1])) 8

# n = 9 and 9 true bits >>> leadingones(np.array([1, 1, 1, 1, 1, 1, 1, 1, 1])) 0

# n = 10 and 0 true bits >>> leadingones(np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0])) 10

# n = 10 and 1 true bit >>> leadingones(np.array([0, 0, 0, 0, 1, 0, 0, 0, 0, 0])) 10

# n = 10 and 1 true bit >>> leadingones(np.array([1, 0, 0, 0, 0, 0, 0, 0, 0, 0])) 9

# n = 10 and 1 true bit >>> leadingones(np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 1])) 10

# n = 10 and 2 true bits >>> leadingones(np.array([0, 1, 1, 0, 0, 0, 0, 0, 0, 0])) 10

# n = 10 and 2 true bits >>> leadingones(np.array([0, 0, 1, 1, 0, 0, 0, 0, 0, 0])) 10

# n = 10 and 2 true bits >>> leadingones(np.array([0, 0, 0, 0, 0, 0, 0, 0, 1, 1])) 10

# n = 10 and 3 true bits >>> leadingones(np.array([0, 1, 0, 1, 0, 0, 0, 1, 0, 0])) 10

# n = 10 and 3 true bits >>> leadingones(np.array([1, 0, 0, 0, 1, 0, 0, 1, 0, 0])) 9

# n = 10 and 3 true bits >>> leadingones(np.array([0, 1, 0, 0, 0, 1, 0, 0, 0, 1])) 10

# n = 10 and 4 true bits >>> leadingones(np.array([1, 1, 0, 0, 0, 1, 0, 0, 1, 0])) 8

# n = 10 and 4 true bits >>> leadingones(np.array([1, 0, 0, 1, 0, 1, 1, 0, 0, 0])) 9

# n = 10 and 4 true bits >>> leadingones(np.array([1, 0, 0, 0, 1, 1, 0, 0, 0, 1])) 9

# n = 10 and 5 true bits >>> leadingones(np.array([0, 0, 0, 1, 1, 1, 0, 0, 1, 1])) 10

# n = 10 and 5 true bits >>> leadingones(np.array([0, 0, 1, 1, 0, 1, 1, 1, 0, 0])) 10

# n = 10 and 5 true bits >>> leadingones(np.array([0, 1, 1, 1, 1, 0, 0, 1, 0, 0])) 10

# n = 10 and 6 true bits >>> leadingones(np.array([1, 0, 1, 1, 1, 1, 1, 0, 0, 0])) 9

# n = 10 and 6 true bits >>> leadingones(np.array([1, 1, 1, 0, 1, 0, 1, 1, 0, 0])) 7

# n = 10 and 6 true bits >>> leadingones(np.array([1, 1, 1, 0, 1, 0, 1, 0, 0, 1])) 7

# n = 10 and 7 true bits >>> leadingones(np.array([0, 1, 1, 1, 1, 1, 0, 1, 1, 0])) 10

# n = 10 and 7 true bits >>> leadingones(np.array([0, 1, 0, 1, 1, 1, 1, 1, 1, 0])) 10

# n = 10 and 7 true bits >>> leadingones(np.array([1, 1, 1, 1, 1, 0, 0, 1, 0, 1])) 5

# n = 10 and 8 true bits >>> leadingones(np.array([1, 0, 1, 1, 1, 1, 1, 1, 0, 1])) 9

# n = 10 and 8 true bits >>> leadingones(np.array([1, 1, 1, 0, 1, 1, 0, 1, 1, 1])) 7

# n = 10 and 8 true bits >>> leadingones(np.array([1, 1, 1, 1, 0, 0, 1, 1, 1, 1])) 6

# n = 10 and 9 true bits >>> leadingones(np.array([1, 1, 1, 1, 0, 1, 1, 1, 1, 1])) 6

# n = 10 and 9 true bits >>> leadingones(np.array([1, 0, 1, 1, 1, 1, 1, 1, 1, 1])) 9

# n = 10 and 9 true bits >>> leadingones(np.array([0, 1, 1, 1, 1, 1, 1, 1, 1, 1])) 10

# n = 10 and 10 true bits >>> leadingones(np.array([1, 1, 1, 1, 1, 1, 1, 1, 1, 1])) 0

moptipy.examples.bitstrings.linearharmonic module

The linear harmonic objective function.

The bit at index i for i in 0..n-1 has weight i+1. This is the penalty that is incurred if the bit is set to False. The best objective value, 0, is hence obtained if all bits are True. The worst objective value, i.e., n * (n + 1) // 2, is obtained if all bits are False.

  1. Carola Doerr, Furong Ye, Naama Horesh, Hao Wang, Ofer M. Shir, and Thomas Bäck. Benchmarking Discrete Optimization Heuristics with IOHprofiler. Applied Soft Computing Journal. 88:106027. 2020. doi: https://doi.org/10.1016/j.asoc.2019.106027

  2. Stefan Droste, Thomas Jansen, and Ingo Wegener. On the Analysis of the (1+1) Evolutionary Algorithm. Theoretical Computer Science. 276(1-2):51-81. April 2002. doi: https://doi.org/10.1016/S0304-3975(01)00182-7

  3. Thomas Weise, Zhize Wu, Xinlu Li, Yan Chen, and Jörg Lässig. Frequency Fitness Assignment: Optimization without Bias for Good Solutions can be Efficient. IEEE Transactions on Evolutionary Computation (TEVC). 27(4):980-992. August 2023. doi: https://doi.org/10.1109/TEVC.2022.3191698

This is code is part of the research work of Mr. Jiazheng ZENG (曾嘉政), a Master’s student at the Institute of Applied Optimization (应用优化研究所, http://iao.hfuu.edu.cn) of the School of Artificial Intelligence and Big Data (人工智能与大数据学院) at Hefei University (合肥大学) in Hefei, Anhui, China (中国安徽省合肥市) under the supervision of Prof. Dr. Thomas Weise (汤卫思教授).

class moptipy.examples.bitstrings.linearharmonic.LinearHarmonic(n)[source]

Bases: BitStringProblem

The objective function of the linear harmonic benchmark problem.

classmethod default_instances(scale_min=2, scale_max=333)[source]

Get the 78 default instances of the LinearHarmonic problem.

Parameters:
  • scale_min (int, default: 2) – the minimum permitted scale, by default 2

  • scale_max (int, default: 333) – the maximum permitted scale, by default 333

Return type:

Iterator[Callable[[], LinearHarmonic]]

Returns:

a sequence of default LinearHarmonic instances

>>> len(list(LinearHarmonic.default_instances()))
78
>>> [x() for x in LinearHarmonic.default_instances()]
[linharm_2, linharm_3, linharm_4, linharm_5, linharm_6, linharm_7, linharm_8, linharm_9, linharm_10, linharm_11, linharm_12, linharm_13, linharm_14, linharm_15, linharm_16, linharm_17, linharm_18, linharm_19, linharm_20, linharm_21, linharm_22, linharm_23, linharm_24, linharm_25, linharm_26, linharm_27, linharm_28, linharm_29, linharm_30, linharm_31, linharm_32, linharm_33, linharm_36, linharm_40, linharm_41, linharm_42, linharm_44, linharm_48, linharm_49, linharm_50, linharm_55, linharm_59, linharm_60, linharm_64, linharm_66, linharm_70, linharm_77, linharm_79, linharm_80, linharm_81, linharm_85, linharm_88, linharm_90, linharm_96, linharm_99, linharm_100, linharm_107, linharm_111, linharm_121, linharm_125, linharm_128, linharm_144, linharm_149, linharm_169, linharm_170, linharm_192, linharm_196, linharm_199, linharm_200, linharm_222, linharm_225, linharm_243, linharm_256, linharm_269, linharm_289, linharm_300, linharm_324, linharm_333]
upper_bound()[source]

Return the upper bound of the linear harmonic function.

Return type:

int

Returns:

n * (n + 1) // 2

>>> LinearHarmonic(5).upper_bound()
15
moptipy.examples.bitstrings.linearharmonic.linear_harmonic(x)[source]

Evaluate the linear function with harmonic weights.

Parameters:

x (ndarray) – np array representing the bit string

Return type:

float

Returns:

the objective value

>>> linear_harmonic(np.array([True, True, True]))
0
>>> linear_harmonic(np.array([False, True, True]))
1
>>> linear_harmonic(np.array([True, False, True]))
2
>>> linear_harmonic(np.array([True, True, False]))
3
>>> linear_harmonic(np.array([False, False, True]))
3
>>> linear_harmonic(np.array([False, True, False]))
4
>>> linear_harmonic(np.array([True, False, False]))
5
>>> linear_harmonic(np.array([False, False, False]))
6
>>> (3 * (3 + 1)) // 2
6
>>> linear_harmonic(np.array([True, True, True, True]))
0
>>> linear_harmonic(np.array([False, True, True, True]))
1
>>> linear_harmonic(np.array([True, False, True, True]))
2
>>> linear_harmonic(np.array([True, True, False, True]))
3
>>> linear_harmonic(np.array([True, True, True, False]))
4
>>> linear_harmonic(np.array([False, False, True, True]))
3
>>> linear_harmonic(np.array([False, True, False, True]))
4
>>> linear_harmonic(np.array([False, True, True, False]))
5
>>> linear_harmonic(np.array([True, False, False, True]))
5
>>> linear_harmonic(np.array([True, False, True, False]))
6
>>> linear_harmonic(np.array([True, True, False, False]))
7
>>> linear_harmonic(np.array([False, False, False, True]))
6
>>> linear_harmonic(np.array([False, False, True, False]))
7
>>> linear_harmonic(np.array([False, True, False, False]))
8
>>> linear_harmonic(np.array([True, False, False, False]))
9
>>> linear_harmonic(np.array([False, False, False, False]))
10
>>> 4 * (4 + 1) // 2
10

# n = 1 and 0 true bits >>> linear_harmonic(np.array([0])) 1

# n = 1 and 1 true bit >>> linear_harmonic(np.array([1])) 0

# n = 2 and 0 true bits >>> linear_harmonic(np.array([0, 0])) 3

# n = 2 and 1 true bit >>> linear_harmonic(np.array([1, 0])) 2

# n = 2 and 1 true bit >>> linear_harmonic(np.array([1, 0])) 2

# n = 2 and 1 true bit >>> linear_harmonic(np.array([1, 0])) 2

# n = 2 and 2 true bits >>> linear_harmonic(np.array([1, 1])) 0

# n = 3 and 0 true bits >>> linear_harmonic(np.array([0, 0, 0])) 6

# n = 3 and 1 true bit >>> linear_harmonic(np.array([0, 1, 0])) 4

# n = 3 and 1 true bit >>> linear_harmonic(np.array([0, 0, 1])) 3

# n = 3 and 1 true bit >>> linear_harmonic(np.array([1, 0, 0])) 5

# n = 3 and 2 true bits >>> linear_harmonic(np.array([0, 1, 1])) 1

# n = 3 and 2 true bits >>> linear_harmonic(np.array([1, 0, 1])) 2

# n = 3 and 2 true bits >>> linear_harmonic(np.array([1, 1, 0])) 3

# n = 3 and 3 true bits >>> linear_harmonic(np.array([1, 1, 1])) 0

# n = 4 and 0 true bits >>> linear_harmonic(np.array([0, 0, 0, 0])) 10

# n = 4 and 1 true bit >>> linear_harmonic(np.array([1, 0, 0, 0])) 9

# n = 4 and 1 true bit >>> linear_harmonic(np.array([1, 0, 0, 0])) 9

# n = 4 and 1 true bit >>> linear_harmonic(np.array([1, 0, 0, 0])) 9

# n = 4 and 2 true bits >>> linear_harmonic(np.array([0, 1, 1, 0])) 5

# n = 4 and 2 true bits >>> linear_harmonic(np.array([0, 1, 0, 1])) 4

# n = 4 and 2 true bits >>> linear_harmonic(np.array([1, 0, 0, 1])) 5

# n = 4 and 3 true bits >>> linear_harmonic(np.array([1, 1, 0, 1])) 3

# n = 4 and 3 true bits >>> linear_harmonic(np.array([0, 1, 1, 1])) 1

# n = 4 and 3 true bits >>> linear_harmonic(np.array([1, 0, 1, 1])) 2

# n = 4 and 4 true bits >>> linear_harmonic(np.array([1, 1, 1, 1])) 0

# n = 5 and 0 true bits >>> linear_harmonic(np.array([0, 0, 0, 0, 0])) 15

# n = 5 and 1 true bit >>> linear_harmonic(np.array([0, 1, 0, 0, 0])) 13

# n = 5 and 1 true bit >>> linear_harmonic(np.array([1, 0, 0, 0, 0])) 14

# n = 5 and 2 true bits >>> linear_harmonic(np.array([0, 0, 1, 0, 1])) 7

# n = 5 and 2 true bits >>> linear_harmonic(np.array([0, 1, 0, 1, 0])) 9

# n = 5 and 2 true bits >>> linear_harmonic(np.array([1, 0, 0, 1, 0])) 10

# n = 5 and 3 true bits >>> linear_harmonic(np.array([0, 0, 1, 1, 1])) 3

# n = 5 and 3 true bits >>> linear_harmonic(np.array([0, 0, 1, 1, 1])) 3

# n = 5 and 3 true bits >>> linear_harmonic(np.array([1, 0, 1, 0, 1])) 6

# n = 5 and 4 true bits >>> linear_harmonic(np.array([1, 1, 1, 1, 0])) 5

# n = 5 and 4 true bits >>> linear_harmonic(np.array([1, 1, 1, 1, 0])) 5

# n = 5 and 4 true bits >>> linear_harmonic(np.array([1, 1, 1, 1, 0])) 5

# n = 5 and 5 true bits >>> linear_harmonic(np.array([1, 1, 1, 1, 1])) 0

# n = 6 and 0 true bits >>> linear_harmonic(np.array([0, 0, 0, 0, 0, 0])) 21

# n = 6 and 1 true bit >>> linear_harmonic(np.array([0, 0, 0, 0, 1, 0])) 16

# n = 6 and 1 true bit >>> linear_harmonic(np.array([0, 0, 1, 0, 0, 0])) 18

# n = 6 and 1 true bit >>> linear_harmonic(np.array([0, 0, 0, 0, 0, 1])) 15

# n = 6 and 2 true bits >>> linear_harmonic(np.array([1, 0, 1, 0, 0, 0])) 17

# n = 6 and 2 true bits >>> linear_harmonic(np.array([0, 0, 1, 0, 1, 0])) 13

# n = 6 and 2 true bits >>> linear_harmonic(np.array([0, 0, 0, 0, 1, 1])) 10

# n = 6 and 3 true bits >>> linear_harmonic(np.array([0, 1, 0, 0, 1, 1])) 8

# n = 6 and 3 true bits >>> linear_harmonic(np.array([1, 1, 0, 0, 0, 1])) 12

# n = 6 and 3 true bits >>> linear_harmonic(np.array([1, 1, 0, 0, 1, 0])) 13

# n = 6 and 4 true bits >>> linear_harmonic(np.array([1, 1, 1, 1, 0, 0])) 11

# n = 6 and 4 true bits >>> linear_harmonic(np.array([1, 1, 0, 1, 1, 0])) 9

# n = 6 and 4 true bits >>> linear_harmonic(np.array([1, 1, 1, 0, 0, 1])) 9

# n = 6 and 5 true bits >>> linear_harmonic(np.array([1, 1, 0, 1, 1, 1])) 3

# n = 6 and 5 true bits >>> linear_harmonic(np.array([1, 1, 1, 1, 1, 0])) 6

# n = 6 and 5 true bits >>> linear_harmonic(np.array([1, 1, 1, 1, 0, 1])) 5

# n = 6 and 6 true bits >>> linear_harmonic(np.array([1, 1, 1, 1, 1, 1])) 0

# n = 7 and 0 true bits >>> linear_harmonic(np.array([0, 0, 0, 0, 0, 0, 0])) 28

# n = 7 and 1 true bit >>> linear_harmonic(np.array([0, 0, 1, 0, 0, 0, 0])) 25

# n = 7 and 1 true bit >>> linear_harmonic(np.array([0, 0, 0, 1, 0, 0, 0])) 24

# n = 7 and 1 true bit >>> linear_harmonic(np.array([1, 0, 0, 0, 0, 0, 0])) 27

# n = 7 and 2 true bits >>> linear_harmonic(np.array([0, 1, 0, 0, 0, 1, 0])) 20

# n = 7 and 2 true bits >>> linear_harmonic(np.array([0, 0, 0, 0, 1, 0, 1])) 16

# n = 7 and 2 true bits >>> linear_harmonic(np.array([1, 0, 0, 0, 0, 1, 0])) 21

# n = 7 and 3 true bits >>> linear_harmonic(np.array([0, 1, 0, 0, 0, 1, 1])) 13

# n = 7 and 3 true bits >>> linear_harmonic(np.array([1, 0, 0, 1, 0, 0, 1])) 16

# n = 7 and 3 true bits >>> linear_harmonic(np.array([0, 1, 0, 0, 0, 1, 1])) 13

# n = 7 and 4 true bits >>> linear_harmonic(np.array([1, 1, 0, 1, 0, 0, 1])) 14

# n = 7 and 4 true bits >>> linear_harmonic(np.array([1, 0, 1, 0, 1, 0, 1])) 12

# n = 7 and 4 true bits >>> linear_harmonic(np.array([0, 0, 1, 1, 1, 1, 0])) 10

# n = 7 and 5 true bits >>> linear_harmonic(np.array([1, 1, 1, 0, 0, 1, 1])) 9

# n = 7 and 5 true bits >>> linear_harmonic(np.array([1, 1, 1, 1, 0, 1, 0])) 12

# n = 7 and 5 true bits >>> linear_harmonic(np.array([1, 1, 0, 1, 0, 1, 1])) 8

# n = 7 and 6 true bits >>> linear_harmonic(np.array([1, 1, 1, 1, 1, 1, 0])) 7

# n = 7 and 6 true bits >>> linear_harmonic(np.array([1, 1, 1, 1, 1, 1, 0])) 7

# n = 7 and 6 true bits >>> linear_harmonic(np.array([1, 1, 0, 1, 1, 1, 1])) 3

# n = 7 and 7 true bits >>> linear_harmonic(np.array([1, 1, 1, 1, 1, 1, 1])) 0

# n = 8 and 0 true bits >>> linear_harmonic(np.array([0, 0, 0, 0, 0, 0, 0, 0])) 36

# n = 8 and 1 true bit >>> linear_harmonic(np.array([0, 1, 0, 0, 0, 0, 0, 0])) 34

# n = 8 and 1 true bit >>> linear_harmonic(np.array([0, 0, 0, 0, 1, 0, 0, 0])) 31

# n = 8 and 1 true bit >>> linear_harmonic(np.array([0, 1, 0, 0, 0, 0, 0, 0])) 34

# n = 8 and 2 true bits >>> linear_harmonic(np.array([0, 0, 1, 1, 0, 0, 0, 0])) 29

# n = 8 and 2 true bits >>> linear_harmonic(np.array([0, 0, 1, 0, 0, 0, 1, 0])) 26

# n = 8 and 2 true bits >>> linear_harmonic(np.array([0, 0, 0, 0, 0, 1, 0, 1])) 22

# n = 8 and 3 true bits >>> linear_harmonic(np.array([1, 1, 0, 0, 0, 0, 0, 1])) 25

# n = 8 and 3 true bits >>> linear_harmonic(np.array([1, 1, 0, 0, 0, 0, 0, 1])) 25

# n = 8 and 3 true bits >>> linear_harmonic(np.array([0, 0, 0, 0, 1, 1, 0, 1])) 17

# n = 8 and 4 true bits >>> linear_harmonic(np.array([1, 1, 1, 0, 0, 0, 0, 1])) 22

# n = 8 and 4 true bits >>> linear_harmonic(np.array([1, 1, 1, 0, 0, 0, 0, 1])) 22

# n = 8 and 4 true bits >>> linear_harmonic(np.array([1, 0, 1, 0, 0, 1, 0, 1])) 18

# n = 8 and 5 true bits >>> linear_harmonic(np.array([0, 1, 1, 1, 0, 1, 0, 1])) 13

# n = 8 and 5 true bits >>> linear_harmonic(np.array([0, 0, 1, 0, 1, 1, 1, 1])) 7

# n = 8 and 5 true bits >>> linear_harmonic(np.array([1, 1, 1, 1, 0, 0, 1, 0])) 19

# n = 8 and 6 true bits >>> linear_harmonic(np.array([0, 1, 1, 1, 1, 0, 1, 1])) 7

# n = 8 and 6 true bits >>> linear_harmonic(np.array([0, 1, 1, 1, 1, 1, 1, 0])) 9

# n = 8 and 6 true bits >>> linear_harmonic(np.array([1, 1, 1, 1, 0, 1, 1, 0])) 13

# n = 8 and 7 true bits >>> linear_harmonic(np.array([1, 1, 1, 1, 1, 1, 0, 1])) 7

# n = 8 and 7 true bits >>> linear_harmonic(np.array([1, 1, 1, 0, 1, 1, 1, 1])) 4

# n = 8 and 7 true bits >>> linear_harmonic(np.array([1, 0, 1, 1, 1, 1, 1, 1])) 2

# n = 8 and 8 true bits >>> linear_harmonic(np.array([1, 1, 1, 1, 1, 1, 1, 1])) 0

# n = 9 and 0 true bits >>> linear_harmonic(np.array([0, 0, 0, 0, 0, 0, 0, 0, 0])) 45

# n = 9 and 1 true bit >>> linear_harmonic(np.array([0, 1, 0, 0, 0, 0, 0, 0, 0])) 43

# n = 9 and 1 true bit >>> linear_harmonic(np.array([0, 0, 0, 0, 0, 0, 0, 1, 0])) 37

# n = 9 and 1 true bit >>> linear_harmonic(np.array([0, 0, 0, 0, 0, 1, 0, 0, 0])) 39

# n = 9 and 2 true bits >>> linear_harmonic(np.array([0, 0, 0, 1, 0, 1, 0, 0, 0])) 35

# n = 9 and 2 true bits >>> linear_harmonic(np.array([1, 0, 0, 1, 0, 0, 0, 0, 0])) 40

# n = 9 and 2 true bits >>> linear_harmonic(np.array([1, 1, 0, 0, 0, 0, 0, 0, 0])) 42

# n = 9 and 3 true bits >>> linear_harmonic(np.array([0, 0, 0, 0, 1, 0, 0, 1, 1])) 23

# n = 9 and 3 true bits >>> linear_harmonic(np.array([0, 0, 1, 1, 1, 0, 0, 0, 0])) 33

# n = 9 and 3 true bits >>> linear_harmonic(np.array([0, 1, 1, 0, 0, 0, 1, 0, 0])) 33

# n = 9 and 4 true bits >>> linear_harmonic(np.array([1, 0, 1, 0, 0, 1, 0, 1, 0])) 27

# n = 9 and 4 true bits >>> linear_harmonic(np.array([0, 0, 1, 1, 0, 1, 0, 0, 1])) 23

# n = 9 and 4 true bits >>> linear_harmonic(np.array([0, 1, 0, 1, 0, 1, 0, 0, 1])) 24

# n = 9 and 5 true bits >>> linear_harmonic(np.array([1, 0, 0, 1, 0, 1, 1, 0, 1])) 18

# n = 9 and 5 true bits >>> linear_harmonic(np.array([1, 0, 0, 1, 1, 0, 0, 1, 1])) 18

# n = 9 and 5 true bits >>> linear_harmonic(np.array([0, 1, 1, 1, 0, 1, 0, 0, 1])) 21

# n = 9 and 6 true bits >>> linear_harmonic(np.array([1, 1, 0, 0, 1, 1, 1, 1, 0])) 16

# n = 9 and 6 true bits >>> linear_harmonic(np.array([1, 1, 0, 1, 0, 1, 1, 0, 1])) 16

# n = 9 and 6 true bits >>> linear_harmonic(np.array([1, 1, 1, 0, 1, 0, 1, 1, 0])) 19

# n = 9 and 7 true bits >>> linear_harmonic(np.array([1, 1, 1, 1, 1, 1, 0, 1, 0])) 16

# n = 9 and 7 true bits >>> linear_harmonic(np.array([1, 1, 1, 1, 1, 1, 1, 0, 0])) 17

# n = 9 and 7 true bits >>> linear_harmonic(np.array([0, 1, 0, 1, 1, 1, 1, 1, 1])) 4

# n = 9 and 8 true bits >>> linear_harmonic(np.array([1, 1, 1, 1, 1, 0, 1, 1, 1])) 6

# n = 9 and 8 true bits >>> linear_harmonic(np.array([0, 1, 1, 1, 1, 1, 1, 1, 1])) 1

# n = 9 and 8 true bits >>> linear_harmonic(np.array([1, 1, 1, 1, 1, 1, 0, 1, 1])) 7

# n = 9 and 9 true bits >>> linear_harmonic(np.array([1, 1, 1, 1, 1, 1, 1, 1, 1])) 0

# n = 10 and 0 true bits >>> linear_harmonic(np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0])) 55

# n = 10 and 1 true bit >>> linear_harmonic(np.array([0, 0, 0, 0, 0, 0, 0, 0, 1, 0])) 46

# n = 10 and 1 true bit >>> linear_harmonic(np.array([0, 0, 0, 0, 1, 0, 0, 0, 0, 0])) 50

# n = 10 and 1 true bit >>> linear_harmonic(np.array([0, 1, 0, 0, 0, 0, 0, 0, 0, 0])) 53

# n = 10 and 2 true bits >>> linear_harmonic(np.array([0, 0, 1, 0, 0, 1, 0, 0, 0, 0])) 46

# n = 10 and 2 true bits >>> linear_harmonic(np.array([0, 0, 1, 0, 1, 0, 0, 0, 0, 0])) 47

# n = 10 and 2 true bits >>> linear_harmonic(np.array([0, 0, 0, 0, 0, 0, 0, 0, 1, 1])) 36

# n = 10 and 3 true bits >>> linear_harmonic(np.array([1, 0, 0, 0, 0, 0, 1, 0, 0, 1])) 37

# n = 10 and 3 true bits >>> linear_harmonic(np.array([0, 0, 0, 1, 0, 0, 0, 1, 1, 0])) 34

# n = 10 and 3 true bits >>> linear_harmonic(np.array([0, 0, 1, 1, 0, 0, 0, 0, 0, 1])) 38

# n = 10 and 4 true bits >>> linear_harmonic(np.array([0, 1, 1, 0, 0, 0, 0, 1, 1, 0])) 33

# n = 10 and 4 true bits >>> linear_harmonic(np.array([0, 1, 0, 0, 0, 1, 1, 0, 1, 0])) 31

# n = 10 and 4 true bits >>> linear_harmonic(np.array([0, 1, 1, 0, 0, 1, 0, 0, 0, 1])) 34

# n = 10 and 5 true bits >>> linear_harmonic(np.array([1, 0, 0, 1, 0, 0, 1, 1, 1, 0])) 26

# n = 10 and 5 true bits >>> linear_harmonic(np.array([0, 0, 1, 0, 1, 1, 1, 0, 1, 0])) 25

# n = 10 and 5 true bits >>> linear_harmonic(np.array([0, 0, 0, 1, 1, 0, 0, 1, 1, 1])) 19

# n = 10 and 6 true bits >>> linear_harmonic(np.array([1, 1, 0, 0, 1, 1, 1, 0, 0, 1])) 24

# n = 10 and 6 true bits >>> linear_harmonic(np.array([0, 1, 1, 1, 1, 0, 1, 0, 0, 1])) 24

# n = 10 and 6 true bits >>> linear_harmonic(np.array([0, 0, 1, 0, 1, 1, 1, 1, 0, 1])) 16

# n = 10 and 7 true bits >>> linear_harmonic(np.array([1, 0, 1, 1, 1, 0, 1, 1, 1, 0])) 18

# n = 10 and 7 true bits >>> linear_harmonic(np.array([1, 0, 1, 0, 1, 1, 0, 1, 1, 1])) 13

# n = 10 and 7 true bits >>> linear_harmonic(np.array([1, 1, 1, 1, 1, 1, 0, 1, 0, 0])) 26

# n = 10 and 8 true bits >>> linear_harmonic(np.array([1, 1, 0, 1, 1, 1, 1, 1, 1, 0])) 13

# n = 10 and 8 true bits >>> linear_harmonic(np.array([1, 1, 0, 1, 1, 1, 1, 0, 1, 1])) 11

# n = 10 and 8 true bits >>> linear_harmonic(np.array([1, 0, 1, 1, 1, 0, 1, 1, 1, 1])) 8

# n = 10 and 9 true bits >>> linear_harmonic(np.array([1, 1, 1, 1, 1, 1, 1, 1, 0, 1])) 9

# n = 10 and 9 true bits >>> linear_harmonic(np.array([1, 1, 0, 1, 1, 1, 1, 1, 1, 1])) 3

# n = 10 and 9 true bits >>> linear_harmonic(np.array([1, 1, 0, 1, 1, 1, 1, 1, 1, 1])) 3

# n = 10 and 10 true bits >>> linear_harmonic(np.array([1, 1, 1, 1, 1, 1, 1, 1, 1, 1])) 0

moptipy.examples.bitstrings.nqueens module

The N-Queens problem.

The N-Queens problem is defined for bit strings of length n = N ** 2. A bit string x is mapped to a chess board and a queen is placed for any bit of value 1. The goal is to place N queens such that they cannot attack each other. The total number of queens on the board be Q(x) is the number of True bits, which might be more or less than N. We also count the number ez(x) of queens in every single row, column, and diagonal z of the chess board. The minimization version of the N-Queens problem is then N - Q(x) + N sum_(all z) max(0, ez(x) - 1). The N-Queens problems are attested moderate difficulty in [1].

Here, N is stored in the k-value of the benchmark function instances.

The best possible objective value of this function is achieved if exactly k=N queens are positioned such that none can beat any other queen. The objective function then returns 0.

The worst case is if a queen is placed on every single field, i.e., if we have n = k*k queens on the field. Then, the objective value will be (((((k - 2) * 4) + 1) * k) + 3) * k.

  1. Carola Doerr, Furong Ye, Naama Horesh, Hao Wang, Ofer M. Shir, and Thomas Bäck. Benchmarking Discrete Optimization Heuristics with IOHprofiler. Applied Soft Computing Journal. 88:106027. 2020. doi: https://doi.org/10.1016/j.asoc.2019.106027

  2. Thomas Weise, Zhize Wu, Xinlu Li, Yan Chen, and Jörg Lässig. Frequency Fitness Assignment: Optimization without Bias for Good Solutions can be Efficient. IEEE Transactions on Evolutionary Computation (TEVC). 27(4):980-992. August 2023. doi: https://doi.org/10.1109/TEVC.2022.3191698

This is code is part of the research work of Mr. Jiazheng ZENG (曾嘉政), a Master’s student at the Institute of Applied Optimization (应用优化研究所, http://iao.hfuu.edu.cn) of the School of Artificial Intelligence and Big Data (人工智能与大数据学院) at Hefei University (合肥大学) in Hefei, Anhui, China (中国安徽省合肥市) under the supervision of Prof. Dr. Thomas Weise (汤卫思教授).

class moptipy.examples.bitstrings.nqueens.NQueens(n)[source]

Bases: SquareBitStringProblem

The N-Queens problem.

classmethod default_instances(scale_min=16, scale_max=144)[source]

Get the 9 default instances of the NQueens problem.

Parameters:
  • scale_min (int, default: 16) – the minimum permitted scale, by default 16

  • scale_max (int, default: 144) – the maximum permitted scale, by default 144

Return type:

Iterator[Callable[[], NQueens]]

Returns:

a sequence of default NQueens instances

>>> len(list(NQueens.default_instances()))
9
>>> [x() for x in NQueens.default_instances()]
[nqueens_16, nqueens_25, nqueens_36, nqueens_49, nqueens_64, nqueens_81, nqueens_100, nqueens_121, nqueens_144]
evaluate(x)[source]

Evaluate a solution to the N-Queens problem.

Parameters:

x (ndarray) – the bit string to evaluate

Return type:

int

Returns:

the value of the N-Queens problem for the string

upper_bound()[source]

Compute the upper bound of the N-Queens objective function.

Return type:

int

>>> NQueens(4 * 4).upper_bound()
156
>>> NQueens(5 * 5).upper_bound()
340
>>> NQueens(6 * 6).upper_bound()
630
>>> NQueens(7 * 7).upper_bound()
1050
>>> NQueens(8 * 8).upper_bound()
1624
>>> NQueens(9 * 9).upper_bound()
2376
>>> NQueens(10 * 10).upper_bound()
3330
>>> NQueens(20 * 20).upper_bound()
29260
>>> NQueens(30 * 30).upper_bound()
101790
>>> NQueens(100 * 100).upper_bound()
3930300
>>> NQueens(6241).upper_bound()
1928706
>>> NQueens(4225).upper_bound()
1069120
moptipy.examples.bitstrings.nqueens.nqueens(x, k)[source]

Evaluate the N-Queens objective function.

Parameters:
  • x (ndarray) – the np array representing the board (bit string)

  • k (int) – the total number of queens (dimension of the problem)

Return type:

int

Returns:

the penalty score

>>> nqueens(np.array([False,  True, False, False,
...                   False, False, False,  True,
...                    True, False, False, False,
...                   False, False,  True, False]), 4)
0
>>> nqueens(np.array([False, False,  True, False,
...                    True, False, False, False,
...                   False, False, False,  True,
...                   False,  True, False, False]), 4)
0
>>> nqueens(np.array([False, False, False, False,
...                   False, False, False, False,
...                   False, False, False, False,
...                   False, False, False, False]), 4)
4
>>> nqueens(np.array([ True, False, False, False,
...                   False, False, False, False,
...                   False, False, False, False,
...                   False, False, False, False]), 4)
3

# two queens, but in the same row, which gives 2 + 4 >>> nqueens(np.array([ True, True, False, False, … False, False, False, False, … False, False, False, False, … False, False, False, False]), 4) 6

# three queens, but 2 in the same row, 2 in the same column, and 2 in one # diagonal, which gives 1 + 4 + 4 + 4 >>> nqueens(np.array([ True, True, False, False, … True, False, False, False, … False, False, False, False, … False, False, False, False]), 4) 13

# four queens, but 3 in the same row, 2 in the same column, and 2 in one # diagonal, which gives 0 + 8 + 4 + 4 >>> nqueens(np.array([ True, True, True, False, … True, False, False, False, … False, False, False, False, … False, False, False, False]), 4) 16

# five queens, but 4 in the same row, 2 in the same column, and 2 in one # diagonal, which gives -1 + 12 + 4 + 4 >>> nqueens(np.array([ True, True, True, True, … True, False, False, False, … False, False, False, False, … False, False, False, False]), 4) 19

>>> nqueens(np.array([
...     False, False, False, True, False, False, False, False,
...     False, False, False, False, False, True, False, False,
...     False, False, False, False, False, False, False, True,
...     False, True, False, False, False, False, False, False,
...     False, False, False, False, False, False, True, False,
...     True, False, False, False, False, False, False, False,
...     False, False, True, False, False, False, False, False,
...     False, False, False, False, True, False, False, False,]), 8)
0

# five queens, but 4 in the same row, 2 in the same column, and 2 in one # diagonal, which gives -1 + 12 + 4 + 4 >>> nqueens(np.array([1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), 4) 19

# 16 bits, board width = 4, and 2 queens >>> nqueens(np.array([0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0]), 4) 6

# 16 bits, board width = 4, and 2 queens >>> nqueens(np.array([0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0]), 4) 2

# 16 bits, board width = 4, and 2 queens >>> nqueens(np.array([0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0]), 4) 2

# 16 bits, board width = 4, and 3 queens >>> nqueens(np.array([0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0]), 4) 5

# 16 bits, board width = 4, and 4 queens >>> nqueens(np.array([0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0]), 4) 12

# 16 bits, board width = 4, and 4 queens >>> nqueens(np.array([0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0]), 4) 12

# 16 bits, board width = 4, and 4 queens >>> nqueens(np.array([0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0]), 4) 12

# 16 bits, board width = 4, and 4 queens >>> nqueens(np.array([0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0]), 4) 20

# 16 bits, board width = 4, and 11 queens >>> nqueens(np.array([1, 0, 1, 1, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1]), 4) 85

# 16 bits, board width = 4, and 8 queens >>> nqueens(np.array([0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 0, 0]), 4) 52

# 16 bits, board width = 4, and 9 queens >>> nqueens(np.array([1, 0, 0, 1, 0, 1, 0, 0, 1, 1, 1, 1, 0, 1, 1, 0]), 4) 67

# 16 bits, board width = 4, and 10 queens >>> nqueens(np.array([0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 1, 1]), 4) 78

# 16 bits, board width = 4, and 0 queens >>> nqueens(np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), 4) 4

# 16 bits, board width = 4, and 16 queens >>> nqueens(np.array([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]), 4) 156

# 25 bits, board width = 5, and 3 queens >>> nqueens(np.array([0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, … 0, 0, 1, 0, 0, 0, 0, 0]), 5) 17

# 25 bits, board width = 5, and 1 queen >>> nqueens(np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0]), 5) 4

# 25 bits, board width = 5, and 4 queens >>> nqueens(np.array([1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, … 0, 0, 0, 0, 1, 1, 0, 0]), 5) 16

# 25 bits, board width = 5, and 1 queen >>> nqueens(np.array([0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0]), 5) 4

# 25 bits, board width = 5, and 5 queens >>> nqueens(np.array([1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 1, 0, 0, 1, 0]), 5) 25

# 25 bits, board width = 5, and 5 queens >>> nqueens(np.array([0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 0, … 0, 0, 0, 0, 0, 0, 0, 0]), 5) 30

# 25 bits, board width = 5, and 5 queens >>> nqueens(np.array([0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 1]), 5) 15

# 25 bits, board width = 5, and 5 queens >>> nqueens(np.array([0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, … 0, 1, 0, 0, 0, 0, 0, 0]), 5) 20

# 25 bits, board width = 5, and 15 queens >>> nqueens(np.array([1, 0, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 0, 1, 1, … 1, 1, 0, 1, 1, 0, 1, 1]), 5) 160

# 25 bits, board width = 5, and 22 queens >>> nqueens(np.array([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 0, … 1, 1, 1, 1, 1, 1, 1, 1]), 5) 283

# 25 bits, board width = 5, and 18 queens >>> nqueens(np.array([1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 0, 0, 1, 1, 1, … 1, 1, 1, 1, 1, 1, 0, 1]), 5) 217

# 25 bits, board width = 5, and 21 queens >>> nqueens(np.array([0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 1, 1, 1, 1, … 1, 1, 1, 1, 1, 1, 1, 1]), 5) 274

# 25 bits, board width = 5, and 0 queens >>> nqueens(np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0]), 5) 5

# 25 bits, board width = 5, and 25 queens >>> nqueens(np.array([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, … 1, 1, 1, 1, 1, 1, 1, 1]), 5) 340

# 36 bits, board width = 6, and 2 queens >>> nqueens(np.array([0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]), 6) 4

# 36 bits, board width = 6, and 2 queens >>> nqueens(np.array([0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), 6) 4

# 36 bits, board width = 6, and 4 queens >>> nqueens(np.array([0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, … 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), 6) 14

# 36 bits, board width = 6, and 3 queens >>> nqueens(np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0]), 6) 3

# 36 bits, board width = 6, and 6 queens >>> nqueens(np.array([0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, … 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0]), 6) 42

# 36 bits, board width = 6, and 6 queens >>> nqueens(np.array([1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, … 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0]), 6) 42

# 36 bits, board width = 6, and 6 queens >>> nqueens(np.array([1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 0]), 6) 36

# 36 bits, board width = 6, and 6 queens >>> nqueens(np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, … 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 1]), 6) 42

# 36 bits, board width = 6, and 17 queens >>> nqueens(np.array([0, 1, 1, 0, 0, 1, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 0, … 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 1, 0, 0, 0, 1, 1, 0, 0, 1]), 6) 223

# 36 bits, board width = 6, and 13 queens >>> nqueens(np.array([1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 0, 0, 0, 0]), 6) 137

# 36 bits, board width = 6, and 20 queens >>> nqueens(np.array([0, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1, 1, … 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 0, 1, 1, 1, 1, 0, 1]), 6) 274

# 36 bits, board width = 6, and 11 queens >>> nqueens(np.array([0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1, … 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0]), 6) 103

# 36 bits, board width = 6, and 0 queens >>> nqueens(np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), 6) 6

# 36 bits, board width = 6, and 36 queens >>> nqueens(np.array([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, … 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]), 6) 630

# 49 bits, board width = 7, and 1 queen >>> nqueens(np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), 7) 6

# 49 bits, board width = 7, and 2 queens >>> nqueens(np.array([0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), 7) 5

# 49 bits, board width = 7, and 3 queens >>> nqueens(np.array([0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), 7) 4

# 49 bits, board width = 7, and 4 queens >>> nqueens(np.array([0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), 7) 17

# 49 bits, board width = 7, and 7 queens >>> nqueens(np.array([0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, … 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), 7) 70

# 49 bits, board width = 7, and 7 queens >>> nqueens(np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, … 0, 0, 0, 0, 1, 0, 0, 0, 0, 0]), 7) 35

# 49 bits, board width = 7, and 7 queens >>> nqueens(np.array([0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 1, 0, 0, 0, 0, 0, 0, 0]), 7) 42

# 49 bits, board width = 7, and 7 queens >>> nqueens(np.array([0, 0, 0, 1, 0, 1, 1, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, … 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), 7) 63

# 49 bits, board width = 7, and 25 queens >>> nqueens(np.array([1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 0, … 0, 1, 0, 0, 0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 1, 0, 0, 1, 0, 1, 0, 0, … 1, 0, 0, 0, 0, 1, 0, 0, 0, 0]), 7) 437

# 49 bits, board width = 7, and 33 queens >>> nqueens(np.array([1, 1, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 1, 1, 0, … 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, … 1, 1, 1, 1, 0, 1, 0, 1, 1, 0]), 7) 625

# 49 bits, board width = 7, and 24 queens >>> nqueens(np.array([1, 0, 1, 1, 1, 1, 0, 1, 0, 1, 0, 0, 0, 0, 1, 0, 1, … 0, 1, 0, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 0, 1, 1, 0, … 0, 0, 1, 0, 0, 1, 1, 0, 0, 0]), 7) 403

# 49 bits, board width = 7, and 15 queens >>> nqueens(np.array([0, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, … 0, 0, 1, 1, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]), 7) 209

# 49 bits, board width = 7, and 0 queens >>> nqueens(np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), 7) 7

# 49 bits, board width = 7, and 49 queens >>> nqueens(np.array([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, … 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, … 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]), 7) 1050

# 64 bits, board width = 8, and 1 queen >>> nqueens(np.array([0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0]), 8) 7

# 64 bits, board width = 8, and 1 queen >>> nqueens(np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0]), 8) 7

# 64 bits, board width = 8, and 3 queens >>> nqueens(np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0]), 8) 21

# 64 bits, board width = 8, and 6 queens >>> nqueens(np.array([0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, … 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0]), 8) 42

# 64 bits, board width = 8, and 8 queens >>> nqueens(np.array([0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 1, 0]), 8) 64

# 64 bits, board width = 8, and 8 queens >>> nqueens(np.array([0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, … 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, … 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, … 0, 0, 0]), 8) 72

# 64 bits, board width = 8, and 8 queens >>> nqueens(np.array([0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, … 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, … 0, 1, 0]), 8) 56

# 64 bits, board width = 8, and 8 queens >>> nqueens(np.array([0, 0, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0]), 8) 64

# 64 bits, board width = 8, and 20 queens >>> nqueens(np.array([0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 1, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 1, 1, 0, 0, 0, … 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, … 0, 0, 0]), 8) 348

# 64 bits, board width = 8, and 46 queens >>> nqueens(np.array([0, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, … 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 0, 1, … 0, 1, 1, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, … 1, 0, 1]), 8) 1074

# 64 bits, board width = 8, and 29 queens >>> nqueens(np.array([1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, … 1, 0, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 0, … 1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 0, 0, 0, 1, 0, 0, 1, 1, 1, 0, … 0, 0, 1]), 8) 579

# 64 bits, board width = 8, and 20 queens >>> nqueens(np.array([1, 1, 1, 1, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 1, … 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, … 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, … 0, 0, 0]), 8) 300

# 64 bits, board width = 8, and 0 queens >>> nqueens(np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0]), 8) 8

# 64 bits, board width = 8, and 64 queens >>> nqueens(np.array([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, … 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, … 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, … 1, 1, 1]), 8) 1624

# 81 bits, board width = 9, and 1 queen >>> nqueens(np.array([0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), 9) 8

# 81 bits, board width = 9, and 7 queens >>> nqueens(np.array([0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, … 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0]), 9) 56

# 81 bits, board width = 9, and 8 queens >>> nqueens(np.array([0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), 9) 73

# 81 bits, board width = 9, and 3 queens >>> nqueens(np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0]), 9) 15

# 81 bits, board width = 9, and 9 queens >>> nqueens(np.array([0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0]), 9) 81

# 81 bits, board width = 9, and 9 queens >>> nqueens(np.array([0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0]), 9) 63

# 81 bits, board width = 9, and 9 queens >>> nqueens(np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, … 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0]), 9) 90

# 81 bits, board width = 9, and 9 queens >>> nqueens(np.array([0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, … 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), 9) 72

# 81 bits, board width = 9, and 22 queens >>> nqueens(np.array([0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, … 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0, 0, 1, … 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, … 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]), 9) 428

# 81 bits, board width = 9, and 43 queens >>> nqueens(np.array([0, 1, 1, 1, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, … 0, 0, 1, 0, 1, 0, 0, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, … 1, 0, 1, 1, 1, 1, 0, 1, 1, 0, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 0, 1, … 0, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 1, 0, 0]), 9) 1091

# 81 bits, board width = 9, and 18 queens >>> nqueens(np.array([0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, … 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, … 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, … 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0]), 9) 288

# 81 bits, board width = 9, and 24 queens >>> nqueens(np.array([0, 0, 1, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, … 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, … 1, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, … 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1]), 9) 444

# 81 bits, board width = 9, and 0 queens >>> nqueens(np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), 9) 9

# 81 bits, board width = 9, and 81 queens >>> nqueens(np.array([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, … 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, … 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, … 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]), 9) 2376

# 100 bits, board width = 10, and 6 queens >>> nqueens(np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0]), 10) 34

# 100 bits, board width = 10, and 7 queens >>> nqueens(np.array([0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, … 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0]), 10) 43

# 100 bits, board width = 10, and 8 queens >>> nqueens(np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, … 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, … 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), 10) 72

# 100 bits, board width = 10, and 6 queens >>> nqueens(np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, … 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0]), 10) 34

# 100 bits, board width = 10, and 10 queens >>> nqueens(np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, … 1, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), 10) 140

# 100 bits, board width = 10, and 10 queens >>> nqueens(np.array([0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, … 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), 10) 80

# 100 bits, board width = 10, and 10 queens >>> nqueens(np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0]), 10) 130

# 100 bits, board width = 10, and 10 queens >>> nqueens(np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 0, 0, 0, … 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, … 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, … 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), 10) 100

# 100 bits, board width = 10, and 50 queens >>> nqueens(np.array([0, 1, 1, 1, 1, 1, 0, 1, 1, 0, 0, 1, 0, 1, 0, 0, 0, … 0, 0, 0, 1, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 1, 1, 0, … 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 0, 1, … 1, 1, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, … 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 0]), 10) 1430

# 100 bits, board width = 10, and 42 queens >>> nqueens(np.array([0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, … 0, 1, 0, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1, 1, 0, 0, 1, … 1, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, … 0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0, … 1, 1, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0]), 10) 1138

# 100 bits, board width = 10, and 93 queens >>> nqueens(np.array([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, … 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, … 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, … 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, … 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1]), 10) 3067

# 100 bits, board width = 10, and 92 queens >>> nqueens(np.array([1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, … 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, … 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, … 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, … 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1]), 10) 3018

# 100 bits, board width = 10, and 0 queens >>> nqueens(np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), 10) 10

# 100 bits, board width = 10, and 100 queens >>> nqueens(np.array([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, … 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, … 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, … 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, … 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]), 10) 3330

>>> nqueens(np.array([True] * 16), 4)
156

moptipy.examples.bitstrings.onemax module

An objective function counting the number of ones in a bit string.

This function tries to maximize the number of True bits in a bit string. Therefore, it returns the lowest possible value 0 if all bits are True. This is the global optimum. It returns the highest possible value n if all bits are False. This is the worst possible value.

  1. Heinz Mühlenbein. How Genetic Algorithms Really Work: Mutation and Hillclimbing. In Reinhard Männer and Bernard Manderick, editors, Proceedings of Parallel Problem Solving from Nature 2 (PPSN-II), September 28-30, 1992, Brussels, Belgium, pages 15-26. Elsevier. https://www.researchgate.net/publication/220702092

  2. Stefan Droste, Thomas Jansen, and Ingo Wegener. Upper and Lower Bounds for Randomized Search Heuristics in Black-Box Optimization. Theory of Computing Systems. 39(4):525-544. July 2006. doi: https://doi.org/10.1007/s00224-004-1177-z

  3. Thomas Weise, Zhize Wu, Xinlu Li, and Yan Chen. Frequency Fitness Assignment: Making Optimization Algorithms Invariant under Bijective Transformations of the Objective Function Value. IEEE Transactions on Evolutionary Computation 25(2):307-319. April 2021. Preprint available at arXiv:2001.01416v5 [cs.NE] 15 Oct 2020. https://dx.doi.org/10.1109/TEVC.2020.3032090

  4. v

class moptipy.examples.bitstrings.onemax.OneMax(n)[source]

Bases: BitStringProblem

Maximize the number of ones in a bit string.

classmethod default_instances(scale_min=2, scale_max=8192)[source]

Get the 202 default instances of the OneMax problem.

Parameters:
  • scale_min (int, default: 2) – the minimum permitted scale, by default 2

  • scale_max (int, default: 8192) – the maximum permitted scale, by default 8192

Return type:

Iterator[Callable[[], OneMax]]

Returns:

a sequence of default OneMax instances

>>> len(list(OneMax.default_instances()))
202
>>> [x() for x in OneMax.default_instances()]
[onemax_2, onemax_3, onemax_4, onemax_5, onemax_6, onemax_7, onemax_8, onemax_9, onemax_10, onemax_11, onemax_12, onemax_13, onemax_14, onemax_15, onemax_16, onemax_17, onemax_18, onemax_19, onemax_20, onemax_21, onemax_22, onemax_23, onemax_24, onemax_25, onemax_26, onemax_27, onemax_28, onemax_29, onemax_30, onemax_31, onemax_32, onemax_33, onemax_36, onemax_40, onemax_41, onemax_42, onemax_44, onemax_48, onemax_49, onemax_50, onemax_55, onemax_59, onemax_60, onemax_64, onemax_66, onemax_70, onemax_77, onemax_79, onemax_80, onemax_81, onemax_85, onemax_88, onemax_90, onemax_96, onemax_99, onemax_100, onemax_107, onemax_111, onemax_121, onemax_125, onemax_128, onemax_144, onemax_149, onemax_169, onemax_170, onemax_192, onemax_196, onemax_199, onemax_200, onemax_222, onemax_225, onemax_243, onemax_256, onemax_269, onemax_289, onemax_300, onemax_324, onemax_333, onemax_341, onemax_343, onemax_359, onemax_361, onemax_384, onemax_400, onemax_441, onemax_444, onemax_479, onemax_484, onemax_500, onemax_512, onemax_529, onemax_555, onemax_576, onemax_600, onemax_625, onemax_641, onemax_666, onemax_676, onemax_682, onemax_700, onemax_729, onemax_768, onemax_777, onemax_784, onemax_800, onemax_841, onemax_857, onemax_888, onemax_900, onemax_961, onemax_999, onemax_1000, onemax_1024, onemax_1089, onemax_1111, onemax_1151, onemax_1156, onemax_1225, onemax_1296, onemax_1365, onemax_1369, onemax_1444, onemax_1521, onemax_1536, onemax_1543, onemax_1600, onemax_1681, onemax_1764, onemax_1849, onemax_1936, onemax_2000, onemax_2025, onemax_2048, onemax_2063, onemax_2116, onemax_2187, onemax_2209, onemax_2222, onemax_2304, onemax_2401, onemax_2500, onemax_2601, onemax_2704, onemax_2730, onemax_2753, onemax_2809, onemax_2916, onemax_3000, onemax_3025, onemax_3072, onemax_3125, onemax_3136, onemax_3249, onemax_3333, onemax_3364, onemax_3481, onemax_3600, onemax_3671, onemax_3721, onemax_3844, onemax_3969, onemax_4000, onemax_4096, onemax_4225, onemax_4356, onemax_4444, onemax_4489, onemax_4624, onemax_4761, onemax_4900, onemax_4903, onemax_5000, onemax_5041, onemax_5184, onemax_5329, onemax_5461, onemax_5476, onemax_5555, onemax_5625, onemax_5776, onemax_5929, onemax_6000, onemax_6084, onemax_6144, onemax_6241, onemax_6400, onemax_6547, onemax_6561, onemax_6666, onemax_6724, onemax_6889, onemax_7000, onemax_7056, onemax_7225, onemax_7396, onemax_7569, onemax_7744, onemax_7777, onemax_7921, onemax_8000, onemax_8100, onemax_8192]
moptipy.examples.bitstrings.onemax.onemax(x)[source]

Get the length of a string minus the number of ones in it.

Parameters:

x (ndarray) – the np array

Return type:

int

Returns:

the length of the string minus the number of ones, i.e., the number of zeros

>>> onemax(np.array([True, True, False, False, False]))
3
>>> onemax(np.array([True, False, True, False, False]))
3
>>> onemax(np.array([False, True,  True, False, False]))
3
>>> onemax(np.array([True, True, True, True, True]))
0
>>> onemax(np.array([False, True, True, True, True]))
1
>>> onemax(np.array([False, False, False, False, False]))
5

# n = 1 and 0 true bits >>> onemax(np.array([0])) 1

# n = 1 and 1 true bit >>> onemax(np.array([1])) 0

# n = 2 and 0 true bits >>> onemax(np.array([0, 0])) 2

# n = 2 and 1 true bit >>> onemax(np.array([0, 1])) 1

# n = 2 and 1 true bit >>> onemax(np.array([1, 0])) 1

# n = 2 and 1 true bit >>> onemax(np.array([0, 1])) 1

# n = 2 and 2 true bits >>> onemax(np.array([1, 1])) 0

# n = 3 and 0 true bits >>> onemax(np.array([0, 0, 0])) 3

# n = 3 and 1 true bit >>> onemax(np.array([1, 0, 0])) 2

# n = 3 and 1 true bit >>> onemax(np.array([0, 1, 0])) 2

# n = 3 and 1 true bit >>> onemax(np.array([0, 0, 1])) 2

# n = 3 and 2 true bits >>> onemax(np.array([1, 1, 0])) 1

# n = 3 and 2 true bits >>> onemax(np.array([0, 1, 1])) 1

# n = 3 and 2 true bits >>> onemax(np.array([1, 1, 0])) 1

# n = 3 and 3 true bits >>> onemax(np.array([1, 1, 1])) 0

# n = 4 and 0 true bits >>> onemax(np.array([0, 0, 0, 0])) 4

# n = 4 and 1 true bit >>> onemax(np.array([1, 0, 0, 0])) 3

# n = 4 and 1 true bit >>> onemax(np.array([0, 0, 0, 1])) 3

# n = 4 and 1 true bit >>> onemax(np.array([0, 0, 1, 0])) 3

# n = 4 and 2 true bits >>> onemax(np.array([0, 0, 1, 1])) 2

# n = 4 and 2 true bits >>> onemax(np.array([0, 1, 0, 1])) 2

# n = 4 and 2 true bits >>> onemax(np.array([0, 1, 0, 1])) 2

# n = 4 and 3 true bits >>> onemax(np.array([0, 1, 1, 1])) 1

# n = 4 and 3 true bits >>> onemax(np.array([1, 1, 1, 0])) 1

# n = 4 and 3 true bits >>> onemax(np.array([1, 0, 1, 1])) 1

# n = 4 and 4 true bits >>> onemax(np.array([1, 1, 1, 1])) 0

# n = 5 and 0 true bits >>> onemax(np.array([0, 0, 0, 0, 0])) 5

# n = 5 and 1 true bit >>> onemax(np.array([0, 0, 0, 0, 1])) 4

# n = 5 and 1 true bit >>> onemax(np.array([0, 1, 0, 0, 0])) 4

# n = 5 and 1 true bit >>> onemax(np.array([1, 0, 0, 0, 0])) 4

# n = 5 and 2 true bits >>> onemax(np.array([0, 1, 0, 0, 1])) 3

# n = 5 and 2 true bits >>> onemax(np.array([0, 1, 1, 0, 0])) 3

# n = 5 and 2 true bits >>> onemax(np.array([0, 0, 0, 1, 1])) 3

# n = 5 and 3 true bits >>> onemax(np.array([1, 0, 1, 1, 0])) 2

# n = 5 and 3 true bits >>> onemax(np.array([1, 1, 0, 1, 0])) 2

# n = 5 and 3 true bits >>> onemax(np.array([0, 1, 1, 1, 0])) 2

# n = 5 and 4 true bits >>> onemax(np.array([1, 0, 1, 1, 1])) 1

# n = 5 and 4 true bits >>> onemax(np.array([1, 1, 0, 1, 1])) 1

# n = 5 and 4 true bits >>> onemax(np.array([1, 0, 1, 1, 1])) 1

# n = 5 and 5 true bits >>> onemax(np.array([1, 1, 1, 1, 1])) 0

# n = 6 and 0 true bits >>> onemax(np.array([0, 0, 0, 0, 0, 0])) 6

# n = 6 and 1 true bit >>> onemax(np.array([0, 0, 0, 0, 1, 0])) 5

# n = 6 and 1 true bit >>> onemax(np.array([1, 0, 0, 0, 0, 0])) 5

# n = 6 and 1 true bit >>> onemax(np.array([0, 0, 0, 0, 1, 0])) 5

# n = 6 and 2 true bits >>> onemax(np.array([0, 1, 0, 1, 0, 0])) 4

# n = 6 and 2 true bits >>> onemax(np.array([0, 1, 0, 0, 1, 0])) 4

# n = 6 and 2 true bits >>> onemax(np.array([0, 0, 0, 0, 1, 1])) 4

# n = 6 and 3 true bits >>> onemax(np.array([0, 0, 1, 0, 1, 1])) 3

# n = 6 and 3 true bits >>> onemax(np.array([1, 0, 0, 1, 0, 1])) 3

# n = 6 and 3 true bits >>> onemax(np.array([0, 1, 1, 0, 0, 1])) 3

# n = 6 and 4 true bits >>> onemax(np.array([1, 1, 1, 0, 1, 0])) 2

# n = 6 and 4 true bits >>> onemax(np.array([1, 1, 0, 0, 1, 1])) 2

# n = 6 and 4 true bits >>> onemax(np.array([1, 1, 1, 0, 1, 0])) 2

# n = 6 and 5 true bits >>> onemax(np.array([1, 1, 0, 1, 1, 1])) 1

# n = 6 and 5 true bits >>> onemax(np.array([1, 1, 1, 1, 0, 1])) 1

# n = 6 and 5 true bits >>> onemax(np.array([1, 1, 1, 1, 0, 1])) 1

# n = 6 and 6 true bits >>> onemax(np.array([1, 1, 1, 1, 1, 1])) 0

# n = 7 and 0 true bits >>> onemax(np.array([0, 0, 0, 0, 0, 0, 0])) 7

# n = 7 and 1 true bit >>> onemax(np.array([0, 1, 0, 0, 0, 0, 0])) 6

# n = 7 and 1 true bit >>> onemax(np.array([0, 0, 0, 0, 1, 0, 0])) 6

# n = 7 and 1 true bit >>> onemax(np.array([0, 1, 0, 0, 0, 0, 0])) 6

# n = 7 and 2 true bits >>> onemax(np.array([1, 0, 0, 0, 1, 0, 0])) 5

# n = 7 and 2 true bits >>> onemax(np.array([0, 1, 0, 1, 0, 0, 0])) 5

# n = 7 and 2 true bits >>> onemax(np.array([1, 0, 0, 0, 0, 0, 1])) 5

# n = 7 and 3 true bits >>> onemax(np.array([1, 0, 1, 1, 0, 0, 0])) 4

# n = 7 and 3 true bits >>> onemax(np.array([0, 0, 1, 1, 0, 0, 1])) 4

# n = 7 and 3 true bits >>> onemax(np.array([0, 0, 1, 1, 0, 0, 1])) 4

# n = 7 and 4 true bits >>> onemax(np.array([0, 1, 0, 1, 1, 1, 0])) 3

# n = 7 and 4 true bits >>> onemax(np.array([1, 1, 1, 0, 1, 0, 0])) 3

# n = 7 and 4 true bits >>> onemax(np.array([0, 1, 1, 1, 0, 1, 0])) 3

# n = 7 and 5 true bits >>> onemax(np.array([1, 1, 1, 1, 1, 0, 0])) 2

# n = 7 and 5 true bits >>> onemax(np.array([1, 1, 1, 1, 0, 1, 0])) 2

# n = 7 and 5 true bits >>> onemax(np.array([0, 1, 1, 1, 1, 1, 0])) 2

# n = 7 and 6 true bits >>> onemax(np.array([1, 1, 1, 1, 0, 1, 1])) 1

# n = 7 and 6 true bits >>> onemax(np.array([1, 1, 1, 0, 1, 1, 1])) 1

# n = 7 and 6 true bits >>> onemax(np.array([0, 1, 1, 1, 1, 1, 1])) 1

# n = 7 and 7 true bits >>> onemax(np.array([1, 1, 1, 1, 1, 1, 1])) 0

# n = 8 and 0 true bits >>> onemax(np.array([0, 0, 0, 0, 0, 0, 0, 0])) 8

# n = 8 and 1 true bit >>> onemax(np.array([0, 0, 0, 0, 0, 1, 0, 0])) 7

# n = 8 and 1 true bit >>> onemax(np.array([1, 0, 0, 0, 0, 0, 0, 0])) 7

# n = 8 and 1 true bit >>> onemax(np.array([0, 0, 0, 0, 0, 0, 0, 1])) 7

# n = 8 and 2 true bits >>> onemax(np.array([0, 0, 0, 0, 0, 0, 1, 1])) 6

# n = 8 and 2 true bits >>> onemax(np.array([0, 0, 1, 0, 0, 1, 0, 0])) 6

# n = 8 and 2 true bits >>> onemax(np.array([0, 0, 0, 0, 0, 1, 1, 0])) 6

# n = 8 and 3 true bits >>> onemax(np.array([0, 1, 0, 0, 1, 1, 0, 0])) 5

# n = 8 and 3 true bits >>> onemax(np.array([0, 1, 0, 1, 1, 0, 0, 0])) 5

# n = 8 and 3 true bits >>> onemax(np.array([0, 0, 0, 0, 1, 1, 1, 0])) 5

# n = 8 and 4 true bits >>> onemax(np.array([1, 0, 1, 1, 0, 0, 1, 0])) 4

# n = 8 and 4 true bits >>> onemax(np.array([1, 1, 0, 0, 1, 1, 0, 0])) 4

# n = 8 and 4 true bits >>> onemax(np.array([1, 0, 0, 0, 1, 1, 0, 1])) 4

# n = 8 and 5 true bits >>> onemax(np.array([0, 1, 1, 0, 0, 1, 1, 1])) 3

# n = 8 and 5 true bits >>> onemax(np.array([1, 1, 0, 0, 1, 0, 1, 1])) 3

# n = 8 and 5 true bits >>> onemax(np.array([1, 1, 0, 0, 1, 1, 0, 1])) 3

# n = 8 and 6 true bits >>> onemax(np.array([1, 1, 0, 1, 1, 1, 1, 0])) 2

# n = 8 and 6 true bits >>> onemax(np.array([1, 1, 0, 1, 1, 0, 1, 1])) 2

# n = 8 and 6 true bits >>> onemax(np.array([0, 0, 1, 1, 1, 1, 1, 1])) 2

# n = 8 and 7 true bits >>> onemax(np.array([1, 1, 1, 1, 1, 1, 0, 1])) 1

# n = 8 and 7 true bits >>> onemax(np.array([1, 1, 1, 1, 1, 1, 1, 0])) 1

# n = 8 and 7 true bits >>> onemax(np.array([1, 1, 1, 1, 1, 0, 1, 1])) 1

# n = 8 and 8 true bits >>> onemax(np.array([1, 1, 1, 1, 1, 1, 1, 1])) 0

# n = 9 and 0 true bits >>> onemax(np.array([0, 0, 0, 0, 0, 0, 0, 0, 0])) 9

# n = 9 and 1 true bit >>> onemax(np.array([0, 0, 0, 0, 0, 0, 0, 1, 0])) 8

# n = 9 and 1 true bit >>> onemax(np.array([0, 0, 0, 0, 0, 0, 0, 0, 1])) 8

# n = 9 and 1 true bit >>> onemax(np.array([0, 0, 0, 0, 1, 0, 0, 0, 0])) 8

# n = 9 and 2 true bits >>> onemax(np.array([1, 0, 0, 0, 0, 0, 0, 1, 0])) 7

# n = 9 and 2 true bits >>> onemax(np.array([0, 1, 0, 0, 0, 0, 1, 0, 0])) 7

# n = 9 and 2 true bits >>> onemax(np.array([0, 0, 1, 0, 1, 0, 0, 0, 0])) 7

# n = 9 and 3 true bits >>> onemax(np.array([0, 0, 1, 0, 0, 1, 0, 0, 1])) 6

# n = 9 and 3 true bits >>> onemax(np.array([1, 0, 0, 0, 0, 0, 0, 1, 1])) 6

# n = 9 and 3 true bits >>> onemax(np.array([0, 0, 1, 0, 1, 0, 0, 1, 0])) 6

# n = 9 and 4 true bits >>> onemax(np.array([0, 0, 0, 0, 1, 1, 0, 1, 1])) 5

# n = 9 and 4 true bits >>> onemax(np.array([0, 0, 0, 1, 0, 0, 1, 1, 1])) 5

# n = 9 and 4 true bits >>> onemax(np.array([0, 0, 1, 1, 1, 0, 0, 0, 1])) 5

# n = 9 and 5 true bits >>> onemax(np.array([0, 0, 1, 1, 0, 1, 0, 1, 1])) 4

# n = 9 and 5 true bits >>> onemax(np.array([0, 0, 1, 1, 0, 1, 0, 1, 1])) 4

# n = 9 and 5 true bits >>> onemax(np.array([1, 1, 0, 0, 1, 0, 0, 1, 1])) 4

# n = 9 and 6 true bits >>> onemax(np.array([0, 0, 1, 1, 1, 1, 1, 0, 1])) 3

# n = 9 and 6 true bits >>> onemax(np.array([1, 1, 0, 0, 1, 0, 1, 1, 1])) 3

# n = 9 and 6 true bits >>> onemax(np.array([0, 1, 1, 1, 0, 1, 1, 0, 1])) 3

# n = 9 and 7 true bits >>> onemax(np.array([0, 1, 1, 0, 1, 1, 1, 1, 1])) 2

# n = 9 and 7 true bits >>> onemax(np.array([1, 1, 0, 1, 1, 1, 1, 0, 1])) 2

# n = 9 and 7 true bits >>> onemax(np.array([1, 1, 1, 0, 1, 1, 0, 1, 1])) 2

# n = 9 and 8 true bits >>> onemax(np.array([1, 1, 1, 0, 1, 1, 1, 1, 1])) 1

# n = 9 and 8 true bits >>> onemax(np.array([1, 1, 1, 1, 1, 0, 1, 1, 1])) 1

# n = 9 and 8 true bits >>> onemax(np.array([1, 1, 1, 0, 1, 1, 1, 1, 1])) 1

# n = 9 and 9 true bits >>> onemax(np.array([1, 1, 1, 1, 1, 1, 1, 1, 1])) 0

# n = 10 and 0 true bits >>> onemax(np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0])) 10

# n = 10 and 1 true bit >>> onemax(np.array([0, 0, 0, 1, 0, 0, 0, 0, 0, 0])) 9

# n = 10 and 1 true bit >>> onemax(np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 1])) 9

# n = 10 and 1 true bit >>> onemax(np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 1])) 9

# n = 10 and 2 true bits >>> onemax(np.array([0, 1, 0, 0, 0, 0, 0, 1, 0, 0])) 8

# n = 10 and 2 true bits >>> onemax(np.array([1, 1, 0, 0, 0, 0, 0, 0, 0, 0])) 8

# n = 10 and 2 true bits >>> onemax(np.array([1, 0, 0, 1, 0, 0, 0, 0, 0, 0])) 8

# n = 10 and 3 true bits >>> onemax(np.array([0, 0, 0, 1, 0, 0, 1, 1, 0, 0])) 7

# n = 10 and 3 true bits >>> onemax(np.array([1, 0, 0, 0, 0, 0, 1, 0, 1, 0])) 7

# n = 10 and 3 true bits >>> onemax(np.array([0, 1, 0, 0, 0, 0, 1, 1, 0, 0])) 7

# n = 10 and 4 true bits >>> onemax(np.array([0, 0, 1, 1, 1, 0, 0, 1, 0, 0])) 6

# n = 10 and 4 true bits >>> onemax(np.array([0, 1, 1, 0, 0, 1, 0, 0, 0, 1])) 6

# n = 10 and 4 true bits >>> onemax(np.array([0, 0, 1, 1, 0, 1, 0, 0, 1, 0])) 6

# n = 10 and 5 true bits >>> onemax(np.array([1, 1, 1, 0, 0, 1, 0, 1, 0, 0])) 5

# n = 10 and 5 true bits >>> onemax(np.array([0, 1, 1, 0, 1, 1, 0, 0, 0, 1])) 5

# n = 10 and 5 true bits >>> onemax(np.array([0, 1, 0, 1, 0, 1, 0, 1, 0, 1])) 5

# n = 10 and 6 true bits >>> onemax(np.array([1, 1, 1, 0, 1, 0, 1, 1, 0, 0])) 4

# n = 10 and 6 true bits >>> onemax(np.array([1, 1, 1, 1, 1, 0, 1, 0, 0, 0])) 4

# n = 10 and 6 true bits >>> onemax(np.array([0, 0, 1, 1, 1, 1, 0, 1, 0, 1])) 4

# n = 10 and 7 true bits >>> onemax(np.array([1, 1, 1, 1, 0, 0, 1, 1, 0, 1])) 3

# n = 10 and 7 true bits >>> onemax(np.array([1, 1, 0, 1, 1, 1, 0, 1, 1, 0])) 3

# n = 10 and 7 true bits >>> onemax(np.array([0, 0, 1, 1, 1, 1, 0, 1, 1, 1])) 3

# n = 10 and 8 true bits >>> onemax(np.array([0, 1, 1, 1, 0, 1, 1, 1, 1, 1])) 2

# n = 10 and 8 true bits >>> onemax(np.array([1, 1, 1, 1, 1, 0, 1, 1, 1, 0])) 2

# n = 10 and 8 true bits >>> onemax(np.array([1, 1, 1, 1, 0, 1, 0, 1, 1, 1])) 2

# n = 10 and 9 true bits >>> onemax(np.array([1, 1, 1, 1, 1, 1, 1, 1, 0, 1])) 1

# n = 10 and 9 true bits >>> onemax(np.array([0, 1, 1, 1, 1, 1, 1, 1, 1, 1])) 1

# n = 10 and 9 true bits >>> onemax(np.array([1, 1, 1, 1, 1, 1, 0, 1, 1, 1])) 1

# n = 10 and 10 true bits >>> onemax(np.array([1, 1, 1, 1, 1, 1, 1, 1, 1, 1])) 0

moptipy.examples.bitstrings.plateau module

The Plateau problem.

The plateau problem is basically OneMax, but with a neutral region of k bit flips before the optimum. The best objective value, 0, is reached if all bits are True. The worst objective value n, is reached if all bits are False.

  1. Denis Antipov and Benjamin Doerr. Precise Runtime Analysis for Plateaus. Parallel Problem Solving from Nature (PPSN XV), 2018, Part II. LNCS 11102, pp. 117-128. doi: https://doi.org/10.1007/978-3-319-99259-4_10

  2. Thomas Weise, Zhize Wu, Xinlu Li, and Yan Chen. Frequency Fitness Assignment: Making Optimization Algorithms Invariant under Bijective Transformations of the Objective Function Value. IEEE Transactions on Evolutionary Computation 25(2):307-319. April 2021. Preprint available at arXiv:2001.01416v5 [cs.NE] 15 Oct 2020. https://dx.doi.org/10.1109/TEVC.2020.3032090

  3. Thomas Weise, Zhize Wu, Xinlu Li, Yan Chen, and Jörg Lässig. Frequency Fitness Assignment: Optimization without Bias for Good Solutions can be Efficient. IEEE Transactions on Evolutionary Computation (TEVC). 27(4):980-992. August 2023. doi: https://doi.org/10.1109/TEVC.2022.3191698

This is code is part of the research work of Mr. Jiazheng ZENG (曾嘉政), a Master’s student at the Institute of Applied Optimization (应用优化研究所, http://iao.hfuu.edu.cn) of the School of Artificial Intelligence and Big Data (人工智能与大数据学院) at Hefei University (合肥大学) in Hefei, Anhui, China (中国安徽省合肥市) under the supervision of Prof. Dr. Thomas Weise (汤卫思教授).

>>> len(list(Plateau.default_instances()))
122
>>> [x() for x in Plateau.default_instances()]
[plateau_6_2, plateau_7_2, plateau_8_2, plateau_8_3, plateau_9_2, plateau_9_3, plateau_10_2, plateau_10_3, plateau_10_4, plateau_11_2, plateau_11_3, plateau_11_4, plateau_12_2, plateau_12_3, plateau_12_4, plateau_12_5, plateau_13_2, plateau_13_3, plateau_13_4, plateau_13_5, plateau_14_2, plateau_14_3, plateau_14_4, plateau_14_6, plateau_15_2, plateau_15_3, plateau_15_4, plateau_15_6, plateau_16_2, plateau_16_4, plateau_16_5, plateau_16_7, plateau_17_2, plateau_17_4, plateau_17_5, plateau_17_7, plateau_18_2, plateau_18_4, plateau_18_6, plateau_18_8, plateau_19_2, plateau_19_4, plateau_19_6, plateau_19_8, plateau_20_2, plateau_20_3, plateau_20_4, plateau_20_5, plateau_20_7, plateau_20_9, plateau_21_2, plateau_21_3, plateau_21_4, plateau_21_5, plateau_21_7, plateau_21_9, plateau_22_2, plateau_22_3, plateau_22_4, plateau_22_5, plateau_22_7, plateau_22_10, plateau_23_2, plateau_23_3, plateau_23_4, plateau_23_5, plateau_23_7, plateau_23_10, plateau_24_2, plateau_24_3, plateau_24_4, plateau_24_6, plateau_24_8, plateau_24_11, plateau_25_2, plateau_25_3, plateau_25_5, plateau_25_6, plateau_25_8, plateau_25_11, plateau_26_2, plateau_26_3, plateau_26_5, plateau_26_6, plateau_26_9, plateau_26_12, plateau_27_2, plateau_27_3, plateau_27_5, plateau_27_6, plateau_27_9, plateau_27_12, plateau_28_2, plateau_28_4, plateau_28_5, plateau_28_7, plateau_28_10, plateau_28_13, plateau_29_2, plateau_29_4, plateau_29_5, plateau_29_7, plateau_29_10, plateau_29_13, plateau_30_2, plateau_30_4, plateau_30_5, plateau_30_7, plateau_30_10, plateau_30_14, plateau_31_2, plateau_31_4, plateau_31_5, plateau_31_7, plateau_31_10, plateau_31_14, plateau_32_2, plateau_32_4, plateau_32_5, plateau_32_8, plateau_32_11, plateau_32_15]
class moptipy.examples.bitstrings.plateau.Plateau(n, k)[source]

Bases: BitStringNKProblem

Compute the Plateau problem.

evaluate(x)[source]

Evaluate a solution to the plateau problem.

Parameters:

x (ndarray) – the bit string to evaluate

Return type:

int

Returns:

the value of the plateau problem for the string

moptipy.examples.bitstrings.plateau.plateau(x, k)[source]

Compute the plateau value.

Parameters:
  • x (ndarray) – the np array

  • k (int) – the k parameter

Return type:

int

Returns:

plateau value

# n = 6, k = 2, and 0 true bits >>> plateau(np.array([0, 0, 0, 0, 0, 0]), 2) 6

# n = 6, k = 2, and 1 true bit >>> plateau(np.array([0, 0, 0, 1, 0, 0]), 2) 5

# n = 6, k = 2, and 2 true bits >>> plateau(np.array([0, 0, 1, 0, 1, 0]), 2) 4

# n = 6, k = 2, and 3 true bits >>> plateau(np.array([1, 1, 1, 0, 0, 0]), 2) 3

# n = 6, k = 2, and 4 true bits >>> plateau(np.array([1, 1, 1, 1, 0, 0]), 2) 2

# n = 6, k = 2, and 5 true bits >>> plateau(np.array([1, 1, 1, 1, 1, 0]), 2) 2

# n = 6, k = 2, and 6 true bits >>> plateau(np.array([1, 1, 1, 1, 1, 1]), 2) 0

# n = 7, k = 2, and 0 true bits >>> plateau(np.array([0, 0, 0, 0, 0, 0, 0]), 2) 7

# n = 7, k = 2, and 1 true bit >>> plateau(np.array([0, 0, 1, 0, 0, 0, 0]), 2) 6

# n = 7, k = 2, and 2 true bits >>> plateau(np.array([0, 1, 0, 1, 0, 0, 0]), 2) 5

# n = 7, k = 2, and 3 true bits >>> plateau(np.array([0, 1, 0, 0, 1, 0, 1]), 2) 4

# n = 7, k = 2, and 4 true bits >>> plateau(np.array([1, 0, 0, 0, 1, 1, 1]), 2) 3

# n = 7, k = 2, and 5 true bits >>> plateau(np.array([1, 0, 1, 1, 0, 1, 1]), 2) 2

# n = 7, k = 2, and 6 true bits >>> plateau(np.array([1, 1, 1, 1, 0, 1, 1]), 2) 2

# n = 7, k = 2, and 7 true bits >>> plateau(np.array([1, 1, 1, 1, 1, 1, 1]), 2) 0

# n = 8, k = 2, and 0 true bits >>> plateau(np.array([0, 0, 0, 0, 0, 0, 0, 0]), 2) 8

# n = 8, k = 2, and 1 true bit >>> plateau(np.array([0, 1, 0, 0, 0, 0, 0, 0]), 2) 7

# n = 8, k = 2, and 2 true bits >>> plateau(np.array([1, 0, 0, 0, 1, 0, 0, 0]), 2) 6

# n = 8, k = 2, and 3 true bits >>> plateau(np.array([0, 0, 0, 1, 0, 1, 0, 1]), 2) 5

# n = 8, k = 2, and 4 true bits >>> plateau(np.array([0, 0, 0, 1, 1, 1, 0, 1]), 2) 4

# n = 8, k = 2, and 5 true bits >>> plateau(np.array([1, 1, 0, 1, 1, 0, 0, 1]), 2) 3

# n = 8, k = 2, and 6 true bits >>> plateau(np.array([0, 0, 1, 1, 1, 1, 1, 1]), 2) 2

# n = 8, k = 2, and 7 true bits >>> plateau(np.array([1, 1, 1, 1, 1, 0, 1, 1]), 2) 2

# n = 8, k = 2, and 8 true bits >>> plateau(np.array([1, 1, 1, 1, 1, 1, 1, 1]), 2) 0

# n = 8, k = 3, and 0 true bits >>> plateau(np.array([0, 0, 0, 0, 0, 0, 0, 0]), 3) 8

# n = 8, k = 3, and 1 true bit >>> plateau(np.array([0, 0, 0, 0, 0, 0, 0, 1]), 3) 7

# n = 8, k = 3, and 2 true bits >>> plateau(np.array([0, 0, 1, 0, 0, 0, 0, 1]), 3) 6

# n = 8, k = 3, and 3 true bits >>> plateau(np.array([0, 1, 0, 0, 1, 1, 0, 0]), 3) 5

# n = 8, k = 3, and 4 true bits >>> plateau(np.array([1, 0, 0, 0, 1, 1, 0, 1]), 3) 4

# n = 8, k = 3, and 5 true bits >>> plateau(np.array([1, 1, 0, 0, 1, 0, 1, 1]), 3) 3

# n = 8, k = 3, and 6 true bits >>> plateau(np.array([1, 0, 1, 1, 1, 0, 1, 1]), 3) 3

# n = 8, k = 3, and 7 true bits >>> plateau(np.array([0, 1, 1, 1, 1, 1, 1, 1]), 3) 3

# n = 8, k = 3, and 8 true bits >>> plateau(np.array([1, 1, 1, 1, 1, 1, 1, 1]), 3) 0

# n = 9, k = 2, and 0 true bits >>> plateau(np.array([0, 0, 0, 0, 0, 0, 0, 0, 0]), 2) 9

# n = 9, k = 2, and 1 true bit >>> plateau(np.array([0, 1, 0, 0, 0, 0, 0, 0, 0]), 2) 8

# n = 9, k = 2, and 2 true bits >>> plateau(np.array([0, 0, 0, 0, 1, 1, 0, 0, 0]), 2) 7

# n = 9, k = 2, and 3 true bits >>> plateau(np.array([0, 1, 0, 1, 0, 1, 0, 0, 0]), 2) 6

# n = 9, k = 2, and 4 true bits >>> plateau(np.array([1, 1, 1, 0, 0, 0, 0, 0, 1]), 2) 5

# n = 9, k = 2, and 5 true bits >>> plateau(np.array([1, 0, 1, 1, 1, 0, 0, 1, 0]), 2) 4

# n = 9, k = 2, and 6 true bits >>> plateau(np.array([1, 1, 0, 1, 0, 0, 1, 1, 1]), 2) 3

# n = 9, k = 2, and 7 true bits >>> plateau(np.array([1, 1, 1, 0, 1, 1, 0, 1, 1]), 2) 2

# n = 9, k = 2, and 8 true bits >>> plateau(np.array([0, 1, 1, 1, 1, 1, 1, 1, 1]), 2) 2

# n = 9, k = 2, and 9 true bits >>> plateau(np.array([1, 1, 1, 1, 1, 1, 1, 1, 1]), 2) 0

# n = 9, k = 3, and 0 true bits >>> plateau(np.array([0, 0, 0, 0, 0, 0, 0, 0, 0]), 3) 9

# n = 9, k = 3, and 1 true bit >>> plateau(np.array([0, 0, 1, 0, 0, 0, 0, 0, 0]), 3) 8

# n = 9, k = 3, and 2 true bits >>> plateau(np.array([0, 0, 0, 0, 1, 0, 1, 0, 0]), 3) 7

# n = 9, k = 3, and 3 true bits >>> plateau(np.array([0, 0, 0, 0, 1, 0, 0, 1, 1]), 3) 6

# n = 9, k = 3, and 4 true bits >>> plateau(np.array([0, 1, 1, 0, 0, 1, 0, 0, 1]), 3) 5

# n = 9, k = 3, and 5 true bits >>> plateau(np.array([1, 1, 0, 1, 1, 1, 0, 0, 0]), 3) 4

# n = 9, k = 3, and 6 true bits >>> plateau(np.array([0, 1, 1, 0, 1, 1, 1, 1, 0]), 3) 3

# n = 9, k = 3, and 7 true bits >>> plateau(np.array([1, 1, 1, 0, 1, 1, 1, 1, 0]), 3) 3

# n = 9, k = 3, and 8 true bits >>> plateau(np.array([1, 1, 0, 1, 1, 1, 1, 1, 1]), 3) 3

# n = 9, k = 3, and 9 true bits >>> plateau(np.array([1, 1, 1, 1, 1, 1, 1, 1, 1]), 3) 0

# n = 10, k = 2, and 0 true bits >>> plateau(np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), 2) 10

# n = 10, k = 2, and 1 true bit >>> plateau(np.array([0, 0, 0, 1, 0, 0, 0, 0, 0, 0]), 2) 9

# n = 10, k = 2, and 2 true bits >>> plateau(np.array([1, 1, 0, 0, 0, 0, 0, 0, 0, 0]), 2) 8

# n = 10, k = 2, and 3 true bits >>> plateau(np.array([0, 0, 0, 1, 0, 1, 0, 0, 0, 1]), 2) 7

# n = 10, k = 2, and 4 true bits >>> plateau(np.array([0, 1, 0, 0, 0, 1, 0, 0, 1, 1]), 2) 6

# n = 10, k = 2, and 5 true bits >>> plateau(np.array([0, 0, 1, 1, 1, 1, 1, 0, 0, 0]), 2) 5

# n = 10, k = 2, and 6 true bits >>> plateau(np.array([0, 1, 0, 1, 1, 1, 0, 1, 0, 1]), 2) 4

# n = 10, k = 2, and 7 true bits >>> plateau(np.array([1, 1, 1, 1, 1, 0, 1, 0, 0, 1]), 2) 3

# n = 10, k = 2, and 8 true bits >>> plateau(np.array([0, 0, 1, 1, 1, 1, 1, 1, 1, 1]), 2) 2

# n = 10, k = 2, and 9 true bits >>> plateau(np.array([1, 0, 1, 1, 1, 1, 1, 1, 1, 1]), 2) 2

# n = 10, k = 2, and 10 true bits >>> plateau(np.array([1, 1, 1, 1, 1, 1, 1, 1, 1, 1]), 2) 0

# n = 10, k = 3, and 0 true bits >>> plateau(np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), 3) 10

# n = 10, k = 3, and 1 true bit >>> plateau(np.array([0, 0, 1, 0, 0, 0, 0, 0, 0, 0]), 3) 9

# n = 10, k = 3, and 2 true bits >>> plateau(np.array([0, 0, 0, 0, 0, 1, 1, 0, 0, 0]), 3) 8

# n = 10, k = 3, and 3 true bits >>> plateau(np.array([0, 0, 1, 0, 0, 1, 0, 0, 1, 0]), 3) 7

# n = 10, k = 3, and 4 true bits >>> plateau(np.array([1, 1, 0, 1, 1, 0, 0, 0, 0, 0]), 3) 6

# n = 10, k = 3, and 5 true bits >>> plateau(np.array([1, 1, 1, 0, 0, 0, 1, 0, 1, 0]), 3) 5

# n = 10, k = 3, and 6 true bits >>> plateau(np.array([1, 1, 0, 0, 1, 1, 1, 0, 0, 1]), 3) 4

# n = 10, k = 3, and 7 true bits >>> plateau(np.array([0, 1, 0, 1, 1, 1, 1, 0, 1, 1]), 3) 3

# n = 10, k = 3, and 8 true bits >>> plateau(np.array([0, 1, 1, 0, 1, 1, 1, 1, 1, 1]), 3) 3

# n = 10, k = 3, and 9 true bits >>> plateau(np.array([1, 1, 1, 0, 1, 1, 1, 1, 1, 1]), 3) 3

# n = 10, k = 3, and 10 true bits >>> plateau(np.array([1, 1, 1, 1, 1, 1, 1, 1, 1, 1]), 3) 0

# n = 10, k = 4, and 0 true bits >>> plateau(np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), 4) 10

# n = 10, k = 4, and 1 true bit >>> plateau(np.array([0, 0, 0, 0, 1, 0, 0, 0, 0, 0]), 4) 9

# n = 10, k = 4, and 2 true bits >>> plateau(np.array([0, 0, 0, 0, 1, 0, 0, 0, 0, 1]), 4) 8

# n = 10, k = 4, and 3 true bits >>> plateau(np.array([0, 1, 0, 1, 0, 1, 0, 0, 0, 0]), 4) 7

# n = 10, k = 4, and 4 true bits >>> plateau(np.array([0, 0, 1, 1, 0, 0, 0, 0, 1, 1]), 4) 6

# n = 10, k = 4, and 5 true bits >>> plateau(np.array([0, 1, 0, 1, 1, 0, 0, 1, 1, 0]), 4) 5

# n = 10, k = 4, and 6 true bits >>> plateau(np.array([1, 1, 1, 1, 1, 0, 0, 0, 1, 0]), 4) 4

# n = 10, k = 4, and 7 true bits >>> plateau(np.array([1, 1, 1, 1, 0, 1, 0, 1, 1, 0]), 4) 4

# n = 10, k = 4, and 8 true bits >>> plateau(np.array([1, 1, 1, 1, 0, 0, 1, 1, 1, 1]), 4) 4

# n = 10, k = 4, and 9 true bits >>> plateau(np.array([0, 1, 1, 1, 1, 1, 1, 1, 1, 1]), 4) 4

# n = 10, k = 4, and 10 true bits >>> plateau(np.array([1, 1, 1, 1, 1, 1, 1, 1, 1, 1]), 4) 0

# n = 11, k = 2, and 0 true bits >>> plateau(np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), 2) 11

# n = 11, k = 2, and 1 true bit >>> plateau(np.array([0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0]), 2) 10

# n = 11, k = 2, and 2 true bits >>> plateau(np.array([0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0]), 2) 9

# n = 11, k = 2, and 3 true bits >>> plateau(np.array([1, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0]), 2) 8

# n = 11, k = 2, and 4 true bits >>> plateau(np.array([0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 1]), 2) 7

# n = 11, k = 2, and 5 true bits >>> plateau(np.array([0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1]), 2) 6

# n = 11, k = 2, and 6 true bits >>> plateau(np.array([0, 1, 1, 1, 0, 0, 1, 0, 1, 1, 0]), 2) 5

# n = 11, k = 2, and 7 true bits >>> plateau(np.array([0, 1, 1, 0, 0, 1, 1, 1, 1, 1, 0]), 2) 4

# n = 11, k = 2, and 8 true bits >>> plateau(np.array([1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 0]), 2) 3

# n = 11, k = 2, and 9 true bits >>> plateau(np.array([0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1]), 2) 2

# n = 11, k = 2, and 10 true bits >>> plateau(np.array([1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1]), 2) 2

# n = 11, k = 2, and 11 true bits >>> plateau(np.array([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]), 2) 0

# n = 11, k = 3, and 0 true bits >>> plateau(np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), 3) 11

# n = 11, k = 3, and 1 true bit >>> plateau(np.array([0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0]), 3) 10

# n = 11, k = 3, and 2 true bits >>> plateau(np.array([0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1]), 3) 9

# n = 11, k = 3, and 3 true bits >>> plateau(np.array([0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1]), 3) 8

# n = 11, k = 3, and 4 true bits >>> plateau(np.array([0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 1]), 3) 7

# n = 11, k = 3, and 5 true bits >>> plateau(np.array([0, 0, 1, 0, 0, 0, 1, 0, 1, 1, 1]), 3) 6

# n = 11, k = 3, and 6 true bits >>> plateau(np.array([0, 1, 1, 0, 1, 1, 1, 1, 0, 0, 0]), 3) 5

# n = 11, k = 3, and 7 true bits >>> plateau(np.array([1, 1, 0, 1, 0, 1, 0, 1, 1, 1, 0]), 3) 4

# n = 11, k = 3, and 8 true bits >>> plateau(np.array([1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 0]), 3) 3

# n = 11, k = 3, and 9 true bits >>> plateau(np.array([0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1]), 3) 3

# n = 11, k = 3, and 10 true bits >>> plateau(np.array([0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]), 3) 3

# n = 11, k = 3, and 11 true bits >>> plateau(np.array([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]), 3) 0

# n = 11, k = 4, and 0 true bits >>> plateau(np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), 4) 11

# n = 11, k = 4, and 1 true bit >>> plateau(np.array([0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0]), 4) 10

# n = 11, k = 4, and 2 true bits >>> plateau(np.array([0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0]), 4) 9

# n = 11, k = 4, and 3 true bits >>> plateau(np.array([0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0]), 4) 8

# n = 11, k = 4, and 4 true bits >>> plateau(np.array([0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0]), 4) 7

# n = 11, k = 4, and 5 true bits >>> plateau(np.array([0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 1]), 4) 6

# n = 11, k = 4, and 6 true bits >>> plateau(np.array([1, 1, 1, 0, 0, 0, 1, 0, 1, 1, 0]), 4) 5

# n = 11, k = 4, and 7 true bits >>> plateau(np.array([1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 0]), 4) 4

# n = 11, k = 4, and 8 true bits >>> plateau(np.array([0, 1, 0, 1, 1, 1, 1, 1, 1, 0, 1]), 4) 4

# n = 11, k = 4, and 9 true bits >>> plateau(np.array([1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1]), 4) 4

# n = 11, k = 4, and 10 true bits >>> plateau(np.array([0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]), 4) 4

# n = 11, k = 4, and 11 true bits >>> plateau(np.array([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]), 4) 0

# n = 12, k = 2, and 0 true bits >>> plateau(np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), 2) 12

# n = 12, k = 2, and 1 true bit >>> plateau(np.array([0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0]), 2) 11

# n = 12, k = 2, and 2 true bits >>> plateau(np.array([0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0]), 2) 10

# n = 12, k = 2, and 3 true bits >>> plateau(np.array([1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0]), 2) 9

# n = 12, k = 2, and 4 true bits >>> plateau(np.array([1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0]), 2) 8

# n = 12, k = 2, and 5 true bits >>> plateau(np.array([1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 0]), 2) 7

# n = 12, k = 2, and 6 true bits >>> plateau(np.array([1, 0, 1, 0, 1, 1, 1, 0, 0, 0, 0, 1]), 2) 6

# n = 12, k = 2, and 7 true bits >>> plateau(np.array([0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 1, 1]), 2) 5

# n = 12, k = 2, and 8 true bits >>> plateau(np.array([0, 0, 1, 1, 1, 1, 1, 0, 1, 1, 0, 1]), 2) 4

# n = 12, k = 2, and 9 true bits >>> plateau(np.array([1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 0]), 2) 3

# n = 12, k = 2, and 10 true bits >>> plateau(np.array([1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1]), 2) 2

# n = 12, k = 2, and 11 true bits >>> plateau(np.array([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]), 2) 2

# n = 12, k = 2, and 12 true bits >>> plateau(np.array([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]), 2) 0

# n = 12, k = 3, and 0 true bits >>> plateau(np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), 3) 12

# n = 12, k = 3, and 1 true bit >>> plateau(np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0]), 3) 11

# n = 12, k = 3, and 2 true bits >>> plateau(np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1]), 3) 10

# n = 12, k = 3, and 3 true bits >>> plateau(np.array([1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0]), 3) 9

# n = 12, k = 3, and 4 true bits >>> plateau(np.array([0, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 1]), 3) 8

# n = 12, k = 3, and 5 true bits >>> plateau(np.array([0, 1, 0, 1, 1, 0, 0, 0, 1, 0, 0, 1]), 3) 7

# n = 12, k = 3, and 6 true bits >>> plateau(np.array([1, 1, 1, 0, 1, 0, 1, 0, 0, 0, 0, 1]), 3) 6

# n = 12, k = 3, and 7 true bits >>> plateau(np.array([1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0]), 3) 5

# n = 12, k = 3, and 8 true bits >>> plateau(np.array([0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 0]), 3) 4

# n = 12, k = 3, and 9 true bits >>> plateau(np.array([0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1]), 3) 3

# n = 12, k = 3, and 10 true bits >>> plateau(np.array([0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1]), 3) 3

# n = 12, k = 3, and 11 true bits >>> plateau(np.array([1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]), 3) 3

# n = 12, k = 3, and 12 true bits >>> plateau(np.array([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]), 3) 0

# n = 12, k = 4, and 0 true bits >>> plateau(np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), 4) 12

# n = 12, k = 4, and 1 true bit >>> plateau(np.array([0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0]), 4) 11

# n = 12, k = 4, and 2 true bits >>> plateau(np.array([0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0]), 4) 10

# n = 12, k = 4, and 3 true bits >>> plateau(np.array([0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0]), 4) 9

# n = 12, k = 4, and 4 true bits >>> plateau(np.array([1, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0]), 4) 8

# n = 12, k = 4, and 5 true bits >>> plateau(np.array([1, 1, 0, 1, 1, 0, 1, 0, 0, 0, 0, 0]), 4) 7

# n = 12, k = 4, and 6 true bits >>> plateau(np.array([0, 0, 0, 1, 1, 0, 1, 1, 1, 0, 1, 0]), 4) 6

# n = 12, k = 4, and 7 true bits >>> plateau(np.array([1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0]), 4) 5

# n = 12, k = 4, and 8 true bits >>> plateau(np.array([1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 0]), 4) 4

# n = 12, k = 4, and 9 true bits >>> plateau(np.array([1, 0, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1]), 4) 4

# n = 12, k = 4, and 10 true bits >>> plateau(np.array([1, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1]), 4) 4

# n = 12, k = 4, and 11 true bits >>> plateau(np.array([1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1]), 4) 4

# n = 12, k = 4, and 12 true bits >>> plateau(np.array([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]), 4) 0

# n = 12, k = 5, and 0 true bits >>> plateau(np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), 5) 12

# n = 12, k = 5, and 1 true bit >>> plateau(np.array([0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0]), 5) 11

# n = 12, k = 5, and 2 true bits >>> plateau(np.array([0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0]), 5) 10

# n = 12, k = 5, and 3 true bits >>> plateau(np.array([1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1]), 5) 9

# n = 12, k = 5, and 4 true bits >>> plateau(np.array([0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1]), 5) 8

# n = 12, k = 5, and 5 true bits >>> plateau(np.array([0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1]), 5) 7

# n = 12, k = 5, and 6 true bits >>> plateau(np.array([1, 1, 1, 1, 0, 0, 0, 1, 0, 1, 0, 0]), 5) 6

# n = 12, k = 5, and 7 true bits >>> plateau(np.array([0, 1, 1, 0, 0, 1, 1, 0, 1, 1, 0, 1]), 5) 5

# n = 12, k = 5, and 8 true bits >>> plateau(np.array([1, 0, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0]), 5) 5

# n = 12, k = 5, and 9 true bits >>> plateau(np.array([1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1]), 5) 5

# n = 12, k = 5, and 10 true bits >>> plateau(np.array([1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1]), 5) 5

# n = 12, k = 5, and 11 true bits >>> plateau(np.array([1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1]), 5) 5

# n = 12, k = 5, and 12 true bits >>> plateau(np.array([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]), 5) 0

moptipy.examples.bitstrings.trap module

The well-known Trap problem.

The Trap function is similar to OneMax, but swaps the worst possible solution with the global optimum. This means that the best-possible objective value, 0, is reached for the string of all False bits. The worst objective value, n, is reached by the strings with exactly one True bit.

  1. Stefan Droste, Thomas Jansen, and Ingo Wegener. On the Analysis of the (1+1) Evolutionary Algorithm. Theoretical Computer Science. 276(1-2):51-81. April 2002. doi: https://doi.org/10.1016/S0304-3975(01)00182-7

  2. Siegfried Nijssen and Thomas Bäck. An Analysis of the Behavior of Simplified Evolutionary Algorithms on Trap Functions. IEEE Transactions on Evolutionary Computation. 7(1):11-22. 2003. doi: https://doi.org/10.1109/TEVC.2002.806169

  3. Thomas Weise, Zhize Wu, Xinlu Li, and Yan Chen. Frequency Fitness Assignment: Making Optimization Algorithms Invariant under Bijective Transformations of the Objective Function Value. IEEE Transactions on Evolutionary Computation 25(2):307-319. April 2021. Preprint available at arXiv:2001.01416v5 [cs.NE] 15 Oct 2020. https://dx.doi.org/10.1109/TEVC.2020.3032090

  4. Thomas Weise, Zhize Wu, Xinlu Li, Yan Chen, and Jörg Lässig. Frequency Fitness Assignment: Optimization without Bias for Good Solutions can be Efficient. IEEE Transactions on Evolutionary Computation (TEVC). 27(4):980-992. August 2023. doi: https://doi.org/10.1109/TEVC.2022.3191698

class moptipy.examples.bitstrings.trap.Trap(n)[source]

Bases: BitStringProblem

The trap problem.

classmethod default_instances(scale_min=3, scale_max=333)[source]

Get the 77 default instances of the Trap problem.

Parameters:
  • scale_min (int, default: 3) – the minimum permitted scale, by default 3

  • scale_max (int, default: 333) – the maximum permitted scale, by default 333

Return type:

Iterator[Callable[[], Trap]]

Returns:

a sequence of default Trap instances

>>> len(list(Trap.default_instances()))
77
>>> [x() for x in Trap.default_instances()]
[trap_3, trap_4, trap_5, trap_6, trap_7, trap_8, trap_9, trap_10, trap_11, trap_12, trap_13, trap_14, trap_15, trap_16, trap_17, trap_18, trap_19, trap_20, trap_21, trap_22, trap_23, trap_24, trap_25, trap_26, trap_27, trap_28, trap_29, trap_30, trap_31, trap_32, trap_33, trap_36, trap_40, trap_41, trap_42, trap_44, trap_48, trap_49, trap_50, trap_55, trap_59, trap_60, trap_64, trap_66, trap_70, trap_77, trap_79, trap_80, trap_81, trap_85, trap_88, trap_90, trap_96, trap_99, trap_100, trap_107, trap_111, trap_121, trap_125, trap_128, trap_144, trap_149, trap_169, trap_170, trap_192, trap_196, trap_199, trap_200, trap_222, trap_225, trap_243, trap_256, trap_269, trap_289, trap_300, trap_324, trap_333]
moptipy.examples.bitstrings.trap.trap(x)[source]

Compute the trap objective value.

Parameters:

x (ndarray) – the np array

Return type:

int

Returns:

the trap function value

>>> print(trap(np.array([True, True, False, False, False])))
4
>>> print(trap(np.array([True, False, True, False, False])))
4
>>> print(trap(np.array([False, True,  True, False, False])))
4
>>> print(trap(np.array([True, True, True, True, True])))
1
>>> print(trap(np.array([False, True, True, True, True])))
2
>>> print(trap(np.array([False, False, False, False, False])))
0
>>> print(trap(np.array([False, True,  False, False, False])))
5
>>> print(trap(np.array([False, True,  True, True, False])))
3

# n = 1 and 0 true bits >>> trap(np.array([0])) 0

# n = 1 and 1 true bit >>> trap(np.array([1])) 1

# n = 2 and 0 true bits >>> trap(np.array([0, 0])) 0

# n = 2 and 1 true bit >>> trap(np.array([0, 1])) 2

# n = 2 and 1 true bit >>> trap(np.array([0, 1])) 2

# n = 2 and 1 true bit >>> trap(np.array([0, 1])) 2

# n = 2 and 2 true bits >>> trap(np.array([1, 1])) 1

# n = 3 and 0 true bits >>> trap(np.array([0, 0, 0])) 0

# n = 3 and 1 true bit >>> trap(np.array([0, 1, 0])) 3

# n = 3 and 1 true bit >>> trap(np.array([1, 0, 0])) 3

# n = 3 and 1 true bit >>> trap(np.array([0, 0, 1])) 3

# n = 3 and 2 true bits >>> trap(np.array([0, 1, 1])) 2

# n = 3 and 2 true bits >>> trap(np.array([1, 0, 1])) 2

# n = 3 and 2 true bits >>> trap(np.array([0, 1, 1])) 2

# n = 3 and 3 true bits >>> trap(np.array([1, 1, 1])) 1

# n = 4 and 0 true bits >>> trap(np.array([0, 0, 0, 0])) 0

# n = 4 and 1 true bit >>> trap(np.array([1, 0, 0, 0])) 4

# n = 4 and 1 true bit >>> trap(np.array([1, 0, 0, 0])) 4

# n = 4 and 1 true bit >>> trap(np.array([0, 0, 0, 1])) 4

# n = 4 and 2 true bits >>> trap(np.array([1, 1, 0, 0])) 3

# n = 4 and 2 true bits >>> trap(np.array([0, 0, 1, 1])) 3

# n = 4 and 2 true bits >>> trap(np.array([0, 1, 1, 0])) 3

# n = 4 and 3 true bits >>> trap(np.array([0, 1, 1, 1])) 2

# n = 4 and 3 true bits >>> trap(np.array([1, 1, 1, 0])) 2

# n = 4 and 3 true bits >>> trap(np.array([1, 1, 0, 1])) 2

# n = 4 and 4 true bits >>> trap(np.array([1, 1, 1, 1])) 1

# n = 5 and 0 true bits >>> trap(np.array([0, 0, 0, 0, 0])) 0

# n = 5 and 1 true bit >>> trap(np.array([0, 0, 0, 0, 1])) 5

# n = 5 and 1 true bit >>> trap(np.array([0, 0, 0, 1, 0])) 5

# n = 5 and 1 true bit >>> trap(np.array([1, 0, 0, 0, 0])) 5

# n = 5 and 2 true bits >>> trap(np.array([1, 0, 1, 0, 0])) 4

# n = 5 and 2 true bits >>> trap(np.array([1, 0, 1, 0, 0])) 4

# n = 5 and 2 true bits >>> trap(np.array([0, 1, 0, 0, 1])) 4

# n = 5 and 3 true bits >>> trap(np.array([1, 0, 1, 1, 0])) 3

# n = 5 and 3 true bits >>> trap(np.array([0, 1, 1, 0, 1])) 3

# n = 5 and 3 true bits >>> trap(np.array([0, 1, 1, 0, 1])) 3

# n = 5 and 4 true bits >>> trap(np.array([1, 0, 1, 1, 1])) 2

# n = 5 and 4 true bits >>> trap(np.array([1, 1, 1, 0, 1])) 2

# n = 5 and 4 true bits >>> trap(np.array([1, 1, 0, 1, 1])) 2

# n = 5 and 5 true bits >>> trap(np.array([1, 1, 1, 1, 1])) 1

# n = 6 and 0 true bits >>> trap(np.array([0, 0, 0, 0, 0, 0])) 0

# n = 6 and 1 true bit >>> trap(np.array([0, 0, 0, 0, 1, 0])) 6

# n = 6 and 1 true bit >>> trap(np.array([0, 0, 0, 0, 0, 1])) 6

# n = 6 and 1 true bit >>> trap(np.array([0, 0, 1, 0, 0, 0])) 6

# n = 6 and 2 true bits >>> trap(np.array([1, 0, 0, 1, 0, 0])) 5

# n = 6 and 2 true bits >>> trap(np.array([1, 0, 0, 0, 1, 0])) 5

# n = 6 and 2 true bits >>> trap(np.array([1, 0, 0, 0, 1, 0])) 5

# n = 6 and 3 true bits >>> trap(np.array([0, 1, 1, 1, 0, 0])) 4

# n = 6 and 3 true bits >>> trap(np.array([1, 1, 0, 0, 0, 1])) 4

# n = 6 and 3 true bits >>> trap(np.array([0, 1, 1, 1, 0, 0])) 4

# n = 6 and 4 true bits >>> trap(np.array([1, 0, 0, 1, 1, 1])) 3

# n = 6 and 4 true bits >>> trap(np.array([1, 0, 0, 1, 1, 1])) 3

# n = 6 and 4 true bits >>> trap(np.array([0, 1, 1, 1, 1, 0])) 3

# n = 6 and 5 true bits >>> trap(np.array([0, 1, 1, 1, 1, 1])) 2

# n = 6 and 5 true bits >>> trap(np.array([1, 1, 1, 1, 0, 1])) 2

# n = 6 and 5 true bits >>> trap(np.array([1, 1, 1, 1, 1, 0])) 2

# n = 6 and 6 true bits >>> trap(np.array([1, 1, 1, 1, 1, 1])) 1

# n = 7 and 0 true bits >>> trap(np.array([0, 0, 0, 0, 0, 0, 0])) 0

# n = 7 and 1 true bit >>> trap(np.array([0, 0, 1, 0, 0, 0, 0])) 7

# n = 7 and 1 true bit >>> trap(np.array([0, 0, 0, 0, 0, 1, 0])) 7

# n = 7 and 1 true bit >>> trap(np.array([0, 0, 0, 1, 0, 0, 0])) 7

# n = 7 and 2 true bits >>> trap(np.array([0, 0, 1, 0, 0, 0, 1])) 6

# n = 7 and 2 true bits >>> trap(np.array([0, 0, 1, 0, 0, 1, 0])) 6

# n = 7 and 2 true bits >>> trap(np.array([1, 0, 1, 0, 0, 0, 0])) 6

# n = 7 and 3 true bits >>> trap(np.array([0, 0, 1, 1, 0, 1, 0])) 5

# n = 7 and 3 true bits >>> trap(np.array([1, 0, 0, 1, 1, 0, 0])) 5

# n = 7 and 3 true bits >>> trap(np.array([1, 1, 0, 0, 0, 0, 1])) 5

# n = 7 and 4 true bits >>> trap(np.array([0, 1, 0, 0, 1, 1, 1])) 4

# n = 7 and 4 true bits >>> trap(np.array([1, 1, 0, 0, 1, 1, 0])) 4

# n = 7 and 4 true bits >>> trap(np.array([1, 0, 1, 0, 0, 1, 1])) 4

# n = 7 and 5 true bits >>> trap(np.array([1, 1, 0, 1, 1, 1, 0])) 3

# n = 7 and 5 true bits >>> trap(np.array([1, 1, 1, 1, 1, 0, 0])) 3

# n = 7 and 5 true bits >>> trap(np.array([1, 1, 0, 1, 0, 1, 1])) 3

# n = 7 and 6 true bits >>> trap(np.array([1, 1, 1, 1, 1, 1, 0])) 2

# n = 7 and 6 true bits >>> trap(np.array([1, 1, 0, 1, 1, 1, 1])) 2

# n = 7 and 6 true bits >>> trap(np.array([1, 1, 1, 1, 1, 1, 0])) 2

# n = 7 and 7 true bits >>> trap(np.array([1, 1, 1, 1, 1, 1, 1])) 1

# n = 8 and 0 true bits >>> trap(np.array([0, 0, 0, 0, 0, 0, 0, 0])) 0

# n = 8 and 1 true bit >>> trap(np.array([0, 0, 0, 0, 1, 0, 0, 0])) 8

# n = 8 and 1 true bit >>> trap(np.array([0, 1, 0, 0, 0, 0, 0, 0])) 8

# n = 8 and 1 true bit >>> trap(np.array([0, 0, 1, 0, 0, 0, 0, 0])) 8

# n = 8 and 2 true bits >>> trap(np.array([1, 0, 0, 0, 0, 1, 0, 0])) 7

# n = 8 and 2 true bits >>> trap(np.array([0, 1, 0, 0, 1, 0, 0, 0])) 7

# n = 8 and 2 true bits >>> trap(np.array([0, 1, 0, 0, 1, 0, 0, 0])) 7

# n = 8 and 3 true bits >>> trap(np.array([0, 1, 0, 0, 0, 1, 1, 0])) 6

# n = 8 and 3 true bits >>> trap(np.array([0, 1, 1, 0, 0, 1, 0, 0])) 6

# n = 8 and 3 true bits >>> trap(np.array([1, 1, 0, 0, 1, 0, 0, 0])) 6

# n = 8 and 4 true bits >>> trap(np.array([1, 0, 1, 0, 1, 0, 0, 1])) 5

# n = 8 and 4 true bits >>> trap(np.array([0, 1, 1, 1, 1, 0, 0, 0])) 5

# n = 8 and 4 true bits >>> trap(np.array([1, 1, 1, 0, 0, 1, 0, 0])) 5

# n = 8 and 5 true bits >>> trap(np.array([1, 1, 0, 0, 0, 1, 1, 1])) 4

# n = 8 and 5 true bits >>> trap(np.array([1, 1, 1, 0, 0, 1, 1, 0])) 4

# n = 8 and 5 true bits >>> trap(np.array([0, 0, 1, 1, 0, 1, 1, 1])) 4

# n = 8 and 6 true bits >>> trap(np.array([0, 1, 1, 1, 1, 1, 1, 0])) 3

# n = 8 and 6 true bits >>> trap(np.array([1, 1, 0, 1, 1, 1, 0, 1])) 3

# n = 8 and 6 true bits >>> trap(np.array([1, 1, 1, 0, 0, 1, 1, 1])) 3

# n = 8 and 7 true bits >>> trap(np.array([1, 1, 1, 1, 1, 1, 0, 1])) 2

# n = 8 and 7 true bits >>> trap(np.array([1, 1, 1, 1, 1, 1, 1, 0])) 2

# n = 8 and 7 true bits >>> trap(np.array([1, 0, 1, 1, 1, 1, 1, 1])) 2

# n = 8 and 8 true bits >>> trap(np.array([1, 1, 1, 1, 1, 1, 1, 1])) 1

# n = 9 and 0 true bits >>> trap(np.array([0, 0, 0, 0, 0, 0, 0, 0, 0])) 0

# n = 9 and 1 true bit >>> trap(np.array([0, 0, 0, 0, 0, 1, 0, 0, 0])) 9

# n = 9 and 1 true bit >>> trap(np.array([0, 0, 0, 0, 0, 0, 0, 1, 0])) 9

# n = 9 and 1 true bit >>> trap(np.array([0, 1, 0, 0, 0, 0, 0, 0, 0])) 9

# n = 9 and 2 true bits >>> trap(np.array([1, 0, 0, 0, 1, 0, 0, 0, 0])) 8

# n = 9 and 2 true bits >>> trap(np.array([0, 0, 0, 0, 0, 0, 0, 1, 1])) 8

# n = 9 and 2 true bits >>> trap(np.array([0, 0, 0, 1, 0, 0, 0, 1, 0])) 8

# n = 9 and 3 true bits >>> trap(np.array([0, 1, 0, 0, 0, 1, 0, 0, 1])) 7

# n = 9 and 3 true bits >>> trap(np.array([1, 0, 0, 1, 1, 0, 0, 0, 0])) 7

# n = 9 and 3 true bits >>> trap(np.array([1, 1, 0, 0, 0, 0, 1, 0, 0])) 7

# n = 9 and 4 true bits >>> trap(np.array([1, 0, 1, 1, 0, 0, 1, 0, 0])) 6

# n = 9 and 4 true bits >>> trap(np.array([1, 0, 1, 0, 0, 0, 1, 1, 0])) 6

# n = 9 and 4 true bits >>> trap(np.array([1, 0, 0, 1, 0, 0, 1, 1, 0])) 6

# n = 9 and 5 true bits >>> trap(np.array([1, 0, 1, 1, 0, 0, 0, 1, 1])) 5

# n = 9 and 5 true bits >>> trap(np.array([0, 1, 0, 1, 0, 1, 1, 0, 1])) 5

# n = 9 and 5 true bits >>> trap(np.array([1, 0, 0, 0, 1, 0, 1, 1, 1])) 5

# n = 9 and 6 true bits >>> trap(np.array([1, 1, 1, 0, 0, 1, 0, 1, 1])) 4

# n = 9 and 6 true bits >>> trap(np.array([0, 1, 1, 0, 1, 1, 0, 1, 1])) 4

# n = 9 and 6 true bits >>> trap(np.array([1, 0, 1, 0, 1, 1, 1, 0, 1])) 4

# n = 9 and 7 true bits >>> trap(np.array([1, 1, 1, 1, 1, 1, 1, 0, 0])) 3

# n = 9 and 7 true bits >>> trap(np.array([1, 0, 1, 1, 1, 1, 1, 0, 1])) 3

# n = 9 and 7 true bits >>> trap(np.array([1, 1, 0, 1, 1, 1, 1, 0, 1])) 3

# n = 9 and 8 true bits >>> trap(np.array([0, 1, 1, 1, 1, 1, 1, 1, 1])) 2

# n = 9 and 8 true bits >>> trap(np.array([1, 1, 1, 1, 1, 1, 1, 1, 0])) 2

# n = 9 and 8 true bits >>> trap(np.array([1, 1, 1, 1, 1, 0, 1, 1, 1])) 2

# n = 9 and 9 true bits >>> trap(np.array([1, 1, 1, 1, 1, 1, 1, 1, 1])) 1

# n = 10 and 0 true bits >>> trap(np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0])) 0

# n = 10 and 1 true bit >>> trap(np.array([0, 0, 0, 0, 0, 1, 0, 0, 0, 0])) 10

# n = 10 and 1 true bit >>> trap(np.array([0, 0, 1, 0, 0, 0, 0, 0, 0, 0])) 10

# n = 10 and 1 true bit >>> trap(np.array([0, 0, 0, 0, 1, 0, 0, 0, 0, 0])) 10

# n = 10 and 2 true bits >>> trap(np.array([1, 0, 0, 0, 0, 1, 0, 0, 0, 0])) 9

# n = 10 and 2 true bits >>> trap(np.array([0, 1, 0, 0, 0, 0, 0, 0, 0, 1])) 9

# n = 10 and 2 true bits >>> trap(np.array([0, 0, 0, 1, 0, 1, 0, 0, 0, 0])) 9

# n = 10 and 3 true bits >>> trap(np.array([0, 1, 0, 0, 0, 0, 0, 1, 0, 1])) 8

# n = 10 and 3 true bits >>> trap(np.array([0, 1, 0, 0, 0, 1, 0, 0, 0, 1])) 8

# n = 10 and 3 true bits >>> trap(np.array([1, 0, 0, 1, 0, 0, 0, 1, 0, 0])) 8

# n = 10 and 4 true bits >>> trap(np.array([0, 0, 1, 0, 1, 0, 0, 1, 1, 0])) 7

# n = 10 and 4 true bits >>> trap(np.array([1, 0, 0, 0, 0, 0, 1, 0, 1, 1])) 7

# n = 10 and 4 true bits >>> trap(np.array([1, 0, 0, 1, 0, 1, 0, 0, 1, 0])) 7

# n = 10 and 5 true bits >>> trap(np.array([1, 1, 0, 1, 0, 1, 0, 0, 0, 1])) 6

# n = 10 and 5 true bits >>> trap(np.array([1, 0, 1, 0, 1, 0, 0, 0, 1, 1])) 6

# n = 10 and 5 true bits >>> trap(np.array([0, 1, 1, 1, 0, 1, 0, 0, 1, 0])) 6

# n = 10 and 6 true bits >>> trap(np.array([0, 1, 1, 0, 0, 1, 1, 1, 0, 1])) 5

# n = 10 and 6 true bits >>> trap(np.array([0, 0, 0, 1, 1, 0, 1, 1, 1, 1])) 5

# n = 10 and 6 true bits >>> trap(np.array([1, 1, 0, 1, 0, 1, 1, 0, 0, 1])) 5

# n = 10 and 7 true bits >>> trap(np.array([0, 1, 1, 0, 1, 1, 1, 1, 0, 1])) 4

# n = 10 and 7 true bits >>> trap(np.array([0, 1, 1, 1, 1, 1, 1, 0, 1, 0])) 4

# n = 10 and 7 true bits >>> trap(np.array([1, 1, 1, 1, 1, 0, 1, 1, 0, 0])) 4

# n = 10 and 8 true bits >>> trap(np.array([1, 1, 0, 0, 1, 1, 1, 1, 1, 1])) 3

# n = 10 and 8 true bits >>> trap(np.array([1, 0, 1, 1, 1, 0, 1, 1, 1, 1])) 3

# n = 10 and 8 true bits >>> trap(np.array([1, 1, 1, 1, 0, 0, 1, 1, 1, 1])) 3

# n = 10 and 9 true bits >>> trap(np.array([1, 1, 1, 1, 1, 1, 0, 1, 1, 1])) 2

# n = 10 and 9 true bits >>> trap(np.array([1, 1, 1, 1, 0, 1, 1, 1, 1, 1])) 2

# n = 10 and 9 true bits >>> trap(np.array([1, 1, 1, 1, 1, 1, 1, 1, 0, 1])) 2

# n = 10 and 10 true bits >>> trap(np.array([1, 1, 1, 1, 1, 1, 1, 1, 1, 1])) 1

moptipy.examples.bitstrings.twomax module

The TwoMax problem.

TwoMax has two optima. The local optimum at the string with all False bits. The objective value of this local optimum is 1. The global optimum is the string with all True bits and its objective value is 0. The worst objective value is reached if half of the bits are True and the other half is False. Then, the objective value will be (n // 2) + 1.

The TwoMax problem is based on OneMax but introduces deceptiveness in the objective function by having a local and a global optimum. Since their basins of attraction have the same size, a (1 + 1) EA can solve the problem in Omega(n ln n) steps with probability 0.5 while otherwise needing exponential runtime in expectation, leading to a total expected runtime in Omega(n ** n).

  1. Tobias Friedrich, Francesco Quinzan, and Markus Wagner. Escaping Large Deceptive Basins of Attraction with Heavy-Tailed Mutation Operators. GECCO 2018. ACM. doi: https://doi.org/10.1145/3205455.3205515.

  2. Clarissa Van Hoyweghen, David E. Goldberg, and Bart Naudts. From TwoMax to the Ising Model: Easy and Hard Symmetrical Problems. GECCO 2002. pp 626-633. Morgan Kaufmann.

  3. Tobias Friedrich, Pietro S. Oliveto, Dirk Sudholt, and Carsten Witt. Analysis of Diversity-Preserving Mechanisms for Global Exploration. Evolutionary Computation. 17(4):455-476. 2009. doi: https://doi.org/10.1162/evco.2009.17.4.17401.

  4. Thomas Weise, Zhize Wu, Xinlu Li, and Yan Chen. Frequency Fitness Assignment: Making Optimization Algorithms Invariant under Bijective Transformations of the Objective Function Value. IEEE Transactions on Evolutionary Computation 25(2):307-319. April 2021. Preprint available at arXiv:2001.01416v5 [cs.NE] 15 Oct 2020. https://dx.doi.org/10.1109/TEVC.2020.3032090

  5. Thomas Weise, Zhize Wu, Xinlu Li, Yan Chen, and Jörg Lässig. Frequency Fitness Assignment: Optimization without Bias for Good Solutions can be Efficient. IEEE Transactions on Evolutionary Computation (TEVC). 27(4):980-992. August 2023. doi: https://doi.org/10.1109/TEVC.2022.3191698

This is code is part of the research work of Mr. Jiazheng ZENG (曾嘉政), a Master’s student at the Institute of Applied Optimization (应用优化研究所, http://iao.hfuu.edu.cn) of the School of Artificial Intelligence and Big Data (人工智能与大数据学院) at Hefei University (合肥大学) in Hefei, Anhui, China (中国安徽省合肥市) under the supervision of Prof. Dr. Thomas Weise (汤卫思教授).

class moptipy.examples.bitstrings.twomax.TwoMax(n)[source]

Bases: BitStringProblem

The TwoMax benchmark problem.

classmethod default_instances(scale_min=3, scale_max=333)[source]

Get the 77 default instances of the TwoMax problem.

Parameters:
  • scale_min (int, default: 3) – the minimum permitted scale, by default 3

  • scale_max (int, default: 333) – the maximum permitted scale, by default 333

Return type:

Iterator[Callable[[], TwoMax]]

Returns:

a sequence of default TwoMax instances

>>> len(list(TwoMax.default_instances()))
77
>>> [x() for x in TwoMax.default_instances()]
[twomax_3, twomax_4, twomax_5, twomax_6, twomax_7, twomax_8, twomax_9, twomax_10, twomax_11, twomax_12, twomax_13, twomax_14, twomax_15, twomax_16, twomax_17, twomax_18, twomax_19, twomax_20, twomax_21, twomax_22, twomax_23, twomax_24, twomax_25, twomax_26, twomax_27, twomax_28, twomax_29, twomax_30, twomax_31, twomax_32, twomax_33, twomax_36, twomax_40, twomax_41, twomax_42, twomax_44, twomax_48, twomax_49, twomax_50, twomax_55, twomax_59, twomax_60, twomax_64, twomax_66, twomax_70, twomax_77, twomax_79, twomax_80, twomax_81, twomax_85, twomax_88, twomax_90, twomax_96, twomax_99, twomax_100, twomax_107, twomax_111, twomax_121, twomax_125, twomax_128, twomax_144, twomax_149, twomax_169, twomax_170, twomax_192, twomax_196, twomax_199, twomax_200, twomax_222, twomax_225, twomax_243, twomax_256, twomax_269, twomax_289, twomax_300, twomax_324, twomax_333]
upper_bound()[source]

Get the upper bound of the twomax problem.

Return type:

int

Returns:

the length of the bit string integer-divided by 2, plus 1

>>> TwoMax(15).upper_bound()
8
>>> TwoMax(5).upper_bound()
3
moptipy.examples.bitstrings.twomax.twomax(x)[source]

Compute the objective value of the TwoMax problem.

Parameters:

x (ndarray) – the np array

Return type:

int

Returns:

the sum of the indices of the first two ones

>>> twomax(np.array([True, True, True, True, True]))
0
>>> twomax(np.array([False, False, False, False, False]))
1
>>> twomax(np.array([False, True, True, False, False]))
3
>>> twomax(np.array([True, True, True, True, True]))
0
>>> twomax(np.array([False, False, False, False, False]))
1
>>> twomax(np.array([False, True, False, False, False]))
2
>>> twomax(np.array([False, False, False, False, False, False]))
1
>>> twomax(np.array([False, False, True, False, False, False]))
2
>>> twomax(np.array([False, True, False, True, False, False]))
3
>>> twomax(np.array([False, True, False, True, False, True]))
4
>>> twomax(np.array([True, False, True, False, True, True]))
3
>>> twomax(np.array([False, True, True, True, True, True]))
2
>>> twomax(np.array([True, True, True, True, True, True]))
0

# n = 1 and 0 true bits >>> twomax(np.array([0])) 1

# n = 1 and 1 true bit >>> twomax(np.array([1])) 0

# n = 2 and 0 true bits >>> twomax(np.array([0, 0])) 1

# n = 2 and 1 true bit >>> twomax(np.array([0, 1])) 2

# n = 2 and 1 true bit >>> twomax(np.array([0, 1])) 2

# n = 2 and 1 true bit >>> twomax(np.array([0, 1])) 2

# n = 2 and 2 true bits >>> twomax(np.array([1, 1])) 0

# n = 3 and 0 true bits >>> twomax(np.array([0, 0, 0])) 1

# n = 3 and 1 true bit >>> twomax(np.array([1, 0, 0])) 2

# n = 3 and 1 true bit >>> twomax(np.array([0, 1, 0])) 2

# n = 3 and 1 true bit >>> twomax(np.array([0, 0, 1])) 2

# n = 3 and 2 true bits >>> twomax(np.array([1, 0, 1])) 2

# n = 3 and 2 true bits >>> twomax(np.array([0, 1, 1])) 2

# n = 3 and 2 true bits >>> twomax(np.array([1, 1, 0])) 2

# n = 3 and 3 true bits >>> twomax(np.array([1, 1, 1])) 0

# n = 4 and 0 true bits >>> twomax(np.array([0, 0, 0, 0])) 1

# n = 4 and 1 true bit >>> twomax(np.array([1, 0, 0, 0])) 2

# n = 4 and 1 true bit >>> twomax(np.array([0, 0, 0, 1])) 2

# n = 4 and 1 true bit >>> twomax(np.array([1, 0, 0, 0])) 2

# n = 4 and 2 true bits >>> twomax(np.array([0, 1, 1, 0])) 3

# n = 4 and 2 true bits >>> twomax(np.array([0, 1, 0, 1])) 3

# n = 4 and 2 true bits >>> twomax(np.array([0, 0, 1, 1])) 3

# n = 4 and 3 true bits >>> twomax(np.array([1, 0, 1, 1])) 2

# n = 4 and 3 true bits >>> twomax(np.array([1, 1, 1, 0])) 2

# n = 4 and 3 true bits >>> twomax(np.array([1, 1, 0, 1])) 2

# n = 4 and 4 true bits >>> twomax(np.array([1, 1, 1, 1])) 0

# n = 5 and 0 true bits >>> twomax(np.array([0, 0, 0, 0, 0])) 1

# n = 5 and 1 true bit >>> twomax(np.array([0, 0, 0, 1, 0])) 2

# n = 5 and 1 true bit >>> twomax(np.array([0, 1, 0, 0, 0])) 2

# n = 5 and 1 true bit >>> twomax(np.array([1, 0, 0, 0, 0])) 2

# n = 5 and 2 true bits >>> twomax(np.array([0, 1, 1, 0, 0])) 3

# n = 5 and 2 true bits >>> twomax(np.array([0, 1, 0, 0, 1])) 3

# n = 5 and 2 true bits >>> twomax(np.array([1, 1, 0, 0, 0])) 3

# n = 5 and 3 true bits >>> twomax(np.array([1, 1, 0, 1, 0])) 3

# n = 5 and 3 true bits >>> twomax(np.array([0, 1, 0, 1, 1])) 3

# n = 5 and 3 true bits >>> twomax(np.array([1, 0, 1, 1, 0])) 3

# n = 5 and 4 true bits >>> twomax(np.array([0, 1, 1, 1, 1])) 2

# n = 5 and 4 true bits >>> twomax(np.array([0, 1, 1, 1, 1])) 2

# n = 5 and 4 true bits >>> twomax(np.array([1, 1, 0, 1, 1])) 2

# n = 5 and 5 true bits >>> twomax(np.array([1, 1, 1, 1, 1])) 0

# n = 6 and 0 true bits >>> twomax(np.array([0, 0, 0, 0, 0, 0])) 1

# n = 6 and 1 true bit >>> twomax(np.array([0, 0, 0, 0, 0, 1])) 2

# n = 6 and 1 true bit >>> twomax(np.array([1, 0, 0, 0, 0, 0])) 2

# n = 6 and 1 true bit >>> twomax(np.array([0, 0, 1, 0, 0, 0])) 2

# n = 6 and 2 true bits >>> twomax(np.array([1, 1, 0, 0, 0, 0])) 3

# n = 6 and 2 true bits >>> twomax(np.array([0, 0, 0, 1, 0, 1])) 3

# n = 6 and 2 true bits >>> twomax(np.array([1, 0, 0, 0, 1, 0])) 3

# n = 6 and 3 true bits >>> twomax(np.array([0, 1, 1, 0, 1, 0])) 4

# n = 6 and 3 true bits >>> twomax(np.array([0, 1, 1, 0, 0, 1])) 4

# n = 6 and 3 true bits >>> twomax(np.array([1, 0, 1, 0, 1, 0])) 4

# n = 6 and 4 true bits >>> twomax(np.array([1, 0, 0, 1, 1, 1])) 3

# n = 6 and 4 true bits >>> twomax(np.array([1, 0, 1, 1, 0, 1])) 3

# n = 6 and 4 true bits >>> twomax(np.array([1, 0, 0, 1, 1, 1])) 3

# n = 6 and 5 true bits >>> twomax(np.array([0, 1, 1, 1, 1, 1])) 2

# n = 6 and 5 true bits >>> twomax(np.array([1, 1, 0, 1, 1, 1])) 2

# n = 6 and 5 true bits >>> twomax(np.array([1, 1, 0, 1, 1, 1])) 2

# n = 6 and 6 true bits >>> twomax(np.array([1, 1, 1, 1, 1, 1])) 0

# n = 7 and 0 true bits >>> twomax(np.array([0, 0, 0, 0, 0, 0, 0])) 1

# n = 7 and 1 true bit >>> twomax(np.array([0, 0, 0, 0, 0, 1, 0])) 2

# n = 7 and 1 true bit >>> twomax(np.array([0, 1, 0, 0, 0, 0, 0])) 2

# n = 7 and 1 true bit >>> twomax(np.array([0, 0, 0, 0, 0, 1, 0])) 2

# n = 7 and 2 true bits >>> twomax(np.array([0, 0, 1, 0, 0, 1, 0])) 3

# n = 7 and 2 true bits >>> twomax(np.array([1, 1, 0, 0, 0, 0, 0])) 3

# n = 7 and 2 true bits >>> twomax(np.array([0, 1, 0, 0, 0, 0, 1])) 3

# n = 7 and 3 true bits >>> twomax(np.array([0, 1, 1, 0, 0, 0, 1])) 4

# n = 7 and 3 true bits >>> twomax(np.array([1, 0, 0, 0, 1, 1, 0])) 4

# n = 7 and 3 true bits >>> twomax(np.array([1, 0, 0, 0, 1, 1, 0])) 4

# n = 7 and 4 true bits >>> twomax(np.array([1, 1, 0, 0, 1, 1, 0])) 4

# n = 7 and 4 true bits >>> twomax(np.array([1, 1, 0, 1, 0, 0, 1])) 4

# n = 7 and 4 true bits >>> twomax(np.array([1, 1, 0, 1, 1, 0, 0])) 4

# n = 7 and 5 true bits >>> twomax(np.array([1, 1, 1, 0, 1, 0, 1])) 3

# n = 7 and 5 true bits >>> twomax(np.array([1, 1, 1, 0, 0, 1, 1])) 3

# n = 7 and 5 true bits >>> twomax(np.array([1, 1, 0, 1, 0, 1, 1])) 3

# n = 7 and 6 true bits >>> twomax(np.array([1, 1, 0, 1, 1, 1, 1])) 2

# n = 7 and 6 true bits >>> twomax(np.array([1, 1, 1, 1, 0, 1, 1])) 2

# n = 7 and 6 true bits >>> twomax(np.array([1, 1, 1, 0, 1, 1, 1])) 2

# n = 7 and 7 true bits >>> twomax(np.array([1, 1, 1, 1, 1, 1, 1])) 0

# n = 8 and 0 true bits >>> twomax(np.array([0, 0, 0, 0, 0, 0, 0, 0])) 1

# n = 8 and 1 true bit >>> twomax(np.array([0, 0, 0, 0, 0, 0, 0, 1])) 2

# n = 8 and 1 true bit >>> twomax(np.array([0, 0, 0, 0, 0, 0, 1, 0])) 2

# n = 8 and 1 true bit >>> twomax(np.array([0, 0, 0, 0, 1, 0, 0, 0])) 2

# n = 8 and 2 true bits >>> twomax(np.array([0, 1, 0, 1, 0, 0, 0, 0])) 3

# n = 8 and 2 true bits >>> twomax(np.array([0, 1, 0, 0, 1, 0, 0, 0])) 3

# n = 8 and 2 true bits >>> twomax(np.array([0, 0, 0, 0, 1, 0, 0, 1])) 3

# n = 8 and 3 true bits >>> twomax(np.array([0, 0, 0, 0, 1, 0, 1, 1])) 4

# n = 8 and 3 true bits >>> twomax(np.array([0, 0, 0, 0, 0, 1, 1, 1])) 4

# n = 8 and 3 true bits >>> twomax(np.array([0, 0, 0, 1, 1, 1, 0, 0])) 4

# n = 8 and 4 true bits >>> twomax(np.array([1, 1, 0, 0, 1, 1, 0, 0])) 5

# n = 8 and 4 true bits >>> twomax(np.array([1, 1, 0, 0, 0, 1, 1, 0])) 5

# n = 8 and 4 true bits >>> twomax(np.array([0, 1, 1, 0, 1, 0, 1, 0])) 5

# n = 8 and 5 true bits >>> twomax(np.array([1, 1, 0, 1, 0, 1, 1, 0])) 4

# n = 8 and 5 true bits >>> twomax(np.array([0, 1, 0, 1, 0, 1, 1, 1])) 4

# n = 8 and 5 true bits >>> twomax(np.array([1, 1, 0, 0, 1, 1, 1, 0])) 4

# n = 8 and 6 true bits >>> twomax(np.array([1, 1, 1, 1, 0, 1, 1, 0])) 3

# n = 8 and 6 true bits >>> twomax(np.array([1, 1, 1, 1, 0, 1, 0, 1])) 3

# n = 8 and 6 true bits >>> twomax(np.array([0, 1, 1, 1, 1, 1, 1, 0])) 3

# n = 8 and 7 true bits >>> twomax(np.array([1, 1, 1, 1, 0, 1, 1, 1])) 2

# n = 8 and 7 true bits >>> twomax(np.array([1, 1, 1, 0, 1, 1, 1, 1])) 2

# n = 8 and 7 true bits >>> twomax(np.array([1, 1, 1, 1, 1, 1, 0, 1])) 2

# n = 8 and 8 true bits >>> twomax(np.array([1, 1, 1, 1, 1, 1, 1, 1])) 0

# n = 9 and 0 true bits >>> twomax(np.array([0, 0, 0, 0, 0, 0, 0, 0, 0])) 1

# n = 9 and 1 true bit >>> twomax(np.array([0, 0, 0, 0, 0, 0, 0, 1, 0])) 2

# n = 9 and 1 true bit >>> twomax(np.array([0, 1, 0, 0, 0, 0, 0, 0, 0])) 2

# n = 9 and 1 true bit >>> twomax(np.array([0, 1, 0, 0, 0, 0, 0, 0, 0])) 2

# n = 9 and 2 true bits >>> twomax(np.array([0, 0, 0, 1, 0, 0, 0, 1, 0])) 3

# n = 9 and 2 true bits >>> twomax(np.array([0, 0, 0, 0, 0, 1, 0, 0, 1])) 3

# n = 9 and 2 true bits >>> twomax(np.array([0, 1, 0, 0, 0, 0, 0, 1, 0])) 3

# n = 9 and 3 true bits >>> twomax(np.array([0, 1, 0, 0, 0, 0, 1, 0, 1])) 4

# n = 9 and 3 true bits >>> twomax(np.array([0, 1, 0, 1, 0, 0, 0, 0, 1])) 4

# n = 9 and 3 true bits >>> twomax(np.array([0, 0, 1, 0, 0, 1, 0, 1, 0])) 4

# n = 9 and 4 true bits >>> twomax(np.array([1, 1, 0, 0, 0, 0, 0, 1, 1])) 5

# n = 9 and 4 true bits >>> twomax(np.array([0, 0, 1, 0, 0, 1, 1, 1, 0])) 5

# n = 9 and 4 true bits >>> twomax(np.array([0, 1, 0, 1, 0, 1, 0, 0, 1])) 5

# n = 9 and 5 true bits >>> twomax(np.array([1, 1, 1, 0, 0, 0, 0, 1, 1])) 5

# n = 9 and 5 true bits >>> twomax(np.array([0, 0, 0, 1, 1, 1, 0, 1, 1])) 5

# n = 9 and 5 true bits >>> twomax(np.array([0, 0, 1, 1, 0, 1, 1, 1, 0])) 5

# n = 9 and 6 true bits >>> twomax(np.array([1, 1, 0, 1, 1, 0, 0, 1, 1])) 4

# n = 9 and 6 true bits >>> twomax(np.array([1, 0, 1, 1, 0, 1, 1, 0, 1])) 4

# n = 9 and 6 true bits >>> twomax(np.array([1, 0, 1, 1, 1, 0, 1, 0, 1])) 4

# n = 9 and 7 true bits >>> twomax(np.array([1, 1, 1, 1, 1, 0, 0, 1, 1])) 3

# n = 9 and 7 true bits >>> twomax(np.array([1, 1, 1, 0, 0, 1, 1, 1, 1])) 3

# n = 9 and 7 true bits >>> twomax(np.array([1, 0, 1, 1, 1, 0, 1, 1, 1])) 3

# n = 9 and 8 true bits >>> twomax(np.array([1, 1, 0, 1, 1, 1, 1, 1, 1])) 2

# n = 9 and 8 true bits >>> twomax(np.array([1, 1, 1, 1, 1, 0, 1, 1, 1])) 2

# n = 9 and 8 true bits >>> twomax(np.array([1, 1, 1, 1, 1, 1, 0, 1, 1])) 2

# n = 9 and 9 true bits >>> twomax(np.array([1, 1, 1, 1, 1, 1, 1, 1, 1])) 0

# n = 10 and 0 true bits >>> twomax(np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0])) 1

# n = 10 and 1 true bit >>> twomax(np.array([0, 0, 0, 0, 0, 0, 0, 1, 0, 0])) 2

# n = 10 and 1 true bit >>> twomax(np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 1])) 2

# n = 10 and 1 true bit >>> twomax(np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 1])) 2

# n = 10 and 2 true bits >>> twomax(np.array([1, 0, 0, 0, 0, 0, 1, 0, 0, 0])) 3

# n = 10 and 2 true bits >>> twomax(np.array([0, 0, 0, 1, 1, 0, 0, 0, 0, 0])) 3

# n = 10 and 2 true bits >>> twomax(np.array([0, 0, 1, 0, 0, 0, 0, 0, 1, 0])) 3

# n = 10 and 3 true bits >>> twomax(np.array([0, 0, 1, 0, 1, 0, 0, 0, 0, 1])) 4

# n = 10 and 3 true bits >>> twomax(np.array([0, 1, 0, 0, 0, 0, 0, 0, 1, 1])) 4

# n = 10 and 3 true bits >>> twomax(np.array([0, 1, 1, 0, 1, 0, 0, 0, 0, 0])) 4

# n = 10 and 4 true bits >>> twomax(np.array([1, 1, 0, 1, 1, 0, 0, 0, 0, 0])) 5

# n = 10 and 4 true bits >>> twomax(np.array([1, 1, 0, 0, 0, 0, 0, 0, 1, 1])) 5

# n = 10 and 4 true bits >>> twomax(np.array([1, 0, 1, 0, 0, 1, 1, 0, 0, 0])) 5

# n = 10 and 5 true bits >>> twomax(np.array([0, 0, 0, 1, 0, 1, 1, 1, 1, 0])) 6

# n = 10 and 5 true bits >>> twomax(np.array([0, 1, 1, 1, 1, 0, 0, 0, 1, 0])) 6

# n = 10 and 5 true bits >>> twomax(np.array([1, 0, 0, 1, 1, 1, 0, 1, 0, 0])) 6

# n = 10 and 6 true bits >>> twomax(np.array([1, 1, 1, 1, 0, 0, 1, 0, 0, 1])) 5

# n = 10 and 6 true bits >>> twomax(np.array([0, 1, 0, 1, 1, 1, 1, 0, 0, 1])) 5

# n = 10 and 6 true bits >>> twomax(np.array([0, 1, 0, 1, 1, 0, 1, 1, 1, 0])) 5

# n = 10 and 7 true bits >>> twomax(np.array([1, 0, 1, 1, 0, 1, 0, 1, 1, 1])) 4

# n = 10 and 7 true bits >>> twomax(np.array([1, 1, 1, 0, 0, 1, 1, 1, 1, 0])) 4

# n = 10 and 7 true bits >>> twomax(np.array([0, 1, 0, 1, 0, 1, 1, 1, 1, 1])) 4

# n = 10 and 8 true bits >>> twomax(np.array([0, 1, 1, 1, 1, 1, 1, 0, 1, 1])) 3

# n = 10 and 8 true bits >>> twomax(np.array([1, 1, 1, 1, 1, 1, 1, 1, 0, 0])) 3

# n = 10 and 8 true bits >>> twomax(np.array([0, 0, 1, 1, 1, 1, 1, 1, 1, 1])) 3

# n = 10 and 9 true bits >>> twomax(np.array([1, 1, 1, 1, 1, 1, 1, 1, 0, 1])) 2

# n = 10 and 9 true bits >>> twomax(np.array([0, 1, 1, 1, 1, 1, 1, 1, 1, 1])) 2

# n = 10 and 9 true bits >>> twomax(np.array([1, 0, 1, 1, 1, 1, 1, 1, 1, 1])) 2

# n = 10 and 10 true bits >>> twomax(np.array([1, 1, 1, 1, 1, 1, 1, 1, 1, 1])) 0

moptipy.examples.bitstrings.w_model module

A Python implementation of the W-Model benchmark problem.

This is a tunable benchmark problem for bit-string based search spaces. It exhibits ruggedness, epistasis, deceptiveness, and (uniform) neutrality in a tunable fashion. In [1], a set of 19 diverse instances of the W-Model are selected for algorithm benchmarking. These instances are provided via default_instances().

  1. Thomas Weise, Yan Chen, Xinlu Li, and Zhize Wu. Selecting a diverse set of benchmark instances from a tunable model problem for black-box discrete optimization algorithms. Applied Soft Computing Journal (ASOC), 92:106269, June 2020. doi: https://doi.org/10.1016/j.asoc.2020.106269

  2. Thomas Weise and Zijun Wu. Difficult Features of Combinatorial Optimization Problems and the Tunable W-Model Benchmark Problem for Simulating them. In Black Box Discrete Optimization Benchmarking (BB-DOB) Workshop of Companion Material Proceedings of the Genetic and Evolutionary Computation Conference (GECCO 2018), July 15th-19th 2018, Kyoto, Japan, pages 1769-1776, ISBN 978-1-4503-5764-7. ACM. doi: https://doi.org/10.1145/3205651.3208240

  3. Thomas Weise, Stefan Niemczyk, Hendrik Skubch, Roland Reichle, and Kurt Geihs. A Tunable Model for Multi-Objective, Epistatic, Rugged, and Neutral Fitness Landscapes. In Maarten Keijzer, Giuliano Antoniol, Clare Bates Congdon, Kalyanmoy Deb, Benjamin Doerr, Nikolaus Hansen, John H. Holmes, Gregory S. Hornby, Daniel Howard, James Kennedy, Sanjeev P. Kumar, Fernando G. Lobo, Julian Francis Miller, Jason H. Moore, Frank Neumann, Martin Pelikan, Jordan B. Pollack, Kumara Sastry, Kenneth Owen Stanley, Adrian Stoica, El-Ghazali, and Ingo Wegener, editors, Proceedings of the 10th Annual Conference on Genetic and Evolutionary Computation (GECCO’08), pages 795-802, July 12-16, 2008, Atlanta, GA, USA. ISBN: 978-1-60558-130-9, New York, NY, USA: ACM Press. doi: https://doi.org/10.1145/1389095.1389252

  4. Carola Doerr, Furong Ye, Naama Horesh, Hao Wang, Ofer M. Shir, Thomas Bäck. Benchmarking Discrete Optimization Heuristics with IOHprofiler. Applied Soft Computing 88:106027, March 2020, doi: https://doi.org/10.1016/j.asoc.2019.106027.

  5. Thomas Weise, Zhize Wu, Xinlu Li, Yan Chen, and Jörg Lässig. Frequency Fitness Assignment: Optimization without Bias for Good Solutions can be Efficient. IEEE Transactions on Evolutionary Computation (TEVC). 27(4):980-992. August 2023. doi: https://doi.org/10.1109/TEVC.2022.3191698

class moptipy.examples.bitstrings.w_model.WModel(nopt, m=1, nu=2, gamma=0, name=None)[source]

Bases: BitStringProblem

The tunable W-Model benchmark problem.

classmethod default_instances(scale_min=16, scale_max=256)[source]

Get the 19 default instances of the W-Model.

Parameters:
  • scale_min (int, default: 16) – the minimum permitted scale

  • scale_max (int, default: 256) – the maximum permitted scale

Return type:

Iterator[Callable[[], WModel]]

Returns:

an Iterable that can provide callables constructing the 19 default instances of the W-Model

>>> len(list(WModel.default_instances()))
19
>>> [x() for x in WModel.default_instances()]
[wmodel_1, wmodel_2, wmodel_3, wmodel_4, wmodel_5, wmodel_6, wmodel_7, wmodel_8, wmodel_9, wmodel_10, wmodel_11, wmodel_12, wmodel_13, wmodel_14, wmodel_15, wmodel_16, wmodel_17, wmodel_18, wmodel_19]
>>> len(list(WModel.default_instances(scale_max=200)))
18
>>> len(list(WModel.default_instances(scale_min=40)))
14
evaluate(x)[source]

Evaluate a solution to the W-Model.

Parameters:

x (ndarray) – the bit string to evaluate

Return type:

int

Returns:

the value of the W-Model for the string

gamma: Final[int]

the ruggedness parameter

gamma1: Final[float]

the normalized ruggedness parameter

gamma_prime: Final[int]

the translated gamma parameter

log_parameters_to(logger)[source]

Log all parameters of this component as key-value pairs.

Parameters:

logger (KeyValueLogSection) – the logger for the parameters

Return type:

None

>>> from moptipy.utils.logger import InMemoryLogger
>>> with InMemoryLogger() as l:
...     with l.key_values("C") as kv:
...         WModel(6, 2, 4, 7).log_parameters_to(kv)
...     text = l.get_log()
>>> text[1]
'name: wmodel_6_2_4_7'
>>> text[3]
'lowerBound: 0'
>>> text[4]
'upperBound: 6'
>>> text[5]
'n: 12'
>>> text[6]
'nopt: 6'
>>> text[7]
'm: 2'
>>> text[8]
'nu: 4'
>>> text[9]
'nu1: 0.5'
>>> text[11]
'gamma: 7'
>>> text[12]
'gamma1: 0.4666666666666667'
>>> text[14]
'gammaPrime: 11'
>>> len(text)
16
m: Final[int]

the neutrality parameter

name: Final[str]

the name of this w-model instance

nopt: Final[int]

the length of the optimal string

nu: Final[int]

the epistasis parameter

nu1: Final[float]

the normalized epistasis parameter

upper_bound()[source]

Get the upper bound of the bit string based problem.

Return type:

int

Returns:

the length of the bit string

>>> WModel(7, 6, 4, 4).upper_bound()
7
moptipy.examples.bitstrings.w_model.w_model_create_ruggedness_permutation(gamma, nopt, r)[source]

Create the raw ruggedness array.

This function creates the ruggedness permutation where groups of rugged transformations alternate with deceptive permutations for increasing gamma.

Parameters:
  • gamma (int) – the parameter for the ruggedness

  • nopt (int) – the length of the optimal string

  • r (array) – the array to receive the permutation

Return type:

None

>>> r = array('i', range(11))
>>> w_model_create_ruggedness_permutation(0, 10, r)
>>> "".join(str(xx) for xx in r)
'012345678910'
>>> r = array('i', range(7))
>>> w_model_create_ruggedness_permutation(9, 6, r)
>>> r[3]
3
>>> r[6]
5
moptipy.examples.bitstrings.w_model.w_model_epistasis(x_in, nu, x_out)[source]

Perform the epistasis transformation.

Parameters:
  • x_in (ndarray) – the input string

  • nu (int) – the epistasis parameter

  • x_out (ndarray) – the output string

Return type:

None

moptipy.examples.bitstrings.w_model.w_model_f(x)[source]

Compute the basic hamming distance of the W-Model to the optimal string.

The optimal string in the W-Model is 0101010101…. Here we compute the objective value of a candidate solution, i.e., the Hamming distance to the string 010101010101…. This is the basic problem objective function. It can be applied either directly, on top of transformations such as the neutrality- or epistasis mappings. Its result can be transformed by a ruggedness permutation to introduce ruggedness into the problem.

Parameters:

x (ndarray) – the bit string to evaluate

Return type:

int

Returns:

the Hamming distance to the string of alternating zeros and ones and starting with 0.

>>> w_model_f(np.array([False]))
0
>>> w_model_f(np.array([True]))
1
>>> w_model_f(np.array([False, True]))
0
>>> w_model_f(np.array([False, False]))
1
>>> w_model_f(np.array([True, True]))
1
>>> w_model_f(np.array([True, False]))
2
>>> w_model_f(np.array([False, True, False]))
0
>>> w_model_f(np.array([True, False, True]))
3
>>> w_model_f(np.array([True, True, True]))
2
>>> w_model_f(np.array([True, True, False]))
1
>>> w_model_f(np.array([False, True, True]))
1
>>> w_model_f(np.array([False, True, False, True, False, True, False]))
0
>>> w_model_f(np.array([False, True, False, True, False, True, True]))
1
>>> w_model_f(np.array([True, False, True, False, True, False, True]))
7
moptipy.examples.bitstrings.w_model.w_model_max_gamma(nopt)[source]

Compute the maximum gamma value for a given length nopt.

Parameters:

nopt (int) – the length of the optimal bit string

Return type:

int

Returns:

the maximum gamma value

moptipy.examples.bitstrings.w_model.w_model_neutrality(x_in, mu, x_out)[source]

Perform the neutrality transformation.

The neutrality transformation is the first layer of the W-Model. It introduces (or better, removes during the mapping) uniform redundancy by basically reducing the size of a bit string by factor mu.

Basically, the input array x_in is split in consecutive bit groups of length mu. Each such group is translated to one bit in the output string x_out. This bit will become 1 if the majority of the bits in the input group are also 1. Otherwise it becomes 0.

Notice that len(x_out) >= mu * length(x_in) must hold.

Parameters:
  • x_in (ndarray) – the input array

  • mu (int) – the number of bits to merge

  • x_out (ndarray) – the output array

Return type:

None

>>> xin = np.array([0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0,
...                 0, 1, 1, 1, 0, 1, 0, 0, 0, 0], bool)
>>> xout = np.empty(len(xin) // 2, bool)
>>> w_model_neutrality(xin, 2, xout)
>>> print("".join('1' if xx else '0' for xx in xout))
1011001110
>>> xin = np.array([0, 1, 0, 1, 0, 1, 1, 0, 0, 0, 0,
...                 0, 1, 1, 1, 0, 1, 0, 0, 0, 0], bool)
>>> w_model_neutrality(xin, 2, xout)
>>> print("".join('1' if xx else '0' for xx in xout))
1111001110
moptipy.examples.bitstrings.w_model.w_model_ruggedness_translate(gamma, nopt)[source]

Transform the gamma values such that deceptive follows rugged.

If the ruggedness permutations are created with raw gamma values, then rugged and deceptive permutations will alternate with rising gamma. With this function here, the gamma parameters are translated such that first all the rugged permutations come (with rising degree of ruggedness) and then the deceptive ones come.

Parameters:
  • gamma (int) – the parameter for the ruggedness

  • nopt (int) – the length of the optimal string

Return type:

int

Returns:

the translated gamma values

>>> w_model_ruggedness_translate(12, 6)
9
>>> w_model_ruggedness_translate(34, 25)
57
>>> w_model_ruggedness_translate(0, 5)
0
>>> w_model_ruggedness_translate(1, 5)
1
>>> w_model_ruggedness_translate(2, 5)
2
>>> w_model_ruggedness_translate(3, 5)
3
>>> w_model_ruggedness_translate(4, 5)
4
>>> w_model_ruggedness_translate(5, 5)
8
>>> w_model_ruggedness_translate(6, 5)
9
>>> w_model_ruggedness_translate(7, 5)
10
>>> w_model_ruggedness_translate(8, 5)
7
>>> w_model_ruggedness_translate(9, 5)
6
>>> w_model_ruggedness_translate(10, 5)
5

moptipy.examples.bitstrings.zeromax module

An objective function counting the number of zeros in a bit string.

This problem exists mainly for testing purposes as counterpart of OneMax.

class moptipy.examples.bitstrings.zeromax.ZeroMax(n)[source]

Bases: BitStringProblem

Maximize the number of zeros in a bit string.

moptipy.examples.bitstrings.zeromax.zeromax(x)[source]

Get the length of a string minus the number of zeros in it.

Parameters:

x (ndarray) – the np array

Return type:

int

Returns:

the length of the string minus the number of zeros, i.e., the number of ones

>>> print(zeromax(np.array([True, True, False, False, False])))
2
>>> print(zeromax(np.array([True, False, True, False, False])))
2
>>> print(zeromax(np.array([False, True,  True, False, False])))
2
>>> print(zeromax(np.array([True, True, True, True, True])))
5
>>> print(zeromax(np.array([False, True, True, True, True])))
4
>>> print(zeromax(np.array([False, False, False, False, False])))
0