SciPyMinimizeOptimizer
- class SciPyMinimizeOptimizer(model, goals, *, frequency=None, aggregation='least_squares', tikhonov_lambda=0.0, **feature_kwargs)[source]
Bases:
FrequentistOptimizerFrequentist optimizer using the SciPy minimize backend with JAX acceleration.
This class wraps
scipy.optimize.minimize, executing the optimization in a normalized parameter space [0, 1] for fully bounded parameters, while preserving natural scaling for unbounded or semi-bounded parameters.- Parameters:
- execute(*, use_jac=True, show_progress=True, **kwargs)[source]
Run the goal-oriented optimization loop using the SciPy backend.
- cdf(theta)
Evaluate the cumulative distribution function (CDF) for the model parameters.
This computes the probability \(P(X \leq \theta)\) and lazily compiles the evaluation graph using
jax.jiton the first call.- Parameters:
theta (jax.numpy.ndarray) – The parameter values to evaluate.
- Returns:
The evaluated CDF probabilities, bounded between \(0\) and \(1\).
- Return type:
jax.numpy.ndarray
- cost(theta)
Calculate the scalar penalty (cost) for the current parameters. Lazily compiles the evaluation graph via
jax.jit.- Parameters:
theta (Array)
- Return type:
Array
- icdf(u)
Evaluate the inverse cumulative distribution function (ICDF), or quantile function.
This computes \(\theta = F^{-1}(u)\) and lazily compiles the evaluation graph using
jax.jiton the first call.- Parameters:
u (jax.numpy.ndarray) – The probability values to evaluate, typically uniformly distributed between \(0\) and \(1\).
- Returns:
The corresponding parameter values \(\theta\).
- Return type:
jax.numpy.ndarray
- log_prior(theta)
Evaluate the log-prior probability \(\log P(\theta)\) of the model parameters.
The prior is calculated by summing the log-probabilities of the flat parameter vector. The JAX graph is lazily compiled on the first call.
- Parameters:
theta (jax.numpy.ndarray) – The parameter values to evaluate.
- Returns:
The scalar log-prior probability.
- Return type:
float or jax.numpy.ndarray
- model_features(theta)
Extract the RF features from the model for a given set of parameters.
This function maps the parameters into the model, simulates it over the defined frequency band, and extracts the target specifications. The entire extraction pipeline is vectorized over the batch dimension and lazily compiled via
jax.jit(jax.vmap(...)).- Parameters:
theta (jax.numpy.ndarray) – A 1D array of a single parameter set, or a 2D array representing a batch of parameters.
- Returns:
The extracted model features. Matches the batch dimension of
theta.- Return type:
jax.numpy.ndarray
- Raises:
RuntimeError – If
frequencyorfeatureswere not provided during initialization.
- static read_results(stream)
Reconstruct backend optimization or sampling results from a bytes stream.
- Parameters:
stream (BytesIO) – The open byte stream to read from.
- Returns:
The deserialized Python objects.
- Return type:
Any
- run(*, output_path=None, output_root=None, plot=None, save_model=True, save_results=True, figure_dir=None, optimized_uniform_frac=None, **kwargs)
Execute the optimization scenario.
- Parameters:
output_path (str | None)
output_root (str | None)
plot (str | tuple[str, str] | tuple[str, str, tuple[int, int]] | Sequence[str | tuple[str, str] | tuple[str, str, tuple[int, int]]] | dict[str, str | tuple[str, str] | tuple[str, str, tuple[int, int]] | Sequence[str | tuple[str, str] | tuple[str, str, tuple[int, int]]]] | Callable[[ModelT | Array], Array] | None)
save_model (bool)
save_results (bool)
figure_dir (str | None)
optimized_uniform_frac (float | None)
- Return type:
- static write_results(stream, results)
Encode backend optimization or sampling results into a bytes stream.
- Parameters:
stream (BytesIO) – The open byte stream to write to.
results (Any) – The data structure containing the backend results.
Notes
The default implementation uses
jsonpicklefor robust, research-grade serialization of complex Python objects.