optimisation.objective.minimize_difference_with_ref module
This module holds a simple objective.
It is a simple difference over a given quantity between the reference linac and the linac under tuning.
- class MinimizeDifferenceWithRef(name: str, weight: float, get_key: str, get_kwargs: dict[str, Element | str | bool], reference: SimulationOutput, descriptor: str | None = None)
Bases:
Objective
A simple difference at a given point between ref and fix.
- __init__(name: str, weight: float, get_key: str, get_kwargs: dict[str, Element | str | bool], reference: SimulationOutput, descriptor: str | None = None) None
Set complementary
get()
flags, reference value.- Parameters:
get_key (str) – Name of the quantity to get, which must be an attribute of
SimulationOutput
.get_kwargs (dict[str, Element | str | bool]) – Keyword arguments for the
get()
method. We do not check its validity, but in general you will want to define the keyselt
andpos
. If objective concerns a phase, you may want to precise theto_deg
key. You also should explicit theto_numpy
key.reference (SimulationOutput) – The reference simulation output from which the ideal value will be taken.
- _abc_impl = <_abc._abc_data object>
- _base_str() str
Return a base text for output.
- _check_ideal_value() None
Assert the the reference value is a float.
- _compute_residues(value: float) float
Compute the residues.
- _value_getter(simulation_output: SimulationOutput) float
Get desired value using
SimulationOutput.get()
method.
- current_value(simulation_output: SimulationOutput) str
Give value of current objective and residue.
- evaluate(simulation_output: SimulationOutput) float
Compute residue of this objective.
- Parameters:
simulation_output (SimulationOutput | float) – Object containing simulation results of the broken linac.
- Returns:
residue – Difference between current evaluation and ideal_value value for
self.name
, scaled byself.weight
.- Return type:
float