src/scBONITA/classDefinitions.py
def cxTwoPointNode(self, ind1, ind2):
        # copied and modified from deap
        # needed to account for bistring only being one of two components of individual
        """Executes a two-point crossover on the input :term:`sequence`
        individuals. The two individuals are modified in place and both keep
        their original length.
        :returns: A tuple of two individuals.
        This function uses the :func:`~random.randint` function from the Python
        base :mod:`random` module.

        Modified to cross over between rules
        """
        size = len(ind1[0].nodeList)
        cxpointer1 = randint(1, size)
        cxpointer2 = randint(1, size - 1)
        # make sure pointers are in right order
        if cxpointer2 >= cxpointer1:
            cxpointer2 += 1
        else:  # Swap the two cx points
            cxpointer1, cxpointer2 = cxpointer2, cxpointer1
        cxpoint1 = ind1[0].individualParse[cxpointer1]
        cxpoint2 = ind1[0].individualParse[cxpointer2]
        # cross over both bitlists and the andNodeLists (as well as andNodeInvertLists)
        ind1[1][cxpoint1:cxpoint2], ind2[1][cxpoint1:cxpoint2] = (
            ind2[1][cxpoint1:cxpoint2],
            ind1[1][cxpoint1:cxpoint2],
        )
        (
            ind1[0].andNodeList[cxpointer1:cxpointer2],
            ind2[0].andNodeList[cxpointer1:cxpointer2],
        ) = (
            ind2[0].andNodeList[cxpointer1:cxpointer2],
            ind1[0].andNodeList[cxpointer1:cxpointer2],
        )
        (
            ind1[0].andNodeInvertList[cxpointer1:cxpointer2],
            ind2[0].andNodeInvertList[cxpointer1:cxpointer2],
        ) = (
            ind2[0].andNodeInvertList[cxpointer1:cxpointer2],
            ind1[0].andNodeInvertList[cxpointer1:cxpointer2],
        )
        # update the arrays seen by C code updateBool
        ind1[0].updateCpointers()
        ind2[0].updateCpointers()
        return ind1, ind2
Executes a two-point crossover on the input :term:`sequence`
        individuals. The two individuals are modified in place and both keep
        their original length.
        :returns: A tuple of two individuals.
        This function uses the :func:`~random.randint` function from the Python
        base :mod:`random` module.

        Modified to cross over between rules
        
Executes a two-point crossover on the input :term:`sequence`
individuals. The two individuals are modified in place and both keep
their original length.
Executes a two - point crossover on the input : term : ` sequence ` individuals . The two individuals are modified in place and both keep their original length .
def cxTwoPointNode(self, ind1, ind2):
        size = len(ind1[0].nodeList)
        cxpointer1 = randint(1, size)
        cxpointer2 = randint(1, size - 1)
        if cxpointer2 >= cxpointer1:
            cxpointer2 += 1
        else:  
            cxpointer1, cxpointer2 = cxpointer2, cxpointer1
        cxpoint1 = ind1[0].individualParse[cxpointer1]
        cxpoint2 = ind1[0].individualParse[cxpointer2]
        ind1[1][cxpoint1:cxpoint2], ind2[1][cxpoint1:cxpoint2] = (
            ind2[1][cxpoint1:cxpoint2],
            ind1[1][cxpoint1:cxpoint2],
        )
        (
            ind1[0].andNodeList[cxpointer1:cxpointer2],
            ind2[0].andNodeList[cxpointer1:cxpointer2],
        ) = (
            ind2[0].andNodeList[cxpointer1:cxpointer2],
            ind1[0].andNodeList[cxpointer1:cxpointer2],
        )
        (
            ind1[0].andNodeInvertList[cxpointer1:cxpointer2],
            ind2[0].andNodeInvertList[cxpointer1:cxpointer2],
        ) = (
            ind2[0].andNodeInvertList[cxpointer1:cxpointer2],
            ind1[0].andNodeInvertList[cxpointer1:cxpointer2],
        )
        ind1[0].updateCpointers()
        ind2[0].updateCpointers()
        return ind1, ind2
def cxTwoPointNode ( self , ind1 , ind2 ) : size = len ( ind1 [ 0 ] . nodeList ) cxpointer1 = randint ( 1 , size ) cxpointer2 = randint ( 1 , size - 1 ) if cxpointer2 >= cxpointer1 : cxpointer2 += 1 else : cxpointer1 , cxpointer2 = cxpointer2 , cxpointer1 cxpoint1 = ind1 [ 0 ] . individualParse [ cxpointer1 ] cxpoint2 = ind1 [ 0 ] . individualParse [ cxpointer2 ] ind1 [ 1 ] [ cxpoint1 : cxpoint2 ] , ind2 [ 1 ] [ cxpoint1 : cxpoint2 ] = ( ind2 [ 1 ] [ cxpoint1 : cxpoint2 ] , ind1 [ 1 ] [ cxpoint1 : cxpoint2 ] , ) ( ind1 [ 0 ] . andNodeList [ cxpointer1 : cxpointer2 ] , ind2 [ 0 ] . andNodeList [ cxpointer1 : cxpointer2 ] , ) = ( ind2 [ 0 ] . andNodeList [ cxpointer1 : cxpointer2 ] , ind1 [ 0 ] . andNodeList [ cxpointer1 : cxpointer2 ] , ) ( ind1 [ 0 ] . andNodeInvertList [ cxpointer1 : cxpointer2 ] , ind2 [ 0 ] . andNodeInvertList [ cxpointer1 : cxpointer2 ] , ) = ( ind2 [ 0 ] . andNodeInvertList [ cxpointer1 : cxpointer2 ] , ind1 [ 0 ] . andNodeInvertList [ cxpointer1 : cxpointer2 ] , ) ind1 [ 0 ] . updateCpointers ( ) ind2 [ 0 ] . updateCpointers ( ) return ind1 , ind2
Executes a two-point crossover on the input :term:`sequence`
individuals.
Executes a two - point crossover on the input : term : ` sequence ` individuals .
# copied and modified from deap # needed to account for bistring only being one of two components of individual """Executes a two-point crossover on the input :term:`sequence`
        individuals. The two individuals are modified in place and both keep
        their original length.
        :returns: A tuple of two individuals.
        This function uses the :func:`~random.randint` function from the Python
        base :mod:`random` module.

        Modified to cross over between rules
        """ # make sure pointers are in right order # Swap the two cx points # cross over both bitlists and the andNodeLists (as well as andNodeInvertLists) # update the arrays seen by C code updateBool
A tuple of two individuals.
This function uses the :func:`~random.randint` function from the Python
base :mod:`random` module.

Modified to cross over between rules
A tuple of two individuals . This function uses the : func : ` ~random . randint ` function from the Python base : mod : ` random ` module . Modified to cross over between rules
self
ind1
ind2