Skip to content

SGP: numpy.linalg.LinAlgError: 58-th leading minor of the array is not positive definite #723

@NAThompson

Description

@NAThompson

If the number of inducing inputs in SGP is >=~58, we get the following exception from numpy:

numpy.linalg.LinAlgError: 58-th leading minor of the array is not positive definite

To reproduce run:

#!/usr/bin/env python3
import random
from math import sin
from math import pi as π
import numpy as np
import random
from smt.surrogate_models import SGP

np.random.seed(41)
random.seed(41)

def generate_sin_volume(samples: int):
    abscissas = np.ndarray(shape=(samples, 3))
    ordinates = np.ndarray(shape=samples)
    for i in range(samples):
        x = random.uniform(-0.5, 0.5)
        y = random.uniform(-1, 1)
        z = random.uniform(-2, 2)
        abscissas[i] = np.array([x, y, z])
        ordinates[i] = sin(2 * π * x) * sin(π * y) * sin(π * z / 2)

    return abscissas, ordinates


def test_sgp_principle_minor():
    # samples = 57 # works
    samples = 58 
    xs, ys = generate_sin_volume(samples)
    sgp = SGP(
        print_global=False,
        inducing_method="kmeans",
        n_inducing=samples,
        random_state=41,
    )
    sgp.set_training_values(xs, ys)
    sgp.train()

    x = np.array([np.array([0.3, -0.4, 0.6])])
    y1 = sgp.predict_values(x)[0][0]


if __name__ == "__main__":
    test_sgp_principle_minor()

Now, arguably the error is here:

capi_return is NULL
Call-back cb_calcfc_in__cobyla__user__routines failed.
Optimization failed. Try increasing the 'nugget' above its current value of 2.220446049250313e-13.

But this error is buried in the subsequent error stack, which I believe is simply continuing with garbage data.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions