optimize_s_params#
- simpleEMS.sim_tools.optimize_s_params(simulate_fn: Callable, x0: dict[str, float], output_path: Path, bounds: tuple | None = None) None#
Optimize simulation parameters using SciPy’s Nelder-Mead algorithm.
Runs
scipy.optimize.minimize(..., method="Nelder-Mead")oversimulate_fn, starting fromx0. Stops on SciPy’s own convergence criteria (xatol=1e-3,fatol=1e-3), or early via a callback that stops the optimization once the parameter vector moves by less than1e-4(Euclidean norm) for 5 consecutive iterations. Prints the optimal parameter values to stdout when finished.- Parameters:
simulate_fn (callable) – Simulation function invoked at each optimization step as
simulate_fn(output_path=output_path, optimize=True, optimize_val=x), wherexis the current parameter vector (in the order ofx0’s values). Must return a scalar cost to minimize, e.g. viaoptimize_s11oroptimize_s21.x0 (dict[str, float]) – Initial parameter values, used as the optimization starting point. Keys are used only for the final printout; the order of the values defines the parameter vector order passed to
simulate_fn.output_path (Path) – Directory where simulation results are stored; forwarded to
simulate_fnon every call.bounds (sequence of (float, float), optional) – Per-parameter
(min, max)bounds, in the same order asx0’s values, passed through toscipy.optimize.minimize.Nonein a pair means no bound on that side. Default isNone(unbounded).
- Returns:
Does not return a value; prints the optimal parameters found.
- Return type:
None