prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Optimizer always trying the same points 
  ## Steps to reproduce
  
    1. Set up an optimizer with a parametrization
    2. Run optimizer.minimize()
    3. Print values being tested
  
  ## Observed Results
  
    * What happened?  This could be a description, log output, etc.
  The argument of the objective function are always the same
  
  ## Expected Results
  
    * What did you expect to happen?
  The optimizer tries new values
  ## Relevant Code
  
    ```
  from concurrent import futures
  
  import nevergrad as ng
  import numpy as np
  
  
  class myobj:
      def __init__(self):
          self.params = ng.p.Dict(
              kernel=ng.p.Log(lower=3, upper=2000).set_integer_casting()
          )
  
      def get_optimizer(self, parametrization, dictA):
          optimizer = ng.optimizers.NGO(
              parametrization=parametrization,
              budget=dictA["budget"],
              num_workers=dictA["workers"],
          )
          return optimizer
  
      def fn(self, params, dictA, X, Y):
          print(params)
          kvalue = params['kernel']
          print(kvalue)
          return kvalue * np.mean((Y - X)**2)
  
      def optimize_params(self, dictA, X, Y):
          # breakpoint()
          parametrization = ng.p.Instrumentation(
              self.params, dictA=dictA, X=X, Y=Y
          )
          optimizer = self.get_optimizer(parametrization, dictA)
          with futures.ThreadPoolExecutor(
              max_workers=optimizer.num_workers
          ) as executor:
              r = optimizer.minimize(
                  self.fn, executor=executor, batch_mode=False
              )
          return r
  
  
  obj = myobj()
  dictA = {'budget':5, 'workers':2}
  recom = obj.optimize_params(dictA, np.zeros(3), np.ones(3))
  print('recommendation: ')
  print(*recom.args)
  
    ```
  
  I am sure I am doing something wrong, but I can not detect what. Any helpful hand is welcome.
  
  <!--- In any case, don't hesitate to join and ask questions if you need on Nevergrad users Facebook group https://www.facebook.com/groups/nevergradusers/ -->
  
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `nevergrad/optimization/mutations.py`
  Content:
  ```
  1 # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
  2 #
  3 # This source code is licensed under the MIT license found in the
  4 # LICENSE file in the root directory of this source tree.
  5 
  6 from typing import Optional, Any
  7 import numpy as np
  8 from ..common.typetools import ArrayLike
  9 from . import utils
  10 
  11 
  12 class Mutator:
  13     """Class defining mutations, and holding a random state used for random generation.
  14     """
  15 
  16     def __init__(self, random_state: np.random.RandomState) -> None:
  17         self.random_state = random_state
  18 
  19     def doerr_discrete_mutation(self, parent: ArrayLike) -> ArrayLike:
  20         """Mutation as in the fast 1+1-ES, Doerr et al. The exponent is 1.5.
  21         """
  22         dimension = len(parent)
  23         if dimension < 5:
  24             return self.discrete_mutation(parent)
  25         return self.doubledoerr_discrete_mutation(parent, max_ratio=.5)
  26 
  27     def doubledoerr_discrete_mutation(self, parent: ArrayLike, max_ratio: float = 1.) -> ArrayLike:
  28         """Doerr's recommendation above can mutate up to half variables
  29         in average.
  30         In our high-arity context, we might need more than that.
  31 
  32         Parameters
  33         ----------
  34         parent: array-like
  35             the point to mutate
  36         max_ratio: float (between 0 and 1)
  37             the maximum mutation ratio (careful: this is not an exact ratio)
  38         """
  39         assert 0 <= max_ratio <= 1
  40         dimension = len(parent)
  41         max_mutations = max(2, int(max_ratio * dimension))
  42         p = 1. / np.arange(1, max_mutations)**1.5
  43         p /= np.sum(p)
  44         u = self.random_state.choice(np.arange(1, max_mutations), p=p)
  45         return self.portfolio_discrete_mutation(parent, u=u)
  46 
  47     def portfolio_discrete_mutation(self, parent: ArrayLike, u: Optional[int] = None) -> ArrayLike:
  48         """Mutation discussed in
  49         https://arxiv.org/pdf/1606.05551v1.pdf
  50         We mutate a randomly drawn number of variables in average.
  51         """
  52         dimension = len(parent)
  53         if u is None:
  54             u = 1 if dimension == 1 else int(self.random_state.randint(1, dimension))
  55         boolean_vector = [True for _ in parent]
  56         while all(boolean_vector) and dimension != 1:
  57             boolean_vector = [self.random_state.rand() > (float(u) / dimension) for _ in parent]
  58         return [s if b else self.random_state.normal(0., 1.) for (b, s) in zip(boolean_vector, parent)]
  59 
  60     def discrete_mutation(self, parent: ArrayLike) -> ArrayLike:
  61         dimension = len(parent)
  62         boolean_vector = [True for _ in parent]
  63         while all(boolean_vector):
  64             boolean_vector = [self.random_state.rand() > (1. / dimension) for _ in parent]
  65         return [s if b else self.random_state.normal(0., 1.) for (b, s) in zip(boolean_vector, parent)]
  66 
  67     def crossover(self, parent: ArrayLike, donor: ArrayLike) -> ArrayLike:
  68         mix = [self.random_state.choice([d, p]) for (p, d) in zip(parent, donor)]
  69         return self.discrete_mutation(mix)
  70 
  71     def get_roulette(self, archive: utils.Archive[utils.MultiValue], num: Optional[int] = None) -> Any:
  72         """Apply a roulette tournament selection.
  73         """
  74         if num is None:
  75             num = int(.999 + np.sqrt(len(archive)))
  76         # the following sort makes the line deterministic, and function seedable, at the cost of complexity!
  77         my_keys = sorted(archive.bytesdict.keys())
  78         my_keys_indices = self.random_state.choice(len(my_keys), size=min(num, len(my_keys)), replace=False)
  79         my_keys = [my_keys[i] for i in my_keys_indices]
  80         # best pessimistic value in a random set of keys
  81         return np.frombuffer(min(my_keys, key=lambda x: archive.bytesdict[x].pessimistic_confidence_bound))
  82
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/nevergrad/optimization/mutations.py b/nevergrad/optimization/mutations.py
  --- a/nevergrad/optimization/mutations.py
  +++ b/nevergrad/optimization/mutations.py
  @@ -52,6 +52,8 @@
           dimension = len(parent)
           if u is None:
               u = 1 if dimension == 1 else int(self.random_state.randint(1, dimension))
  +        if dimension == 1:  # corner case.
  +            return self.random_state.normal(0., 1., size=1)  # type: ignore
           boolean_vector = [True for _ in parent]
           while all(boolean_vector) and dimension != 1:
               boolean_vector = [self.random_state.rand() > (float(u) / dimension) for _ in parent]
  
verification_info: {"golden_diff": "diff --git a/nevergrad/optimization/mutations.py b/nevergrad/optimization/mutations.py\n--- a/nevergrad/optimization/mutations.py\n+++ b/nevergrad/optimization/mutations.py\n@@ -52,6 +52,8 @@\n         dimension = len(parent)\n         if u is None:\n             u = 1 if dimension == 1 else int(self.random_state.randint(1, dimension))\n+        if dimension == 1:  # corner case.\n+            return self.random_state.normal(0., 1., size=1)  # type: ignore\n         boolean_vector = [True for _ in parent]\n         while all(boolean_vector) and dimension != 1:\n             boolean_vector = [self.random_state.rand() > (float(u) / dimension) for _ in parent]\n", "issue": "Optimizer always trying the same points \n## Steps to reproduce\r\n\r\n  1. Set up an optimizer with a parametrization\r\n  2. Run optimizer.minimize()\r\n  3. Print values being tested\r\n\r\n## Observed Results\r\n\r\n  * What happened?  This could be a description, log output, etc.\r\nThe argument of the objective function are always the same\r\n\r\n## Expected Results\r\n\r\n  * What did you expect to happen?\r\nThe optimizer tries new values\r\n## Relevant Code\r\n\r\n  ```\r\nfrom concurrent import futures\r\n\r\nimport nevergrad as ng\r\nimport numpy as np\r\n\r\n\r\nclass myobj:\r\n    def __init__(self):\r\n        self.params = ng.p.Dict(\r\n            kernel=ng.p.Log(lower=3, upper=2000).set_integer_casting()\r\n        )\r\n\r\n    def get_optimizer(self, parametrization, dictA):\r\n        optimizer = ng.optimizers.NGO(\r\n            parametrization=parametrization,\r\n            budget=dictA[\"budget\"],\r\n            num_workers=dictA[\"workers\"],\r\n        )\r\n        return optimizer\r\n\r\n    def fn(self, params, dictA, X, Y):\r\n        print(params)\r\n        kvalue = params['kernel']\r\n        print(kvalue)\r\n        return kvalue * np.mean((Y - X)**2)\r\n\r\n    def optimize_params(self, dictA, X, Y):\r\n        # breakpoint()\r\n        parametrization = ng.p.Instrumentation(\r\n            self.params, dictA=dictA, X=X, Y=Y\r\n        )\r\n        optimizer = self.get_optimizer(parametrization, dictA)\r\n        with futures.ThreadPoolExecutor(\r\n            max_workers=optimizer.num_workers\r\n        ) as executor:\r\n            r = optimizer.minimize(\r\n                self.fn, executor=executor, batch_mode=False\r\n            )\r\n        return r\r\n\r\n\r\nobj = myobj()\r\ndictA = {'budget':5, 'workers':2}\r\nrecom = obj.optimize_params(dictA, np.zeros(3), np.ones(3))\r\nprint('recommendation: ')\r\nprint(*recom.args)\r\n\r\n  ```\r\n\r\nI am sure I am doing something wrong, but I can not detect what. Any helpful hand is welcome.\r\n\r\n<!--- In any case, don't hesitate to join and ask questions if you need on Nevergrad users Facebook group https://www.facebook.com/groups/nevergradusers/ -->\r\n\n", "before_files": [{"content": "# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.\n#\n# This source code is licensed under the MIT license found in the\n# LICENSE file in the root directory of this source tree.\n\nfrom typing import Optional, Any\nimport numpy as np\nfrom ..common.typetools import ArrayLike\nfrom . import utils\n\n\nclass Mutator:\n    \"\"\"Class defining mutations, and holding a random state used for random generation.\n    \"\"\"\n\n    def __init__(self, random_state: np.random.RandomState) -> None:\n        self.random_state = random_state\n\n    def doerr_discrete_mutation(self, parent: ArrayLike) -> ArrayLike:\n        \"\"\"Mutation as in the fast 1+1-ES, Doerr et al. The exponent is 1.5.\n        \"\"\"\n        dimension = len(parent)\n        if dimension < 5:\n            return self.discrete_mutation(parent)\n        return self.doubledoerr_discrete_mutation(parent, max_ratio=.5)\n\n    def doubledoerr_discrete_mutation(self, parent: ArrayLike, max_ratio: float = 1.) -> ArrayLike:\n        \"\"\"Doerr's recommendation above can mutate up to half variables\n        in average.\n        In our high-arity context, we might need more than that.\n\n        Parameters\n        ----------\n        parent: array-like\n            the point to mutate\n        max_ratio: float (between 0 and 1)\n            the maximum mutation ratio (careful: this is not an exact ratio)\n        \"\"\"\n        assert 0 <= max_ratio <= 1\n        dimension = len(parent)\n        max_mutations = max(2, int(max_ratio * dimension))\n        p = 1. / np.arange(1, max_mutations)**1.5\n        p /= np.sum(p)\n        u = self.random_state.choice(np.arange(1, max_mutations), p=p)\n        return self.portfolio_discrete_mutation(parent, u=u)\n\n    def portfolio_discrete_mutation(self, parent: ArrayLike, u: Optional[int] = None) -> ArrayLike:\n        \"\"\"Mutation discussed in\n        https://arxiv.org/pdf/1606.05551v1.pdf\n        We mutate a randomly drawn number of variables in average.\n        \"\"\"\n        dimension = len(parent)\n        if u is None:\n            u = 1 if dimension == 1 else int(self.random_state.randint(1, dimension))\n        boolean_vector = [True for _ in parent]\n        while all(boolean_vector) and dimension != 1:\n            boolean_vector = [self.random_state.rand() > (float(u) / dimension) for _ in parent]\n        return [s if b else self.random_state.normal(0., 1.) for (b, s) in zip(boolean_vector, parent)]\n\n    def discrete_mutation(self, parent: ArrayLike) -> ArrayLike:\n        dimension = len(parent)\n        boolean_vector = [True for _ in parent]\n        while all(boolean_vector):\n            boolean_vector = [self.random_state.rand() > (1. / dimension) for _ in parent]\n        return [s if b else self.random_state.normal(0., 1.) for (b, s) in zip(boolean_vector, parent)]\n\n    def crossover(self, parent: ArrayLike, donor: ArrayLike) -> ArrayLike:\n        mix = [self.random_state.choice([d, p]) for (p, d) in zip(parent, donor)]\n        return self.discrete_mutation(mix)\n\n    def get_roulette(self, archive: utils.Archive[utils.MultiValue], num: Optional[int] = None) -> Any:\n        \"\"\"Apply a roulette tournament selection.\n        \"\"\"\n        if num is None:\n            num = int(.999 + np.sqrt(len(archive)))\n        # the following sort makes the line deterministic, and function seedable, at the cost of complexity!\n        my_keys = sorted(archive.bytesdict.keys())\n        my_keys_indices = self.random_state.choice(len(my_keys), size=min(num, len(my_keys)), replace=False)\n        my_keys = [my_keys[i] for i in my_keys_indices]\n        # best pessimistic value in a random set of keys\n        return np.frombuffer(min(my_keys, key=lambda x: archive.bytesdict[x].pessimistic_confidence_bound))\n", "path": "nevergrad/optimization/mutations.py"}], "after_files": [{"content": "# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.\n#\n# This source code is licensed under the MIT license found in the\n# LICENSE file in the root directory of this source tree.\n\nfrom typing import Optional, Any\nimport numpy as np\nfrom ..common.typetools import ArrayLike\nfrom . import utils\n\n\nclass Mutator:\n    \"\"\"Class defining mutations, and holding a random state used for random generation.\n    \"\"\"\n\n    def __init__(self, random_state: np.random.RandomState) -> None:\n        self.random_state = random_state\n\n    def doerr_discrete_mutation(self, parent: ArrayLike) -> ArrayLike:\n        \"\"\"Mutation as in the fast 1+1-ES, Doerr et al. The exponent is 1.5.\n        \"\"\"\n        dimension = len(parent)\n        if dimension < 5:\n            return self.discrete_mutation(parent)\n        return self.doubledoerr_discrete_mutation(parent, max_ratio=.5)\n\n    def doubledoerr_discrete_mutation(self, parent: ArrayLike, max_ratio: float = 1.) -> ArrayLike:\n        \"\"\"Doerr's recommendation above can mutate up to half variables\n        in average.\n        In our high-arity context, we might need more than that.\n\n        Parameters\n        ----------\n        parent: array-like\n            the point to mutate\n        max_ratio: float (between 0 and 1)\n            the maximum mutation ratio (careful: this is not an exact ratio)\n        \"\"\"\n        assert 0 <= max_ratio <= 1\n        dimension = len(parent)\n        max_mutations = max(2, int(max_ratio * dimension))\n        p = 1. / np.arange(1, max_mutations)**1.5\n        p /= np.sum(p)\n        u = self.random_state.choice(np.arange(1, max_mutations), p=p)\n        return self.portfolio_discrete_mutation(parent, u=u)\n\n    def portfolio_discrete_mutation(self, parent: ArrayLike, u: Optional[int] = None) -> ArrayLike:\n        \"\"\"Mutation discussed in\n        https://arxiv.org/pdf/1606.05551v1.pdf\n        We mutate a randomly drawn number of variables in average.\n        \"\"\"\n        dimension = len(parent)\n        if u is None:\n            u = 1 if dimension == 1 else int(self.random_state.randint(1, dimension))\n        if dimension == 1:  # corner case.\n            return self.random_state.normal(0., 1., size=1)  # type: ignore\n        boolean_vector = [True for _ in parent]\n        while all(boolean_vector) and dimension != 1:\n            boolean_vector = [self.random_state.rand() > (float(u) / dimension) for _ in parent]\n        return [s if b else self.random_state.normal(0., 1.) for (b, s) in zip(boolean_vector, parent)]\n\n    def discrete_mutation(self, parent: ArrayLike) -> ArrayLike:\n        dimension = len(parent)\n        boolean_vector = [True for _ in parent]\n        while all(boolean_vector):\n            boolean_vector = [self.random_state.rand() > (1. / dimension) for _ in parent]\n        return [s if b else self.random_state.normal(0., 1.) for (b, s) in zip(boolean_vector, parent)]\n\n    def crossover(self, parent: ArrayLike, donor: ArrayLike) -> ArrayLike:\n        mix = [self.random_state.choice([d, p]) for (p, d) in zip(parent, donor)]\n        return self.discrete_mutation(mix)\n\n    def get_roulette(self, archive: utils.Archive[utils.MultiValue], num: Optional[int] = None) -> Any:\n        \"\"\"Apply a roulette tournament selection.\n        \"\"\"\n        if num is None:\n            num = int(.999 + np.sqrt(len(archive)))\n        # the following sort makes the line deterministic, and function seedable, at the cost of complexity!\n        my_keys = sorted(archive.bytesdict.keys())\n        my_keys_indices = self.random_state.choice(len(my_keys), size=min(num, len(my_keys)), replace=False)\n        my_keys = [my_keys[i] for i in my_keys_indices]\n        # best pessimistic value in a random set of keys\n        return np.frombuffer(min(my_keys, key=lambda x: archive.bytesdict[x].pessimistic_confidence_bound))\n", "path": "nevergrad/optimization/mutations.py"}]}