示例#1
0
def individual_multi():
    genes = [0, 0, 0, 0, 1, 0, 0, 1, 0, 3, 3]
    bounds = [0, 0, 0, 0, 1, 1, 0, 2, 2, 3, 3]
    funset = FunctionSet()
    funset.add(np.add, 2)
    params = Parameters(2, 2, 1, 3, funset)
    return params.individual_class(genes, bounds, params)
示例#2
0
def individual_sin():
    genes = [0, 0, 1, 1, 0, 2, 0, 0, 3, 4]
    bounds = [1, 1, 1, 1, 2, 2, 1, 3, 3, 4]
    funset = FunctionSet()
    funset.add(np.add, 2)
    funset.add(np.sin, 1)
    params = Parameters(2, 1, 1, 3, funset)
    return params.individual_class(genes, bounds, params)
示例#3
0
def test_simple_es_with_non_existing_mutation(function_set, input_data_1d):
    X, y = input_data_1d

    params = Parameters(1, 1, 1, 4, function_set)

    random.seed(0)
    try:
        _ = simple_es(X, y, mean_squared_error, params, mutation='rofl')
        assert False, "passed without expected exception"
    except UnknownMutationException:
        assert True, "mutation fired, good"
示例#4
0
def test_simple_es_with_active_mutation(function_set, input_data_1d):
    X, y = input_data_1d

    params = Parameters(1, 1, 1, 4, function_set)

    random.seed(0)
    start = time()
    result = simple_es(X, y, mean_squared_error, params, mutation='active')

    print_result(result, start)

    assert True, "passed without errors"
示例#5
0
def test_simple_es_with_inf(advanced_function_set, input_data_1d):
    X, y = input_data_1d

    params = Parameters(1, 1, 1, 3, advanced_function_set)

    random.seed(0)
    start = time()
    result = simple_es(X, y, mean_squared_error, params)

    print_result(result, start)

    assert True, "passed without errors"
示例#6
0
def test_simple_es_with_log(function_set, input_data_1d):
    X, y = input_data_1d

    params = Parameters(1, 1, 1, 3, function_set)
    log = []

    random.seed(0)
    start = time()
    result = simple_es(X, y, mean_squared_error, params, log=log)

    print_result(result, start)

    assert len(log) > 0

    assert True, "passed without errors"
示例#7
0
def define_cgp_system(n_nodes, n_inputs, n_outputs, funset, max_back):
    """
    define CCGP system

    Return:
        IndividualBuilder object
        Parameters
        bounds (tuple)
    """
    params = Parameters(n_inputs,
                        n_outputs,
                        1,
                        n_nodes,
                        funset,
                        real_valued=False,
                        max_back=max_back)
    ib = IndividualBuilder(params)
    bounds = ib.create().bounds
    return ib, params, bounds