fcmaes 1.5.10__tar.gz → 1.5.11__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.
Potentially problematic release.
This version of fcmaes might be problematic. Click here for more details.
- {fcmaes-1.5.10/fcmaes.egg-info → fcmaes-1.5.11}/PKG-INFO +1 -1
- {fcmaes-1.5.10 → fcmaes-1.5.11}/fcmaes/__init__.py +1 -1
- {fcmaes-1.5.10 → fcmaes-1.5.11}/fcmaes/diversifier.py +2 -1
- {fcmaes-1.5.10 → fcmaes-1.5.11}/fcmaes/lib/libacmalib.dll +0 -0
- {fcmaes-1.5.10 → fcmaes-1.5.11}/fcmaes/lib/libacmalib.so +0 -0
- fcmaes-1.5.11/fcmaes/lib/libacmalibRK4.so +0 -0
- fcmaes-1.5.11/fcmaes/lib/libmazda.so +0 -0
- fcmaes-1.5.11/fcmaes/lib/libs/libacmalib.so +0 -0
- fcmaes-1.5.11/fcmaes/lib/libs/libacmalibDOPRI45.so +0 -0
- fcmaes-1.5.11/fcmaes/lib/libs/libacmalibPC233.so +0 -0
- fcmaes-1.5.11/fcmaes/lib/libs/libacmalibRK4.so +0 -0
- {fcmaes-1.5.10 → fcmaes-1.5.11}/fcmaes/mapelites.py +40 -12
- {fcmaes-1.5.10 → fcmaes-1.5.11}/fcmaes/mode.py +1 -1
- {fcmaes-1.5.10 → fcmaes-1.5.11}/fcmaes/retry.py +4 -3
- {fcmaes-1.5.10 → fcmaes-1.5.11/fcmaes.egg-info}/PKG-INFO +1 -1
- {fcmaes-1.5.10 → fcmaes-1.5.11}/fcmaes.egg-info/SOURCES.txt +7 -1
- {fcmaes-1.5.10 → fcmaes-1.5.11}/LICENSE +0 -0
- {fcmaes-1.5.10 → fcmaes-1.5.11}/MANIFEST.in +0 -0
- {fcmaes-1.5.10 → fcmaes-1.5.11}/README.md +0 -0
- {fcmaes-1.5.10 → fcmaes-1.5.11}/fcmaes/advretry.py +0 -0
- {fcmaes-1.5.10 → fcmaes-1.5.11}/fcmaes/astro.py +0 -0
- {fcmaes-1.5.10 → fcmaes-1.5.11}/fcmaes/bitecpp.py +0 -0
- {fcmaes-1.5.10 → fcmaes-1.5.11}/fcmaes/cmaes.py +0 -0
- {fcmaes-1.5.10 → fcmaes-1.5.11}/fcmaes/cmaescpp.py +0 -0
- {fcmaes-1.5.10 → fcmaes-1.5.11}/fcmaes/crfmnes.py +0 -0
- {fcmaes-1.5.10 → fcmaes-1.5.11}/fcmaes/crfmnescpp.py +0 -0
- {fcmaes-1.5.10 → fcmaes-1.5.11}/fcmaes/csmacpp.py +0 -0
- {fcmaes-1.5.10 → fcmaes-1.5.11}/fcmaes/dacpp.py +0 -0
- {fcmaes-1.5.10 → fcmaes-1.5.11}/fcmaes/de.py +0 -0
- {fcmaes-1.5.10 → fcmaes-1.5.11}/fcmaes/decpp.py +0 -0
- {fcmaes-1.5.10 → fcmaes-1.5.11}/fcmaes/evaluator.py +0 -0
- {fcmaes-1.5.10 → fcmaes-1.5.11}/fcmaes/gcldecpp.py +0 -0
- {fcmaes-1.5.10 → fcmaes-1.5.11}/fcmaes/lcldecpp.py +0 -0
- {fcmaes-1.5.10 → fcmaes-1.5.11}/fcmaes/ldecpp.py +0 -0
- {fcmaes-1.5.10 → fcmaes-1.5.11}/fcmaes/lib/libacmalib.dylib +0 -0
- {fcmaes-1.5.10 → fcmaes-1.5.11}/fcmaes/lib/libhbv.so +0 -0
- {fcmaes-1.5.10 → fcmaes-1.5.11}/fcmaes/lib/liblrgv.so +0 -0
- {fcmaes-1.5.10 → fcmaes-1.5.11}/fcmaes/lib/librw_top_trumps.dll +0 -0
- {fcmaes-1.5.10 → fcmaes-1.5.11}/fcmaes/lib/librw_top_trumps.so +0 -0
- {fcmaes-1.5.10 → fcmaes-1.5.11}/fcmaes/modecpp.py +0 -0
- {fcmaes-1.5.10 → fcmaes-1.5.11}/fcmaes/moretry.py +0 -0
- {fcmaes-1.5.10 → fcmaes-1.5.11}/fcmaes/multiretry.py +0 -0
- {fcmaes-1.5.10 → fcmaes-1.5.11}/fcmaes/optimizer.py +0 -0
- {fcmaes-1.5.10 → fcmaes-1.5.11}/fcmaes/pgpecpp.py +0 -0
- {fcmaes-1.5.10 → fcmaes-1.5.11}/fcmaes/pygmoretry.py +0 -0
- {fcmaes-1.5.10 → fcmaes-1.5.11}/fcmaes/test_cma.py +0 -0
- {fcmaes-1.5.10 → fcmaes-1.5.11}/fcmaes/testfun.py +0 -0
- {fcmaes-1.5.10 → fcmaes-1.5.11}/fcmaes.egg-info/dependency_links.txt +0 -0
- {fcmaes-1.5.10 → fcmaes-1.5.11}/fcmaes.egg-info/requires.txt +0 -0
- {fcmaes-1.5.10 → fcmaes-1.5.11}/fcmaes.egg-info/top_level.txt +0 -0
- {fcmaes-1.5.10 → fcmaes-1.5.11}/setup.cfg +0 -0
- {fcmaes-1.5.10 → fcmaes-1.5.11}/setup.py +0 -0
|
@@ -76,7 +76,8 @@ def minimize(qd_fitness: Callable[[ArrayLike], Tuple[float, np.ndarray]],
|
|
|
76
76
|
niche_num : int, optional
|
|
77
77
|
Number of niches.
|
|
78
78
|
samples_per_niche : int, optional
|
|
79
|
-
Number of samples used for niche computation.
|
|
79
|
+
Number of samples used for niche computation.
|
|
80
|
+
If samples_per_niche > 0 cvt-clustering is used, else grid-clustering is used.
|
|
80
81
|
max_evals : int, optional
|
|
81
82
|
Number of fitness evaluations.
|
|
82
83
|
workers : int, optional
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -59,6 +59,7 @@ from numpy.random import default_rng
|
|
|
59
59
|
import ctypes as ct
|
|
60
60
|
from time import perf_counter
|
|
61
61
|
import threadpoolctl
|
|
62
|
+
from numba import njit
|
|
62
63
|
|
|
63
64
|
import logging
|
|
64
65
|
from typing import Optional, Callable, Tuple, Dict
|
|
@@ -186,7 +187,8 @@ def set_KDTree(archive: Archive,
|
|
|
186
187
|
Bounds on behavior descriptors. Instance of the `scipy.Bounds` class.
|
|
187
188
|
Required if centers is None.
|
|
188
189
|
samples_per_niche : int, optional
|
|
189
|
-
Number of samples used for niche computation.
|
|
190
|
+
Number of samples used for niche computation.
|
|
191
|
+
If samples_per_niche > 0 cvt-clustering is used, else grid-clustering is used.
|
|
190
192
|
|
|
191
193
|
Returns
|
|
192
194
|
-------
|
|
@@ -299,8 +301,8 @@ def optimize_cma_(archive, fitness, bounds, rg, cma_params):
|
|
|
299
301
|
old_ys = np.sort(ys)
|
|
300
302
|
|
|
301
303
|
def update_archive(archive: Archive, xs: np.ndarray,
|
|
302
|
-
fitness: Callable[[ArrayLike], Tuple[float, np.ndarray]],
|
|
303
|
-
yds: Optional
|
|
304
|
+
fitness: Optional[Callable[[ArrayLike], Tuple[float, np.ndarray]]] = None,
|
|
305
|
+
yds: Optional[ArrayLike] = None):
|
|
304
306
|
# evaluate population, update archive and determine ranking
|
|
305
307
|
popsize = len(xs)
|
|
306
308
|
if yds is None:
|
|
@@ -309,6 +311,9 @@ def update_archive(archive: Archive, xs: np.ndarray,
|
|
|
309
311
|
niches = archive.index_of_niches(descs)
|
|
310
312
|
# real values
|
|
311
313
|
ys = np.fromiter((yd[0] for yd in yds), dtype=float)
|
|
314
|
+
|
|
315
|
+
#print(len(archive.ys), np.amax(niches), np.amin(niches))
|
|
316
|
+
|
|
312
317
|
oldys = np.fromiter((archive.get_y(niches[i]) for i in range(popsize)), dtype=float)
|
|
313
318
|
improvement = ys - oldys
|
|
314
319
|
neg = np.argwhere(improvement < 0)
|
|
@@ -325,6 +330,20 @@ def update_archive(archive: Archive, xs: np.ndarray,
|
|
|
325
330
|
improvement[empty] = min_valid + norm_ys
|
|
326
331
|
# return both improvement compared to archive elites and real fitness
|
|
327
332
|
return improvement, ys
|
|
333
|
+
|
|
334
|
+
@njit()
|
|
335
|
+
def get_grid_indices(ds, capacity, lb, ub):
|
|
336
|
+
rdim = capacity ** (1/ds.shape[1])
|
|
337
|
+
ds_norm = rdim * (ds - lb) / (ub - lb)
|
|
338
|
+
indices = np.empty(len(ds), dtype=np.int32)
|
|
339
|
+
for i, d in enumerate(ds_norm):
|
|
340
|
+
index = 0
|
|
341
|
+
f = 1
|
|
342
|
+
for di in d:
|
|
343
|
+
index += f*di
|
|
344
|
+
f *= rdim
|
|
345
|
+
indices[i] = max(0, min(capacity-1, int(index)))
|
|
346
|
+
return indices
|
|
328
347
|
|
|
329
348
|
class Archive(object):
|
|
330
349
|
"""Multi-processing map elites archive.
|
|
@@ -370,10 +389,13 @@ class Archive(object):
|
|
|
370
389
|
self.set_stat(i, 3, np.full(self.dim, -np.inf)) # max
|
|
371
390
|
|
|
372
391
|
def init_niches(self, samples_per_niche: int = 10):
|
|
373
|
-
"""Computes the niche centers using KMeans and builds the KDTree for niche determination."""
|
|
374
|
-
|
|
375
|
-
self.
|
|
376
|
-
self.
|
|
392
|
+
"""Computes the niche centers using KMeans and builds the KDTree for niche determination."""
|
|
393
|
+
# If samples_per_niche > 0 cvt-clustering is used, else grid-clustering is used.
|
|
394
|
+
self.cvt_clustering = samples_per_niche > 0
|
|
395
|
+
if self.cvt_clustering:
|
|
396
|
+
set_KDTree(self, None, self.capacity, self.qd_bounds, samples_per_niche)
|
|
397
|
+
self.cs = mp.RawArray(ct.c_double, self.capacity * self.qd_dim)
|
|
398
|
+
self.set_cs(self.centers)
|
|
377
399
|
|
|
378
400
|
def get_occupied_data(self):
|
|
379
401
|
ys = self.get_ys()
|
|
@@ -398,7 +420,7 @@ class Archive(object):
|
|
|
398
420
|
xs=self.get_xs(),
|
|
399
421
|
ds=self.get_ds(),
|
|
400
422
|
ys=self.get_ys(),
|
|
401
|
-
cs=self.get_cs(),
|
|
423
|
+
cs=self.get_cs() if self.cvt_clustering else np.empty(0),
|
|
402
424
|
stats=self.get_stats(),
|
|
403
425
|
counts=self.get_counts()
|
|
404
426
|
)
|
|
@@ -407,12 +429,14 @@ class Archive(object):
|
|
|
407
429
|
"""Loads the archive from disc."""
|
|
408
430
|
self.cs = mp.RawArray(ct.c_double, self.capacity * self.qd_dim)
|
|
409
431
|
with np.load(self.fname(name) + '.npz') as data:
|
|
432
|
+
self.cvt_clustering = len(data['cs']) > 0
|
|
410
433
|
xs = data['xs']
|
|
411
434
|
ds = data['ds']
|
|
412
435
|
self.set_xs(xs)
|
|
413
436
|
self.set_ds(ds)
|
|
414
437
|
self.set_ys(data['ys'])
|
|
415
|
-
self.
|
|
438
|
+
if self.cvt_clustering:
|
|
439
|
+
self.set_cs(data['cs'])
|
|
416
440
|
self.counts[:] = data['counts']
|
|
417
441
|
stats = data['stats']
|
|
418
442
|
if len(stats) == len(self.stats):
|
|
@@ -421,10 +445,14 @@ class Archive(object):
|
|
|
421
445
|
self.dim = xs.shape[1]
|
|
422
446
|
self.qd_dim = ds.shape[1]
|
|
423
447
|
self.capacity = xs.shape[0]
|
|
424
|
-
|
|
425
|
-
|
|
448
|
+
if self.cvt_clustering:
|
|
449
|
+
set_KDTree(self, self.get_cs(), None, None, None)
|
|
450
|
+
|
|
426
451
|
def index_of_niches(self, ds):
|
|
427
|
-
|
|
452
|
+
if hasattr(self, "kdt"): # use k-means clusters
|
|
453
|
+
return self.kdt.query(self.encode_d(ds), k=1, sort_results=False)[1].T[0]
|
|
454
|
+
else: # use grid based clustering
|
|
455
|
+
return get_grid_indices(ds, self.capacity, self.qd_bounds.lb, self.qd_bounds.ub)
|
|
428
456
|
|
|
429
457
|
def in_niche_filter(self,
|
|
430
458
|
fit: Callable[[ArrayLike], float],
|
|
@@ -154,7 +154,8 @@ def minimize_plot(name: str,
|
|
|
154
154
|
def plot(front: ArrayLike, fname: str, interp: Optional[bool] = True,
|
|
155
155
|
label: Optional[str] = r'$\chi$',
|
|
156
156
|
xlabel: Optional[str] = r'$f_1$', ylabel:Optional[str] = r'$f_2$',
|
|
157
|
-
zlabel: Optional[str] = r'$f_3$', plot3d: Optional[bool] = False
|
|
157
|
+
zlabel: Optional[str] = r'$f_3$', plot3d: Optional[bool] = False,
|
|
158
|
+
s = 1, dpi=300):
|
|
158
159
|
if len(front[0]) == 3 and plot3d:
|
|
159
160
|
plot3(front, fname, label, xlabel, ylabel, zlabel)
|
|
160
161
|
return
|
|
@@ -181,12 +182,12 @@ def plot(front: ArrayLike, fname: str, interp: Optional[bool] = True,
|
|
|
181
182
|
tck = interpolate.InterpolatedUnivariateSpline(x,y,k=1)
|
|
182
183
|
x = np.linspace(min(x),max(x),1000)
|
|
183
184
|
y = [tck(xi) for xi in x]
|
|
184
|
-
ax.scatter(x, y, label=label, s=
|
|
185
|
+
ax.scatter(x, y, label=label, s=s)
|
|
185
186
|
ax.grid()
|
|
186
187
|
ax.set_xlabel(xlabel)
|
|
187
188
|
ax.set_ylabel(ylabel)
|
|
188
189
|
ax.legend()
|
|
189
|
-
fig.savefig(fname, dpi=
|
|
190
|
+
fig.savefig(fname, dpi=dpi)
|
|
190
191
|
pl.close('all')
|
|
191
192
|
|
|
192
193
|
def plot3(front: ArrayLike, fname: str, label: Optional[str] =r'$\chi$',
|
|
@@ -38,7 +38,13 @@ fcmaes.egg-info/top_level.txt
|
|
|
38
38
|
fcmaes/lib/libacmalib.dll
|
|
39
39
|
fcmaes/lib/libacmalib.dylib
|
|
40
40
|
fcmaes/lib/libacmalib.so
|
|
41
|
+
fcmaes/lib/libacmalibRK4.so
|
|
41
42
|
fcmaes/lib/libhbv.so
|
|
42
43
|
fcmaes/lib/liblrgv.so
|
|
44
|
+
fcmaes/lib/libmazda.so
|
|
43
45
|
fcmaes/lib/librw_top_trumps.dll
|
|
44
|
-
fcmaes/lib/librw_top_trumps.so
|
|
46
|
+
fcmaes/lib/librw_top_trumps.so
|
|
47
|
+
fcmaes/lib/libs/libacmalib.so
|
|
48
|
+
fcmaes/lib/libs/libacmalibDOPRI45.so
|
|
49
|
+
fcmaes/lib/libs/libacmalibPC233.so
|
|
50
|
+
fcmaes/lib/libs/libacmalibRK4.so
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|