factory module
Define a factory function to create OptimisationAlgorithm.
- ALGORITHM_SELECTOR: dict[str, ABCMeta] = { 'NSGA-III': <class 'lightwin.optimisation.algorithms.nsga.NSGA3Algorithm'>, 'NSGA-III Multi-threaded': <class 'lightwin.optimisation.algorithms.nsga.NSGA3AlgorithmMulti'>, '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'>, '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-III’, ‘NSGA-III Multi-threaded’, ‘simulated_annealing’]
- class OptimisationAlgorithmFactory(opti_method, beam_calculator, reference_simulation_output, accelerator_id, **wtf)[source]
Bases:
objectHolds methods to easily create
OptimisationAlgorithm.- 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-III','NSGA-III Multi-threaded','simulated_annealing'])beam_calculator (
BeamCalculator)reference_simulation_output (
SimulationOutput)accelerator_id (
str)wtf (
Any)
- __init__(opti_method, beam_calculator, reference_simulation_output, accelerator_id, **wtf)[source]
Save properties common to every optimization algorithhm.
- 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-III','NSGA-III Multi-threaded','simulated_annealing']) – Name of the desired optimisation algorithm.beam_calculator (
BeamCalculator) – Object that will be used to compute propagation of the beam.reference_simulation_output (
SimulationOutput) – Simulation of the nominal accelerator.accelerator_id (
str) – Associated solutionAccelerator.id. Looks like:0000001_Solution.kwargs – Other keyword arguments that will be passed to the
OptimisationAlgorithm.wtf (
Any)
- Return type:
None
- create(compensating_elements, objective_factory, design_space, subset_elts)[source]
Instantiate an optimisation algorithm for a given fault.
- Parameters:
compensating_elements (
Collection[Element])objective_factory (
ObjectiveFactory)design_space (
DesignSpace)subset_elts (
ListOfElements)
- Return type:
- create_from_preset(compensating_elements, objective_factory, design_space, subset_elts, predefined_cavity_settings, predefined_simulation_output=None)[source]
Instantiate a fake optimization algorithm bypassing the solver.
- Parameters:
compensating_elements (
Collection[Element])objective_factory (
ObjectiveFactory)design_space (
DesignSpace)subset_elts (
ListOfElements)predefined_cavity_settings (
SetOfCavitySettings)predefined_simulation_output (
SimulationOutput|None, default:None)
- Return type:
- _make_default_kwargs(compensating_elements, objective_factory, design_space, subset_elts)[source]
Build default arguments for
OptimisationAlgorithm.The kwargs for
OptimisationAlgorithmthat are defined inFault.optimisation_algorithmwill override the ones defined here.- Return type:
- Returns:
A dictionary of keyword arguments for the initialisation of
OptimisationAlgorithm.- Parameters:
compensating_elements (
Collection[Element])objective_factory (
ObjectiveFactory)design_space (
DesignSpace)subset_elts (
ListOfElements)