factory module
Define a factory function to create OptimisationAlgorithm.
Todo
Docstrings
- ALGORITHM_SELECTOR: dict[str, ABCMeta] = { 'bayesian_optimization': <class 'lightwin.optimisation.algorithms.bayesian_optimization.BayesianOptimizationLW'>, 'differential_evolution': <class 'lightwin.optimisation.algorithms.differential_evolution.DifferentialEvolution'>, 'downhill_simplex': <class 'lightwin.optimisation.algorithms.downhill_simplex.DownhillSimplex'>, 'downhill_simplex_penalty': <class 'lightwin.optimisation.algorithms.downhill_simplex_penalty.DownhillSimplexPenalty'>, 'experimental': <class 'lightwin.optimisation.algorithms.bayesian_optimization.BayesianOptimizationLW'>, 'explorator': <class 'lightwin.optimisation.algorithms.explorator.Explorator'>, 'least_squares': <class 'lightwin.optimisation.algorithms.least_squares.LeastSquares'>, 'least_squares_penalty': <class 'lightwin.optimisation.algorithms.least_squares_penalty.LeastSquaresPenalty'>, 'nelder_mead': <class 'lightwin.optimisation.algorithms.downhill_simplex.DownhillSimplex'>, 'nelder_mead_penalty': <class 'lightwin.optimisation.algorithms.downhill_simplex_penalty.DownhillSimplexPenalty'>, 'nsga': <class 'lightwin.optimisation.algorithms.nsga.NSGA'>, 'simulated_annealing': <class 'lightwin.optimisation.algorithms.simulated_annealing.SimulatedAnnealing'>}
Maps the
optimisation_algorithmkey in theTOMLfile to the actualOptimisationAlgorithmwe use.
- ALGORITHMS_T
Implemented optimization algorithms.
alias of
Literal[‘bayesian_optimization’, ‘differential_evolution’, ‘downhill_simplex’, ‘downhill_simplex_penalty’, ‘experimental’, ‘explorator’, ‘least_squares’, ‘least_squares_penalty’, ‘nelder_mead’, ‘nelder_mead_penalty’, ‘nsga’, ‘simulated_annealing’]
- optimisation_algorithm_factory(opti_method, fault, beam_calculator, **wtf)[source]
Create the proper
OptimisationAlgorithminstance.- Parameters:
opti_method (
Literal['bayesian_optimization','differential_evolution','downhill_simplex','downhill_simplex_penalty','experimental','explorator','least_squares','least_squares_penalty','nelder_mead','nelder_mead_penalty','nsga','simulated_annealing']) – Name of the desired optimisation algorithm.fault (
Fault) – Fault that will be compensated by the optimisation algorithm.beam_calculator (
BeamCalculator) – Object that will be used to computte propagation of the beam.kwargs – Other keyword arguments that will be passed to the
OptimisationAlgorithm.wtf (
Any)
- Return type:
- Returns:
Instantiated optimisation algorithm.
- _default_kwargs(fault, run_with_this, cavity_settings_factory)[source]
Set default arguments to instantiate the optimisation algorithm.
The kwargs for
OptimisationAlgorithmthat are defined inFaultScenario._optimisation_algorithms()will override the ones defined here.- Parameters:
fault (
Fault) – Fault that will be compensated by the optimisation algorithm.compute_beam_propagation – Function that takes in a set of cavity settings and a list of elements, computes the beam propagation with these, and returns a simulation output.
run_with_this (
Callable)cavity_settings_factory (
CavitySettingsFactory)
- Return type:
- Returns:
A dictionary of keyword arguments for the initialisation of
OptimisationAlgorithm.