예제 #1
0
파일: pyhv.py 프로젝트: phelps-sg/deap
        Inserts 'node' at the position it had in all lists in [0, 'index'[
        before it was removed. This method assumes that the next and previous 
        nodes of the node that is reinserted are in the list.

        """
        for i in range(index):
            node.prev[i].next[i] = node
            node.next[i].prev[i] = node
            if bounds[i] > node.cargo[i]:
                bounds[i] = node.cargo[i]
            
__all__ = ["hypervolume_kmax", "hypervolume"]

if __name__ == "__main__":
    try:
        from deap.tools import hv
    except ImportError:
        hv = None
        print("Cannot import C version of hypervolume")

    from deap.tools import sortLogNondominated

    pointset = [(a, a) for a in numpy.arange(1, 0, -0.01)]
    ref = numpy.array([2, 2])

    print("Python version: %f" % hypervolume(pointset, ref))
    if hv:
        print("C version: %f" % hv.hypervolume(pointset, ref))
    print("Approximated: %f" % hypervolume_approximation(pointset, ref))

예제 #2
0
파일: pyhv.py 프로젝트: quatrosem/Bangkok
        Inserts 'node' at the position it had in all lists in [0, 'index'[
        before it was removed. This method assumes that the next and previous 
        nodes of the node that is reinserted are in the list.

        """
        for i in xrange(index):
            node.prev[i].next[i] = node
            node.next[i].prev[i] = node
            if bounds[i] > node.cargo[i]:
                bounds[i] = node.cargo[i]
            
__all__ = ["hypervolume_kmax", "hypervolume"]

if __name__ == "__main__":
    try:
        from deap.tools import hv
    except ImportError:
        hv = None
        print("Cannot import C version of hypervolume")

    from deap.tools import sortLogNondominated

    pointset = [(a, a) for a in numpy.arange(1, 0, -0.01)]
    ref = numpy.array([2, 2])

    print("Python version: %f" % hypervolume(pointset, ref))
    if hv:
        print("C version: %f" % hv.hypervolume(pointset, ref))
    #print("Approximated: %f" % hypervolume_approximation(pointset, ref))