complete fully stateful!
use black to format all files!
This commit is contained in:
@@ -5,7 +5,7 @@ from algorithm.neat import *
|
||||
|
||||
from problem.rl_env import GymNaxEnv
|
||||
|
||||
if __name__ == '__main__':
|
||||
if __name__ == "__main__":
|
||||
pipeline = Pipeline(
|
||||
algorithm=NEAT(
|
||||
species=DefaultSpecies(
|
||||
@@ -14,21 +14,23 @@ if __name__ == '__main__':
|
||||
num_outputs=3,
|
||||
max_nodes=50,
|
||||
max_conns=100,
|
||||
output_transform=lambda out: jnp.argmax(out) # the action of acrobot is {0, 1, 2}
|
||||
output_transform=lambda out: jnp.argmax(
|
||||
out
|
||||
), # the action of acrobot is {0, 1, 2}
|
||||
),
|
||||
pop_size=10000,
|
||||
species_size=10,
|
||||
),
|
||||
),
|
||||
problem=GymNaxEnv(
|
||||
env_name='Acrobot-v1',
|
||||
env_name="Acrobot-v1",
|
||||
),
|
||||
generation_limit=10000,
|
||||
fitness_target=-62
|
||||
fitness_target=-62,
|
||||
)
|
||||
|
||||
# initialize state
|
||||
state = pipeline.setup()
|
||||
# print(state)
|
||||
# run until terminate
|
||||
state, best = pipeline.auto_run(state)
|
||||
state, best = pipeline.auto_run(state)
|
||||
|
||||
@@ -5,7 +5,7 @@ from algorithm.neat import *
|
||||
|
||||
from problem.rl_env import GymNaxEnv
|
||||
|
||||
if __name__ == '__main__':
|
||||
if __name__ == "__main__":
|
||||
pipeline = Pipeline(
|
||||
algorithm=NEAT(
|
||||
species=DefaultSpecies(
|
||||
@@ -14,21 +14,23 @@ if __name__ == '__main__':
|
||||
num_outputs=2,
|
||||
max_nodes=50,
|
||||
max_conns=100,
|
||||
output_transform=lambda out: jnp.argmax(out) # the action of cartpole is {0, 1}
|
||||
output_transform=lambda out: jnp.argmax(
|
||||
out
|
||||
), # the action of cartpole is {0, 1}
|
||||
),
|
||||
pop_size=10000,
|
||||
species_size=10,
|
||||
),
|
||||
),
|
||||
problem=GymNaxEnv(
|
||||
env_name='CartPole-v1',
|
||||
env_name="CartPole-v1",
|
||||
),
|
||||
generation_limit=10000,
|
||||
fitness_target=500
|
||||
fitness_target=500,
|
||||
)
|
||||
|
||||
# initialize state
|
||||
state = pipeline.setup()
|
||||
# print(state)
|
||||
# run until terminate
|
||||
state, best = pipeline.auto_run(state)
|
||||
state, best = pipeline.auto_run(state)
|
||||
|
||||
@@ -10,11 +10,7 @@ from problem.rl_env import GymNaxConfig, GymNaxEnv
|
||||
|
||||
def example_conf():
|
||||
return Config(
|
||||
basic=BasicConfig(
|
||||
seed=42,
|
||||
fitness_target=500,
|
||||
pop_size=10000
|
||||
),
|
||||
basic=BasicConfig(seed=42, fitness_target=500, pop_size=10000),
|
||||
neat=NeatConfig(
|
||||
inputs=4,
|
||||
outputs=1,
|
||||
@@ -23,28 +19,31 @@ def example_conf():
|
||||
activation_default=Act.tanh,
|
||||
activation_options=(Act.tanh,),
|
||||
),
|
||||
hyperneat=HyperNeatConfig(
|
||||
activation=Act.sigmoid,
|
||||
inputs=4,
|
||||
outputs=2
|
||||
),
|
||||
hyperneat=HyperNeatConfig(activation=Act.sigmoid, inputs=4, outputs=2),
|
||||
substrate=NormalSubstrateConfig(
|
||||
input_coors=((-1, -1), (-0.5, -1), (0, -1), (0.5, -1), (1, -1)),
|
||||
hidden_coors=(
|
||||
# (-1, -0.5), (-0.5, -0.5), (0, -0.5), (0.5, -0.5),
|
||||
(1, 0), (-1, 0), (-0.5, 0), (0, 0), (0.5, 0), (1, 0),
|
||||
(1, 0),
|
||||
(-1, 0),
|
||||
(-0.5, 0),
|
||||
(0, 0),
|
||||
(0.5, 0),
|
||||
(1, 0),
|
||||
# (1, 0.5), (-1, 0.5), (-0.5, 0.5), (0, 0.5), (0.5, 0.5), (1, 0.5),
|
||||
),
|
||||
output_coors=((-1, 1), (1, 1)),
|
||||
),
|
||||
problem=GymNaxConfig(
|
||||
env_name='CartPole-v1',
|
||||
output_transform=lambda out: jnp.argmax(out) # the action of cartpole is {0, 1}
|
||||
)
|
||||
env_name="CartPole-v1",
|
||||
output_transform=lambda out: jnp.argmax(
|
||||
out
|
||||
), # the action of cartpole is {0, 1}
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
if __name__ == "__main__":
|
||||
conf = example_conf()
|
||||
|
||||
algorithm = HyperNEAT(conf, NormalGene, NormalSubstrate)
|
||||
|
||||
@@ -5,7 +5,7 @@ from algorithm.neat import *
|
||||
|
||||
from problem.rl_env import GymNaxEnv
|
||||
|
||||
if __name__ == '__main__':
|
||||
if __name__ == "__main__":
|
||||
pipeline = Pipeline(
|
||||
algorithm=NEAT(
|
||||
species=DefaultSpecies(
|
||||
@@ -14,21 +14,23 @@ if __name__ == '__main__':
|
||||
num_outputs=3,
|
||||
max_nodes=50,
|
||||
max_conns=100,
|
||||
output_transform=lambda out: jnp.argmax(out) # the action of mountain car is {0, 1, 2}
|
||||
output_transform=lambda out: jnp.argmax(
|
||||
out
|
||||
), # the action of mountain car is {0, 1, 2}
|
||||
),
|
||||
pop_size=10000,
|
||||
species_size=10,
|
||||
),
|
||||
),
|
||||
problem=GymNaxEnv(
|
||||
env_name='MountainCar-v0',
|
||||
env_name="MountainCar-v0",
|
||||
),
|
||||
generation_limit=10000,
|
||||
fitness_target=0
|
||||
fitness_target=0,
|
||||
)
|
||||
|
||||
# initialize state
|
||||
state = pipeline.setup()
|
||||
# print(state)
|
||||
# run until terminate
|
||||
state, best = pipeline.auto_run(state)
|
||||
state, best = pipeline.auto_run(state)
|
||||
|
||||
@@ -4,7 +4,7 @@ from algorithm.neat import *
|
||||
from problem.rl_env import GymNaxEnv
|
||||
from utils import Act
|
||||
|
||||
if __name__ == '__main__':
|
||||
if __name__ == "__main__":
|
||||
pipeline = Pipeline(
|
||||
algorithm=NEAT(
|
||||
species=DefaultSpecies(
|
||||
@@ -14,23 +14,23 @@ if __name__ == '__main__':
|
||||
max_nodes=50,
|
||||
max_conns=100,
|
||||
node_gene=DefaultNodeGene(
|
||||
activation_options=(Act.tanh, ),
|
||||
activation_options=(Act.tanh,),
|
||||
activation_default=Act.tanh,
|
||||
)
|
||||
),
|
||||
),
|
||||
pop_size=10000,
|
||||
species_size=10,
|
||||
),
|
||||
),
|
||||
problem=GymNaxEnv(
|
||||
env_name='MountainCarContinuous-v0',
|
||||
env_name="MountainCarContinuous-v0",
|
||||
),
|
||||
generation_limit=10000,
|
||||
fitness_target=500
|
||||
fitness_target=500,
|
||||
)
|
||||
|
||||
# initialize state
|
||||
state = pipeline.setup()
|
||||
# print(state)
|
||||
# run until terminate
|
||||
state, best = pipeline.auto_run(state)
|
||||
state, best = pipeline.auto_run(state)
|
||||
|
||||
@@ -4,7 +4,7 @@ from algorithm.neat import *
|
||||
from problem.rl_env import GymNaxEnv
|
||||
from utils import Act
|
||||
|
||||
if __name__ == '__main__':
|
||||
if __name__ == "__main__":
|
||||
pipeline = Pipeline(
|
||||
algorithm=NEAT(
|
||||
species=DefaultSpecies(
|
||||
@@ -17,21 +17,22 @@ if __name__ == '__main__':
|
||||
activation_options=(Act.tanh,),
|
||||
activation_default=Act.tanh,
|
||||
),
|
||||
output_transform=lambda out: out * 2 # the action of pendulum is [-2, 2]
|
||||
output_transform=lambda out: out
|
||||
* 2, # the action of pendulum is [-2, 2]
|
||||
),
|
||||
pop_size=10000,
|
||||
species_size=10,
|
||||
),
|
||||
),
|
||||
problem=GymNaxEnv(
|
||||
env_name='Pendulum-v1',
|
||||
env_name="Pendulum-v1",
|
||||
),
|
||||
generation_limit=10000,
|
||||
fitness_target=0
|
||||
fitness_target=0,
|
||||
)
|
||||
|
||||
# initialize state
|
||||
state = pipeline.setup()
|
||||
# print(state)
|
||||
# run until terminate
|
||||
state, best = pipeline.auto_run(state)
|
||||
state, best = pipeline.auto_run(state)
|
||||
|
||||
@@ -5,7 +5,7 @@ from algorithm.neat import *
|
||||
|
||||
from problem.rl_env import GymNaxEnv
|
||||
|
||||
if __name__ == '__main__':
|
||||
if __name__ == "__main__":
|
||||
pipeline = Pipeline(
|
||||
algorithm=NEAT(
|
||||
species=DefaultSpecies(
|
||||
@@ -20,14 +20,14 @@ if __name__ == '__main__':
|
||||
),
|
||||
),
|
||||
problem=GymNaxEnv(
|
||||
env_name='Reacher-misc',
|
||||
env_name="Reacher-misc",
|
||||
),
|
||||
generation_limit=10000,
|
||||
fitness_target =500
|
||||
fitness_target=500,
|
||||
)
|
||||
|
||||
# initialize state
|
||||
state = pipeline.setup()
|
||||
# print(state)
|
||||
# run until terminate
|
||||
state, best = pipeline.auto_run(state)
|
||||
state, best = pipeline.auto_run(state)
|
||||
|
||||
Reference in New Issue
Block a user