coco-experiment 2.7.1__tar.gz → 2.7.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (22) hide show
  1. {coco_experiment-2.7.1 → coco_experiment-2.7.2}/PKG-INFO +1 -1
  2. {coco_experiment-2.7.1 → coco_experiment-2.7.2}/src/cocoex/_version.py +1 -1
  3. {coco_experiment-2.7.1 → coco_experiment-2.7.2}/src/cocoex/coco.c +1 -1
  4. {coco_experiment-2.7.1 → coco_experiment-2.7.2}/src/cocoex/noiser.py +49 -23
  5. {coco_experiment-2.7.1 → coco_experiment-2.7.2}/.gitignore +0 -0
  6. {coco_experiment-2.7.1 → coco_experiment-2.7.2}/LICENSE +0 -0
  7. {coco_experiment-2.7.1 → coco_experiment-2.7.2}/README.md +0 -0
  8. {coco_experiment-2.7.1 → coco_experiment-2.7.2}/meson.build +0 -0
  9. {coco_experiment-2.7.1 → coco_experiment-2.7.2}/pyproject.toml +0 -0
  10. {coco_experiment-2.7.1 → coco_experiment-2.7.2}/scripts/run-doctest.py +0 -0
  11. {coco_experiment-2.7.1 → coco_experiment-2.7.2}/src/cocoex/__init__.py +0 -0
  12. {coco_experiment-2.7.1 → coco_experiment-2.7.2}/src/cocoex/bare_problem.pyx +0 -0
  13. {coco_experiment-2.7.1 → coco_experiment-2.7.2}/src/cocoex/coco.h +0 -0
  14. {coco_experiment-2.7.1 → coco_experiment-2.7.2}/src/cocoex/exceptions.py +0 -0
  15. {coco_experiment-2.7.1 → coco_experiment-2.7.2}/src/cocoex/interface.pyx +0 -0
  16. {coco_experiment-2.7.1 → coco_experiment-2.7.2}/src/cocoex/solvers.py +0 -0
  17. {coco_experiment-2.7.1 → coco_experiment-2.7.2}/src/cocoex/utilities.py +0 -0
  18. {coco_experiment-2.7.1 → coco_experiment-2.7.2}/tests/bbob2009_testcases.txt +0 -0
  19. {coco_experiment-2.7.1 → coco_experiment-2.7.2}/tests/bbob2009_testcases2.txt +0 -0
  20. {coco_experiment-2.7.1 → coco_experiment-2.7.2}/tests/test_bare_problem.py +0 -0
  21. {coco_experiment-2.7.1 → coco_experiment-2.7.2}/tests/test_regression.py +0 -0
  22. {coco_experiment-2.7.1 → coco_experiment-2.7.2}/tests/test_suite.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: coco-experiment
3
- Version: 2.7.1
3
+ Version: 2.7.2
4
4
  Summary: Benchmarking framework for all types of black-box optimization algorithms.
5
5
  Project-URL: Homepage, https://github.com/numbbo/coco-experiment
6
6
  Project-URL: Documentation, https://numbbo.github.io/coco-doc/apidocs/cocoex/
@@ -1,7 +1,7 @@
1
1
  # file generated by fabricate
2
2
  # Do not change, do not track in version control!
3
3
 
4
- __version__ = "2.7.1"
4
+ __version__ = "2.7.2"
5
5
  version = __version__
6
6
 
7
7
  if __name__ == "__main__":
@@ -31526,7 +31526,7 @@ void coco_archive_free(coco_archive_t *archive) {
31526
31526
  * don't change, don't track in version control!
31527
31527
  */
31528
31528
 
31529
- const char *coco_version = "2.7.1";
31529
+ const char *coco_version = "2.7.2";
31530
31530
  #line 1 "coco_runtime_c.c"
31531
31531
  /**
31532
31532
  * @file coco_runtime_c.c
@@ -33,12 +33,12 @@ class Noisifier:
33
33
  - adding a value (leading to bad outliers)
34
34
  - adding a small `epsilon` normally distributed noise
35
35
 
36
- The noise is frozen in x and y: whether it's applied and its
37
- sampled value depend deterministically on the input x and i.
36
+ The noise is frozen in x and y: whether the noise is applied to y and
37
+ its value depend both _deterministically_ on the input x.
38
38
 
39
- The outlier noise distribution is a Cauchy distribution multiplied by
40
- pi/2, which generates values larger than k with a probability awfully
41
- close to k**-1 when k >= 10.
39
+ The outlier noise distribution is a half Cauchy distribution multiplied
40
+ by pi/2, which generates values larger than k with a probability
41
+ awfully close to 1/k when k >= 10.
42
42
 
43
43
  Example::
44
44
 
@@ -63,23 +63,41 @@ class Noisifier:
63
63
  of the original problem.
64
64
 
65
65
  Details: the random number generators can be passed as argument and
66
- need to obey the interface of `noiser.rand`. ``rands[0]`` is assumed to
67
- be uniform in [0,1], ``rands[1]`` is used to sample the Gaussian noise,
68
- ``abs(rands[2])`` is used to sample added noise and ``abs(rands[-1])``
69
- is used to sample subtracted noise, both of which are assumed to be
70
- absolute Cauchy numbers scaled by pi/2 such that P(number > a) equals
71
- about 1/a when a >= 5.
66
+ need to obey the interface of `noiser.rand`. By default, ``rands[0]``
67
+ is uniform in [0,1] and ``rands[1]`` is Gaussian noise,
68
+ ``abs(rands[2])`` and ``abs(rands[-1])`` are used to sample added and
69
+ subtracted noise, respectively. Both are by default the same Cauchy
70
+ noise generator and the numbers scaled by pi/2 such that P(number > k)
71
+ equals about 1/k when k >= 5.
72
72
 
73
- See https://github.com/numbbo/coco-experiment/blob/main/build/python/example/example_experiment_complete.py
73
+ See also https://github.com/numbbo/coco-experiment/blob/main/build/python/example/example_experiment_complete.py
74
74
 
75
75
  """
76
76
  def __init__(self, p_add=0.2, p_subtract=0.0, p_epsilon=0, epsilon=1e-4,
77
77
  rands=(rand, randn, randc)):
78
+ """constructor with 4 optional parameters for the noise model,
79
+
80
+ `p_add`: probability for adding a positive heavy tail random value
81
+ making the solution look worse than it is.
82
+
83
+ `p_subtract`: probability for subtracting a positive heavy tail
84
+ random value making the solution look better than it is.
85
+
86
+ `p_epsilon`: probability for adding a Gaussian random value
87
+
88
+ `epsilon`: standard deviation of the Gaussian random value
89
+ """
78
90
  self._params = {k: v for k, v in locals().items() if k != 'self'}
79
91
  if sum(self._params[p] for p in ('p_subtract', 'p_add')) > 1:
80
92
  warnings.warn("p_subtract={0} + p_add={1} > 1, hence p_add is interpreted"
81
93
  " as ``1-p_subtract``"
82
94
  .format(self._params['p_subtract'], self._params['p_add']))
95
+ if p_add < 0 or p_subtract < 0 or p_epsilon < 0 or epsilon < 0:
96
+ raise ValueError("parameters cannot be negative but were {0}"
97
+ .format(self._params))
98
+ if p_epsilon > 0 and epsilon == 0:
99
+ warnings.warn("p_epsilon = {0} > 0 is not effective because epsilon = 0"
100
+ .format(p_epsilon))
83
101
 
84
102
  def noisify(self, problem):
85
103
  """wrap `problem` with frozen noise"""
@@ -113,7 +131,12 @@ class Noisifier:
113
131
  return getattr(self._problem, name)
114
132
 
115
133
  def __call__(self, x):
116
- return self._fnoise(x) + self._problem(x)
134
+ fval = self._problem(x)
135
+ try: # as quick as hasattr(fval, '__iter__')
136
+ en = enumerate(fval) # multiobjective
137
+ except TypeError:
138
+ return fval + self._fnoise(x) # single objective
139
+ return np.array([f + self._fnoise([x[0] + 1.001 * i, x[1]]) for i, f in en])
117
140
 
118
141
  def constraint(self, x):
119
142
  """return noisy constraint values"""
@@ -122,11 +145,14 @@ class Noisifier:
122
145
  constraint[i] += self._cnoise([x[i % 2], c])
123
146
  return constraint
124
147
 
125
- def rand1(self, x, fac=1):
148
+ def rand0(self, x, fac=1):
149
+ """uniform by default"""
126
150
  return self._params['rands'][0](x, fac)
127
- def rand2(self, x, fac=1):
151
+ def rand1(self, x, fac=1):
152
+ """Gaussian by default"""
128
153
  return self._params['rands'][1](x, fac)
129
- def rand3(self, x, fac=1):
154
+ def rand2(self, x, fac=1):
155
+ """Cauchy by default"""
130
156
  return self._params['rands'][2](x, fac)
131
157
 
132
158
  def _cnoise(self, x):
@@ -135,24 +161,24 @@ class Noisifier:
135
161
  def _fnoise(self, x):
136
162
  """x-dependent abs Cauchy noise with median pi/2"""
137
163
  n = 0 # no noise by default
138
- if self._params['p_epsilon'] > 0 and self.rand1(x, 3) < self._params['p_epsilon']:
139
- n = self._params['epsilon'] * self.rand2(x)
164
+ if self._params['p_epsilon'] > 0 and self.rand0(x, 3) < self._params['p_epsilon']:
165
+ n = self._params['epsilon'] * self.rand1(x)
140
166
  assert np.isfinite(n)
141
167
  if all(self._params[p] <= 0 for p in ('p_add', 'p_subtract')):
142
168
  return n
143
- r = self.rand1(x, 2) # a uniform random number
169
+ r = self.rand0(x, 2) # a uniform random number
144
170
  assert 0 <= r <= 1, r
145
171
  i = 4
146
- for s, p, irand in [(1, 'p_add', 2), (-1, 'p_subtract', -1)]:
147
- p = self._params[p]
172
+ for p, fac, irand in [(self._params['p_add'], 1.5707963267948966, 2),
173
+ (self._params['p_subtract'], -1.5707963267948966, -1)]:
148
174
  if r < p:
149
175
  assert p > 0, (r, p)
150
176
  nn = self._params['rands'][irand](x, i)
151
177
  if nn < 0:
152
178
  nn *= -1
153
- return n + s * 3.141592653589793 / 2 * nn
179
+ return n + fac * nn
154
180
  # self.randn(x, 2) / self.randn(x, 12)
155
- # was: return n + s * 2 * r / self._params[p] / self.rand1(x)
181
+ # was: return n + s * 2 * r / self._params[p] / self.rand0(x)
156
182
  r = 1 - r # prevent sampling another r
157
183
  i += 1 # not clear why we need to change i
158
184
  assert np.isfinite(n)
File without changes