moptipy.operators.intspace package¶
Search operators defined on integer spaces. A nullary operator filling an integer list with random values. A multi-normal distribution. Bases: Randomly choose a number of ints to change with normal distribution. Log the parameters of this operator to the given logger. logger ( Copy x into dest and change each value with probability m/n. This method will first copy x to dest. Then it will change each value in dest with probability m/n, where n is the length of dest. Regardless of the probability, at least one value will always be changed if self.at_least_1 is True. If a value is changed, we will put a normal distribution around it and sample it from that. Of course, we only accept values within the limits of the integer space and that are different from the original value. The bit-string based uniform crossover operator used for intspaces.Submodules¶
moptipy.operators.intspace.op0_random module¶
>>> from moptipy.utils.nputils import rand_generator
>>> gen = rand_generator(12)
>>> space = IntSpace(4, -2, 2)
>>> op = Op0Random(space)
>>> xx = space.create()
>>> op.op0(gen, xx)
>>> xx
array([-1, 2, 2, 1], dtype=int8)
>>> op.op0(gen, xx)
>>> xx
array([-2, -2, -1, -1], dtype=int8)
>>> op.op0(gen, xx)
>>> xx
array([ 1, 0, -2, 2], dtype=int8)
>>> space = IntSpace(5, 12000, 20000)
>>> op = Op0Random(space)
>>> xx = space.create()
>>> op.op0(gen, xx)
>>> xx
array([15207, 19574, 18014, 12515, 14406], dtype=int16)
>>> op.op0(gen, xx)
>>> xx
array([16080, 13596, 13434, 14148, 16655], dtype=int16)
moptipy.operators.intspace.op1_mnormal module¶
>>> from moptipy.utils.nputils import rand_generator
>>> gen = rand_generator(12)
>>> from moptipy.operators.intspace.op0_random import Op0Random
>>> space = IntSpace(4, -2, 2)
>>> op0 = Op0Random(space)
>>> x1 = space.create()
>>> op0.op0(gen, x1)
>>> x1
array([-1, 2, 2, 1], dtype=int8)
>>> op1 = Op1MNormal(space, 1, True, 1.5)
>>> op1.initialize()
>>> x2 = space.create()
>>> op1.op1(gen, x2, x1)
>>> x2
array([-1, 0, 0, 1], dtype=int8)
>>> op1.op1(gen, x2, x1)
>>> x2
array([-1, 2, 1, -2], dtype=int8)
>>> op1.op1(gen, x2, x1)
>>> x2
array([-1, 2, 2, 0], dtype=int8)
>>> space = IntSpace(12, 0, 20)
>>> op0 = Op0Random(space)
>>> x1 = space.create()
>>> op0.op0(gen, x1)
>>> x1
array([ 6, 1, 18, 11, 13, 11, 2, 3, 13, 7, 10, 14], dtype=int8)
>>> op1 = Op1MNormal(space, 1, True, 1.5)
>>> op1.initialize()
>>> x2 = space.create()
>>> op1.op1(gen, x2, x1)
>>> x2
array([ 6, 1, 18, 11, 13, 11, 2, 3, 12, 7, 9, 13], dtype=int8)
>>> op1.op1(gen, x2, x1)
>>> x2
array([ 6, 1, 20, 11, 13, 11, 2, 3, 13, 7, 10, 14], dtype=int8)
>>> op1.op1(gen, x2, x1)
>>> x2
array([ 3, 1, 18, 11, 13, 11, 2, 3, 13, 7, 9, 14], dtype=int8)
>>> str(op1)
'normB1_1d5'
Op1KeyValueLogSection) – the logger for the parametersmoptipy.operators.intspace.op2_uniform module¶