predefined_solution module
Define a pass-through ‘algorithm’ that accepts a pre-built solution.
- class PredefinedSolution(*, compensating_elements, objective_factory, design_space, compute_beam_propagation, cavity_settings_factory, reference_simulation_output, predefined_cavity_settings, optimisation_algorithm_kwargs=None, history_kwargs=None, predefined_simulation_output=None, **kwargs)[source]
Bases:
OptimisationAlgorithmBypass optimization and use a pre-built cavity settings solution.
Useful for testing, replaying a known solution, or warm-starting a downstream workflow without running a solver.
- Parameters:
compensating_elements (
Collection[TypeVar(FieldMap)])objective_factory (
ObjectiveFactory)design_space (
DesignSpace)compute_beam_propagation (
Callable[[Mapping[FieldMap,CavitySettings]],SimulationOutput])cavity_settings_factory (
CavitySettingsFactory)reference_simulation_output (
SimulationOutput)predefined_cavity_settings (
SetOfCavitySettings)optimisation_algorithm_kwargs (
dict[str,Any] |None, default:None)predefined_simulation_output (
SimulationOutput|None, default:None)
- __init__(*, compensating_elements, objective_factory, design_space, compute_beam_propagation, cavity_settings_factory, reference_simulation_output, predefined_cavity_settings, optimisation_algorithm_kwargs=None, history_kwargs=None, predefined_simulation_output=None, **kwargs)[source]
Instantiate a fake algorithm bypassing optimization.
- Parameters:
compensating_elements (
Collection[TypeVar(FieldMap)]) – Tunable elements performing compensation.objective_factory (
ObjectiveFactory) – Objects holdingObjectivecreation logic.design_space (
DesignSpace) – HoldsVariable,Constraint.compute_beam_propagation (
Callable[[Mapping[FieldMap,CavitySettings]],SimulationOutput]) – Takes in aSetOfCavitySettings, propages the beam in a version ofeltsthat uses them, and produce aSimulationOutput.cavity_settings_factory (
CavitySettingsFactory) – An object that can createSetOfCavitySettingseasily.reference_simulation_output (
SimulationOutput) – The reference simulation output on the reference accelerator.predefined_cavity_settings (
SetOfCavitySettings) – The solution to use directly.optimisation_algorithm_kwargs (
dict[str,Any] |None, default:None) – Additional kwargs for algorithm, set by user in the configurationTOML.history_kwargs (
dict[str,Any] |None, default:None) – If given, records in a file the different evaluations of residuals during optimization.predefined_simulation_output (
SimulationOutput|None, default:None) – If provided, residuals are computed from this output rather than re-running beam propagation. Useful when you already have the associated simulation results.
- Return type:
None
- _generate_opti_sol()[source]
Build sol from predefined settings, computing beam only if needed.
- Return type:
- _abc_impl = <_abc._abc_data object at 0x7318f8d5f2c0>