src/scBONITA/classDefinitions.py
def assignCrowdingDist(self, individuals):
        """Assign a crowding distance to each individual's fitness. The
        crowding distance can be retrieve via the :attr:`crowding_dist`
        attribute of each individual's fitness.
        """
        if len(individuals) == 0:
            return

        distances = [0.0] * len(individuals)
        crowd = [(ind.fitness.values, i) for i, ind in enumerate(individuals)]

        nobj = len(individuals[0].fitness.values)

        for i in range(nobj):
            crowd.sort(key=lambda element: element[0][i])
            distances[crowd[0][1]] = float("inf")
            distances[crowd[-1][1]] = float("inf")
            if crowd[-1][0][i] == crowd[0][0][i]:
                continue
            norm = nobj * float(crowd[-1][0][i] - crowd[0][0][i])
            for prev, cur, next in zip(crowd[:-2], crowd[1:-1], crowd[2:]):
                distances[cur[1]] += 1.0 * (next[0][i] - prev[0][i]) / norm

        for i, dist in enumerate(distances):
            individuals[i].fitness.crowding_dist = dist
Assign a crowding distance to each individual's fitness. The
        crowding distance can be retrieve via the :attr:`crowding_dist`
        attribute of each individual's fitness.
        
Assign a crowding distance to each individual's fitness. The
crowding distance can be retrieve via the :attr:`crowding_dist`
attribute of each individual's fitness.
Assign a crowding distance to each individual ' s fitness . The crowding distance can be retrieve via the : attr : ` crowding_dist ` attribute of each individual ' s fitness .
def assignCrowdingDist(self, individuals):
        if len(individuals) == 0:
            return
        distances = [0.0] * len(individuals)
        crowd = [(ind.fitness.values, i) for i, ind in enumerate(individuals)]
        nobj = len(individuals[0].fitness.values)
        for i in range(nobj):
            crowd.sort(key=lambda element: element[0][i])
            distances[crowd[0][1]] = float("inf")
            distances[crowd[-1][1]] = float("inf")
            if crowd[-1][0][i] == crowd[0][0][i]:
                continue
            norm = nobj * float(crowd[-1][0][i] - crowd[0][0][i])
            for prev, cur, next in zip(crowd[:-2], crowd[1:-1], crowd[2:]):
                distances[cur[1]] += 1.0 * (next[0][i] - prev[0][i]) / norm
        for i, dist in enumerate(distances):
            individuals[i].fitness.crowding_dist = dist
def assignCrowdingDist ( self , individuals ) : if len ( individuals ) == 0 : return distances = [ 0.0 ] * len ( individuals ) crowd = [ ( ind . fitness . values , i ) for i , ind in enumerate ( individuals ) ] nobj = len ( individuals [ 0 ] . fitness . values ) for i in range ( nobj ) : crowd . sort ( key = lambda element : element [ 0 ] [ i ] ) distances [ crowd [ 0 ] [ 1 ] ] = float ( "inf" ) distances [ crowd [ - 1 ] [ 1 ] ] = float ( "inf" ) if crowd [ - 1 ] [ 0 ] [ i ] == crowd [ 0 ] [ 0 ] [ i ] : continue norm = nobj * float ( crowd [ - 1 ] [ 0 ] [ i ] - crowd [ 0 ] [ 0 ] [ i ] ) for prev , cur , next in zip ( crowd [ : - 2 ] , crowd [ 1 : - 1 ] , crowd [ 2 : ] ) : distances [ cur [ 1 ] ] += 1.0 * ( next [ 0 ] [ i ] - prev [ 0 ] [ i ] ) / norm for i , dist in enumerate ( distances ) : individuals [ i ] . fitness . crowding_dist = dist
Assign a crowding distance to each individual's fitness.
Assign a crowding distance to each individual ' s fitness .
"""Assign a crowding distance to each individual's fitness. The
        crowding distance can be retrieve via the :attr:`crowding_dist`
        attribute of each individual's fitness.
        """
self
individuals