SEAMsurrogates package

Submodules

surmod.bayesian_optimization module

class surmod.bayesian_optimization.BayesianOptimizer(objective_function: str, x_init: ndarray, y_init: ndarray, kernel: str = 'matern', isotropic: bool = False, acquisition_function: str = 'EI', n_acquire: int = 10, seed: int = 42, noise_bounds: Tuple[float, float] | None = None, fixed_noise: float | None = None, init_design: str = 'random', init_design_kwargs: dict | None = None, **acquisition_kwargs)

Bases: object

bayes_opt(df: DataFrame | None = None, n_init: int = 10) Tuple[ndarray, ndarray, ndarray]
evaluate_objective(x_next: ndarray) ndarray
gp_model_fit() GPSurrogate
propose_location(num_restarts: int = 30, raw_samples: int = 1000) ndarray
score_candidates(x_candidates: ndarray) ndarray
step(df: DataFrame | None = None, remaining_indices: set[int] | None = None, x_grid: ndarray | None = None, grid_shape: tuple[int, int] | None = None, return_diagnostics: bool = False) dict
surmod.bayesian_optimization.get_synth_global_optima(objective_function: str) Tuple[List[List[float]], float]
surmod.bayesian_optimization.plot_acquisition_comparison(max_output_EI: ndarray, max_output_PI: ndarray, max_output_UCB: ndarray, max_output_PV: ndarray, max_output_random: ndarray, kernel: str = 'rbf', n_iter: int = 10, n_init: int = 5, objective_data: str = '___ data', beta: float = 2.0) None
surmod.bayesian_optimization.sample_data(objective_function: str, bounds_low: float | Sequence[float] | ndarray, bounds_high: float | Sequence[float] | ndarray, n_initial: int, input_size: int = 2, init_design: str = 'random', seed: int | None = None, **design_kwargs) Tuple[ndarray, ndarray]

Generate input and output samples from the specified synthetic objective.

Parameters:
  • objective_function – Name of the objective function.

  • bounds_low – Lower bounds.

  • bounds_high – Upper bounds.

  • n_initial – Number of initial points.

  • input_size – Input dimension.

  • init_design – One of ‘random’, ‘lhd’, ‘maximin_lhd’.

  • seed – Random seed.

  • design_kwargs – Extra kwargs forwarded to generate_initial_design().

Returns:

x_sample: shape (n_initial, input_size) y_sample: shape (n_initial,)

Return type:

Tuple of

surmod.bayesian_optimization.sample_parabola(n_initial: int, bounds_low: float | Sequence[float] | ndarray, bounds_high: float | Sequence[float] | ndarray, input_size: int, radius: float = 7) ndarray
surmod.bayesian_optimization.select_initial_dataset_indices(x: ndarray, n_init: int, method: str = 'random', seed: int = 42, **design_kwargs) ndarray

Select initial dataset rows.

For method=’random’, sample rows uniformly without replacement. For method=’lhd’ or ‘maximin_lhd’, generate a space-filling design in normalized [0,1]^d space and map each design point to the nearest available dataset row, enforcing uniqueness.

Parameters:
  • x – Dataset inputs, assumed already normalized to [0,1], shape (n, d)

  • n_init – Number of initial points

  • method – ‘random’, ‘lhd’, or ‘maximin_lhd’

  • seed – Random seed

  • design_kwargs – Extra arguments forwarded to generate_initial_design()

Returns:

Array of selected row indices, shape (n_init,)

surmod.data_processing module

General data loading and splitting utilities for JAG and borehole datasets.

JAG:
  • 5 inputs, 1 output

  • default path: “../../data/JAG_10k.csv”

Borehole:
  • 8 inputs, 1 output

  • default path: “../../data/borehole_10k.csv”

surmod.data_processing.load_and_split(dataset: str = 'JAG', path_to_csv: str | None = None, n_samples: int = 10000, random_rows: bool = True, seed: int = 42, LHD: bool = False, n_train: int = 100) Tuple[ndarray, ndarray, ndarray, ndarray]

Convenience function: load dataset, then split into train and test.

Parameters:
  • dataset – “JAG” or “borehole”.

  • path_to_csv – Optional explicit path, overrides default.

  • n_samples – Number of samples to load from CSV.

  • random_rows – Randomly choose rows or take first n_samples.

  • seed – Random seed used for row sampling and splitting.

  • LHD – Use LHD based train selection if True.

  • n_train – Number of training samples.

Returns:

x_train, x_test, y_train, y_test

surmod.data_processing.load_data(dataset: str = 'JAG', n_samples: int = 10000, random: bool = True, path_to_csv: str | None = None, seed: int | None = None) DataFrame

Load a subset of a dataset from CSV.

Assumes:
  • CSV has exactly n_inputs + n_outputs columns

  • No header, or any header will be ignored and replaced

Parameters:
  • dataset – Which dataset to load, “JAG” or “borehole”.

  • path_to_csv – Optional explicit path; if None, use default from config.

  • n_samples – Number of rows to load.

  • random – If True, select rows randomly; else select first n_samples rows.

  • seed – Random seed for reproducibility (used if random is True).

Returns:

For JAG:

columns: [x0, x1, x2, x3, x4, y]

For borehole:

columns: [rw, r, Tu, Hu, Tl, Hl, L, Kw, y]

Return type:

pd.DataFrame

surmod.data_processing.split_data(df: DataFrame, LHD: bool = False, n_train: int = 100, seed: int = 42) Tuple[ndarray, ndarray, ndarray, ndarray]

Split data into train and test sets using either Latin Hypercube Design (LHD) or random split.

Parameters:
  • df – Input DataFrame where the last column is the output.

  • LHD – If True, use Latin Hypercube Design for selecting training samples; if False, use random split.

  • n_train – Number of training samples to select.

  • seed – Random seed for reproducibility.

Returns:

Training features array. x_test: Testing features array. y_train: Training labels array (column vector). y_test: Testing labels array (column vector).

Return type:

x_train

Raises:

ValueError – If n_train is greater than the total number of samples in df.

surmod.gaussian_process_regression module

class surmod.gpytorch_gaussian_process.GPSurrogate(x_train: ndarray[tuple[int, ...], dtype[_ScalarType_co]], y_train: ndarray[tuple[int, ...], dtype[_ScalarType_co]], x_test: ndarray[tuple[int, ...], dtype[_ScalarType_co]] | None = None, y_test: ndarray[tuple[int, ...], dtype[_ScalarType_co]] | None = None, kernel: str = 'rbf', isotropic: bool = False, scale_inputs: bool = True, scale_outputs: bool = True, lengthscale_bounds: tuple[float, float] = (0.01, 10.0), noise_bounds: tuple[float, float] = (1e-08, 0.1), outputscale_bounds: tuple[float, float] = (0.001, 1000.0), optimization_restarts: int = 3, fixed_noise: float | None = None)

Bases: object

Gaussian Process surrogate model using BoTorch SingleTaskGP.

This class stores training and optional test data, optionally applies input normalization and output standardization, fits a GP model with BoTorch, and provides prediction, evaluation, and plotting utilities.

Parameters:
  • x_train – Training input array of shape (n_train, n_features).

  • y_train – Training target array of shape (n_train,) or (n_train, 1).

  • x_test – Optional test input array of shape (n_test, n_features).

  • y_test – Optional test target array of shape (n_test,) or (n_test, 1).

  • kernel – Kernel type, one of “rbf”, “matern”, or “periodic”.

  • isotropic – If True, use a shared lengthscale. If False, use ARD.

  • scale_inputs – Whether to normalize inputs to the unit cube.

  • scale_outputs – Whether to standardize outputs.

  • lengthscale_bounds – Bounds on the lengthscale parameter(s), current option is for inputs scaled to [0,1]. Defaults to [1e-2,10]

  • noise_bounds – Bounds on the nugget parameter, default is assuming output scaled to mean 0, variance 1. Defaults to [1e-16,1e-1]

static compute_max_error(output: ndarray[tuple[int, ...], dtype[_ScalarType_co]], target: ndarray[tuple[int, ...], dtype[_ScalarType_co]], inputs: ndarray[tuple[int, ...], dtype[_ScalarType_co]]) Tuple[float, ndarray[tuple[int, ...], dtype[_ScalarType_co]]]

Compute the maximum absolute error and the corresponding input.

Parameters:
  • output – Predicted values.

  • target – True values.

  • inputs – Inputs corresponding to predictions.

Returns:

Maximum absolute error and associated input row.

evaluate(include_nugget: bool = False) dict[str, Any]

Evaluate the GP model on the stored test dataset.

Computes MSE, RMSE, and 95 percent interval coverage.

Returns:

Dictionary of evaluation metrics and predictions.

Raises:

ValueError – If test data is unavailable.

fit() None

Fit the GP model by maximizing the exact marginal log likelihood.

Returns:

None

get_fitted_kernel_label() str

Helper function for plotting

Returns:

Summary of fitted model parameters

Return type:

str

get_fitted_parameters() dict[str, Any]

Return fitted GP hyperparameters in a simple dictionary.

plot_gp_mean_prediction(test_mse: float, objective_data_name: str, scale_x: bool = False, normalize_y: bool = False) None

Plot GP mean surface in a style closely matching the legacy sklearn version. Uses learned likelihood noise as the alpha analog.

plot_gp_std_dev_prediction(test_mse: float, objective_data_name: str, scale_x: bool = False, normalize_y: bool = False) None

Plot GP predictive standard deviation in a style closely matching the legacy sklearn version.

plot_test_predictions(objective_data_name: str = 'GP Test Predictions', scale_x: bool = False, normalize_y: bool = False) None

Plot observed versus predicted test values with 95 percent intervals. Styled to closely match the legacy sklearn plotting function.

posterior_gradient(x: ndarray) ndarray

Compute the gradient of the posterior mean with respect to the inputs.

Parameters:

x – Input array of shape (n_points, n_features).

Returns:

Gradient of the posterior mean with respect to x, as a NumPy array of shape (n_points, n_features).

predict(x: ndarray[tuple[int, ...], dtype[_ScalarType_co]] | Tensor | None = None, include_nugget: bool = False) Tuple[ndarray[tuple[int, ...], dtype[_ScalarType_co]], ndarray[tuple[int, ...], dtype[_ScalarType_co]]]

Predict posterior mean and standard deviation for input points.

sample_posterior(x: ndarray | None = None, n_samples: int = 1) ndarray

Draw samples from the GP posterior at the given input points.

Parameters:
  • x – Optional prediction inputs of shape (n_points, n_features). If not provided, stored test inputs are used.

  • n_samples – Number of posterior samples to draw.

Returns:

Posterior samples as a NumPy array of shape (n_samples, n_points).

surmod.gpytorch_gaussian_process.fit_gpytorch_mll_multistart(build_model_and_mll, n_restarts: int = 10, seed: int | None = None)
surmod.gpytorch_gaussian_process.load_test_function(objective_function: str)

Loads a test function instance for simulating data based on the given objective function name.

Parameters:

objective_function (str) – The name of the objective function to load. Supported values are “Parabola”, “Ackley”, “Griewank”, “Branin”, and “HolderTable”.

Returns:

An instance of the requested test function, initialized with standard parameters.

Return type:

object

Raises:

ValueError – If the specified objective function name is not recognized.

surmod.neural_network module

Functions for neural network surrogates.

class surmod.neural_network.NeuralNet(input_size: int, hidden_sizes: List[int], output_size: int, initialize_weights_normal: bool)

Bases: Module

A customizable feedforward neural network for regression tasks.

forward(x: Tensor) Tensor

Forward pass through the neural network.

Parameters:

x (torch.Tensor) – Input tensor.

Returns:

Output tensor after passing through the network.

Return type:

torch.Tensor

surmod.neural_network.load_test_function(objective_function: str) SyntheticTestFunction

Load a test function instance for simulating data.

Parameters:

objective_function (str) – Name of the test function to load. Must be one of: “Ackley”, “SixHumpCamel”, “Griewank”.

Returns:

An instance of the requested BoTorch synthetic test function.

Return type:

SyntheticTestFunction

Raises:

ValueError – If the objective_function name is not recognized.

surmod.neural_network.plot_losses(train_losses: List[float], test_losses: List[float], objective_data: str = '___ data') None

Plot and save the training and testing loss curves across epochs.

Parameters:
  • train_losses (List[float]) – List of training loss values (MSE) for each epoch.

  • test_losses (List[float]) – List of testing loss values (MSE) for each epoch.

  • objective_data (str, optional) – Name or description of the objective function or dataset. Used in the plot title and filename. Defaults to “___ data”.

surmod.neural_network.plot_losses_multiplot(train_losses_grid: List[List[List[float]]], test_losses_grid: List[List[List[float]]], learning_rates: List[float], hid_dims: List[int], axs: Sequence[Sequence[Axes]], objective_data: str = '___ data') None

Plots training and test losses for multiple runs on a grid of subplots.

Each subplot corresponds to a specific combination of hidden dimension and learning rate, displaying the training and test loss curves over epochs. The final test loss (RMSE) is shown in each subplot title. The resulting multiplot figure is saved to ‘plots’ directory with a filename that includes the objective data and a timestamp.

Parameters:
  • train_losses_grid (Sequence[Sequence[List[float]]]) – 2D grid where each element is a list of training losses per epoch for a specific (hidden_dim, learning_rate) pair.

  • test_losses_grid (Sequence[Sequence[List[float]]]) – 2D grid where each element is a list of test losses per epoch for a specific (hidden_dim, learning_rate) pair.

  • learning_rates (List[float]) – List of learning rates corresponding to the columns of the subplot grid.

  • hid_dims (List[int]) – List of hidden dimensions corresponding to the rows of the subplot grid.

  • axs (Sequence[Sequence[matplotlib.axes.Axes]]) – 2D grid of matplotlib Axes objects for plotting.

  • objective_data (str, optional) – String identifier for the data/objective function, used in the saved filename.

surmod.neural_network.plot_losses_verbose(train_losses: List[float], test_losses: List[float], learning_rate: float, batch_size: int, hidden_sizes: List[int], normalize_x: bool, scale_x: bool, normalize_y: bool, scale_y: bool, train_data_size: int, test_data_size: int, objective_data: str = '___ data') None

Plot and save training and testing loss curves across epochs, with hyperparameter values in the plot title.

Parameters:
  • train_losses (List[float]) – List of training loss values (MSE) for each epoch.

  • test_losses (List[float]) – List of testing loss values (MSE) for each epoch.

  • learning_rate (float) – Learning rate used during training.

  • batch_size (int) – Batch size used during training.

  • hidden_sizes (List[int]) – List of hidden layer sizes in the model.

  • normalize_x (bool) – Whether input features (x) were normalized.

  • scale_x (bool) – Whether input features (x) were scaled.

  • normalize_y (bool) – Whether target values (y) were normalized.

  • scale_y (bool) – Whether target values (y) were scaled.

  • train_data_size (int) – Number of samples in the training set.

  • test_data_size (int) – Number of samples in the testing set.

  • objective_data (str, optional) – Name or description of the objective function or dataset. Used in the plot title and filename. Defaults to “___ data”.

surmod.neural_network.plot_predictions(y_test: Tensor, predictions: Tensor, final_test_mse: float, objective_data: str = '___ data') None

Plots the actual test values against the predicted values.

This function creates a parity plot comparing the true test values to the model’s predictions. A reference line for perfect prediction is included. The final test loss (RMSE) is displayed in the plot title. The plot is saved in the ‘plots’ directory, with a filename that includes the objective data and a timestamp.

Parameters:
  • y_test (torch.Tensor) – The true target values for the test set.

  • predictions (torch.Tensor) – The predicted values from the model for the test set.

  • final_test_mse (float) – The final mean squared error on the test set.

  • objective_data (str, optional) – Identifier for the data/objective, used in the filename. Defaults to “___ data”.

surmod.neural_network.train_neural_net(x_train: Tensor, y_train: Tensor, x_test: Tensor, y_test: Tensor, hidden_sizes: List[int], num_epochs: int, learning_rate: float, batch_size: int, seed: int, initialize_weights_normal: bool) Tuple[Module, List[float], List[float]]

Train a feedforward neural network and evaluate its performance.

Parameters:
  • x_train (torch.Tensor) – Training input features of shape (n_samples, n_features).

  • y_train (torch.Tensor) – Training target values of shape (n_samples,) or (n_samples, 1).

  • x_test (torch.Tensor) – Test input features of shape (n_test_samples, n_features).

  • y_test (torch.Tensor) – Test target values of shape (n_test_samples,) or (n_test_samples, 1).

  • hidden_sizes (List[int]) – List specifying the number of units in each hidden layer.

  • num_epochs (int) – Number of epochs to train the network.

  • learning_rate (float) – Learning rate for the optimizer.

  • batch_size (int) – Number of samples per training batch.

  • seed (int) – Random seed for reproducibility.

  • initialize_weights_normal (bool) – If True, initialize weights with a normal distribution.

Returns:

Trained neural network model, list of training losses per epoch, and list of test losses per epoch.

Return type:

Tuple[nn.Module, List[float], List[float]]

surmod.sensitivity_analysis module

Utility functions for simulating, evaluating, and visualizing surrogate modeling sensitivity analysis experiments using benchmark engineering test problems.

surmod.sensitivity_analysis.load_test_settings(objective_function: str) Tuple[int, Callable[[ndarray, float, float, float], ndarray]]

Load the test function and its input dimension for simulating data.

Parameters:

objective_function (str) – Name of the objective function to load. Must be one of ‘parabola’, ‘otlcircuit’, ‘wingweight’, or ‘piston’.

Returns:

A tuple containing:
  • out_dim (int): The number of input dimensions for the selected

    test function.

  • test_function (Callable): The test function to simulate data

    from.

Return type:

Tuple[int, Callable[[np.ndarray, float, float, float], np.ndarray]]

Raises:

ValueError – If the provided objective_function is not recognized.

surmod.sensitivity_analysis.plot_test_predictions(x_test, y_test, gp_model, objective_function: str) None

Plot test set predictions vs. ground truth for a GP model.

Compatible with GPSurrogate.predict(), which returns (mean, std) and does not accept return_std=…

surmod.sensitivity_analysis.simulate_data(objective_function: str, num_train: int, num_test: int, b1: float, b2: float, b12: float) Tuple[ndarray, ndarray, ndarray, ndarray]

Simulate training and testing data from a selected test function.

Parameters:
  • objective_function (str) – Name of the objective function to use. Must be one of ‘parabola’, ‘otlcircuit’, ‘wingweight’, or ‘piston’.

  • num_train (int) – Number of training samples to generate.

  • num_test (int) – Number of testing samples to generate.

  • b1 (float) – First coefficient parameter for the test function.

  • b2 (float) – Second coefficient parameter for the test function.

  • b12 (float) – Interaction coefficient parameter for the test function.

Returns:

  • x_train (np.ndarray): Training input data of shape (num_train, input_dim).

  • x_test (np.ndarray): Testing input data of shape (num_test, input_dim).

  • y_train (np.ndarray): Training output data.

  • y_test (np.ndarray): Testing output data.

Return type:

Tuple[np.ndarray, np.ndarray, np.ndarray, np.ndarray]

surmod.sensitivity_analysis.sobol_plot(S1: Sequence[float], ST: Sequence[float], variables: List[str], S1_conf: Sequence[float], ST_conf: Sequence[float], objective_function: str)

Plots first and total order Sobol sensitivity indices with confidence intervals and saves the figure.

Parameters:
  • S1 (Sequence[float]) – First order sensitivity indices for each variable.

  • ST (Sequence[float]) – Total order sensitivity indices for each variable.

  • variables (List[str]) – List of variable names.

  • S1_conf (Sequence[float]) – Confidence intervals for first order indices.

  • ST_conf (Sequence[float]) – Confidence intervals for total order indices.

  • objective_function (str) – Name of the objective function, used in the saved plot filename.

Returns:

None, for visualization purposes only.

surmod.space_fill_design module

surmod.space_fill_design.generate_initial_design(bounds_low, bounds_high, n_samples, method='random', seed=None, **kwargs)
surmod.space_fill_design.latin_hypercube_design(bounds_low, bounds_high, n_samples, seed=None)
surmod.space_fill_design.maximin_sa_lhd(bounds_low, bounds_high, n_samples: int, T0: float = 10.0, c: float = 0.95, it: int = 2000, p: float = 50, profile: str = 'GEOM', Imax: int = 100, jitter: bool = False, seed: int | None = None, return_history: bool = False)

Python approximation of DiceDesign::maximinSA_LHS in R.

Parameters mirror the R routine where practical. The optimization is done over a Latin hypercube permutation structure.

surmod.space_fill_design.mindist_criterion(x: ndarray) float
surmod.space_fill_design.phi_p_criterion(x: ndarray, p: float = 50) float

DiceDesign-style phi_p criterion.

Lower is better. As p -> infinity, minimizing phi_p approaches maximin optimization.

surmod.space_fill_design.random_design(bounds_low, bounds_high, n_samples, seed=None)

surmod.test_functions module

class surmod.test_functions.Borehole_synth_test_func(noise_std: float | None = None, negate: bool = False, bounds: List[Tuple[float, float]] | None = None)

Bases: SyntheticTestFunction

Borehole test function.

This is the 8 dimensional borehole function used as a test case in computer experiments. Implementation follows the definition from Sonja Surjanovic and Derek Bingham (SFU).

Inputs (in order):

rw : radius of borehole (m) r : radius of influence (m) Tu : transmissivity upper aquifer (m^2/yr) Hu : potentiometric head upper aquifer (m) Tl : transmissivity lower aquifer (m^2/yr) Hl : potentiometric head lower aquifer (m) L : length of borehole (m) Kw : hydraulic conductivity of borehole (m/yr)

Vector form:

x = [rw, r, Tu, Hu, Tl, Hl, L, Kw]

Output:

y = water flow rate (m^3/yr)

Reference:

https://www.sfu.ca/~ssurjano/borehole.html

class surmod.test_functions.Parabola_synth_test_func(dim: int = 2, noise_std: float | None = None, negate: bool = True, bounds: List[Tuple[float, float]] | None = None)

Bases: SyntheticTestFunction

Parabola test function.

Default is bivariate parabola evaluated on [-8,8]x[-8,8].

surmod.test_functions.borehole(x: ndarray[tuple[int, ...], dtype[_ScalarType_co]], *args) ndarray[tuple[int, ...], dtype[_ScalarType_co]]

This function computes the water flow rate through a borehole.

Parameters:

x (np.ndarray) – Array of shape (n_samples, n_variables) with normalized values in [0, 1]. Each column corresponds to an input variable, scaled according to its bounds.

Returns:

Array of borehole water flow rates (in m^3/year) for each input sample.

Return type:

np.ndarray

References

[1] Formula source: Borehole Function, Simon Fraser University,

https://www.sfu.ca/~ssurjano/borehole.html (accessed Dec 2025).

surmod.test_functions.load_test_function(objective_function: str)

Loads a test function instance for simulating data based on the given objective function name.

Parameters:

objective_function (str) – The name of the objective function to load. Supported values are “Parabola”, “Ackley”, “Griewank”, “Branin”, and “HolderTable”.

Returns:

An instance of the requested test function, initialized with standard parameters.

Return type:

object

Raises:

ValueError – If the specified objective function name is not recognized.

surmod.test_functions.otlcircuit(x: ndarray[tuple[int, ...], dtype[_ScalarType_co]], *args) ndarray[tuple[int, ...], dtype[_ScalarType_co]]

This function computes the midpoint voltage of output transformerless (OTL) push-pull circuit.

Parameters:

x (np.ndarray) – Array of shape (n_samples, n_variables) with normalized values in [0, 1]. Each column corresponds to an input variable, scaled according to its bounds.

Returns:

Array of calculated midpoint voltages (in volts) for each input sample.

Return type:

np.ndarray

References

[1] Formula source: OTL Circuit Function, Simon Fraser University,

https://www.sfu.ca/~ssurjano/otlcircuit.html (accessed July 2024).

[2] Ben-Ari, E. N., & Steinberg, D. M. (2007). Modeling data from computer experiments:

an empirical comparison of kriging with MARS and projection pursuit regression. Quality Engineering, 19(4), 327-338.

surmod.test_functions.parabola(x: ndarray[tuple[int, ...], dtype[_ScalarType_co]], beta1: float, beta2: float, beta12: float) ndarray[tuple[int, ...], dtype[_ScalarType_co]]

Computes a quadratic function with an interaction term for a set of 2D input points.

The function is defined as:

f(x1, x2) = beta1 * x1^2 + beta2 * x2^2 + beta12 * sin(6 * x1 * x2 - 3)

Parameters:
  • x (np.ndarray) – Array of shape (n_samples, 2), where each row is a 2D input point [x1, x2].

  • beta1 (float) – Coefficient for the x1^2 term.

  • beta2 (float) – Coefficient for the x2^2 term.

  • beta12 (float) – Coefficient for the interaction term sin(6 * x1 * x2 - 3).

Returns:

Array of shape (n_samples,) containing the computed function values for each input.

Return type:

np.ndarray

surmod.test_functions.piston(x: ndarray[tuple[int, ...], dtype[_ScalarType_co]], *args) ndarray[tuple[int, ...], dtype[_ScalarType_co]]

This function computes the time it takes a piston to complete one cycle.

Parameters:

x (np.ndarray) – Array of shape (n_samples, n_variables) with normalized values in [0, 1]. Each column corresponds to an input variable, scaled according to its bounds.

Returns:

Array of calculated cycle times (in seconds) for each input sample.

Return type:

np.ndarray

References

[1] Formula source: Piston Simulation Function, Simon Fraser University,

https://www.sfu.ca/~ssurjano/piston.html (accessed July 2024).

[2] Ben-Ari, E. N., & Steinberg, D. M. (2007). Modeling data from computer experiments:

an empirical comparison of kriging with MARS and projection pursuit regression. Quality Engineering, 19(4), 327-338.

surmod.test_functions.scale_inputs(x: ndarray[tuple[int, ...], dtype[_ScalarType_co]], bounds: dict[str, tuple[float, float]]) ndarray

Scales normalized input values to their actual ranges based on provided bounds.

Parameters:
  • x (np.ndarray) – Array of shape (n_samples, n_variables) with normalized values in [0, 1]. Each column corresponds to an input variable, scaled according to its bounds.

  • bounds (dict) – Dictionary mapping variable names to (min, max) tuples. The order of variables in x columns should match the order of keys in bounds.

Raises:

ValueError – If any element in x is outside the [0, 1] interval.

Returns:

Array of shape (n_samples, n_variables) with values scaled to their respective bounds.

Return type:

np.ndarray

surmod.test_functions.simulate_data(objective_function: str, num_train: int, num_test: int)

Simulates training and testing data from a specified test function.

Parameters:
  • objective_function (str) – The name of the objective function to simulate data from. Supported values are “Parabola”, “Ackley”, “Griewank”, “Branin”, and “HolderTable”.

  • num_train (int) – Number of training samples to generate.

  • num_test (int) – Number of testing samples to generate.

Returns:

A tuple containing:
  • x_train (np.ndarray): Training input data of shape (num_train, 2).

  • x_test (np.ndarray): Testing input data of shape (num_test, 2).

  • y_train (np.ndarray): Training target data of shape (num_train,).

  • y_test (np.ndarray): Testing target data of shape (num_test,).

Return type:

Tuple[np.ndarray, np.ndarray, np.ndarray, np.ndarray]

Raises:

ValueError – If the specified objective function name is not recognized.

surmod.test_functions.wingweight(x: ndarray[tuple[int, ...], dtype[_ScalarType_co]], *args) ndarray[tuple[int, ...], dtype[_ScalarType_co]]

This function computes the weight of a light aircraft wing.

Parameters:

x (np.ndarray) – Array of shape (n_samples, n_variables) with normalized values in [0, 1]. Each column corresponds to an input variable, scaled according to its bounds.

Returns:

Array of wing weights (in pounds) for each input sample.

Return type:

np.ndarray

References

[1] Formula source: Wing Weight Function, Simon Fraser University,

https://www.sfu.ca/~ssurjano/wingweight.html (accessed July 2024).

Module contents