-
Couldn't load subscription status.
- Fork 155
Description
The goal of moocore is not to replace jMetalPy but simply to provide high-quality basic building blocks to make building such libraries easier.
Even with its current non-state-of-the-art algorithms (and implementing the state-of-the-art ones is a goal of the project), moocore is order of magnitudes faster than most multi-objective python packages, not only in hypervolume but in all indicators.
If you find any benchmarks were moocore is slower or produces the wrong output, please let me know.
Feedback on how to make moocore easier to use in jMetalPy would be welcome.
Benchmark source code
The following benchmark compares the computation of the hypervolume in moocore and in jMetalPy:
import numpy as np
import moocore
from jmetal.core.quality_indicator import HyperVolume as jmetal_HV
import timeit
timeit.template = """
def inner(_it, _timer{init}):
{setup}
_t0 = _timer()
for _i in _it:
retval = {stmt}
_t1 = _timer()
return _t1 - _t0, retval
"""
def read_data(name):
files = {"DTLZLinearShape.3d": "~/work/perfassess/moocore/testsuite/data/DTLZLinearShape.3d.front.1000pts.10",
"DTLZLinearShape.4d" : "~/work/perfassess/moocore/testsuite/data/DTLZLinearShape.4d.front.1000pts.10"}
x = moocore.read_datasets(files[name])[:, :-1]
x = moocore.filter_dominated(x)
return x
name = "DTLZLinearShape.4d"
x = read_data(name)
ref = np.ones(x.shape[1])
jmetal_hv = jmetal_HV(ref)
moocore_hv = moocore.Hypervolume(ref = ref)
n = np.arange(500, 3000 + 1, 500)
jmetal_values = []
moocore_values = []
jmetal_times = []
moocore_times = []
for maxrow in n:
z = x[:maxrow, :]
duration, values = timeit.timeit('jmetal_hv.compute(z)', globals=globals(), number = 2)
jmetal_times += [duration]
jmetal_values += [values]
duration, values = timeit.timeit('moocore_hv(z)', globals=globals(), number = 2)
moocore_times += [duration]
moocore_values += [values]
jmetal_values = np.array(jmetal_values)
moocore_values = np.array(moocore_values)
assert np.allclose(jmetal_values, moocore_values)
jmetal_times = np.array(jmetal_times)
moocore_times = np.array(moocore_times)
import pandas as pd
import matplotlib.pyplot as plt
cpu = "Intel i5-6200U 2.30GHz"
df = pd.DataFrame(dict(n = n, jMetalPy = jmetal_times, moocore = moocore_times)).set_index('n')
df.plot(grid=True, ylabel='CPU time (seconds)', title = f'HV computation for {name} ({cpu})')
plt.savefig(f'jmetal-{name}-time.pdf')
plt.show()You can find the benchmark files here: https://github.com/multi-objective/testsuite or use your own.

