finesse.analysis.actions.optimisation.Maximize

Overview

class finesse.analysis.actions.optimisation.Maximize(detector, parameter, name='maximize', *args, **kwargs)[source]

Bases: Optimize

An action that maximizes some detector output by applying some feedback to multiple targets in a model.

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.

fatolfloat, optional

Absolute error in func(xopt) between iterations that is acceptable for convergence.

These can be set as keyword arguments to the action.

Examples

Simple example that maximizes the power in a coupled cavity solution by moving multilpe mirrors:

model = finesse.Model()
model.parse('''
l l1 P=1
m m1 R=0.98 T=0.02 phi=10
m m2 R=0.99 T=0.01
m m3 R=1 T=0 phi=-20
link(l1, m1, m2, m3)
pd P m3.p1.i

maximize(P, [m1.phi, m3.phi], xatol=1e-7, adaptive=True)
''')
print(sol.result)