aquakin.optimize_design#
- aquakin.optimize_design(objective, bounds, *, input_names=None, constraints=(), x0=None, maximize=False, method='SLSQP', n_starts=1, seed=0, tol=1e-06, constraint_tol=0.0001)[source]#
Minimise (or maximise) an objective over a bounded design space subject to inequality constraints, using autodiff gradients.
The canonical use is “size a design to a permit at minimum cost”:
objectiveis an operational-cost / energy metric and eachConstraintis an effluent-quality ceiling.objectiveand the constraint functions share thefn(x) -> scalarcontract ofmonte_carlo()– they build the params / initial state and run the solve themselves – and must be JAX-differentiable, since their gradients are taken by autodiff and passed to the optimizer (a gradient-based, constrained NLP solver via SciPy).- Parameters:
objective (callable) –
objective(x) -> scalarto minimise (or maximise; seemaximize).bounds (sequence of (low, high)) – Box bounds for each design variable, length
d.input_names (sequence of str, optional) – Design-variable names (defaults to
x0..).constraints (sequence of Constraint) – Inequality constraints
lower <= c.fn(x) <= upper.x0 (sequence of float, optional) – Starting point. Defaults to the box centre; with
n_starts > 1it is ignored in favour of quasi-random starts.maximize (bool) – Maximise instead of minimise.
method (str) – SciPy constrained method (default
"SLSQP";"trust-constr"also works with bounds + constraints).n_starts (int) – Multistart count – quasi-random (Sobol) starts in the box; the best feasible optimum is returned. Escapes local minima on multimodal designs.
seed (int) – Seed for the multistart sampler (reproducible).
tol (float) – Optimizer tolerance and the slack within which a constraint counts as satisfied when judging feasibility / picking the multistart winner.
constraint_tol (float) – Optimizer tolerance and the slack within which a constraint counts as satisfied when judging feasibility / picking the multistart winner.
- Return type: