Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plus #6

Open
wants to merge 98 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
98 commits
Select commit Hold shift + click to select a range
0b40743
update the licence year
ruiwang2uber Apr 15, 2020
900ca4e
mise en modele Flechette
LeonaireHo Jan 2, 2022
4f06f76
Env_config
LeonaireHo Jan 3, 2022
f5e7790
make niche
LeonaireHo Jan 3, 2022
f480ad8
debug
LeonaireHo Jan 3, 2022
b6e546d
debug
LeonaireHo Jan 3, 2022
63d1865
debug
LeonaireHo Jan 3, 2022
786b295
debug
LeonaireHo Jan 3, 2022
70b3061
debug
LeonaireHo Jan 3, 2022
ab8a50b
debug
LeonaireHo Jan 3, 2022
d3ec059
debug
LeonaireHo Jan 5, 2022
4aafa4a
debug
LeonaireHo Jan 5, 2022
189b085
debug
LeonaireHo Jan 5, 2022
4cc3bb4
debug
LeonaireHo Jan 5, 2022
4beb8a6
debug
LeonaireHo Jan 5, 2022
e1c0c0f
debug
LeonaireHo Jan 5, 2022
5cdd00c
debug
LeonaireHo Jan 5, 2022
72ffd8c
debug
LeonaireHo Jan 5, 2022
4bd0a2d
debug
LeonaireHo Jan 5, 2022
874163b
debug
LeonaireHo Jan 5, 2022
3aaf48b
debug
LeonaireHo Jan 5, 2022
4e20436
debug
LeonaireHo Jan 5, 2022
09a5e15
debug
LeonaireHo Jan 5, 2022
8a2f984
debug
LeonaireHo Jan 5, 2022
86d22a9
debug
LeonaireHo Jan 5, 2022
77df8fe
debug
LeonaireHo Jan 5, 2022
d31078c
debug
LeonaireHo Jan 5, 2022
97ab5c7
debug
LeonaireHo Jan 5, 2022
645be09
debug
LeonaireHo Jan 5, 2022
a370b19
debug
LeonaireHo Jan 5, 2022
b39e221
debug
LeonaireHo Jan 5, 2022
d00002c
debug
LeonaireHo Jan 5, 2022
f8d1d29
debug
LeonaireHo Jan 5, 2022
320d278
debug
LeonaireHo Jan 5, 2022
4cb69c3
debug
LeonaireHo Jan 5, 2022
2b6bcba
debug
LeonaireHo Jan 5, 2022
28ebebb
debug
LeonaireHo Jan 5, 2022
29be679
debug
LeonaireHo Jan 5, 2022
68cd42e
debug
LeonaireHo Jan 5, 2022
4393a04
debug
LeonaireHo Jan 5, 2022
68d9dfb
debug
LeonaireHo Jan 5, 2022
83d62f8
modifier
LeonaireHo Jan 7, 2022
c119d7c
modifier
LeonaireHo Jan 7, 2022
a9ca983
modifier
LeonaireHo Jan 7, 2022
db5dd9f
modifier
LeonaireHo Jan 7, 2022
c49ae43
modifier
LeonaireHo Jan 7, 2022
d58566e
modifier
LeonaireHo Jan 7, 2022
88d3417
test
LeonaireHo Jan 8, 2022
9b1722f
create env
LeonaireHo Jan 8, 2022
259b303
create env
LeonaireHo Jan 8, 2022
1fac0cf
create env
LeonaireHo Jan 8, 2022
9b4b851
create env
LeonaireHo Jan 8, 2022
abfb18f
create env
LeonaireHo Jan 8, 2022
e6e6222
create env
LeonaireHo Jan 8, 2022
0d360c2
create env
LeonaireHo Jan 8, 2022
50e5f9a
create env
LeonaireHo Jan 8, 2022
d5f6503
create env
LeonaireHo Jan 8, 2022
62b0185
create env
LeonaireHo Jan 8, 2022
da600f7
create env
LeonaireHo Jan 8, 2022
7835997
create env
LeonaireHo Jan 8, 2022
7d0bcc4
create env
LeonaireHo Jan 8, 2022
0da8e1b
create env
LeonaireHo Jan 8, 2022
ddf0c1a
create env
LeonaireHo Jan 8, 2022
612dcab
create env
LeonaireHo Jan 8, 2022
75d905f
create env
LeonaireHo Jan 8, 2022
bd3a69f
create env
LeonaireHo Jan 8, 2022
4a11971
create env
LeonaireHo Jan 8, 2022
bead29c
create env
LeonaireHo Jan 8, 2022
5039f94
create env
LeonaireHo Jan 8, 2022
50a4549
debug
LeonaireHo Jan 8, 2022
8a546fb
debug
LeonaireHo Jan 8, 2022
23d7e76
debug
LeonaireHo Jan 8, 2022
ec9cfcd
test
LeonaireHo Jan 10, 2022
68f8561
test
LeonaireHo Jan 10, 2022
e3b9018
test
LeonaireHo Jan 10, 2022
20110c3
test
LeonaireHo Jan 10, 2022
1aa2af2
test
LeonaireHo Jan 10, 2022
1dccc3d
test
LeonaireHo Jan 10, 2022
79ddce1
debug
LeonaireHo Jan 10, 2022
fea69c1
debug
LeonaireHo Jan 10, 2022
57b7871
debug
LeonaireHo Jan 10, 2022
dc9d074
debug
LeonaireHo Jan 10, 2022
05b89c5
debug
LeonaireHo Jan 10, 2022
07f52bd
debug
LeonaireHo Jan 10, 2022
d6da72d
debug
LeonaireHo Jan 10, 2022
27668a3
debug
LeonaireHo Jan 10, 2022
735872f
debug
LeonaireHo Jan 10, 2022
fe103c9
debug
LeonaireHo Jan 10, 2022
aa0e8b9
debug
LeonaireHo Jan 10, 2022
edbc60a
debug
LeonaireHo Jan 10, 2022
03560db
debug
LeonaireHo Jan 10, 2022
6f84e36
plus
LeonaireHo Jan 10, 2022
26bc5e9
debug
LeonaireHo Jan 10, 2022
d0121e0
debug
LeonaireHo Jan 10, 2022
b041e1c
debug
LeonaireHo Jan 10, 2022
be85fcc
debug
LeonaireHo Jan 10, 2022
38d7f30
more try cre new env
LeonaireHo Jan 11, 2022
03c10d7
more try cre new env
LeonaireHo Jan 11, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion master.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2019 Uber Technologies, Inc.
# Copyright (c) 2020 Uber Technologies, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion poet_distributed/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2019 Uber Technologies, Inc.
# Copyright (c) 2020 Uber Technologies, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
4 changes: 2 additions & 2 deletions poet_distributed/es.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2019 Uber Technologies, Inc.
# Copyright (c) 2020 Uber Technologies, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -393,7 +393,7 @@ def delete_env(self, env_name):
logger.debug('Optimizer {} delete env {}...'.format(self.optim_id, env_name))

niches = self.fiber_shared["niches"]
niches[optim_id].delete_env(env_name)
niches[self.optim_id].delete_env(env_name)

def start_chunk_fiber(self, runner, batches_per_chunk, batch_size, *args):
logger.debug('Optimizer {} spawning {} batches of size {}'.format(
Expand Down
2 changes: 1 addition & 1 deletion poet_distributed/logger.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2019 Uber Technologies, Inc.
# Copyright (c) 2020 Uber Technologies, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion poet_distributed/niches/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2019 Uber Technologies, Inc.
# Copyright (c) 2020 Uber Technologies, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion poet_distributed/niches/box2d/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2019 Uber Technologies, Inc.
# Copyright (c) 2020 Uber Technologies, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
131 changes: 66 additions & 65 deletions poet_distributed/niches/box2d/bipedal_walker_custom.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# The following code is modified from openai/gym (https://github.com/openai/gym) under the MIT License.

# Modifications Copyright (c) 2019 Uber Technologies, Inc.
# Modifications Copyright (c) 2020 Uber Technologies, Inc.


import sys
Expand Down Expand Up @@ -169,18 +169,19 @@ def set_env_config(self, env_config):
def _set_terrain_number(self):
self.hardcore = False
self.GRASS = 0
self.STUMP, self.STAIRS, self.PIT = -1, -1, -1
# self.STUMP, self.STAIRS, self.PIT = -1, -1, -1
self.PIT = -1,
self._STATES_ = 1

if self.config.stump_width and self.config.stump_height and self.config.stump_float:
# STUMP exist
self.STUMP = self._STATES_
self._STATES_ += 1
# if self.config.stump_width and self.config.stump_height and self.config.stump_float:
# # STUMP exist
# self.STUMP = self._STATES_
# self._STATES_ += 1

if self.config.stair_height and self.config.stair_width and self.config.stair_steps:
# STAIRS exist
self.STAIRS = self._STATES_
self._STATES_ += 1
# if self.config.stair_height and self.config.stair_width and self.config.stair_steps:
# # STAIRS exist
# self.STAIRS = self._STATES_
# self._STATES_ += 1

if self.config.pit_gap:
# PIT exist
Expand Down Expand Up @@ -280,61 +281,61 @@ def _generate_terrain(self, hardcore):
self.terrain_x[-1] = self.terrain_x[-1] - pit_diff * TERRAIN_STEP
pit_diff = 0

elif state == self.STUMP and oneshot:
# input parameter stump_width, stump_height, stump_float
#stump_width = self.np_random.uniform(*self.config.stump_width)
stump_width = self.np_random.randint(*self.config.stump_width)
stump_height = self.np_random.uniform(
*self.config.stump_height)
stump_float = self.np_random.randint(*self.config.stump_float)
#counter = np.ceil(stump_width)
counter = stump_width
countery = stump_height
poly = [
(x, y + stump_float * TERRAIN_STEP),
(x + stump_width * TERRAIN_STEP, y + stump_float * TERRAIN_STEP),
(x + stump_width * TERRAIN_STEP, y + countery *
TERRAIN_STEP + stump_float * TERRAIN_STEP),
(x, y + countery *
TERRAIN_STEP + stump_float * TERRAIN_STEP),
]
self.fd_polygon.shape.vertices = poly
t = self.world.CreateStaticBody(
fixtures=self.fd_polygon)
t.color1, t.color2 = (1, 1, 1), (0.6, 0.6, 0.6)
self.terrain.append(t)

elif state == self.STAIRS and oneshot:
# input parameters: stair_height, stair_width, stair_steps
stair_height = self.np_random.uniform(
*self.config.stair_height)
stair_slope = 1 if self.np_random.rand() > 0.5 else -1
stair_width = self.np_random.randint(*self.config.stair_width)
stair_steps = self.np_random.randint(*self.config.stair_steps)
original_y = y
for s in range(stair_steps):
poly = [
(x + (s * stair_width) * TERRAIN_STEP, y +
(s * stair_height * stair_slope) * TERRAIN_STEP),
(x + ((1 + s) * stair_width) * TERRAIN_STEP, y +
(s * stair_height * stair_slope) * TERRAIN_STEP),
(x + ((1 + s) * stair_width) * TERRAIN_STEP, y +
(-stair_height + s * stair_height * stair_slope) * TERRAIN_STEP),
(x + (s * stair_width) * TERRAIN_STEP, y + (-stair_height +
s * stair_height * stair_slope) * TERRAIN_STEP),
]
self.fd_polygon.shape.vertices = poly
t = self.world.CreateStaticBody(
fixtures=self.fd_polygon)
t.color1, t.color2 = (1, 1, 1), (0.6, 0.6, 0.6)
self.terrain.append(t)
counter = stair_steps * stair_width + 1

elif state == self.STAIRS and not oneshot:
s = stair_steps * stair_width - counter
n = s // stair_width
y = original_y + (n * stair_height * stair_slope) * TERRAIN_STEP - \
(stair_height if stair_slope == -1 else 0) * TERRAIN_STEP
# elif state == self.STUMP and oneshot:
# # input parameter stump_width, stump_height, stump_float
# #stump_width = self.np_random.uniform(*self.config.stump_width)
# stump_width = self.np_random.randint(*self.config.stump_width)
# stump_height = self.np_random.uniform(
# *self.config.stump_height)
# stump_float = self.np_random.randint(*self.config.stump_float)
# #counter = np.ceil(stump_width)
# counter = stump_width
# countery = stump_height
# poly = [
# (x, y + stump_float * TERRAIN_STEP),
# (x + stump_width * TERRAIN_STEP, y + stump_float * TERRAIN_STEP),
# (x + stump_width * TERRAIN_STEP, y + countery *
# TERRAIN_STEP + stump_float * TERRAIN_STEP),
# (x, y + countery *
# TERRAIN_STEP + stump_float * TERRAIN_STEP),
# ]
# self.fd_polygon.shape.vertices = poly
# t = self.world.CreateStaticBody(
# fixtures=self.fd_polygon)
# t.color1, t.color2 = (1, 1, 1), (0.6, 0.6, 0.6)
# self.terrain.append(t)

# elif state == self.STAIRS and oneshot:
# # input parameters: stair_height, stair_width, stair_steps
# stair_height = self.np_random.uniform(
# *self.config.stair_height)
# stair_slope = 1 if self.np_random.rand() > 0.5 else -1
# stair_width = self.np_random.randint(*self.config.stair_width)
# stair_steps = self.np_random.randint(*self.config.stair_steps)
# original_y = y
# for s in range(stair_steps):
# poly = [
# (x + (s * stair_width) * TERRAIN_STEP, y +
# (s * stair_height * stair_slope) * TERRAIN_STEP),
# (x + ((1 + s) * stair_width) * TERRAIN_STEP, y +
# (s * stair_height * stair_slope) * TERRAIN_STEP),
# (x + ((1 + s) * stair_width) * TERRAIN_STEP, y +
# (-stair_height + s * stair_height * stair_slope) * TERRAIN_STEP),
# (x + (s * stair_width) * TERRAIN_STEP, y + (-stair_height +
# s * stair_height * stair_slope) * TERRAIN_STEP),
# ]
# self.fd_polygon.shape.vertices = poly
# t = self.world.CreateStaticBody(
# fixtures=self.fd_polygon)
# t.color1, t.color2 = (1, 1, 1), (0.6, 0.6, 0.6)
# self.terrain.append(t)
# counter = stair_steps * stair_width + 1

# elif state == self.STAIRS and not oneshot:
# s = stair_steps * stair_width - counter
# n = s // stair_width
# y = original_y + (n * stair_height * stair_slope) * TERRAIN_STEP - \
# (stair_height if stair_slope == -1 else 0) * TERRAIN_STEP

oneshot = False
self.terrain_y.append(y)
Expand Down
15 changes: 8 additions & 7 deletions poet_distributed/niches/box2d/box2d.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2019 Uber Technologies, Inc.
# Copyright (c) 2020 Uber Technologies, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -22,12 +22,13 @@
name='default_env',
ground_roughness=0,
pit_gap=[],
stump_width=[],
stump_height=[],
stump_float=[],
stair_height=[],
stair_width=[],
stair_steps=[])
stump_width = [],
stump_height = [],
stump_float = [],
stair_height = [],
stair_width = [],
stair_steps = []
)

class Box2DNiche(Niche):
def __init__(self, env_configs, seed, init='random', stochastic=False):
Expand Down
4 changes: 2 additions & 2 deletions poet_distributed/niches/box2d/env.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# The following code is modified from hardmaru/estool (https://github.com/hardmaru/estool/) under the MIT License.

# Modifications Copyright (c) 2019 Uber Technologies, Inc.
# Modifications Copyright (c) 2020 Uber Technologies, Inc.


from collections import namedtuple
Expand Down Expand Up @@ -39,7 +39,7 @@ def make_env(env_name, seed, render_mode=False, env_config=None):
input_size=24,
output_size=4,
time_factor=0,
layers=[40, 40],
layers=[30, 30],
activation='tanh',
noise_bias=0.0,
output_noise=[False, False, False],
Expand Down
2 changes: 1 addition & 1 deletion poet_distributed/niches/box2d/model.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# The following code is modified from hardmaru/estool (https://github.com/hardmaru/estool/) under the MIT License.

# Modifications Copyright (c) 2019 Uber Technologies, Inc.
# Modifications Copyright (c) 2020 Uber Technologies, Inc.


import numpy as np
Expand Down
2 changes: 1 addition & 1 deletion poet_distributed/niches/core.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2019 Uber Technologies, Inc.
# Copyright (c) 2020 Uber Technologies, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion poet_distributed/noise.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# (https://github.com/openai/evolution-strategies-starter)
# under the MIT License.

# Modifications Copyright (c) 2019 Uber Technologies, Inc.
# Modifications Copyright (c) 2020 Uber Technologies, Inc.


import numpy as np
Expand Down
2 changes: 1 addition & 1 deletion poet_distributed/noise_module.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2019 Uber Technologies, Inc.
# Copyright (c) 2020 Uber Technologies, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
14 changes: 8 additions & 6 deletions poet_distributed/novelty.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2019 Uber Technologies, Inc.
# Copyright (c) 2020 Uber Technologies, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -16,14 +16,15 @@
import numpy as np

def env2array(env):
arr = [0., 0., 0., 0., 0.]
# arr = [0., 0., 0., 0., 0.]
arr = [0., 0.,0.]
arr[0] = env.ground_roughness
if len(env.pit_gap) > 0:
arr[1] = env.pit_gap[0]
arr[2] = env.pit_gap[1]
if len(env.stump_height) > 0:
arr[3] = env.stump_height[0]
arr[4] = env.stump_height[1]
# if len(env.stump_height) > 0:
# arr[3] = env.stump_height[0]
# arr[4] = env.stump_height[1]

return arr

Expand All @@ -36,7 +37,8 @@ def euclidean_distance(nx, ny, normalize=False):
y = y.astype(float)

if normalize:
norm = np.array([8., 8., 8., 3., 3.])
# norm = np.array([8., 8., 8., 3., 3.])
norm = np.array([8., 8., 8])
x /= norm
y /= norm

Expand Down
2 changes: 1 addition & 1 deletion poet_distributed/optimizers.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# (https://github.com/openai/evolution-strategies-starter)
# under the MIT License.

# Modifications Copyright (c) 2019 Uber Technologies, Inc.
# Modifications Copyright (c) 2020 Uber Technologies, Inc.


import numpy as np
Expand Down
Loading