Dispersion of the Best Solutions (disp_best)¶
import math
from pyxla import disp_best
from pyxla.util import load_data
from pyxla.sampling import HilbertCurveSampler
sphere_sample = {
"name": "Sphere",
"X": HilbertCurveSampler(sample_size=100, dim=1, l_bound=-5, u_bound=5, seed=42),
"F": lambda x: x**2,
"V": [lambda x: x**2 - 2, lambda x: 8 * math.sin(20 * x)]
}
deceptive_sample = {
"name": "Deceptive",
"X": HilbertCurveSampler(sample_size=100, dim=1, l_bound=0, u_bound=6),
"F": lambda x: (0.4 * x - 2) ** 2 if x > 0.625 else (10 * x - 4) ** 2 - 2,
"V": lambda x: ((0.4 * x - 2) ** 2 if x > 0.625 else (10 * x - 4) ** 2 - 2) - 1
}
load_data(sphere_sample)
load_data(deceptive_sample)
WARNING:root:The Hilbert curve with dimension 1 is just a number line. You are sampling around points on a number line.
WARNING:root:The Hilbert curve with dimension 1 is just a number line. You are sampling around points on a number line.
disp_best(sphere_sample)
INFO:root:D file has been loaded to the current sample and is saved to ./Sphere_D.csv
/home/toni/Projects/pyxla-wg/src/pyxla/__init__.py:1403: RuntimeWarning: divide by zero encountered in log
forward = lambda x: np.log(x / init_percentage) / np.log(growth_factor)
({'f0': np.float64(-2.3311144065621137),
'v0': np.float64(-1.9550832390075028),
'v1': np.float64(-2.3759920331127558),
'paretoV': np.float64(-2.0005069244278824),
'Deb': np.float64(-2.0329915369090545),
'paretoFV': np.float64(-2.3311144065621137)},
<Figure size 1500x1000 with 6 Axes>)
disp_best(deceptive_sample)
INFO:root:D file has been loaded to the current sample and is saved to ./Deceptive_D.csv
/home/toni/Projects/pyxla-wg/src/pyxla/__init__.py:1403: RuntimeWarning: divide by zero encountered in log
forward = lambda x: np.log(x / init_percentage) / np.log(growth_factor)
({'f0': np.float64(0.8798950823101237),
'v0': np.float64(0.2080819699794536),
'Deb': np.float64(0.8798950823101237),
'paretoFV': np.float64(0.8798950823101237)},
<Figure size 1500x1000 with 6 Axes>)