romtools.workflows.parameter_spaces#

Model reduction is often focused on parameterized PDEs, where \(\boldsymbol \mu\) is the parameter set. The ParameterSpace class encapsulates the notion of the parameter space.

Classes

BoundedParameterSpace()

Abstract implementation

ConstParameterSpace(parameter_names, ...)

Homogeneous parameter space in which every parameter is a constant StringParameter.

EmptyParameterSpace()

Empty parameter space that is useful for initializations

GaussianParameterSpace(parameter_names, ...)

Homogeneous parameter space in which every parameter is a GaussianParameter

HeterogeneousParameterSpace(parameter_objs)

Heterogeneous parameter space consisting of a list of arbitrary Parameter objects

HomogeneousParameterSpace(parameter_names, ...)

Homogenous parameter space in which every parameter is of the same type

MultivariateGaussianParameterSpace(...[, ...])

Multivariate Gaussian parameter space with dense covariance coupling across all parameter dimensions.

ParameterSpace()

Abstract implementation

UniformParameterSpace(parameter_names, ...)

Homogeneous parameter space in which every parameter is a UniformParameter

UnionParameterSpace(regions)

Independent uniform Monte Carlo samples over a geometric union of boxes.

class romtools.workflows.parameter_spaces.BoundedParameterSpace[source]#

Bases: ParameterSpace

Abstract implementation

abstractmethod bound_samples(samples)[source]#
Inputs: a sample distribution that potentially exceeds

the bounds of the parameter space

Outputs:

a bounded sample distribution

(number_of_samples, self.get_dimensionality())

Parameters:

samples (ndarray)

Return type:

array

class romtools.workflows.parameter_spaces.ConstParameterSpace(parameter_names, parameter_values)[source]#

Bases: HomogeneousParameterSpace

Homogeneous parameter space in which every parameter is a constant StringParameter. All numeric values are converted to str-type.

Useful if you need to execute workflows in a non-stochastic setting

Parameters:

parameter_names (Iterable[str])

class romtools.workflows.parameter_spaces.EmptyParameterSpace[source]#

Bases: ParameterSpace

Empty parameter space that is useful for initializations

generate_samples(number_of_samples, seed=None)[source]#

Generates samples from the parameter space

Returns np.array of shape (number_of_samples, self.get_dimensionality())

Parameters:

number_of_samples (int)

Return type:

ndarray

get_dimensionality()[source]#

Returns an integer for the size of the parameter domain

Return type:

int

get_names()[source]#

Returns a list of parameter names # e.g., [‘sigma’,’beta’,…]

Return type:

list

class romtools.workflows.parameter_spaces.GaussianParameterSpace(parameter_names, means, stds, sampler)[source]#

Bases: HomogeneousParameterSpace

Homogeneous parameter space in which every parameter is a GaussianParameter

Parameters:
  • parameter_names (Iterable[str])

  • sampler (Sampler)

class romtools.workflows.parameter_spaces.HeterogeneousParameterSpace(parameter_objs, sampler=<function MonteCarloSampler>)[source]#

Bases: ParameterSpace

Heterogeneous parameter space consisting of a list of arbitrary Parameter objects

Parameters:
generate_samples(number_of_samples, seed=None)[source]#

Generates samples from the parameter space

Returns np.array of shape (number_of_samples, self.get_dimensionality())

Parameters:

number_of_samples (int)

Return type:

array

get_dimensionality()[source]#

Returns an integer for the size of the parameter domain

Return type:

int

get_names()[source]#

Returns a list of parameter names # e.g., [‘sigma’,’beta’,…]

Return type:

Iterable[str]

class romtools.workflows.parameter_spaces.HomogeneousParameterSpace(parameter_names, sampler, param_constructor, **kwargs)[source]#

Bases: HeterogeneousParameterSpace

Homogenous parameter space in which every parameter is of the same type

Parameters:
  • parameter_names (Iterable[str])

  • sampler (Sampler)

class romtools.workflows.parameter_spaces.MultivariateGaussianParameterSpace(parameter_names, means, covariance, sampler=<function MonteCarloSampler>)[source]#

Bases: ParameterSpace

Multivariate Gaussian parameter space with dense covariance coupling across all parameter dimensions.

Parameters:
  • parameter_names (Iterable[str])

  • sampler (Sampler)

generate_samples(number_of_samples, seed=None)[source]#

Generates samples from the parameter space

Returns np.array of shape (number_of_samples, self.get_dimensionality())

Parameters:

number_of_samples (int)

Return type:

array

get_dimensionality()[source]#

Returns an integer for the size of the parameter domain

Return type:

int

get_names()[source]#

Returns a list of parameter names # e.g., [‘sigma’,’beta’,…]

Return type:

Iterable[str]

class romtools.workflows.parameter_spaces.ParameterSpace[source]#

Bases: ABC

Abstract implementation

abstractmethod generate_samples(number_of_samples, seed=None)[source]#

Generates samples from the parameter space

Returns np.array of shape (number_of_samples, self.get_dimensionality())

Parameters:

number_of_samples (int)

Return type:

array

abstractmethod get_dimensionality()[source]#

Returns an integer for the size of the parameter domain

Return type:

int

abstractmethod get_names()[source]#

Returns a list of parameter names # e.g., [‘sigma’,’beta’,…]

Return type:

Iterable[str]

class romtools.workflows.parameter_spaces.UniformParameterSpace(parameter_names, lower_bounds, upper_bounds, sampler)[source]#

Bases: HomogeneousParameterSpace

Homogeneous parameter space in which every parameter is a UniformParameter

Parameters:
  • parameter_names (Iterable[str])

  • sampler (Sampler)

get_bounds()[source]#

Return copies of coordinate bounds, flattened in parameter order.

Return type:

Tuple[ndarray, ndarray]

class romtools.workflows.parameter_spaces.UnionParameterSpace(regions)[source]#

Bases: ParameterSpace

Independent uniform Monte Carlo samples over a geometric union of boxes.

Regions must be UniformParameterSpace instances with identical ordered names and dimensionality, finite real bounds, and strictly positive widths. Names and bounds are copied at construction. Region samplers are ignored: even LHS-configured regions produce independent Monte Carlo union samples.

A proposal chooses a box by volume, samples uniformly within it, and is accepted with probability 1 / (number of containing boxes). This corrects overlap bias without rejecting from a potentially sparse bounding box. The acceptance rate is union volume / sum of region volumes, so heavy overlap increases sampling cost. Products of widths are normalized in log space; unrepresentable widths or region probabilities raise ValueError.

Parameters:

regions (Iterable[UniformParameterSpace])

contains(samples)[source]#

Return membership for a point (d,) or a batch (n, d).

Boundaries are included. NaN/infinite coordinates are outside the union. Other shapes or nonnumeric/complex inputs are rejected.

Return type:

bool | ndarray

generate_samples(number_of_samples, seed=None)[source]#

Draw (number_of_samples, d) independent uniform union samples.

Uses a local NumPy generator without changing global RNG state. Fixed seeds reproduce draws; these samples are not an LHS design.

Parameters:

number_of_samples (int)

Return type:

ndarray

get_dimensionality()[source]#

Returns an integer for the size of the parameter domain

Return type:

int

get_names()[source]#

Returns a list of parameter names # e.g., [‘sigma’,’beta’,…]

Return type:

Iterable[str]