This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from collections import defaultdict | |
from pandas import DataFrame, concat | |
from sys import stdout | |
from numpy import random | |
from matplotlib import pyplot as plt | |
class DataLogger(object): | |
def __init__(self, key=None): | |
self.key = key |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import operator | |
import numpy | |
from math import sqrt | |
from deap import gp | |
# Our dataset is 100 random arrays of 0s and 1s | |
# and the function we are trying to find is simply |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
try: | |
import numpy | |
except ImportError: | |
import platform | |
if platform.python_implementation() == "PyPy": | |
import numpypy as numpy | |
else: | |
raise ImportError("DEAP requires Numpy.") | |
from collections import OrderedDict |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
import numpy | |
from deap import base | |
from deap import creator | |
from deap import tools | |
creator.create("Fitness", base.Fitness, weights=(1.0,)) | |
creator.create("Individual", numpy.ndarray, fitness=creator.Fitness) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import networkx | |
from metric import measure_A, measure_B, measure_C, measure_D | |
def evaluate(individual): | |
matrix = numpy.zeros((n,n)) | |
index = 0 | |
for i in range(n-1): | |
for j in range(i+1, n): | |
matrix[i,j] = matrix[j,i] = individual[index] | |
index += 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import array | |
import random | |
from deap import algorithms | |
from deap import base | |
from deap import creator | |
from deap import tools | |
import networkx as nx | |
import math | |
import drawG |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import operator | |
import math | |
import random | |
import ctypes | |
from functools import reduce | |
import numpy | |
from deap import algorithms | |
from deap import base |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import math | |
import numpy | |
from scipy.stats import chi2 | |
from matplotlib import pyplot as plt | |
from matplotlib import animation | |
from matplotlib.patches import Ellipse | |
def cov_patch(centroid, cov, perc, alpha=0.5, color='b'): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from cpython.mem cimport PyMem_Malloc, PyMem_Free | |
# Declare the few types and functions we need | |
cdef extern from "gsl/gsl_qrng.h": | |
ctypedef struct gsl_qrng | |
ctypedef struct gsl_qrng_type | |
gsl_qrng_type* gsl_qrng_sobol | |
gsl_qrng* gsl_qrng_alloc(gsl_qrng_type* T, unsigned int d) | |
void gsl_qrng_free(gsl_qrng* q) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy | |
from deap import tools | |
logbook1 = tools.Logbook() | |
logbook2 = tools.Logbook() | |
logbook3 = tools.Logbook() | |
# Filling the logbooks [...] |