Skip to content

Commit

Permalink
XPs with sparsity on Open AI Gym (#1319)
Browse files Browse the repository at this point in the history
* XPs with sparsity on Open AI Gym

* Update gymexperiments.py
  • Loading branch information
teytaud authored Dec 15, 2021
1 parent f5dc4f4 commit 7b99d1a
Showing 1 changed file with 29 additions and 11 deletions.
40 changes: 29 additions & 11 deletions nevergrad/benchmark/gymexperiments.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ def ng_full_gym(
ng_gym: bool = False, # pylint: disable=redefined-outer-name
conformant: bool = False,
gp: bool = False,
sparse: bool = False,
) -> tp.Iterator[Experiment]:
"""Gym simulator. Maximize reward. Many distinct problems.
Expand Down Expand Up @@ -159,17 +160,25 @@ def ng_full_gym(
)
for neural_factor in neural_factors:
for name in env_names:
try:
func = nevergrad_gym.GymMulti(
name, control=control, neural_factor=neural_factor, randomized=randomized
)
except MemoryError:
continue
for budget in budgets:
for algo in optims:
xp = Experiment(func, algo, budget, num_workers=1, seed=next(seedg))
if not xp.is_incoherent:
yield xp
sparse_limits: tp.List[tp.Optional[int]] = [None]
if sparse:
sparse_limits += [10, 100, 1000]
for sparse_limit in sparse_limits:
try:
func = nevergrad_gym.GymMulti(
name,
control=control,
neural_factor=neural_factor,
randomized=randomized,
sparse_limit=sparse_limit,
)
except MemoryError:
continue
for budget in budgets:
for algo in optims:
xp = Experiment(func, algo, budget, num_workers=1, seed=next(seedg))
if not xp.is_incoherent:
yield xp


@registry.register
Expand Down Expand Up @@ -205,6 +214,15 @@ def gp(seed: tp.Optional[int] = None) -> tp.Iterator[Experiment]:
return ng_full_gym(seed, gp=True)


@registry.register
def sparse_gp(seed: tp.Optional[int] = None) -> tp.Iterator[Experiment]:
"""GP benchmark.
Counterpart of ng_full_gym with a specific, reduced list of problems for matching
a genetic programming benchmark."""
return ng_full_gym(seed, gp=True, sparse=True)


@registry.register
def ng_stacking_gym(seed: tp.Optional[int] = None) -> tp.Iterator[Experiment]:
"""Counterpart of ng_gym with a recurrent network."""
Expand Down

0 comments on commit 7b99d1a

Please sign in to comment.