relentless.optimize.FixedStepDescent#
- class relentless.optimize.FixedStepDescent(stop, max_iter, step_size, scale=1.0, line_search=None)#
Fixed-step steepest descent algorithm.
This is a modification of
SteepestDescentin which the function is iteratively minimized by taking successive steps of fixed magnitude down the normalized gradient of the function.If the scaled variables are \(\mathbf{y}_n\) at iteration \(n\), the next value of the variables is:
\[\mathbf{y}_{n+1} = \mathbf{y}_n -\frac{\alpha}{\left\lVert\nabla f\left(\mathbf{y}_n\right)\right\rVert} \nabla f\left(\mathbf{y}_n\right)\]- Parameters:
stop (
ConvergenceTest) – The convergence test used as the stopping criterion for the optimizer. Note that the result being tested will have unscaled variables and gradient.max_iter (int) – The maximum number of optimization iterations allowed.
step_size (float) – The step size hyperparameter (\(\alpha\)).
scale (float or dict) – A scalar scaling parameter or scaling parameters (\(\mathbf{X}\)) keyed on one or more
ObjectiveFunctiondesign variables (defaults to1.0, so that the variables are unscaled).line_search (
LineSearch) – The line search object used to find the optimal step size, using the specified step size value as the “maximum” step size (defaults toNone).
Methods
descent_amount(gradient)Calculate the descent amount for the optimization.
optimize(objective, variables[, directory, ...])Perform the steepest descent optimization for the given objective function.
Attributes
The line search used to optimize the step size.
The maximum number of optimization iterations allowed.
Scaling parameter.
The step size hyperparameter (\(\alpha\)).
The convergence test used as the stopping criterion for the optimizer.
- descent_amount(gradient)#
Calculate the descent amount for the optimization.
The amount that each update descends down the scaled gradient is:
\[\frac{\alpha}{\left\lVert\nabla y\right\rVert}\]which makes a step of constant magnitude.
- Parameters:
gradient (
KeyedArray) – The scaled gradient of the objective function.- Returns:
The descent amount, keyed on the objective function design variables.
- Return type:
- property line_search#
The line search used to optimize the step size.
- Type:
- optimize(objective, variables, directory=None, overwrite=False)#
Perform the steepest descent optimization for the given objective function.
If specified, a
LineSearchis performed to choose an optimal step size.If
directoryis specified andoverwriteisTrue,directorywill be cleared before the optimization begins. The output will be saved into a directory created for each iteration of the optimization, e.g.,directory/0. To advance to the next iteration of the optimization (e.g., from iteration 0 to iteration 1), a directorydirectory/0/.nextis created at iteration 0 to hold the proposed result at iteration 1. Ifline_searchisNone, its contents are immediately moved todirectory/1(leavingdirectory/0/.next) empty. Ifline_searchis notNone,directory/0/.linewill be created forLineSearch.find()to use; the final result of the line search will be moved todirectory/1.- Parameters:
objective (
ObjectiveFunction) – The objective function to be optimized.variables (
IndependentVariableor tuple) – Design variable(s) to optimize.directory (str or
Directory) – Directory for writing output during optimization. Default ofNonerequests no output is written.overwrite (bool) – If
True, overwrite the directory before beginning optimization.
- Returns:
Trueif converged,Falseif not converged,Noneif no design variables are specified for the objective function.- Return type:
bool or None
- Raises:
OSError – If
directoryis not empty and overwrite isFalse.
- property scale#
Scaling parameter.
A scalar scaling parameter or scaling parameters (\(\mathbf{X}\)) keyed on one or more
ObjectiveFunctiondesign variables. Must be positive.
- property stop#
The convergence test used as the stopping criterion for the optimizer.
- Type: