Limits and trust

A surrogate is limited by its data: its domain, its error, and confirmation by the solver.

Outcome: Name the main limits of a surrogate and the check for each; flag inputs that are outside or far from the training data; state what to report with every prediction.

Builds on Testing on unseen designs

|ΔCp| 0≥ 0.3
Figure 7-1. Error |ΔCp| of the site’s surrogate against the solver at α 12°, sweep 40°, outside the training range: the surrogate answers just as confidently, and is wrong.

A surrogate returns a number quickly and, unless it carries its own uncertainty estimate, it returns one with the same confidence where it has no data behind it. Outside the training data, error usually grows, often without warning, as Figure 7-1 shows.

Inside or outside the data

The first check is the box: whether every input is within the range of the training runs.

The second check is the distance to the nearest training run, which Example 4-8 already printed for the 12 test runs (Table 4-1: 0.39 for the run at 4°, 28°, 1.77 for the one at 12°, 40°). A distance becomes a flag only against a threshold, the spacing of the training runs themselves. Example 7-5 adds that threshold and the box check for the same two runs. It scales each input to [0,1][0, 1] over its training range rather than standardising it, so that the threshold reads as a fraction of the box; the two distances therefore differ from those of Table 4-1.

Example 7-5. Flag designs far from the training data, with NumPy and SciPy
import numpy as np
from scipy.spatial import KDTree
from aircraft import load_runs, split_runs

d = load_runs()
train, val, test, in_box = split_runs(d)
D = np.stack([d["alpha"], d["sweep"]], axis=1)  # (56, 2)
X_train = D[train]                # the 36 training designs

lo, hi = X_train.min(0), X_train.max(0)
def scale(X):
    return (X - lo) / (hi - lo)       # each input to [0, 1]1
tree = KDTree(scale(X_train))
# Each run's distance to its nearest other run; the
# largest of these measures the spacing of the runs.
d_train = tree.query(scale(X_train), k=2)[0][:, 1]2
limit = d_train.max()3

def check(x):
    inside = bool(np.all((x >= lo) & (x <= hi)))
    dist = float(tree.query(scale(x))[0])
    return inside, round(dist, 3), bool(dist <= limit)4

print(round(limit, 3))
# Two of the test runs: 4 deg, 28 deg and 12 deg, 40 deg.
print(check(np.array([4.0, 28.0])))
print(check(np.array([12.0, 40.0])))
  1. The scaling uses the training runs’ own minimum and maximum, so a distance of 1 spans a whole input range and neither input dominates.
  2. k=2 because each training run’s nearest neighbour is itself, at distance 0; column 1 is the nearest other run.
  3. The threshold: the largest gap between a training run and its nearest neighbour.
  4. Each check returns: inside the box, distance to the nearest run, and whether that distance is within the threshold.

Example 7-5 prints a threshold of 0.309, then (True, 0.118, True) for the test run at 4°, 28° and (False, 0.523, False) for the one at 12°, 40°. The first sits inside the box and closer to a training run than the widest gap between training runs; the second fails both checks. The threshold is set by the single most isolated training run, so it is lenient: the median gap is 0.066.

For field models with many inputs (a whole geometry), the same test is done on a compact description of the input: a few shape parameters, the coefficients of a POD (proper orthogonal decomposition) of the geometry, or the model's own latent vector. Far from every training point in that space suggests far from the data. The reverse can fail: a network can map an input far from the data close to its training points in that space, which is called feature collapse (van Amersfoort et al. 2020).

Other limits

  • Data cost and dimension. The high-fidelity simulations usually dominate the budget, and the number of runs needed to cover a space evenly grows exponentially with the number of parameters: the curse of dimensionality. For smooth responses that depend on a few parameters, a rule of thumb for a first Gaussian-process fit is about ten runs per parameter (Loeppky, Sacks and Welch 2009); rough or many-parameter responses usually need more.
  • Regime changes. Separation, transition, shocks, buckling or contact can switch on between two training runs, and a smooth surrogate tends to blur across the switch. Such regions need dense sampling and their own tests.
  • More than one solution. A deterministic surrogate returns one field per input, which assumes that each posed problem has one solution. Some symmetric problems have several stable solutions, none of them symmetric, which is called symmetry breaking: the wake behind a symmetric blunt body can switch between two mirror-image states (Grandemange et al. 2013). For a mirror-symmetric input, an exactly equivariant model must return a mirror-symmetric field, which is neither state (symmetries). Training data averaged over a time long enough to visit both states hide this.
  • A symmetry is not generalisation. A model exact under rotation or a change of units still meets a new kind of problem as new data (train, validation and test).
  • A changed setup. A new solver version, turbulence model or meshing template can make new runs a different dataset. The surrogate should be checked against them before they are mixed in.
  • Interpretability. A neural surrogate is largely a black box; physics constraints, physical checks and calibrated uncertainty make it easier to audit.

Reporting and confirmation

A prediction should be reported with the training range, the error on held-out designs (and on tests where possible), whether the input is inside the data, and an uncertainty estimate if there is one, checked as in the next lesson.

The selected design is then confirmed with high-fidelity simulation and, where it matters, testing.

Certification sets its own evidence

For transport aircraft structure, for example, analysis counts only where experience has shown the method to be reliable, and otherwise tests are required (14 CFR 25.307). A surrogate used as evidence would need its own credibility case, in proportion to the risk: how far the decision relies on it, and how bad a wrong decision would be (ASME V&V 40, written for medical devices).

Check yourself

  1. 1A new design is inside the training range of each of its 8 parameters. Is it inside the data?
  2. 2For a model that takes a whole geometry as input, where should the nearest-run check be applied?
  3. 3A surrogate prediction for a new design reads “CD = 0.312”. What should come with that number?
The wake of a symmetric blunt body switches between two mirror-image states. Why can an exactly equivariant, deterministic model not predict one of them?

For a mirror-symmetric input it must return a mirror-symmetric field, and each wake state is asymmetric. The problem has more than one stable solution, while a deterministic model returns one field per input. Time-averaged data hide this.

Exercises

  1. Exercise 7-4. Apply the distance check of this lesson to all 12 test runs, and compare each run’s distance to the nearest training run with its relative L2 error under the project’s neural field (field.pt). Does the distance rank the errors? Use the Spearman rank correlation of Measuring error.

    Answer

    Largely. With the project’s saved field, the Spearman correlation between distance and the neural field’s relative L2 error is about 0.93. The three closest test runs (distances 0.07 to 0.12) have errors of 6 to 7 %, the farthest (12°, 40°, at 0.52) about 30 %. The ranking is not exact: the run at 4°, 16° is farther than the one at −4°, 28° but has the smaller error. For the POD + GP baseline the correlation is about 0.83.

Go further