minimize_difference_with_ref module

Define a simple optimization objective.

It is a simple difference over a given quantity between the reference linac and the linac under tuning.

class MinimizeDifferenceWithRef(name, weight, get_key, get_kwargs, reference, descriptor=None)[source]

Bases: Objective

A simple difference at a given point between ref and fix.

Parameters:
__init__(name, weight, get_key, get_kwargs, reference, descriptor=None)[source]

Set complementary SimulationOutput.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 SimulationOutput.get() method. We do not check its validity, but in general you will want to define the keys elt and pos. If objective concerns a phase, you may want to precise the to_deg key. You also should explicit the to_numpy key.

  • reference (SimulationOutput) – The reference simulation output from which the ideal value will be taken.

  • name (str)

  • weight (float)

  • descriptor (str | None, default: None)

base_str()[source]

Tell nature and position of objective.

Return type:

str

__str__()[source]

Give objective information value.

Return type:

str

_value_getter(simulation_output)[source]

Get desired value using SimulationOutput.get() method.

Parameters:

simulation_output (SimulationOutput)

Return type:

float

_check_ideal_value()[source]

Assert the the reference value is a float.

Return type:

None

evaluate(simulation_output)[source]

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 by self.weight.

Return type:

float

_compute_residues(value)[source]

Compute the residues.

Parameters:

value (float)

Return type:

float

_abc_impl = <_abc._abc_data object at 0x73dca7c83880>