simopt.solvers.spsa

Simultaneous Perturbation Stochastic Approximation (SPSA) Solver.

Simultaneous perturbation stochastic approximation (SPSA) is an algorithm for optimizing systems with multiple unknown parameters.

Module Contents

class simopt.solvers.spsa.SPSAConfig

Bases: simopt.base.SolverConfig

Configuration for SPSA solver.

alpha: Annotated[float, Field(default=0.602, gt=0, description='non-negative coefficient in the SPSA gain sequence ak')]
gamma: Annotated[float, Field(default=0.101, gt=0, description='non-negative coefficient in the SPSA gain sequence ck')]
step: Annotated[float, Field(default=0.1, gt=0, description='initial desired magnitude of change in the theta elements')]
gavg: Annotated[int, Field(default=1, gt=0, description='averaged SP gradients used per iteration')]
n_reps: Annotated[int, Field(default=30, gt=0, description='number of replications takes at each solution')]
n_loss: Annotated[int, Field(default=2, gt=0, description='number of loss function evaluations used in gain calculation')]
eval_pct: Annotated[float, Field(default=2 / 3, gt=0, le=1, description='percentage of the expected number of loss evaluations per run')]
iter_pct: Annotated[float, Field(default=0.1, gt=0, le=1, description='percentage of the maximum expected number of iterations')]
class simopt.solvers.spsa.SPSA(name: str = '', fixed_factors: dict | None = None)

Bases: simopt.base.Solver

Simultaneous Perturbation Stochastic Approximation (SPSA) Solver.

Simultaneous perturbation stochastic approximation (SPSA) is an algorithm for optimizing systems with multiple unknown parameters.

Initialize a solver object.

Parameters:
  • name (str, optional) – Name of the solver. Defaults to an empty string.

  • fixed_factors (dict | None, optional) – Dictionary of user-specified solver factors. Defaults to None.

name: str = 'SPSA'
config_class: ClassVar[type[simopt.base.SolverConfig]]

Configuration class for the solver.

class_name_abbr: ClassVar[str] = 'SPSA'

Short name of the solver class.

class_name: ClassVar[str] = 'SPSA'

Long name of the solver class.

objective_type: ClassVar[simopt.base.ObjectiveType]

Description of objective types.

constraint_type: ClassVar[simopt.base.ConstraintType]

Description of constraint types.

variable_type: ClassVar[simopt.base.VariableType]

Description of variable types.

gradient_needed: ClassVar[bool] = False

True if gradient of objective function is needed, otherwise False.

check_problem_factors() bool

Determine if the joint settings of problem factors are permissible.

Returns:

True if problem factors are permissible; False otherwise.

Return type:

bool

solve(problem: simopt.base.Problem) None

Run a single macroreplication of a solver on a problem.

Parameters:

problem (Problem) – Simulation-optimization problem to solve.

Returns:

  • list [Solution]: List of solutions recommended throughout the budget.

  • list [int]: List of intermediate budgets when recommended solutions

    change.

Return type:

tuple