change a lot

This commit is contained in:
wls2002
2023-07-17 19:59:46 +08:00
parent f4763ebcea
commit 40cf0b6fbe
8 changed files with 248 additions and 18 deletions

View File

@@ -2,15 +2,16 @@ import jax
from algorithm.config import Configer
from algorithm.neat import NEAT
from algorithm.neat.genome import create_mutate
if __name__ == '__main__':
config = Configer.load_config()
neat = NEAT(config)
randkey = jax.random.PRNGKey(42)
state = neat.setup(randkey)
mutate_func = jax.jit(create_mutate(config, neat.gene_type))
state = mutate_func(state)
state = neat.mutate(state)
print(state)
pop_nodes, pop_conns = state.pop_nodes, state.pop_conns
print(neat.distance(state, pop_nodes[0], pop_conns[0], pop_nodes[1], pop_conns[1]))
print(neat.crossover(state, pop_nodes[0], pop_conns[0], pop_nodes[1], pop_conns[1]))