Expand description
Stochastic optimization via Sample-Average Approximation (SAA).
Given an objective f(x, xi) that depends on random parameters xi,
SAA draws N scenarios and solves:
min_x (1/N) sum_{s=1}^{N} f(x, xi_s)
Chance constraints P{g(x, xi) <= 0} >= alpha are enforced via a smooth
quadratic penalty relaxation.
§Example
use numra_optim::stochastic::StochasticProblem;
let result = StochasticProblem::new(1)
.x0(&[0.0])
.objective(|x: &[f64], p: &[f64]| (x[0] - p[0]) * (x[0] - p[0]))
.param_normal("xi", 5.0, 1.0)
.n_samples(200)
.solve()
.unwrap();
assert!((result.x[0] - 5.0).abs() < 0.5);Author: Moussa Leblouba Date: 9 February 2026 Modified: 2 May 2026
Structs§
- Stochastic
Options - Options for stochastic optimization.
- Stochastic
Param - A stochastic parameter with a sampling function.
- Stochastic
Problem - Declarative builder for stochastic optimization problems.
- Stochastic
Result - Result of stochastic optimization.
Functions§
- param_
normal - Create a normally distributed stochastic parameter.
- param_
sampled - Create a stochastic parameter with a custom sampling closure.
- param_
uniform - Create a uniformly distributed stochastic parameter.