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

Add TransitionChoice with repetitions #696

Merged
merged 12 commits into from
May 26, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
Prev Previous commit
Next Next commit
Add test
  • Loading branch information
jrapin committed May 26, 2020
commit 037c4422186a442baad3169f408b5891d9dc34e8
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
- `recommend` now provides an evaluated candidate when possible. For non-deterministic parametrization like `Choice`, this means we won't
resample, and we will actually recommend the best past evaluated candidate [#668](https://github.com/facebookresearch/nevergrad/pull/668).
Still, some optimizers (like `TBPSA`) may recommend a non-evaluated point.
- `Choice` now takes a new `repetitions` parameters for sampling several times,
it is equivalent to :code:`Tuple(*[Choice(options) for _ in range(repetitions)])` but can be be around 30x faster for large numbers of repetitions [#670](https://github.com/facebookresearch/nevergrad/pull/670).
- `Choice` and `TransitionChoice` can now take a `repetitions` parameters for sampling several times,
it is equivalent to :code:`Tuple(*[Choice(options) for _ in range(repetitions)])` but can be be up to 30x faster for large numbers of repetitions [#670](https://github.com/facebookresearch/nevergrad/pull/670).
- Defaults for bounds in `Array` is now `bouncing`, which is a variant of `clipping` avoiding over-sompling on the bounds [#684](https://github.com/facebookresearch/nevergrad/pull/684)
and [#691](https://github.com/facebookresearch/nevergrad/pull/691).

Expand Down
11 changes: 11 additions & 0 deletions nevergrad/parametrization/test_parameter.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,17 @@ def test_choice_repetitions() -> None:
choice.mutate()


def test_transition_choice_repetitions() -> None:
choice = par.TransitionChoice([0, 1, 2, 3], repetitions=2)
choice.random_state.seed(12)
assert len(choice) == 4
assert choice.value == (2, 2)
choice.value = (3, 1)
np.testing.assert_almost_equal(choice.position.value, [3.5, 1.5], decimal=3)
choice.mutate()
assert choice.value == (3, 0)


def test_descriptors() -> None:
d1 = utils.Descriptors()
d2 = utils.Descriptors(continuous=False)
Expand Down