Neighbouring Change in Feasibility (N∆Feas)

import math

from pyxla import ncf
from pyxla.util import load_data
from pyxla.sampling import HilbertCurveSampler
sphere_sample_all_v = {
    "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)]
}

sphere_sample_v0 = {
    "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]
}

sphere_sample_v1 = {
    "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: 8 * math.sin(20 * x)]
}

load_data(sphere_sample_all_v)
load_data(sphere_sample_v0)
load_data(sphere_sample_v1)
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.
WARNING:root:The Hilbert curve with dimension 1 is just a number line. You are sampling around points on a number line.

The constrained sphere problem has 2 constraints:

(1)\[v_0(x) = x^2 - 2 \leq 0,~\text{and}\]
(2)\[v_1(x) = 8 \cdot \sin(20 \cdot x) \leq 0.\]

NCF with both constraints:

proportions, plot = ncf(sphere_sample_all_v, title=False)
plot.figure.savefig('ncf-all-v.png', dpi=300)
../../_images/c9aa5e97ab386910e4846cbde2c64dc037e5ad35e9ba00ea8134271c156c551c.png

For the spherical constraint:

proportions, plot = ncf(sphere_sample_v0, title=False)
plot.figure.savefig('ncf-v0.png', dpi=300)
../../_images/80cdb2e88407af17ad81e3ca49cf8fe604ce5efc96a8dd77d6f457b6510e9afb.png

For the sinusodial constraint:

proportions, plot = ncf(sphere_sample_v1, title=False)
plot.figure.savefig('ncf-v1.png', dpi=300)
../../_images/19216fb9838da5ecdd3fa0533c6bc3c760f5ecfb3a7d7bec2935d218c8e2e32f.png