simopt.solvers.utils
Utility functions for optimization solvers.
Module Contents
- simopt.solvers.utils.finite_diff(solver: simopt.base.Solver, new_solution: simopt.base.Solution, bounds_check: numpy.ndarray, problem: simopt.base.Problem, stepsize: float, r: int) numpy.ndarray
Compute the finite difference approximation of the gradient for a solution.
- Parameters:
solver (Solver) – The solver instance used to create new solutions.
new_solution (Solution) – The current solution to perturb.
bounds_check (np.ndarray) – Array indicating which perturbation method to use per dimension.
problem (Problem) – The problem instance providing bounds and function evaluations.
stepsize (float) – The step size used for finite difference calculations.
r (int) – The number of replications used for each function evaluation.
- Returns:
The approximated gradient of the function at the given solution.
- Return type:
np.ndarray
- simopt.solvers.utils.bfgs_hessian_approx(solver: simopt.base.Solver, new_solution: simopt.base.Solution, bounds_check: numpy.ndarray, problem: simopt.base.Problem, r: int) numpy.ndarray
Approximate Hessian using BFGS.
This method applies BFGS updates to build or refine a Hessian approximation.
- Parameters:
solver (Solver) – The solver instance used to create new solutions.
new_solution (Solution) – The solution at which derivatives are computed.
bounds_check (np.ndarray) – Boolean mask indicating which variables are within bounds and eligible for perturbation.
problem (Problem) – The simulation-optimization problem being solved.
r (int) – Number of replications used when estimating gradients.
- Returns:
Hessian approximation (updated via BFGS).
- Return type:
np.ndarray