Skip to content

Commit

Permalink
test: lock new target value due to monitor being a stateful causing r…
Browse files Browse the repository at this point in the history
…andom key change
  • Loading branch information
BillHuang2001 committed Sep 9, 2024
1 parent bcd30f6 commit ccdb748
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions tests/test_gym.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def __call__(self, x):
ub=jnp.full_like(center, 10.0),
mean=center,
stdev=0.1,
pop_size=16,
pop_size=32,
),
problem=problem,
monitors=[monitor],
Expand All @@ -63,13 +63,12 @@ def __call__(self, x):

min_fitness, _state = use_state(monitor.get_best_fitness)(state)
fit_history, _state = use_state(monitor.get_fitness_history)(state)
print(fit_history)
# gym is deterministic, so the result should always be the same
assert min_fitness == 40.0
assert min_fitness == 10.0

# run the workflow for another 25 steps
for i in range(25):
# run the workflow for another 10 steps
for i in range(10):
state = workflow.step(state)

min_fitness, state = use_state(monitor.get_best_fitness)(state)
assert min_fitness == 48.0
assert min_fitness == 13.0

0 comments on commit ccdb748

Please sign in to comment.