Ejemplo n.º 1
0
def test_import():
    grn = grns.ClassicGRN()
    grn.random(10, 10, 10)
    str_grn = str(grn)
    grn2 = grns.ClassicGRN()
    grn2.from_str(str_grn)
    assert grn.num_input == grn2.num_input
    assert grn.num_output == grn2.num_output
    assert grn.num_regulatory == grn2.num_regulatory
    assert np.all(grn.identifiers == grn2.identifiers)
    assert np.all(grn.enhancers == grn2.enhancers)
    assert np.all(grn.inhibitors == grn2.inhibitors)
    assert grn.beta == grn2.beta
    assert grn.delta == grn2.delta
Ejemplo n.º 2
0
def test_double_fit():
    p = problems.DoubleFrequency()
    g = grns.ClassicGRN()
    g.random(p.nin, p.nout, 10)
    fitness = p.eval(g)
    print(fitness)
    assert fitness <= 0.0
Ejemplo n.º 3
0
def test_double_evolution():
    p = problems.DoubleFrequency()
    g = grns.ClassicGRN()
    config.POPULATION_SIZE = 30
    g.random(p.nin, p.nout, 5)
    random_fitness = p.eval(g)
    evo = evolution.Evolution(p)
    best_fit, best_ind = evo.run(5)
    print(random_fitness, ", ", best_fit)
    assert best_fit > random_fitness
Ejemplo n.º 4
0
def test_export():
    grn = grns.ClassicGRN()
    grn.random(10, 10, 10)
    str_grn = str(grn)
    assert str_grn == json.dumps({
        'num_input': grn.num_input,
        'num_output': grn.num_output,
        'num_regulatory': grn.num_regulatory,
        'ids': grn.identifiers.tolist(),
        'enh': grn.enhancers.tolist(),
        'inh': grn.inhibitors.tolist(),
        'beta': grn.beta,
        'delta': grn.delta
    })
Ejemplo n.º 5
0
def test_classic_diff():
    grn1 = grns.ClassicGRN()
    grn2 = grns.DiffGRN()
    compare_grns(grn1, grn2)
Ejemplo n.º 6
0
def test_classic_gpu():
    grn1 = grns.ClassicGRN()
    grn2 = grns.GPUGRN()
    compare_grns(grn1, grn2)
Ejemplo n.º 7
0
def test_classic_matrix():
    grn1 = grns.ClassicGRN()
    grn2 = grns.MatrixGRN()
    compare_grns(grn1, grn2)
Ejemplo n.º 8
0
def test_sanity():
    grn1 = grns.ClassicGRN()
    grn2 = grns.ClassicGRN()
    compare_grns(grn1, grn2)
Ejemplo n.º 9
0
log_dir = os.path.join(args.root_dir, 'logs')

config.START_REGULATORY_SIZE = args.nreg
PROBLEM = "GymGRN"

log_file = os.path.join(log_dir, 'fits_' + args.id + '.log')
grn_dir = os.path.join(args.root_dir, 'grns')
data_dir = os.path.join(args.root_dir, 'data')
log_file = os.path.join(log_dir, 'fits_' + args.id + '.log')

p = eval('problems.' + args.problem)
p = p(args.env, args.nin, args.nout, args.ep_max)

print("..Init GRN..")
newgrn = grns.ClassicGRN()  #DiffGRN()
newgrn2 = lambda: grns.ClassicGRN()  #DiffGRN()
if args.evo:
    print("..Evolv GRN..")
    grneat = evolution.Evolution(p,
                                 newgrn2,
                                 run_id=args.id,
                                 grn_dir=grn_dir,
                                 log_dir=log_dir)
    grneat.run(args.gens)
else:
    for i in range(1):
        print("..Init GRN", i, "..")
        #grn = grns.ClassicGRN()
        if args.grn_file:
            print("..Load GRN..")