finesse.analysis.actions.optimisation.Optimize

Overview

class finesse.analysis.actions.optimisation.Optimize(detector, parameters, bounds=None, offset=0, kind='max', max_iterations=10000, tol=None, verbose=False, method='nelder-mead', opfunc=None, update_maps=False, pre_step=None, name='optimize', **kwargs)[source]

Bases: Action

An action that will optimize the value of parameter to either maximize or minimize the output of a detector during a simulation. Extra keyword arguments are passed on to the Scipy method:

minimize

This action offers a simplified interface that allows an optimization to be done during a simulation. By default the the Nelder-Mead optimization method is used but can be overriden. The user should read the Scipy documentation to determine which options should be used which are method dependant.

Parameters
detectorstr

The name of the detector output to maximize / minimize.

parameter[Parameter | str | tuple]

The parameter or name of the parameter to optimize, or a tuple of parameters when using multiple targets to optimize over.

boundslist, optional

A pair of (lower, upper) bounds on the parameter value. Requires a method that uses bounds.

offsetfloat, optional

An offset applied to the detector output when optimizing, defaults to 0.

kindstr, optional

Either ‘max’ for maximization or ‘min’ for minimization, defaults to ‘max’.

max_iterationsint, optional

Maximum number of solver iterations, defaults to 10000.

methodstr, optional

Optimisation method to use, see Scipy documentation for options.

namestr, optional

The name of this action, defaults to ‘maximize’.

update_mapsbool, optional

If you are changing some parameter or variable that a Map depends on then setting this flag to True will recompute the Map data for each iteration of the optimiser.

pre_stepAction, optional

Action to run on each step of the optimisation.

**kwargs

Optional parameters passed to the Scipy optimisation routine as the options input. See Scipy method documentation to determine what is available.

Notes

Default optimizer used is nelder-mead. To set the absolute and relative error targets use (From the scipy documentation: https://docs.scipy.org/doc/scipy/reference/optimize.minimize-neldermead.html)

xatolfloat, optional

Absolute error in xopt between iterations that is acceptable for convergence. Defaults to 1e-4.

fatolfloat, optional

Absolute error in func(xopt) between iterations that is acceptable for convergence. Defaults to 1e-4.

These can be set as keyword arguments to the action.

Properties

Optimize.parameter_names