Neighbouring Solutions’ Violation Values Correlation (NVC)

import math

from pyxla import nvc
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)]
}

load_data(sphere_sample)
WARNING:root:The Hilbert curve with dimension 1 is just a number line. You are sampling around points on a number line.
nvc(sphere_sample)
({'NVC_for_v0': '0.9944', 'NVC_for_v1': '0.0360'},
 <Figure size 1000x500 with 2 Axes>)
../../_images/ebb3de5dd2cb360be970e0065a8c4c8bc1b5560f0769720fd114c6d10315fc74.png