We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Upgrade pycma so that garage can install without numpy
The current version of pycma we use requires numpy to run its setup.py. This breaks most automated install processes. Later versions of pycma don't have this problem, but they have an API change which requires updating `garage.np.algos.cmaes`.

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `setup.py`
Content:
```
1 """setuptools based setup module."""
2 from setuptools import find_packages
3 from setuptools import setup
4 
5 try:
6     # pylint: disable=unused-import
7     import numpy  # noqa: F401
8 except ImportError:
9     raise RuntimeError(
10         'garage requires numpy in the environment to install. '
11         'Please install numpy==1.14.5 and try again. See '
12         'https://github.com/rlworkgroup/garage/issues/800 for more info.')
13 
14 TF_VERSION = '<1.15,>=1.14.0'
15 GYM_VERSION = '==0.12.4'
16 
17 # Required dependencies
18 required = [
19     # Please keep alphabetized
20     'akro==0.0.6',
21     'cached_property',
22     'click',
23     'cloudpickle',
24     'cma==1.1.06',
25     'dowel==0.0.2',
26     'gym[atari,box2d,classic_control]' + GYM_VERSION,
27     'joblib<0.13,>=0.12',
28     'matplotlib',
29     'numpy==1.14.5',
30     'psutil',
31     # Pyglet 1.4.0 introduces some api change which breaks some
32     # gym environments
33     # See: https://github.com/openai/gym/issues/1588
34     'pyglet<1.4.0,>=1.3.0',
35     'pyprind',
36     'python-dateutil',
37     'torch==1.1.0',
38     'ray',
39     'scikit-image',
40     'scipy',
41     'tensorflow' + TF_VERSION,
42     'tensorflow-probability<0.8.0,>=0.7.0',  # for tensorflow 1.12
43     'torchvision==0.3.0'
44 ]
45 
46 # Dependencies for optional features
47 extras = {}
48 
49 extras['mujoco'] = [
50     'mujoco-py<2.1,>=2.0',
51     'gym[all]' + GYM_VERSION,
52 ]
53 
54 extras['dm_control'] = [
55     # dm_control throws an error during install about not being able to
56     # find a build dependency (absl-py). Later pip executes the `install`
57     # command again and the install succeeds because absl-py has been
58     # installed. This is stupid, but harmless.
59     'dm_control @ https://api.github.com/repos/deepmind/dm_control/tarball/7a36377879c57777e5d5b4da5aae2cd2a29b607a',  # noqa: E501
60 ]
61 
62 extras['all'] = list(set(sum(extras.values(), [])))
63 
64 # dependencies for using gpu, not included in all
65 extras['gpu'] = ['tensorflow-gpu' + TF_VERSION]
66 
67 # Development dependencies (*not* included in "all")
68 extras['dev'] = [
69     # Please keep alphabetized
70     'baselines @ https://api.github.com/repos/openai/baselines/tarball/f2729693253c0ef4d4086231d36e0a4307ec1cb3',  # noqa: E501
71     'flake8',
72     'flake8-docstrings==1.3.0',
73     'flake8-import-order',
74     'pandas',
75     'pep8-naming==0.7.0',
76     'pre-commit',
77     # pydocstyle 4.0.0 breaks flake8-docstrings 1.3.0
78     # See https://gitlab.com/pycqa/flake8-docstrings/issues/36
79     'pydocstyle<4.0.0',
80     'pylint==1.9.2',
81     'pytest>=3.6',  # Required for pytest-cov on Python 3.6
82     'pytest-cov',
83     'pytest-xdist',
84     'recommonmark',
85     'sphinx',
86     'sphinx_rtd_theme',
87     'yapf==0.28.0',
88 ]
89 
90 with open('README.md') as f:
91     readme = f.read()
92 
93 # Get the package version dynamically
94 with open('VERSION') as v:
95     version = v.read().strip()
96 
97 setup(
98     name='garage',
99     version=version,
100     author='Reinforcement Learning Working Group',
101     description='A framework for reproducible reinforcement learning research',
102     url='https://github.com/rlworkgroup/garage',
103     packages=find_packages(where='src'),
104     package_dir={'': 'src'},
105     scripts=['scripts/garage'],
106     python_requires='>=3.5',
107     install_requires=required,
108     extras_require=extras,
109     license='MIT',
110     long_description=readme,
111     long_description_content_type='text/markdown',
112     classifiers=[
113         'Development Status :: 4 - Beta',
114         'Intended Audience :: Developers',
115         'Intended Audience :: Education',
116         'Intended Audience :: Science/Research',
117         'License :: OSI Approved :: MIT License',
118         'Programming Language :: Python :: 3.5',
119         'Programming Language :: Python :: 3.6',
120         'Programming Language :: Python :: 3.7',
121         'Programming Language :: Python :: 3 :: Only',
122         'Topic :: Scientific/Engineering :: Artificial Intelligence',
123         'Topic :: Scientific/Engineering :: Mathematics',
124         'Topic :: Software Development :: Libraries',
125     ],
126 )
127
```

Path: `src/garage/np/algos/cma_es.py`
Content:
```
1 """Covariance Matrix Adaptation Evolution Strategy."""
2 import cma
3 from dowel import logger, tabular
4 import numpy as np
5 
6 from garage.np.algos import BatchPolopt
7 
8 
9 class CMAES(BatchPolopt):
10     """Covariance Matrix Adaptation Evolution Strategy.
11 
12     Note:
13         The CMA-ES method can hardly learn a successful policy even for
14         simple task. It is still maintained here only for consistency with
15         original rllab paper.
16 
17     Args:
18         env_spec (garage.envs.EnvSpec): Environment specification.
19         policy (garage.np.policies.Policy): Action policy.
20         baseline (garage.np.baselines.Baseline): Baseline for GAE
21             (Generalized Advantage Estimation).
22         n_samples (int): Number of policies sampled in one epoch.
23         discount (float): Environment reward discount.
24         max_path_length (int): Maximum length of a single rollout.
25         sigma0 (float): Initial std for param distribution.
26 
27     """
28 
29     def __init__(self,
30                  env_spec,
31                  policy,
32                  baseline,
33                  n_samples,
34                  discount=0.99,
35                  max_path_length=500,
36                  sigma0=1.):
37         super().__init__(policy, baseline, discount, max_path_length,
38                          n_samples)
39         self.env_spec = env_spec
40         self.policy = policy
41 
42         self.sigma0 = sigma0
43 
44     def _sample_params(self):
45         return self.es.ask(self.n_samples)
46 
47     def train(self, runner):
48         """Initialize variables and start training.
49 
50         Args:
51             runner (LocalRunner): LocalRunner is passed to give algorithm
52                 the access to runner.step_epochs(), which provides services
53                 such as snapshotting and sampler control.
54 
55         Returns:
56             The average return in last epoch cycle.
57 
58         """
59         init_mean = self.policy.get_param_values()
60         self.es = cma.CMAEvolutionStrategy(init_mean, self.sigma0)
61         self.all_params = self._sample_params()
62         self.cur_params = self.all_params[0]
63         self.policy.set_param_values(self.cur_params)
64         self.all_returns = []
65 
66         return super().train(runner)
67 
68     def train_once(self, itr, paths):
69         """Perform one step of policy optimization given one batch of samples.
70 
71         Args:
72             itr (int): Iteration number.
73             paths (list[dict]): A list of collected paths.
74 
75         """
76         paths = self.process_samples(itr, paths)
77 
78         epoch = itr // self.n_samples
79         i_sample = itr - epoch * self.n_samples
80 
81         tabular.record('Epoch', epoch)
82         tabular.record('# Sample', i_sample)
83 
84         rtn = paths['average_return']
85         self.all_returns.append(paths['average_return'])
86 
87         if (itr + 1) % self.n_samples == 0:
88             avg_rtns = np.array(self.all_returns)
89             self.es.tell(self.all_params, -avg_rtns)
90             self.policy.set_param_values(self.es.result()[0])
91 
92             # Clear for next epoch
93             rtn = max(self.all_returns)
94             self.all_returns.clear()
95             self.all_params = self._sample_params()
96 
97         self.cur_params = self.all_params[(i_sample + 1) % self.n_samples]
98         self.policy.set_param_values(self.cur_params)
99 
100         logger.log(tabular)
101         return rtn
102
```
--- 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()

```

diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -2,15 +2,6 @@
 from setuptools import find_packages
 from setuptools import setup
 
-try:
-    # pylint: disable=unused-import
-    import numpy  # noqa: F401
-except ImportError:
-    raise RuntimeError(
-        'garage requires numpy in the environment to install. '
-        'Please install numpy==1.14.5 and try again. See '
-        'https://github.com/rlworkgroup/garage/issues/800 for more info.')
-
 TF_VERSION = '<1.15,>=1.14.0'
 GYM_VERSION = '==0.12.4'
 
@@ -21,12 +12,12 @@
     'cached_property',
     'click',
     'cloudpickle',
-    'cma==1.1.06',
+    'cma==2.7.0',
     'dowel==0.0.2',
     'gym[atari,box2d,classic_control]' + GYM_VERSION,
     'joblib<0.13,>=0.12',
     'matplotlib',
-    'numpy==1.14.5',
+    'numpy>=1.14.5',
     'psutil',
     # Pyglet 1.4.0 introduces some api change which breaks some
     # gym environments
diff --git a/src/garage/np/algos/cma_es.py b/src/garage/np/algos/cma_es.py
--- a/src/garage/np/algos/cma_es.py
+++ b/src/garage/np/algos/cma_es.py
@@ -42,7 +42,7 @@
         self.sigma0 = sigma0
 
     def _sample_params(self):
-        return self.es.ask(self.n_samples)
+        return self.es.ask()
 
     def train(self, runner):
         """Initialize variables and start training.
@@ -57,7 +57,8 @@
 
         """
         init_mean = self.policy.get_param_values()
-        self.es = cma.CMAEvolutionStrategy(init_mean, self.sigma0)
+        self.es = cma.CMAEvolutionStrategy(init_mean, self.sigma0,
+                                           {'popsize': self.n_samples})
         self.all_params = self._sample_params()
         self.cur_params = self.all_params[0]
         self.policy.set_param_values(self.cur_params)
@@ -87,7 +88,7 @@
         if (itr + 1) % self.n_samples == 0:
             avg_rtns = np.array(self.all_returns)
             self.es.tell(self.all_params, -avg_rtns)
-            self.policy.set_param_values(self.es.result()[0])
+            self.policy.set_param_values(self.es.best.get()[0])
 
             # Clear for next epoch
             rtn = max(self.all_returns)

{"golden_diff": "diff --git a/setup.py b/setup.py\n--- a/setup.py\n+++ b/setup.py\n@@ -2,15 +2,6 @@\n from setuptools import find_packages\n from setuptools import setup\n \n-try:\n-    # pylint: disable=unused-import\n-    import numpy  # noqa: F401\n-except ImportError:\n-    raise RuntimeError(\n-        'garage requires numpy in the environment to install. '\n-        'Please install numpy==1.14.5 and try again. See '\n-        'https://github.com/rlworkgroup/garage/issues/800 for more info.')\n-\n TF_VERSION = '<1.15,>=1.14.0'\n GYM_VERSION = '==0.12.4'\n \n@@ -21,12 +12,12 @@\n     'cached_property',\n     'click',\n     'cloudpickle',\n-    'cma==1.1.06',\n+    'cma==2.7.0',\n     'dowel==0.0.2',\n     'gym[atari,box2d,classic_control]' + GYM_VERSION,\n     'joblib<0.13,>=0.12',\n     'matplotlib',\n-    'numpy==1.14.5',\n+    'numpy>=1.14.5',\n     'psutil',\n     # Pyglet 1.4.0 introduces some api change which breaks some\n     # gym environments\ndiff --git a/src/garage/np/algos/cma_es.py b/src/garage/np/algos/cma_es.py\n--- a/src/garage/np/algos/cma_es.py\n+++ b/src/garage/np/algos/cma_es.py\n@@ -42,7 +42,7 @@\n         self.sigma0 = sigma0\n \n     def _sample_params(self):\n-        return self.es.ask(self.n_samples)\n+        return self.es.ask()\n \n     def train(self, runner):\n         \"\"\"Initialize variables and start training.\n@@ -57,7 +57,8 @@\n \n         \"\"\"\n         init_mean = self.policy.get_param_values()\n-        self.es = cma.CMAEvolutionStrategy(init_mean, self.sigma0)\n+        self.es = cma.CMAEvolutionStrategy(init_mean, self.sigma0,\n+                                           {'popsize': self.n_samples})\n         self.all_params = self._sample_params()\n         self.cur_params = self.all_params[0]\n         self.policy.set_param_values(self.cur_params)\n@@ -87,7 +88,7 @@\n         if (itr + 1) % self.n_samples == 0:\n             avg_rtns = np.array(self.all_returns)\n             self.es.tell(self.all_params, -avg_rtns)\n-            self.policy.set_param_values(self.es.result()[0])\n+            self.policy.set_param_values(self.es.best.get()[0])\n \n             # Clear for next epoch\n             rtn = max(self.all_returns)\n", "issue": "Upgrade pycma so that garage can install without numpy\nThe current version of pycma we use requires numpy to run its setup.py. This breaks most automated install processes. Later versions of pycma don't have this problem, but they have an API change which requires updating `garage.np.algos.cmaes`.\n", "before_files": [{"content": "\"\"\"setuptools based setup module.\"\"\"\nfrom setuptools import find_packages\nfrom setuptools import setup\n\ntry:\n    # pylint: disable=unused-import\n    import numpy  # noqa: F401\nexcept ImportError:\n    raise RuntimeError(\n        'garage requires numpy in the environment to install. '\n        'Please install numpy==1.14.5 and try again. See '\n        'https://github.com/rlworkgroup/garage/issues/800 for more info.')\n\nTF_VERSION = '<1.15,>=1.14.0'\nGYM_VERSION = '==0.12.4'\n\n# Required dependencies\nrequired = [\n    # Please keep alphabetized\n    'akro==0.0.6',\n    'cached_property',\n    'click',\n    'cloudpickle',\n    'cma==1.1.06',\n    'dowel==0.0.2',\n    'gym[atari,box2d,classic_control]' + GYM_VERSION,\n    'joblib<0.13,>=0.12',\n    'matplotlib',\n    'numpy==1.14.5',\n    'psutil',\n    # Pyglet 1.4.0 introduces some api change which breaks some\n    # gym environments\n    # See: https://github.com/openai/gym/issues/1588\n    'pyglet<1.4.0,>=1.3.0',\n    'pyprind',\n    'python-dateutil',\n    'torch==1.1.0',\n    'ray',\n    'scikit-image',\n    'scipy',\n    'tensorflow' + TF_VERSION,\n    'tensorflow-probability<0.8.0,>=0.7.0',  # for tensorflow 1.12\n    'torchvision==0.3.0'\n]\n\n# Dependencies for optional features\nextras = {}\n\nextras['mujoco'] = [\n    'mujoco-py<2.1,>=2.0',\n    'gym[all]' + GYM_VERSION,\n]\n\nextras['dm_control'] = [\n    # dm_control throws an error during install about not being able to\n    # find a build dependency (absl-py). Later pip executes the `install`\n    # command again and the install succeeds because absl-py has been\n    # installed. This is stupid, but harmless.\n    'dm_control @ https://api.github.com/repos/deepmind/dm_control/tarball/7a36377879c57777e5d5b4da5aae2cd2a29b607a',  # noqa: E501\n]\n\nextras['all'] = list(set(sum(extras.values(), [])))\n\n# dependencies for using gpu, not included in all\nextras['gpu'] = ['tensorflow-gpu' + TF_VERSION]\n\n# Development dependencies (*not* included in \"all\")\nextras['dev'] = [\n    # Please keep alphabetized\n    'baselines @ https://api.github.com/repos/openai/baselines/tarball/f2729693253c0ef4d4086231d36e0a4307ec1cb3',  # noqa: E501\n    'flake8',\n    'flake8-docstrings==1.3.0',\n    'flake8-import-order',\n    'pandas',\n    'pep8-naming==0.7.0',\n    'pre-commit',\n    # pydocstyle 4.0.0 breaks flake8-docstrings 1.3.0\n    # See https://gitlab.com/pycqa/flake8-docstrings/issues/36\n    'pydocstyle<4.0.0',\n    'pylint==1.9.2',\n    'pytest>=3.6',  # Required for pytest-cov on Python 3.6\n    'pytest-cov',\n    'pytest-xdist',\n    'recommonmark',\n    'sphinx',\n    'sphinx_rtd_theme',\n    'yapf==0.28.0',\n]\n\nwith open('README.md') as f:\n    readme = f.read()\n\n# Get the package version dynamically\nwith open('VERSION') as v:\n    version = v.read().strip()\n\nsetup(\n    name='garage',\n    version=version,\n    author='Reinforcement Learning Working Group',\n    description='A framework for reproducible reinforcement learning research',\n    url='https://github.com/rlworkgroup/garage',\n    packages=find_packages(where='src'),\n    package_dir={'': 'src'},\n    scripts=['scripts/garage'],\n    python_requires='>=3.5',\n    install_requires=required,\n    extras_require=extras,\n    license='MIT',\n    long_description=readme,\n    long_description_content_type='text/markdown',\n    classifiers=[\n        'Development Status :: 4 - Beta',\n        'Intended Audience :: Developers',\n        'Intended Audience :: Education',\n        'Intended Audience :: Science/Research',\n        'License :: OSI Approved :: MIT License',\n        'Programming Language :: Python :: 3.5',\n        'Programming Language :: Python :: 3.6',\n        'Programming Language :: Python :: 3.7',\n        'Programming Language :: Python :: 3 :: Only',\n        'Topic :: Scientific/Engineering :: Artificial Intelligence',\n        'Topic :: Scientific/Engineering :: Mathematics',\n        'Topic :: Software Development :: Libraries',\n    ],\n)\n", "path": "setup.py"}, {"content": "\"\"\"Covariance Matrix Adaptation Evolution Strategy.\"\"\"\nimport cma\nfrom dowel import logger, tabular\nimport numpy as np\n\nfrom garage.np.algos import BatchPolopt\n\n\nclass CMAES(BatchPolopt):\n    \"\"\"Covariance Matrix Adaptation Evolution Strategy.\n\n    Note:\n        The CMA-ES method can hardly learn a successful policy even for\n        simple task. It is still maintained here only for consistency with\n        original rllab paper.\n\n    Args:\n        env_spec (garage.envs.EnvSpec): Environment specification.\n        policy (garage.np.policies.Policy): Action policy.\n        baseline (garage.np.baselines.Baseline): Baseline for GAE\n            (Generalized Advantage Estimation).\n        n_samples (int): Number of policies sampled in one epoch.\n        discount (float): Environment reward discount.\n        max_path_length (int): Maximum length of a single rollout.\n        sigma0 (float): Initial std for param distribution.\n\n    \"\"\"\n\n    def __init__(self,\n                 env_spec,\n                 policy,\n                 baseline,\n                 n_samples,\n                 discount=0.99,\n                 max_path_length=500,\n                 sigma0=1.):\n        super().__init__(policy, baseline, discount, max_path_length,\n                         n_samples)\n        self.env_spec = env_spec\n        self.policy = policy\n\n        self.sigma0 = sigma0\n\n    def _sample_params(self):\n        return self.es.ask(self.n_samples)\n\n    def train(self, runner):\n        \"\"\"Initialize variables and start training.\n\n        Args:\n            runner (LocalRunner): LocalRunner is passed to give algorithm\n                the access to runner.step_epochs(), which provides services\n                such as snapshotting and sampler control.\n\n        Returns:\n            The average return in last epoch cycle.\n\n        \"\"\"\n        init_mean = self.policy.get_param_values()\n        self.es = cma.CMAEvolutionStrategy(init_mean, self.sigma0)\n        self.all_params = self._sample_params()\n        self.cur_params = self.all_params[0]\n        self.policy.set_param_values(self.cur_params)\n        self.all_returns = []\n\n        return super().train(runner)\n\n    def train_once(self, itr, paths):\n        \"\"\"Perform one step of policy optimization given one batch of samples.\n\n        Args:\n            itr (int): Iteration number.\n            paths (list[dict]): A list of collected paths.\n\n        \"\"\"\n        paths = self.process_samples(itr, paths)\n\n        epoch = itr // self.n_samples\n        i_sample = itr - epoch * self.n_samples\n\n        tabular.record('Epoch', epoch)\n        tabular.record('# Sample', i_sample)\n\n        rtn = paths['average_return']\n        self.all_returns.append(paths['average_return'])\n\n        if (itr + 1) % self.n_samples == 0:\n            avg_rtns = np.array(self.all_returns)\n            self.es.tell(self.all_params, -avg_rtns)\n            self.policy.set_param_values(self.es.result()[0])\n\n            # Clear for next epoch\n            rtn = max(self.all_returns)\n            self.all_returns.clear()\n            self.all_params = self._sample_params()\n\n        self.cur_params = self.all_params[(i_sample + 1) % self.n_samples]\n        self.policy.set_param_values(self.cur_params)\n\n        logger.log(tabular)\n        return rtn\n", "path": "src/garage/np/algos/cma_es.py"}], "after_files": [{"content": "\"\"\"setuptools based setup module.\"\"\"\nfrom setuptools import find_packages\nfrom setuptools import setup\n\nTF_VERSION = '<1.15,>=1.14.0'\nGYM_VERSION = '==0.12.4'\n\n# Required dependencies\nrequired = [\n    # Please keep alphabetized\n    'akro==0.0.6',\n    'cached_property',\n    'click',\n    'cloudpickle',\n    'cma==2.7.0',\n    'dowel==0.0.2',\n    'gym[atari,box2d,classic_control]' + GYM_VERSION,\n    'joblib<0.13,>=0.12',\n    'matplotlib',\n    'numpy>=1.14.5',\n    'psutil',\n    # Pyglet 1.4.0 introduces some api change which breaks some\n    # gym environments\n    # See: https://github.com/openai/gym/issues/1588\n    'pyglet<1.4.0,>=1.3.0',\n    'pyprind',\n    'python-dateutil',\n    'torch==1.1.0',\n    'ray',\n    'scikit-image',\n    'scipy',\n    'tensorflow' + TF_VERSION,\n    'tensorflow-probability<0.8.0,>=0.7.0',  # for tensorflow 1.12\n    'torchvision==0.3.0'\n]\n\n# Dependencies for optional features\nextras = {}\n\nextras['mujoco'] = [\n    'mujoco-py<2.1,>=2.0',\n    'gym[all]' + GYM_VERSION,\n]\n\nextras['dm_control'] = [\n    # dm_control throws an error during install about not being able to\n    # find a build dependency (absl-py). Later pip executes the `install`\n    # command again and the install succeeds because absl-py has been\n    # installed. This is stupid, but harmless.\n    'dm_control @ https://api.github.com/repos/deepmind/dm_control/tarball/7a36377879c57777e5d5b4da5aae2cd2a29b607a',  # noqa: E501\n]\n\nextras['all'] = list(set(sum(extras.values(), [])))\n\n# dependencies for using gpu, not included in all\nextras['gpu'] = ['tensorflow-gpu' + TF_VERSION]\n\n# Development dependencies (*not* included in \"all\")\nextras['dev'] = [\n    # Please keep alphabetized\n    'baselines @ https://api.github.com/repos/openai/baselines/tarball/f2729693253c0ef4d4086231d36e0a4307ec1cb3',  # noqa: E501\n    'flake8',\n    'flake8-docstrings==1.3.0',\n    'flake8-import-order',\n    'pandas',\n    'pep8-naming==0.7.0',\n    'pre-commit',\n    # pydocstyle 4.0.0 breaks flake8-docstrings 1.3.0\n    # See https://gitlab.com/pycqa/flake8-docstrings/issues/36\n    'pydocstyle<4.0.0',\n    'pylint==1.9.2',\n    'pytest>=3.6',  # Required for pytest-cov on Python 3.6\n    'pytest-cov',\n    'pytest-xdist',\n    'recommonmark',\n    'sphinx',\n    'sphinx_rtd_theme',\n    'yapf==0.28.0',\n]\n\nwith open('README.md') as f:\n    readme = f.read()\n\n# Get the package version dynamically\nwith open('VERSION') as v:\n    version = v.read().strip()\n\nsetup(\n    name='garage',\n    version=version,\n    author='Reinforcement Learning Working Group',\n    description='A framework for reproducible reinforcement learning research',\n    url='https://github.com/rlworkgroup/garage',\n    packages=find_packages(where='src'),\n    package_dir={'': 'src'},\n    scripts=['scripts/garage'],\n    python_requires='>=3.5',\n    install_requires=required,\n    extras_require=extras,\n    license='MIT',\n    long_description=readme,\n    long_description_content_type='text/markdown',\n    classifiers=[\n        'Development Status :: 4 - Beta',\n        'Intended Audience :: Developers',\n        'Intended Audience :: Education',\n        'Intended Audience :: Science/Research',\n        'License :: OSI Approved :: MIT License',\n        'Programming Language :: Python :: 3.5',\n        'Programming Language :: Python :: 3.6',\n        'Programming Language :: Python :: 3.7',\n        'Programming Language :: Python :: 3 :: Only',\n        'Topic :: Scientific/Engineering :: Artificial Intelligence',\n        'Topic :: Scientific/Engineering :: Mathematics',\n        'Topic :: Software Development :: Libraries',\n    ],\n)\n", "path": "setup.py"}, {"content": "\"\"\"Covariance Matrix Adaptation Evolution Strategy.\"\"\"\nimport cma\nfrom dowel import logger, tabular\nimport numpy as np\n\nfrom garage.np.algos import BatchPolopt\n\n\nclass CMAES(BatchPolopt):\n    \"\"\"Covariance Matrix Adaptation Evolution Strategy.\n\n    Note:\n        The CMA-ES method can hardly learn a successful policy even for\n        simple task. It is still maintained here only for consistency with\n        original rllab paper.\n\n    Args:\n        env_spec (garage.envs.EnvSpec): Environment specification.\n        policy (garage.np.policies.Policy): Action policy.\n        baseline (garage.np.baselines.Baseline): Baseline for GAE\n            (Generalized Advantage Estimation).\n        n_samples (int): Number of policies sampled in one epoch.\n        discount (float): Environment reward discount.\n        max_path_length (int): Maximum length of a single rollout.\n        sigma0 (float): Initial std for param distribution.\n\n    \"\"\"\n\n    def __init__(self,\n                 env_spec,\n                 policy,\n                 baseline,\n                 n_samples,\n                 discount=0.99,\n                 max_path_length=500,\n                 sigma0=1.):\n        super().__init__(policy, baseline, discount, max_path_length,\n                         n_samples)\n        self.env_spec = env_spec\n        self.policy = policy\n\n        self.sigma0 = sigma0\n\n    def _sample_params(self):\n        return self.es.ask()\n\n    def train(self, runner):\n        \"\"\"Initialize variables and start training.\n\n        Args:\n            runner (LocalRunner): LocalRunner is passed to give algorithm\n                the access to runner.step_epochs(), which provides services\n                such as snapshotting and sampler control.\n\n        Returns:\n            The average return in last epoch cycle.\n\n        \"\"\"\n        init_mean = self.policy.get_param_values()\n        self.es = cma.CMAEvolutionStrategy(init_mean, self.sigma0,\n                                           {'popsize': self.n_samples})\n        self.all_params = self._sample_params()\n        self.cur_params = self.all_params[0]\n        self.policy.set_param_values(self.cur_params)\n        self.all_returns = []\n\n        return super().train(runner)\n\n    def train_once(self, itr, paths):\n        \"\"\"Perform one step of policy optimization given one batch of samples.\n\n        Args:\n            itr (int): Iteration number.\n            paths (list[dict]): A list of collected paths.\n\n        \"\"\"\n        paths = self.process_samples(itr, paths)\n\n        epoch = itr // self.n_samples\n        i_sample = itr - epoch * self.n_samples\n\n        tabular.record('Epoch', epoch)\n        tabular.record('# Sample', i_sample)\n\n        rtn = paths['average_return']\n        self.all_returns.append(paths['average_return'])\n\n        if (itr + 1) % self.n_samples == 0:\n            avg_rtns = np.array(self.all_returns)\n            self.es.tell(self.all_params, -avg_rtns)\n            self.policy.set_param_values(self.es.best.get()[0])\n\n            # Clear for next epoch\n            rtn = max(self.all_returns)\n            self.all_returns.clear()\n            self.all_params = self._sample_params()\n\n        self.cur_params = self.all_params[(i_sample + 1) % self.n_samples]\n        self.policy.set_param_values(self.cur_params)\n\n        logger.log(tabular)\n        return rtn\n", "path": "src/garage/np/algos/cma_es.py"}]}