finesse.analysis.actions.optimisation module
Collection of Actions that deal linear time invariant (LTI) modelling tasks.
- class finesse.analysis.actions.optimisation.Maximize(detector, parameter, name='maximize', *args, **kwargs)[source]
Bases:
OptimizeAn action that maximizes some detector output by applying some feedback to multiple targets in a model. Extra keyword arguments are passed on to the Scipy method:
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 overridden. The user should read the Scipy documentation to determine which options should be used which are method dependant.
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.
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.
Examples
Simple example that maximizes the power in a coupled cavity solution by moving multiple 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 ''') sol = model.run("maximize(P, [m1.phi, m3.phi], xatol=1e-7)") print(sol.result)
- class finesse.analysis.actions.optimisation.Minimize(detector, parameter, name='minimize', *args, **kwargs)[source]
Bases:
OptimizeAn action that minimizes some detector output by applying some feedback to multiple targets in a model. Extra keyword arguments are passed on to the Scipy method:
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 overridden. The user should read the Scipy documentation to determine which options should be used which are method dependant.
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.
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.
Examples
Simple example that minimizes some measured power by feeding back to the laser power
model = finesse.Model() model.parse(''' l l1 P=1 pd P l1.p1.o ''') sol = model.run("minimize(P, l1.P)") print(sol.result)
- exception finesse.analysis.actions.optimisation.OptimizationWarning[source]
Bases:
RuntimeWarning
- 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
- class finesse.analysis.actions.optimisation.OptimizeSolution(*args, **kwargs)[source]
Bases:
BaseSolutionSolution for an optimization action.
Attributes
- resultscipy.optimize.optimize.OptimizeResult
Result from the scipy optimization method that contains the results and some extra data about the process and any errors that might happen.
- parameters[Parameter | tuple]
Name or names of parameters that were optimized over
- x[numeric | ndarray]
The final minimized values for the parameters requested.