Correlation of Values (corr)

Sphere Problem

import math

from pyxla import load_data, corr
from pyxla.util import load_sample
from pyxla.sampling import HilbertCurveSampler
from matplotlib import rc_file
rc_file('../../../../src/.matplotlibrc')
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)
corrs, plot = corr(sphere_sample)
corrs

NK Problem

The corr feature is very useful for multiobjective problems.

An NK instance with 3 objectives and 2 constraints is exemplified below:

# change directory to access samples
%cd ../../..
nk = load_sample('nk_n14_k2_id5_F3_V2')
nk['V'] = None
nk['numV'] = 0
corrs, plot = corr(nk, title=False)
plot.savefig('corr-nk-f3.pdf', bbox_inches='tight')
corr