objective module
Define a class to hold optimisation objective with its ideal value.
- DEFAULT_ELT_KEY = 'all'
Default value of
eltfromget_kwargs. Corresponds to evaluation on all the elements. But you may prefer set them manually.
- class Objective(name, weight, get_key, get_kwargs, ideal_value, descriptor=None)[source]
Bases:
ABCHold an objective and methods to evaluate it.
Todo
Should this object also store its final value?
- Parameters:
name (
str)weight (
float)get_key (
Literal['acceptance_energy','acceptance_phi','beam_parameters','element_to_index','elt_idx','mismatch_factor_zdelta','phi_s','set_of_cavity_settings','synch_trajectory','v_cav_mv','z_abs'] |Literal['alpha_phiw','beta_phiw','envelope_energy_phiw','envelope_pos_phiw','eps_phiw','eps_no_normalization_phiw','eps_normalized_phiw','gamma_phiw','sigma_phiw','twiss_phiw','alpha_phiw99','beta_phiw99','envelope_energy_phiw99','envelope_pos_phiw99','eps_phiw99','eps_no_normalization_phiw99','eps_normalized_phiw99','gamma_phiw99','sigma_phiw99','twiss_phiw99','alpha_t','beta_t','envelope_energy_t','envelope_pos_t','eps_t','eps_no_normalization_t','eps_normalized_t','gamma_t','sigma_t','twiss_t','alpha_x','beta_x','envelope_energy_x','envelope_pos_x','eps_x','eps_no_normalization_x','eps_normalized_x','gamma_x','sigma_x','twiss_x','alpha_x99','beta_x99','envelope_energy_x99','envelope_pos_x99','eps_x99','eps_no_normalization_x99','eps_normalized_x99','gamma_x99','sigma_x99','twiss_x99','alpha_y','beta_y','envelope_energy_y','envelope_pos_y','eps_y','eps_no_normalization_y','eps_normalized_y','gamma_y','sigma_y','twiss_y','alpha_y99','beta_y99','envelope_energy_y99','envelope_pos_y99','eps_y99','eps_no_normalization_y99','eps_normalized_y99','gamma_y99','sigma_y99','twiss_y99','alpha_z','beta_z','envelope_energy_z','envelope_pos_z','eps_z','eps_no_normalization_z','eps_normalized_z','gamma_z','sigma_z','twiss_z','alpha_zdelta','beta_zdelta','envelope_energy_zdelta','envelope_pos_zdelta','eps_zdelta','eps_no_normalization_zdelta','eps_normalized_zdelta','gamma_zdelta','sigma_zdelta','twiss_zdelta'] |Literal['alpha','beta','beta_kin','envelope_energy','envelope_pos','eps','eps_no_normalization','eps_normalized','gamma','gamma_kin','sigma','twiss','z_abs'] |Literal['phiw','phiw99','t','x','x99','y','y99','z','zdelta'] |Literal['beta','gamma','phi_abs','synchronous','w_kin','z_in'] |Literal['e_mev','e_rest_mev','f_bunch_mhz','i_milli_a','q_adim','sigma','inv_e_rest_mev','gamma_init','omega_0_bunch','lambda_bunch','q_over_m','m_over_q'] |Literal['cumulated','individual','n_points','r_xx','r_yy','r_zdelta','r_zz','r_zdelta_11','r_zdelta_12','r_zdelta_21','r_zdelta_22'] |Literal['eps_t','eps_x','eps_y','mismatch_factor_t','mismatch_factor_x','mismatch_factor_y'] |Literal['eps_phiw99','eps_x99','eps_y99','pow_lost'])
- _gettable: Collection[str] = ( 'acceptance_energy', 'acceptance_phi', 'beam_parameters', 'element_to_index', 'elt_idx', 'mismatch_factor_zdelta', 'phi_s', 'set_of_cavity_settings', 'synch_trajectory', 'v_cav_mv', 'z_abs', 'alpha_phiw', 'beta_phiw', 'envelope_energy_phiw', 'envelope_pos_phiw', 'eps_phiw', 'eps_no_normalization_phiw', 'eps_normalized_phiw', 'gamma_phiw', 'sigma_phiw', 'twiss_phiw', 'alpha_phiw99', 'beta_phiw99', 'envelope_energy_phiw99', 'envelope_pos_phiw99', 'eps_phiw99', 'eps_no_normalization_phiw99', 'eps_normalized_phiw99', 'gamma_phiw99', 'sigma_phiw99', 'twiss_phiw99', 'alpha_t', 'beta_t', 'envelope_energy_t', 'envelope_pos_t', 'eps_t', 'eps_no_normalization_t', 'eps_normalized_t', 'gamma_t', 'sigma_t', 'twiss_t', 'alpha_x', 'beta_x', 'envelope_energy_x', 'envelope_pos_x', 'eps_x', 'eps_no_normalization_x', 'eps_normalized_x', 'gamma_x', 'sigma_x', 'twiss_x', 'alpha_x99', 'beta_x99', 'envelope_energy_x99', 'envelope_pos_x99', 'eps_x99', 'eps_no_normalization_x99', 'eps_normalized_x99', 'gamma_x99', 'sigma_x99', 'twiss_x99', 'alpha_y', 'beta_y', 'envelope_energy_y', 'envelope_pos_y', 'eps_y', 'eps_no_normalization_y', 'eps_normalized_y', 'gamma_y', 'sigma_y', 'twiss_y', 'alpha_y99', 'beta_y99', 'envelope_energy_y99', 'envelope_pos_y99', 'eps_y99', 'eps_no_normalization_y99', 'eps_normalized_y99', 'gamma_y99', 'sigma_y99', 'twiss_y99', 'alpha_z', 'beta_z', 'envelope_energy_z', 'envelope_pos_z', 'eps_z', 'eps_no_normalization_z', 'eps_normalized_z', 'gamma_z', 'sigma_z', 'twiss_z', 'alpha_zdelta', 'beta_zdelta', 'envelope_energy_zdelta', 'envelope_pos_zdelta', 'eps_zdelta', 'eps_no_normalization_zdelta', 'eps_normalized_zdelta', 'gamma_zdelta', 'sigma_zdelta', 'twiss_zdelta', 'alpha', 'beta', 'beta_kin', 'envelope_energy', 'envelope_pos', 'eps', 'eps_no_normalization', 'eps_normalized', 'gamma', 'gamma_kin', 'sigma', 'twiss', 'z_abs', 'phiw', 'phiw99', 't', 'x', 'x99', 'y', 'y99', 'z', 'zdelta', 'beta', 'gamma', 'phi_abs', 'synchronous', 'w_kin', 'z_in', 'e_mev', 'e_rest_mev', 'f_bunch_mhz', 'i_milli_a', 'q_adim', 'sigma', 'inv_e_rest_mev', 'gamma_init', 'omega_0_bunch', 'lambda_bunch', 'q_over_m', 'm_over_q', 'cumulated', 'individual', 'n_points', 'r_xx', 'r_yy', 'r_zdelta', 'r_zdelta_11', 'r_zdelta_12', 'r_zdelta_21', 'r_zdelta_22', 'r_zz', 'eps_t', 'eps_x', 'eps_y', 'mismatch_factor_t', 'mismatch_factor_x', 'mismatch_factor_y', 'eps_phiw99', 'eps_x99', 'eps_y99', 'pow_lost')
List of authorized values for the
get_key. Checked by the_check_get_arguments()method
- _advised_get_kwargs: set[str] = {'elt', 'pos', 'to_numpy'}
get_kwargs that should raise a warning if they are not present.
- __init__(name, weight, get_key, get_kwargs, ideal_value, descriptor=None)[source]
Hold an objective and methods to evaluate it.
- Parameters:
name (
str) – A short string to describe the objective and access to it.weight (
float) – A scaling constant to set the weight of current objective.get_key (
Literal['acceptance_energy','acceptance_phi','beam_parameters','element_to_index','elt_idx','mismatch_factor_zdelta','phi_s','set_of_cavity_settings','synch_trajectory','v_cav_mv','z_abs'] |Literal['alpha_phiw','beta_phiw','envelope_energy_phiw','envelope_pos_phiw','eps_phiw','eps_no_normalization_phiw','eps_normalized_phiw','gamma_phiw','sigma_phiw','twiss_phiw','alpha_phiw99','beta_phiw99','envelope_energy_phiw99','envelope_pos_phiw99','eps_phiw99','eps_no_normalization_phiw99','eps_normalized_phiw99','gamma_phiw99','sigma_phiw99','twiss_phiw99','alpha_t','beta_t','envelope_energy_t','envelope_pos_t','eps_t','eps_no_normalization_t','eps_normalized_t','gamma_t','sigma_t','twiss_t','alpha_x','beta_x','envelope_energy_x','envelope_pos_x','eps_x','eps_no_normalization_x','eps_normalized_x','gamma_x','sigma_x','twiss_x','alpha_x99','beta_x99','envelope_energy_x99','envelope_pos_x99','eps_x99','eps_no_normalization_x99','eps_normalized_x99','gamma_x99','sigma_x99','twiss_x99','alpha_y','beta_y','envelope_energy_y','envelope_pos_y','eps_y','eps_no_normalization_y','eps_normalized_y','gamma_y','sigma_y','twiss_y','alpha_y99','beta_y99','envelope_energy_y99','envelope_pos_y99','eps_y99','eps_no_normalization_y99','eps_normalized_y99','gamma_y99','sigma_y99','twiss_y99','alpha_z','beta_z','envelope_energy_z','envelope_pos_z','eps_z','eps_no_normalization_z','eps_normalized_z','gamma_z','sigma_z','twiss_z','alpha_zdelta','beta_zdelta','envelope_energy_zdelta','envelope_pos_zdelta','eps_zdelta','eps_no_normalization_zdelta','eps_normalized_zdelta','gamma_zdelta','sigma_zdelta','twiss_zdelta'] |Literal['alpha','beta','beta_kin','envelope_energy','envelope_pos','eps','eps_no_normalization','eps_normalized','gamma','gamma_kin','sigma','twiss','z_abs'] |Literal['phiw','phiw99','t','x','x99','y','y99','z','zdelta'] |Literal['beta','gamma','phi_abs','synchronous','w_kin','z_in'] |Literal['e_mev','e_rest_mev','f_bunch_mhz','i_milli_a','q_adim','sigma','inv_e_rest_mev','gamma_init','omega_0_bunch','lambda_bunch','q_over_m','m_over_q'] |Literal['cumulated','individual','n_points','r_xx','r_yy','r_zdelta','r_zz','r_zdelta_11','r_zdelta_12','r_zdelta_21','r_zdelta_22'] |Literal['eps_t','eps_x','eps_y','mismatch_factor_t','mismatch_factor_x','mismatch_factor_y'] |Literal['eps_phiw99','eps_x99','eps_y99','pow_lost']) – Name of the quantity to get.get_kwargs (
dict[str,Any]) – Keyword arguments for theSimulationOutput.get()method. We do not enforce its validity, but in general you will want to define the keyseltandpos. If objective concerns a phase, you may want to precise theto_degkey. You also should explicit theto_numpykey.ideal_value (
float|tuple[float,float] |None) –Ideal value to match.
It is a float when we want to be as close as possible of a value.
It is a tuple of floats when we want to be within two bounds.
It is not defined (
None) when we want to minimize or maximize an objective.
descriptor (
str|None, default:None) – A longer string to explain the objective.
- Return type:
None
- ideal_value: Any
Ideal value to match.
It is a float when we want to be as close as possible of a value.
It is a tuple of floats when we want to be within two bounds.
It is not defined (
None) when we want to minimize or maximize an objective.
- get_key: Literal['acceptance_energy', 'acceptance_phi', 'beam_parameters', 'element_to_index', 'elt_idx', 'mismatch_factor_zdelta', 'phi_s', 'set_of_cavity_settings', 'synch_trajectory', 'v_cav_mv', 'z_abs', 'alpha_phiw', 'beta_phiw', 'envelope_energy_phiw', 'envelope_pos_phiw', 'eps_phiw', 'eps_no_normalization_phiw', 'eps_normalized_phiw', 'gamma_phiw', 'sigma_phiw', 'twiss_phiw', 'alpha_phiw99', 'beta_phiw99', 'envelope_energy_phiw99', 'envelope_pos_phiw99', 'eps_phiw99', 'eps_no_normalization_phiw99', 'eps_normalized_phiw99', 'gamma_phiw99', 'sigma_phiw99', 'twiss_phiw99', 'alpha_t', 'beta_t', 'envelope_energy_t', 'envelope_pos_t', 'eps_t', 'eps_no_normalization_t', 'eps_normalized_t', 'gamma_t', 'sigma_t', 'twiss_t', 'alpha_x', 'beta_x', 'envelope_energy_x', 'envelope_pos_x', 'eps_x', 'eps_no_normalization_x', 'eps_normalized_x', 'gamma_x', 'sigma_x', 'twiss_x', 'alpha_x99', 'beta_x99', 'envelope_energy_x99', 'envelope_pos_x99', 'eps_x99', 'eps_no_normalization_x99', 'eps_normalized_x99', 'gamma_x99', 'sigma_x99', 'twiss_x99', 'alpha_y', 'beta_y', 'envelope_energy_y', 'envelope_pos_y', 'eps_y', 'eps_no_normalization_y', 'eps_normalized_y', 'gamma_y', 'sigma_y', 'twiss_y', 'alpha_y99', 'beta_y99', 'envelope_energy_y99', 'envelope_pos_y99', 'eps_y99', 'eps_no_normalization_y99', 'eps_normalized_y99', 'gamma_y99', 'sigma_y99', 'twiss_y99', 'alpha_z', 'beta_z', 'envelope_energy_z', 'envelope_pos_z', 'eps_z', 'eps_no_normalization_z', 'eps_normalized_z', 'gamma_z', 'sigma_z', 'twiss_z', 'alpha_zdelta', 'beta_zdelta', 'envelope_energy_zdelta', 'envelope_pos_zdelta', 'eps_zdelta', 'eps_no_normalization_zdelta', 'eps_normalized_zdelta', 'gamma_zdelta', 'sigma_zdelta', 'twiss_zdelta', 'alpha', 'beta', 'beta_kin', 'envelope_energy', 'envelope_pos', 'eps', 'eps_no_normalization', 'eps_normalized', 'gamma', 'gamma_kin', 'sigma', 'twiss', 'phiw', 'phiw99', 't', 'x', 'x99', 'y', 'y99', 'z', 'zdelta', 'phi_abs', 'synchronous', 'w_kin', 'z_in', 'e_mev', 'e_rest_mev', 'f_bunch_mhz', 'i_milli_a', 'q_adim', 'inv_e_rest_mev', 'gamma_init', 'omega_0_bunch', 'lambda_bunch', 'q_over_m', 'm_over_q', 'cumulated', 'individual', 'n_points', 'r_xx', 'r_yy', 'r_zdelta', 'r_zz', 'r_zdelta_11', 'r_zdelta_12', 'r_zdelta_21', 'r_zdelta_22', 'mismatch_factor_t', 'mismatch_factor_x', 'mismatch_factor_y', 'pow_lost']
Name of the quantity to get from
SimulationOutput,
- get_kwargs: dict[str, Any]
Keyword arguments for the
SimulationOutput.get()method.
- _value_getter(simulation_output, handle_missing_elt=False)[source]
Get desired value using
SimulationOutput.get()method.See also
- Parameters:
simulation_output (
SimulationOutput) – Object togetself.get_keyfrom.handle_missing_elt (
bool, default:False) – Automatically look for an equivalentElementwhen the current one is not inSimulationOutput. Set it toTruewhen calculating reference value (referenceElementis not in compensating list of elements).
- Return type:
- _check_get_arguments(get_key, get_kwargs)[source]
Check validity of
get_args,get_kwargs.In general, residuals evaluation relies on a
SimulationOutput.get()method. This method usesget_argsandget_kwargs; we perform here some basic checks.- Parameters:
get_key (
Literal['acceptance_energy','acceptance_phi','beam_parameters','element_to_index','elt_idx','mismatch_factor_zdelta','phi_s','set_of_cavity_settings','synch_trajectory','v_cav_mv','z_abs'] |Literal['alpha_phiw','beta_phiw','envelope_energy_phiw','envelope_pos_phiw','eps_phiw','eps_no_normalization_phiw','eps_normalized_phiw','gamma_phiw','sigma_phiw','twiss_phiw','alpha_phiw99','beta_phiw99','envelope_energy_phiw99','envelope_pos_phiw99','eps_phiw99','eps_no_normalization_phiw99','eps_normalized_phiw99','gamma_phiw99','sigma_phiw99','twiss_phiw99','alpha_t','beta_t','envelope_energy_t','envelope_pos_t','eps_t','eps_no_normalization_t','eps_normalized_t','gamma_t','sigma_t','twiss_t','alpha_x','beta_x','envelope_energy_x','envelope_pos_x','eps_x','eps_no_normalization_x','eps_normalized_x','gamma_x','sigma_x','twiss_x','alpha_x99','beta_x99','envelope_energy_x99','envelope_pos_x99','eps_x99','eps_no_normalization_x99','eps_normalized_x99','gamma_x99','sigma_x99','twiss_x99','alpha_y','beta_y','envelope_energy_y','envelope_pos_y','eps_y','eps_no_normalization_y','eps_normalized_y','gamma_y','sigma_y','twiss_y','alpha_y99','beta_y99','envelope_energy_y99','envelope_pos_y99','eps_y99','eps_no_normalization_y99','eps_normalized_y99','gamma_y99','sigma_y99','twiss_y99','alpha_z','beta_z','envelope_energy_z','envelope_pos_z','eps_z','eps_no_normalization_z','eps_normalized_z','gamma_z','sigma_z','twiss_z','alpha_zdelta','beta_zdelta','envelope_energy_zdelta','envelope_pos_zdelta','eps_zdelta','eps_no_normalization_zdelta','eps_normalized_zdelta','gamma_zdelta','sigma_zdelta','twiss_zdelta'] |Literal['alpha','beta','beta_kin','envelope_energy','envelope_pos','eps','eps_no_normalization','eps_normalized','gamma','gamma_kin','sigma','twiss','z_abs'] |Literal['phiw','phiw99','t','x','x99','y','y99','z','zdelta'] |Literal['beta','gamma','phi_abs','synchronous','w_kin','z_in'] |Literal['e_mev','e_rest_mev','f_bunch_mhz','i_milli_a','q_adim','sigma','inv_e_rest_mev','gamma_init','omega_0_bunch','lambda_bunch','q_over_m','m_over_q'] |Literal['cumulated','individual','n_points','r_xx','r_yy','r_zdelta','r_zz','r_zdelta_11','r_zdelta_12','r_zdelta_21','r_zdelta_22'] |Literal['eps_t','eps_x','eps_y','mismatch_factor_t','mismatch_factor_x','mismatch_factor_y'] |Literal['eps_phiw99','eps_x99','eps_y99','pow_lost'])
- Return type:
tuple[Literal['acceptance_energy','acceptance_phi','beam_parameters','element_to_index','elt_idx','mismatch_factor_zdelta','phi_s','set_of_cavity_settings','synch_trajectory','v_cav_mv','z_abs'] |Literal['alpha_phiw','beta_phiw','envelope_energy_phiw','envelope_pos_phiw','eps_phiw','eps_no_normalization_phiw','eps_normalized_phiw','gamma_phiw','sigma_phiw','twiss_phiw','alpha_phiw99','beta_phiw99','envelope_energy_phiw99','envelope_pos_phiw99','eps_phiw99','eps_no_normalization_phiw99','eps_normalized_phiw99','gamma_phiw99','sigma_phiw99','twiss_phiw99','alpha_t','beta_t','envelope_energy_t','envelope_pos_t','eps_t','eps_no_normalization_t','eps_normalized_t','gamma_t','sigma_t','twiss_t','alpha_x','beta_x','envelope_energy_x','envelope_pos_x','eps_x','eps_no_normalization_x','eps_normalized_x','gamma_x','sigma_x','twiss_x','alpha_x99','beta_x99','envelope_energy_x99','envelope_pos_x99','eps_x99','eps_no_normalization_x99','eps_normalized_x99','gamma_x99','sigma_x99','twiss_x99','alpha_y','beta_y','envelope_energy_y','envelope_pos_y','eps_y','eps_no_normalization_y','eps_normalized_y','gamma_y','sigma_y','twiss_y','alpha_y99','beta_y99','envelope_energy_y99','envelope_pos_y99','eps_y99','eps_no_normalization_y99','eps_normalized_y99','gamma_y99','sigma_y99','twiss_y99','alpha_z','beta_z','envelope_energy_z','envelope_pos_z','eps_z','eps_no_normalization_z','eps_normalized_z','gamma_z','sigma_z','twiss_z','alpha_zdelta','beta_zdelta','envelope_energy_zdelta','envelope_pos_zdelta','eps_zdelta','eps_no_normalization_zdelta','eps_normalized_zdelta','gamma_zdelta','sigma_zdelta','twiss_zdelta'] |Literal['alpha','beta','beta_kin','envelope_energy','envelope_pos','eps','eps_no_normalization','eps_normalized','gamma','gamma_kin','sigma','twiss','z_abs'] |Literal['phiw','phiw99','t','x','x99','y','y99','z','zdelta'] |Literal['beta','gamma','phi_abs','synchronous','w_kin','z_in'] |Literal['e_mev','e_rest_mev','f_bunch_mhz','i_milli_a','q_adim','sigma','inv_e_rest_mev','gamma_init','omega_0_bunch','lambda_bunch','q_over_m','m_over_q'] |Literal['cumulated','individual','n_points','r_xx','r_yy','r_zdelta','r_zz','r_zdelta_11','r_zdelta_12','r_zdelta_21','r_zdelta_22'] |Literal['eps_t','eps_x','eps_y','mismatch_factor_t','mismatch_factor_x','mismatch_factor_y'] |Literal['eps_phiw99','eps_x99','eps_y99','pow_lost'],dict[str,Any]]
- static str_header_solved()[source]
Give a header to explain, after optimization, what is printed.
- Return type:
- abstractmethod _compute_residuals(objective_value)[source]
Compute residual (loss), ie what we want to minimize.
In general, you will want to call this function from
Objective.evaluate().- Parameters:
objective_value (
Any) – Value ofObjective.name, taken from aSimulationOutput.- Return type:
- Returns:
residual for current objective, scaled by
Objective.weight.
- evaluate(simulation_output)[source]
Get desired value from
simulation_outputand compute residuals.- Parameters:
simulation_output (
SimulationOutput) – Object containing simulation results of the broken linac.- Return type:
- Returns:
Residual for current objective, scaled by
Objective.weight.
- _abc_impl = <_abc._abc_data object at 0x7318f90cf740>
- class MinimizeDifferenceWithRef(name, weight, get_key, get_kwargs, reference, descriptor=None)[source]
Bases:
ObjectiveA simple difference at a given point between ref and fix.
- Parameters:
name (
str)weight (
float)get_key (
Literal['acceptance_energy','acceptance_phi','beam_parameters','element_to_index','elt_idx','mismatch_factor_zdelta','phi_s','set_of_cavity_settings','synch_trajectory','v_cav_mv','z_abs'] |Literal['alpha_phiw','beta_phiw','envelope_energy_phiw','envelope_pos_phiw','eps_phiw','eps_no_normalization_phiw','eps_normalized_phiw','gamma_phiw','sigma_phiw','twiss_phiw','alpha_phiw99','beta_phiw99','envelope_energy_phiw99','envelope_pos_phiw99','eps_phiw99','eps_no_normalization_phiw99','eps_normalized_phiw99','gamma_phiw99','sigma_phiw99','twiss_phiw99','alpha_t','beta_t','envelope_energy_t','envelope_pos_t','eps_t','eps_no_normalization_t','eps_normalized_t','gamma_t','sigma_t','twiss_t','alpha_x','beta_x','envelope_energy_x','envelope_pos_x','eps_x','eps_no_normalization_x','eps_normalized_x','gamma_x','sigma_x','twiss_x','alpha_x99','beta_x99','envelope_energy_x99','envelope_pos_x99','eps_x99','eps_no_normalization_x99','eps_normalized_x99','gamma_x99','sigma_x99','twiss_x99','alpha_y','beta_y','envelope_energy_y','envelope_pos_y','eps_y','eps_no_normalization_y','eps_normalized_y','gamma_y','sigma_y','twiss_y','alpha_y99','beta_y99','envelope_energy_y99','envelope_pos_y99','eps_y99','eps_no_normalization_y99','eps_normalized_y99','gamma_y99','sigma_y99','twiss_y99','alpha_z','beta_z','envelope_energy_z','envelope_pos_z','eps_z','eps_no_normalization_z','eps_normalized_z','gamma_z','sigma_z','twiss_z','alpha_zdelta','beta_zdelta','envelope_energy_zdelta','envelope_pos_zdelta','eps_zdelta','eps_no_normalization_zdelta','eps_normalized_zdelta','gamma_zdelta','sigma_zdelta','twiss_zdelta'] |Literal['alpha','beta','beta_kin','envelope_energy','envelope_pos','eps','eps_no_normalization','eps_normalized','gamma','gamma_kin','sigma','twiss','z_abs'] |Literal['phiw','phiw99','t','x','x99','y','y99','z','zdelta'] |Literal['beta','gamma','phi_abs','synchronous','w_kin','z_in'] |Literal['e_mev','e_rest_mev','f_bunch_mhz','i_milli_a','q_adim','sigma','inv_e_rest_mev','gamma_init','omega_0_bunch','lambda_bunch','q_over_m','m_over_q'] |Literal['cumulated','individual','n_points','r_xx','r_yy','r_zdelta','r_zz','r_zdelta_11','r_zdelta_12','r_zdelta_21','r_zdelta_22'] |Literal['eps_t','eps_x','eps_y','mismatch_factor_t','mismatch_factor_x','mismatch_factor_y'] |Literal['eps_phiw99','eps_x99','eps_y99','pow_lost'])reference (
SimulationOutput)
- __init__(name, weight, get_key, get_kwargs, reference, descriptor=None)[source]
Set complementary
SimulationOutput.get()flags, reference value.- Parameters:
name (
str) – A short string to describe the objective and access to it.weight (
float) – A scaling constant to set the weight of current objective.get_key (
Literal['acceptance_energy','acceptance_phi','beam_parameters','element_to_index','elt_idx','mismatch_factor_zdelta','phi_s','set_of_cavity_settings','synch_trajectory','v_cav_mv','z_abs'] |Literal['alpha_phiw','beta_phiw','envelope_energy_phiw','envelope_pos_phiw','eps_phiw','eps_no_normalization_phiw','eps_normalized_phiw','gamma_phiw','sigma_phiw','twiss_phiw','alpha_phiw99','beta_phiw99','envelope_energy_phiw99','envelope_pos_phiw99','eps_phiw99','eps_no_normalization_phiw99','eps_normalized_phiw99','gamma_phiw99','sigma_phiw99','twiss_phiw99','alpha_t','beta_t','envelope_energy_t','envelope_pos_t','eps_t','eps_no_normalization_t','eps_normalized_t','gamma_t','sigma_t','twiss_t','alpha_x','beta_x','envelope_energy_x','envelope_pos_x','eps_x','eps_no_normalization_x','eps_normalized_x','gamma_x','sigma_x','twiss_x','alpha_x99','beta_x99','envelope_energy_x99','envelope_pos_x99','eps_x99','eps_no_normalization_x99','eps_normalized_x99','gamma_x99','sigma_x99','twiss_x99','alpha_y','beta_y','envelope_energy_y','envelope_pos_y','eps_y','eps_no_normalization_y','eps_normalized_y','gamma_y','sigma_y','twiss_y','alpha_y99','beta_y99','envelope_energy_y99','envelope_pos_y99','eps_y99','eps_no_normalization_y99','eps_normalized_y99','gamma_y99','sigma_y99','twiss_y99','alpha_z','beta_z','envelope_energy_z','envelope_pos_z','eps_z','eps_no_normalization_z','eps_normalized_z','gamma_z','sigma_z','twiss_z','alpha_zdelta','beta_zdelta','envelope_energy_zdelta','envelope_pos_zdelta','eps_zdelta','eps_no_normalization_zdelta','eps_normalized_zdelta','gamma_zdelta','sigma_zdelta','twiss_zdelta'] |Literal['alpha','beta','beta_kin','envelope_energy','envelope_pos','eps','eps_no_normalization','eps_normalized','gamma','gamma_kin','sigma','twiss','z_abs'] |Literal['phiw','phiw99','t','x','x99','y','y99','z','zdelta'] |Literal['beta','gamma','phi_abs','synchronous','w_kin','z_in'] |Literal['e_mev','e_rest_mev','f_bunch_mhz','i_milli_a','q_adim','sigma','inv_e_rest_mev','gamma_init','omega_0_bunch','lambda_bunch','q_over_m','m_over_q'] |Literal['cumulated','individual','n_points','r_xx','r_yy','r_zdelta','r_zz','r_zdelta_11','r_zdelta_12','r_zdelta_21','r_zdelta_22'] |Literal['eps_t','eps_x','eps_y','mismatch_factor_t','mismatch_factor_x','mismatch_factor_y'] |Literal['eps_phiw99','eps_x99','eps_y99','pow_lost']) – Name of the quantity to get.get_kwargs (
dict[str,Any]) – Keyword arguments for theSimulationOutput.get()method. We do not check its validity, but in general you will want to define the keyseltandpos. If objective concerns a phase, you may want to precise theto_degkey. You also should explicit theto_numpykey.reference (
SimulationOutput) – The reference simulation output from which the ideal value will be taken.descriptor (
str|None, default:None) – A longer string to explain the objective.
- Return type:
None
- _compute_residuals(objective_value)[source]
Compute residual (loss), ie what we want to minimize.
In general, you will want to call this function from
Objective.evaluate().- Parameters:
objective_value (
float) – Value ofObjective.name, taken from aSimulationOutput.- Return type:
- Returns:
residual for current objective, scaled by
Objective.weight.
- _abc_impl = <_abc._abc_data object at 0x7318fae92740>
- class MinimizeMismatch(name, weight, get_key, get_kwargs, reference, descriptor=None)[source]
Bases:
ObjectiveMinimize a mismatch factor.
- Parameters:
name (
str)weight (
float)get_key (
Literal['alpha_phiw','beta_phiw','envelope_energy_phiw','envelope_pos_phiw','eps_phiw','eps_no_normalization_phiw','eps_normalized_phiw','gamma_phiw','sigma_phiw','twiss_phiw','alpha_phiw99','beta_phiw99','envelope_energy_phiw99','envelope_pos_phiw99','eps_phiw99','eps_no_normalization_phiw99','eps_normalized_phiw99','gamma_phiw99','sigma_phiw99','twiss_phiw99','alpha_t','beta_t','envelope_energy_t','envelope_pos_t','eps_t','eps_no_normalization_t','eps_normalized_t','gamma_t','sigma_t','twiss_t','alpha_x','beta_x','envelope_energy_x','envelope_pos_x','eps_x','eps_no_normalization_x','eps_normalized_x','gamma_x','sigma_x','twiss_x','alpha_x99','beta_x99','envelope_energy_x99','envelope_pos_x99','eps_x99','eps_no_normalization_x99','eps_normalized_x99','gamma_x99','sigma_x99','twiss_x99','alpha_y','beta_y','envelope_energy_y','envelope_pos_y','eps_y','eps_no_normalization_y','eps_normalized_y','gamma_y','sigma_y','twiss_y','alpha_y99','beta_y99','envelope_energy_y99','envelope_pos_y99','eps_y99','eps_no_normalization_y99','eps_normalized_y99','gamma_y99','sigma_y99','twiss_y99','alpha_z','beta_z','envelope_energy_z','envelope_pos_z','eps_z','eps_no_normalization_z','eps_normalized_z','gamma_z','sigma_z','twiss_z','alpha_zdelta','beta_zdelta','envelope_energy_zdelta','envelope_pos_zdelta','eps_zdelta','eps_no_normalization_zdelta','eps_normalized_zdelta','gamma_zdelta','sigma_zdelta','twiss_zdelta'] |Literal['alpha','beta','beta_kin','envelope_energy','envelope_pos','eps','eps_no_normalization','eps_normalized','gamma','gamma_kin','sigma','twiss','z_abs'] |Literal['phiw','phiw99','t','x','x99','y','y99','z','zdelta'])reference (
SimulationOutput)
- _gettable: Collection[str] = ( 'alpha_phiw', 'beta_phiw', 'envelope_energy_phiw', 'envelope_pos_phiw', 'eps_phiw', 'eps_no_normalization_phiw', 'eps_normalized_phiw', 'gamma_phiw', 'sigma_phiw', 'twiss_phiw', 'alpha_phiw99', 'beta_phiw99', 'envelope_energy_phiw99', 'envelope_pos_phiw99', 'eps_phiw99', 'eps_no_normalization_phiw99', 'eps_normalized_phiw99', 'gamma_phiw99', 'sigma_phiw99', 'twiss_phiw99', 'alpha_t', 'beta_t', 'envelope_energy_t', 'envelope_pos_t', 'eps_t', 'eps_no_normalization_t', 'eps_normalized_t', 'gamma_t', 'sigma_t', 'twiss_t', 'alpha_x', 'beta_x', 'envelope_energy_x', 'envelope_pos_x', 'eps_x', 'eps_no_normalization_x', 'eps_normalized_x', 'gamma_x', 'sigma_x', 'twiss_x', 'alpha_x99', 'beta_x99', 'envelope_energy_x99', 'envelope_pos_x99', 'eps_x99', 'eps_no_normalization_x99', 'eps_normalized_x99', 'gamma_x99', 'sigma_x99', 'twiss_x99', 'alpha_y', 'beta_y', 'envelope_energy_y', 'envelope_pos_y', 'eps_y', 'eps_no_normalization_y', 'eps_normalized_y', 'gamma_y', 'sigma_y', 'twiss_y', 'alpha_y99', 'beta_y99', 'envelope_energy_y99', 'envelope_pos_y99', 'eps_y99', 'eps_no_normalization_y99', 'eps_normalized_y99', 'gamma_y99', 'sigma_y99', 'twiss_y99', 'alpha_z', 'beta_z', 'envelope_energy_z', 'envelope_pos_z', 'eps_z', 'eps_no_normalization_z', 'eps_normalized_z', 'gamma_z', 'sigma_z', 'twiss_z', 'alpha_zdelta', 'beta_zdelta', 'envelope_energy_zdelta', 'envelope_pos_zdelta', 'eps_zdelta', 'eps_no_normalization_zdelta', 'eps_normalized_zdelta', 'gamma_zdelta', 'sigma_zdelta', 'twiss_zdelta', 'alpha', 'beta', 'beta_kin', 'envelope_energy', 'envelope_pos', 'eps', 'eps_no_normalization', 'eps_normalized', 'gamma', 'gamma_kin', 'sigma', 'twiss', 'z_abs', 'phiw', 'phiw99', 't', 'x', 'x99', 'y', 'y99', 'z', 'zdelta')
List of authorized values for the
get_key. Checked by the_check_get_arguments()method
- __init__(name, weight, get_key, get_kwargs, reference, descriptor=None)[source]
Set complementary
SimulationOutput.get()flags, reference value.- Parameters:
name (
str) – A short string to describe the objective and access to it.weight (
float) – A scaling constant to set the weight of current objective.get_key (
Literal['alpha_phiw','beta_phiw','envelope_energy_phiw','envelope_pos_phiw','eps_phiw','eps_no_normalization_phiw','eps_normalized_phiw','gamma_phiw','sigma_phiw','twiss_phiw','alpha_phiw99','beta_phiw99','envelope_energy_phiw99','envelope_pos_phiw99','eps_phiw99','eps_no_normalization_phiw99','eps_normalized_phiw99','gamma_phiw99','sigma_phiw99','twiss_phiw99','alpha_t','beta_t','envelope_energy_t','envelope_pos_t','eps_t','eps_no_normalization_t','eps_normalized_t','gamma_t','sigma_t','twiss_t','alpha_x','beta_x','envelope_energy_x','envelope_pos_x','eps_x','eps_no_normalization_x','eps_normalized_x','gamma_x','sigma_x','twiss_x','alpha_x99','beta_x99','envelope_energy_x99','envelope_pos_x99','eps_x99','eps_no_normalization_x99','eps_normalized_x99','gamma_x99','sigma_x99','twiss_x99','alpha_y','beta_y','envelope_energy_y','envelope_pos_y','eps_y','eps_no_normalization_y','eps_normalized_y','gamma_y','sigma_y','twiss_y','alpha_y99','beta_y99','envelope_energy_y99','envelope_pos_y99','eps_y99','eps_no_normalization_y99','eps_normalized_y99','gamma_y99','sigma_y99','twiss_y99','alpha_z','beta_z','envelope_energy_z','envelope_pos_z','eps_z','eps_no_normalization_z','eps_normalized_z','gamma_z','sigma_z','twiss_z','alpha_zdelta','beta_zdelta','envelope_energy_zdelta','envelope_pos_zdelta','eps_zdelta','eps_no_normalization_zdelta','eps_normalized_zdelta','gamma_zdelta','sigma_zdelta','twiss_zdelta'] |Literal['alpha','beta','beta_kin','envelope_energy','envelope_pos','eps','eps_no_normalization','eps_normalized','gamma','gamma_kin','sigma','twiss','z_abs'] |Literal['phiw','phiw99','t','x','x99','y','y99','z','zdelta']) – Must contain ‘twiss’ plus the name of a phase-space, or simply ‘twiss’ and the phase-space is defined inget_kwargs.get_kwargs (
dict[str,Any]) – Keyword arguments for theSimulationOutput.get()method. We do not check its validity, but in general you will want to define the keyseltandpos. You should also define thephase_space_namekey if it is not defined in theget_key.reference (
SimulationOutput) – The reference simulation output from which the Twiss parameters will be taken.descriptor (
str|None, default:None) – A longer string to explain the objective.
- Return type:
None
- _check_get_arguments(get_key, get_kwargs)[source]
Add default values if necessary.
- Parameters:
get_key (
Literal['acceptance_energy','acceptance_phi','beam_parameters','element_to_index','elt_idx','mismatch_factor_zdelta','phi_s','set_of_cavity_settings','synch_trajectory','v_cav_mv','z_abs'] |Literal['alpha_phiw','beta_phiw','envelope_energy_phiw','envelope_pos_phiw','eps_phiw','eps_no_normalization_phiw','eps_normalized_phiw','gamma_phiw','sigma_phiw','twiss_phiw','alpha_phiw99','beta_phiw99','envelope_energy_phiw99','envelope_pos_phiw99','eps_phiw99','eps_no_normalization_phiw99','eps_normalized_phiw99','gamma_phiw99','sigma_phiw99','twiss_phiw99','alpha_t','beta_t','envelope_energy_t','envelope_pos_t','eps_t','eps_no_normalization_t','eps_normalized_t','gamma_t','sigma_t','twiss_t','alpha_x','beta_x','envelope_energy_x','envelope_pos_x','eps_x','eps_no_normalization_x','eps_normalized_x','gamma_x','sigma_x','twiss_x','alpha_x99','beta_x99','envelope_energy_x99','envelope_pos_x99','eps_x99','eps_no_normalization_x99','eps_normalized_x99','gamma_x99','sigma_x99','twiss_x99','alpha_y','beta_y','envelope_energy_y','envelope_pos_y','eps_y','eps_no_normalization_y','eps_normalized_y','gamma_y','sigma_y','twiss_y','alpha_y99','beta_y99','envelope_energy_y99','envelope_pos_y99','eps_y99','eps_no_normalization_y99','eps_normalized_y99','gamma_y99','sigma_y99','twiss_y99','alpha_z','beta_z','envelope_energy_z','envelope_pos_z','eps_z','eps_no_normalization_z','eps_normalized_z','gamma_z','sigma_z','twiss_z','alpha_zdelta','beta_zdelta','envelope_energy_zdelta','envelope_pos_zdelta','eps_zdelta','eps_no_normalization_zdelta','eps_normalized_zdelta','gamma_zdelta','sigma_zdelta','twiss_zdelta'] |Literal['alpha','beta','beta_kin','envelope_energy','envelope_pos','eps','eps_no_normalization','eps_normalized','gamma','gamma_kin','sigma','twiss','z_abs'] |Literal['phiw','phiw99','t','x','x99','y','y99','z','zdelta'] |Literal['beta','gamma','phi_abs','synchronous','w_kin','z_in'] |Literal['e_mev','e_rest_mev','f_bunch_mhz','i_milli_a','q_adim','sigma','inv_e_rest_mev','gamma_init','omega_0_bunch','lambda_bunch','q_over_m','m_over_q'] |Literal['cumulated','individual','n_points','r_xx','r_yy','r_zdelta','r_zz','r_zdelta_11','r_zdelta_12','r_zdelta_21','r_zdelta_22'] |Literal['eps_t','eps_x','eps_y','mismatch_factor_t','mismatch_factor_x','mismatch_factor_y'] |Literal['eps_phiw99','eps_x99','eps_y99','pow_lost'])
- Return type:
tuple[Literal['acceptance_energy','acceptance_phi','beam_parameters','element_to_index','elt_idx','mismatch_factor_zdelta','phi_s','set_of_cavity_settings','synch_trajectory','v_cav_mv','z_abs'] |Literal['alpha_phiw','beta_phiw','envelope_energy_phiw','envelope_pos_phiw','eps_phiw','eps_no_normalization_phiw','eps_normalized_phiw','gamma_phiw','sigma_phiw','twiss_phiw','alpha_phiw99','beta_phiw99','envelope_energy_phiw99','envelope_pos_phiw99','eps_phiw99','eps_no_normalization_phiw99','eps_normalized_phiw99','gamma_phiw99','sigma_phiw99','twiss_phiw99','alpha_t','beta_t','envelope_energy_t','envelope_pos_t','eps_t','eps_no_normalization_t','eps_normalized_t','gamma_t','sigma_t','twiss_t','alpha_x','beta_x','envelope_energy_x','envelope_pos_x','eps_x','eps_no_normalization_x','eps_normalized_x','gamma_x','sigma_x','twiss_x','alpha_x99','beta_x99','envelope_energy_x99','envelope_pos_x99','eps_x99','eps_no_normalization_x99','eps_normalized_x99','gamma_x99','sigma_x99','twiss_x99','alpha_y','beta_y','envelope_energy_y','envelope_pos_y','eps_y','eps_no_normalization_y','eps_normalized_y','gamma_y','sigma_y','twiss_y','alpha_y99','beta_y99','envelope_energy_y99','envelope_pos_y99','eps_y99','eps_no_normalization_y99','eps_normalized_y99','gamma_y99','sigma_y99','twiss_y99','alpha_z','beta_z','envelope_energy_z','envelope_pos_z','eps_z','eps_no_normalization_z','eps_normalized_z','gamma_z','sigma_z','twiss_z','alpha_zdelta','beta_zdelta','envelope_energy_zdelta','envelope_pos_zdelta','eps_zdelta','eps_no_normalization_zdelta','eps_normalized_zdelta','gamma_zdelta','sigma_zdelta','twiss_zdelta'] |Literal['alpha','beta','beta_kin','envelope_energy','envelope_pos','eps','eps_no_normalization','eps_normalized','gamma','gamma_kin','sigma','twiss','z_abs'] |Literal['phiw','phiw99','t','x','x99','y','y99','z','zdelta'] |Literal['beta','gamma','phi_abs','synchronous','w_kin','z_in'] |Literal['e_mev','e_rest_mev','f_bunch_mhz','i_milli_a','q_adim','sigma','inv_e_rest_mev','gamma_init','omega_0_bunch','lambda_bunch','q_over_m','m_over_q'] |Literal['cumulated','individual','n_points','r_xx','r_yy','r_zdelta','r_zz','r_zdelta_11','r_zdelta_12','r_zdelta_21','r_zdelta_22'] |Literal['eps_t','eps_x','eps_y','mismatch_factor_t','mismatch_factor_x','mismatch_factor_y'] |Literal['eps_phiw99','eps_x99','eps_y99','pow_lost'],dict[str,Any]]
- _twiss_getter(simulation_output)[source]
Get desired value using
SimulationOutput.get()method.
- evaluate(simulation_output)[source]
Get desired value from
simulation_outputand compute residuals.- Parameters:
simulation_output (
SimulationOutput) – Object containing simulation results of the broken linac.- Return type:
- Returns:
Residual for current objective, scaled by
Objective.weight.
- _compute_residuals(objective_value)[source]
Compute residual (loss), ie what we want to minimize.
In general, you will want to call this function from
Objective.evaluate().- Parameters:
objective_value (
ndarray[tuple[Any,...],dtype[TypeVar(_ScalarT, bound=generic)]]) – Value ofObjective.name, taken from aSimulationOutput.- Return type:
- Returns:
residual for current objective, scaled by
Objective.weight.
- _abc_impl = <_abc._abc_data object at 0x7318f90cf7c0>
- class MinimizeVariation(name, weight, get_key, get_kwargs, descriptor=None, **kwargs)[source]
Bases:
ObjectiveQuantity must be the same.
We can compare a quantity:
at a specific location, eg compare floats at the exit of every lattice.
Todo
Also implement quantity comparison:
on full lattices, eg compare arrays on complete lattices.
This
Objectivewas designed to penalize important quantity variations, while slow variations are fine. It was thought to be utilized with envelopes, where regularity is a relatable objective.- Parameters:
name (
str)weight (
float)get_key (
Literal['acceptance_energy','acceptance_phi','beam_parameters','element_to_index','elt_idx','mismatch_factor_zdelta','phi_s','set_of_cavity_settings','synch_trajectory','v_cav_mv','z_abs'] |Literal['alpha_phiw','beta_phiw','envelope_energy_phiw','envelope_pos_phiw','eps_phiw','eps_no_normalization_phiw','eps_normalized_phiw','gamma_phiw','sigma_phiw','twiss_phiw','alpha_phiw99','beta_phiw99','envelope_energy_phiw99','envelope_pos_phiw99','eps_phiw99','eps_no_normalization_phiw99','eps_normalized_phiw99','gamma_phiw99','sigma_phiw99','twiss_phiw99','alpha_t','beta_t','envelope_energy_t','envelope_pos_t','eps_t','eps_no_normalization_t','eps_normalized_t','gamma_t','sigma_t','twiss_t','alpha_x','beta_x','envelope_energy_x','envelope_pos_x','eps_x','eps_no_normalization_x','eps_normalized_x','gamma_x','sigma_x','twiss_x','alpha_x99','beta_x99','envelope_energy_x99','envelope_pos_x99','eps_x99','eps_no_normalization_x99','eps_normalized_x99','gamma_x99','sigma_x99','twiss_x99','alpha_y','beta_y','envelope_energy_y','envelope_pos_y','eps_y','eps_no_normalization_y','eps_normalized_y','gamma_y','sigma_y','twiss_y','alpha_y99','beta_y99','envelope_energy_y99','envelope_pos_y99','eps_y99','eps_no_normalization_y99','eps_normalized_y99','gamma_y99','sigma_y99','twiss_y99','alpha_z','beta_z','envelope_energy_z','envelope_pos_z','eps_z','eps_no_normalization_z','eps_normalized_z','gamma_z','sigma_z','twiss_z','alpha_zdelta','beta_zdelta','envelope_energy_zdelta','envelope_pos_zdelta','eps_zdelta','eps_no_normalization_zdelta','eps_normalized_zdelta','gamma_zdelta','sigma_zdelta','twiss_zdelta'] |Literal['alpha','beta','beta_kin','envelope_energy','envelope_pos','eps','eps_no_normalization','eps_normalized','gamma','gamma_kin','sigma','twiss','z_abs'] |Literal['phiw','phiw99','t','x','x99','y','y99','z','zdelta'] |Literal['beta','gamma','phi_abs','synchronous','w_kin','z_in'] |Literal['e_mev','e_rest_mev','f_bunch_mhz','i_milli_a','q_adim','sigma','inv_e_rest_mev','gamma_init','omega_0_bunch','lambda_bunch','q_over_m','m_over_q'] |Literal['cumulated','individual','n_points','r_xx','r_yy','r_zdelta','r_zz','r_zdelta_11','r_zdelta_12','r_zdelta_21','r_zdelta_22'] |Literal['eps_t','eps_x','eps_y','mismatch_factor_t','mismatch_factor_x','mismatch_factor_y'] |Literal['eps_phiw99','eps_x99','eps_y99','pow_lost'])
- __init__(name, weight, get_key, get_kwargs, descriptor=None, **kwargs)[source]
Set complementary
SimulationOutput.get()flags, reference value.Note
You should double check that the
eltand theposkey-value pairs inget_kwargsare regular. Example: the exit of every lattice.Todo
Clarify these docstrings.
- Parameters:
name (
str) – A short string to describe the objective and access to it.weight (
float) – A scaling constant to set the weight of current objective.get_key (
Literal['acceptance_energy','acceptance_phi','beam_parameters','element_to_index','elt_idx','mismatch_factor_zdelta','phi_s','set_of_cavity_settings','synch_trajectory','v_cav_mv','z_abs'] |Literal['alpha_phiw','beta_phiw','envelope_energy_phiw','envelope_pos_phiw','eps_phiw','eps_no_normalization_phiw','eps_normalized_phiw','gamma_phiw','sigma_phiw','twiss_phiw','alpha_phiw99','beta_phiw99','envelope_energy_phiw99','envelope_pos_phiw99','eps_phiw99','eps_no_normalization_phiw99','eps_normalized_phiw99','gamma_phiw99','sigma_phiw99','twiss_phiw99','alpha_t','beta_t','envelope_energy_t','envelope_pos_t','eps_t','eps_no_normalization_t','eps_normalized_t','gamma_t','sigma_t','twiss_t','alpha_x','beta_x','envelope_energy_x','envelope_pos_x','eps_x','eps_no_normalization_x','eps_normalized_x','gamma_x','sigma_x','twiss_x','alpha_x99','beta_x99','envelope_energy_x99','envelope_pos_x99','eps_x99','eps_no_normalization_x99','eps_normalized_x99','gamma_x99','sigma_x99','twiss_x99','alpha_y','beta_y','envelope_energy_y','envelope_pos_y','eps_y','eps_no_normalization_y','eps_normalized_y','gamma_y','sigma_y','twiss_y','alpha_y99','beta_y99','envelope_energy_y99','envelope_pos_y99','eps_y99','eps_no_normalization_y99','eps_normalized_y99','gamma_y99','sigma_y99','twiss_y99','alpha_z','beta_z','envelope_energy_z','envelope_pos_z','eps_z','eps_no_normalization_z','eps_normalized_z','gamma_z','sigma_z','twiss_z','alpha_zdelta','beta_zdelta','envelope_energy_zdelta','envelope_pos_zdelta','eps_zdelta','eps_no_normalization_zdelta','eps_normalized_zdelta','gamma_zdelta','sigma_zdelta','twiss_zdelta'] |Literal['alpha','beta','beta_kin','envelope_energy','envelope_pos','eps','eps_no_normalization','eps_normalized','gamma','gamma_kin','sigma','twiss','z_abs'] |Literal['phiw','phiw99','t','x','x99','y','y99','z','zdelta'] |Literal['beta','gamma','phi_abs','synchronous','w_kin','z_in'] |Literal['e_mev','e_rest_mev','f_bunch_mhz','i_milli_a','q_adim','sigma','inv_e_rest_mev','gamma_init','omega_0_bunch','lambda_bunch','q_over_m','m_over_q'] |Literal['cumulated','individual','n_points','r_xx','r_yy','r_zdelta','r_zz','r_zdelta_11','r_zdelta_12','r_zdelta_21','r_zdelta_22'] |Literal['eps_t','eps_x','eps_y','mismatch_factor_t','mismatch_factor_x','mismatch_factor_y'] |Literal['eps_phiw99','eps_x99','eps_y99','pow_lost']) – Name of the quantity to get.get_kwargs (
dict[str,Any]) – Keyword arguments for theSimulationOutput.get()method. We do not check its validity, but in general you will want to define the keyseltandpos. If objective concerns a phase, you may want to precise theto_degkey. You also should explicit theto_numpykey.descriptor (
str|None, default:None) – A longer string to explain the objective.kwargs – Other keyword arguments. Note that
referencemay be passed but will not be used.
- Return type:
None
- _check_get_arguments(get_key, get_kwargs, advised_keys=['to_numpy'])[source]
Check validity of
get_args,get_kwargs.In general, residuals evaluation relies on a
SimulationOutput.get()method. This method usesget_argsandget_kwargs; we perform here some basic checks.We raise errors instead of warnings of the keys
"elt"and"pos"are missing.- Parameters:
get_key (
Literal['acceptance_energy','acceptance_phi','beam_parameters','element_to_index','elt_idx','mismatch_factor_zdelta','phi_s','set_of_cavity_settings','synch_trajectory','v_cav_mv','z_abs'] |Literal['alpha_phiw','beta_phiw','envelope_energy_phiw','envelope_pos_phiw','eps_phiw','eps_no_normalization_phiw','eps_normalized_phiw','gamma_phiw','sigma_phiw','twiss_phiw','alpha_phiw99','beta_phiw99','envelope_energy_phiw99','envelope_pos_phiw99','eps_phiw99','eps_no_normalization_phiw99','eps_normalized_phiw99','gamma_phiw99','sigma_phiw99','twiss_phiw99','alpha_t','beta_t','envelope_energy_t','envelope_pos_t','eps_t','eps_no_normalization_t','eps_normalized_t','gamma_t','sigma_t','twiss_t','alpha_x','beta_x','envelope_energy_x','envelope_pos_x','eps_x','eps_no_normalization_x','eps_normalized_x','gamma_x','sigma_x','twiss_x','alpha_x99','beta_x99','envelope_energy_x99','envelope_pos_x99','eps_x99','eps_no_normalization_x99','eps_normalized_x99','gamma_x99','sigma_x99','twiss_x99','alpha_y','beta_y','envelope_energy_y','envelope_pos_y','eps_y','eps_no_normalization_y','eps_normalized_y','gamma_y','sigma_y','twiss_y','alpha_y99','beta_y99','envelope_energy_y99','envelope_pos_y99','eps_y99','eps_no_normalization_y99','eps_normalized_y99','gamma_y99','sigma_y99','twiss_y99','alpha_z','beta_z','envelope_energy_z','envelope_pos_z','eps_z','eps_no_normalization_z','eps_normalized_z','gamma_z','sigma_z','twiss_z','alpha_zdelta','beta_zdelta','envelope_energy_zdelta','envelope_pos_zdelta','eps_zdelta','eps_no_normalization_zdelta','eps_normalized_zdelta','gamma_zdelta','sigma_zdelta','twiss_zdelta'] |Literal['alpha','beta','beta_kin','envelope_energy','envelope_pos','eps','eps_no_normalization','eps_normalized','gamma','gamma_kin','sigma','twiss','z_abs'] |Literal['phiw','phiw99','t','x','x99','y','y99','z','zdelta'] |Literal['beta','gamma','phi_abs','synchronous','w_kin','z_in'] |Literal['e_mev','e_rest_mev','f_bunch_mhz','i_milli_a','q_adim','sigma','inv_e_rest_mev','gamma_init','omega_0_bunch','lambda_bunch','q_over_m','m_over_q'] |Literal['cumulated','individual','n_points','r_xx','r_yy','r_zdelta','r_zz','r_zdelta_11','r_zdelta_12','r_zdelta_21','r_zdelta_22'] |Literal['eps_t','eps_x','eps_y','mismatch_factor_t','mismatch_factor_x','mismatch_factor_y'] |Literal['eps_phiw99','eps_x99','eps_y99','pow_lost'])
- Return type:
tuple[Literal['acceptance_energy','acceptance_phi','beam_parameters','element_to_index','elt_idx','mismatch_factor_zdelta','phi_s','set_of_cavity_settings','synch_trajectory','v_cav_mv','z_abs'] |Literal['alpha_phiw','beta_phiw','envelope_energy_phiw','envelope_pos_phiw','eps_phiw','eps_no_normalization_phiw','eps_normalized_phiw','gamma_phiw','sigma_phiw','twiss_phiw','alpha_phiw99','beta_phiw99','envelope_energy_phiw99','envelope_pos_phiw99','eps_phiw99','eps_no_normalization_phiw99','eps_normalized_phiw99','gamma_phiw99','sigma_phiw99','twiss_phiw99','alpha_t','beta_t','envelope_energy_t','envelope_pos_t','eps_t','eps_no_normalization_t','eps_normalized_t','gamma_t','sigma_t','twiss_t','alpha_x','beta_x','envelope_energy_x','envelope_pos_x','eps_x','eps_no_normalization_x','eps_normalized_x','gamma_x','sigma_x','twiss_x','alpha_x99','beta_x99','envelope_energy_x99','envelope_pos_x99','eps_x99','eps_no_normalization_x99','eps_normalized_x99','gamma_x99','sigma_x99','twiss_x99','alpha_y','beta_y','envelope_energy_y','envelope_pos_y','eps_y','eps_no_normalization_y','eps_normalized_y','gamma_y','sigma_y','twiss_y','alpha_y99','beta_y99','envelope_energy_y99','envelope_pos_y99','eps_y99','eps_no_normalization_y99','eps_normalized_y99','gamma_y99','sigma_y99','twiss_y99','alpha_z','beta_z','envelope_energy_z','envelope_pos_z','eps_z','eps_no_normalization_z','eps_normalized_z','gamma_z','sigma_z','twiss_z','alpha_zdelta','beta_zdelta','envelope_energy_zdelta','envelope_pos_zdelta','eps_zdelta','eps_no_normalization_zdelta','eps_normalized_zdelta','gamma_zdelta','sigma_zdelta','twiss_zdelta'] |Literal['alpha','beta','beta_kin','envelope_energy','envelope_pos','eps','eps_no_normalization','eps_normalized','gamma','gamma_kin','sigma','twiss','z_abs'] |Literal['phiw','phiw99','t','x','x99','y','y99','z','zdelta'] |Literal['beta','gamma','phi_abs','synchronous','w_kin','z_in'] |Literal['e_mev','e_rest_mev','f_bunch_mhz','i_milli_a','q_adim','sigma','inv_e_rest_mev','gamma_init','omega_0_bunch','lambda_bunch','q_over_m','m_over_q'] |Literal['cumulated','individual','n_points','r_xx','r_yy','r_zdelta','r_zz','r_zdelta_11','r_zdelta_12','r_zdelta_21','r_zdelta_22'] |Literal['eps_t','eps_x','eps_y','mismatch_factor_t','mismatch_factor_x','mismatch_factor_y'] |Literal['eps_phiw99','eps_x99','eps_y99','pow_lost'],dict[str,Any]]
- _abc_impl = <_abc._abc_data object at 0x7318f9a6f600>
- class QuantityIsBetween(name, weight, get_key, get_kwargs, limits, descriptor=None, loss_function=None)[source]
Bases:
ObjectiveQuantity must be within some bounds.
- Parameters:
name (
str)weight (
float)get_key (
Literal['acceptance_energy','acceptance_phi','beam_parameters','element_to_index','elt_idx','mismatch_factor_zdelta','phi_s','set_of_cavity_settings','synch_trajectory','v_cav_mv','z_abs'] |Literal['alpha_phiw','beta_phiw','envelope_energy_phiw','envelope_pos_phiw','eps_phiw','eps_no_normalization_phiw','eps_normalized_phiw','gamma_phiw','sigma_phiw','twiss_phiw','alpha_phiw99','beta_phiw99','envelope_energy_phiw99','envelope_pos_phiw99','eps_phiw99','eps_no_normalization_phiw99','eps_normalized_phiw99','gamma_phiw99','sigma_phiw99','twiss_phiw99','alpha_t','beta_t','envelope_energy_t','envelope_pos_t','eps_t','eps_no_normalization_t','eps_normalized_t','gamma_t','sigma_t','twiss_t','alpha_x','beta_x','envelope_energy_x','envelope_pos_x','eps_x','eps_no_normalization_x','eps_normalized_x','gamma_x','sigma_x','twiss_x','alpha_x99','beta_x99','envelope_energy_x99','envelope_pos_x99','eps_x99','eps_no_normalization_x99','eps_normalized_x99','gamma_x99','sigma_x99','twiss_x99','alpha_y','beta_y','envelope_energy_y','envelope_pos_y','eps_y','eps_no_normalization_y','eps_normalized_y','gamma_y','sigma_y','twiss_y','alpha_y99','beta_y99','envelope_energy_y99','envelope_pos_y99','eps_y99','eps_no_normalization_y99','eps_normalized_y99','gamma_y99','sigma_y99','twiss_y99','alpha_z','beta_z','envelope_energy_z','envelope_pos_z','eps_z','eps_no_normalization_z','eps_normalized_z','gamma_z','sigma_z','twiss_z','alpha_zdelta','beta_zdelta','envelope_energy_zdelta','envelope_pos_zdelta','eps_zdelta','eps_no_normalization_zdelta','eps_normalized_zdelta','gamma_zdelta','sigma_zdelta','twiss_zdelta'] |Literal['alpha','beta','beta_kin','envelope_energy','envelope_pos','eps','eps_no_normalization','eps_normalized','gamma','gamma_kin','sigma','twiss','z_abs'] |Literal['phiw','phiw99','t','x','x99','y','y99','z','zdelta'] |Literal['beta','gamma','phi_abs','synchronous','w_kin','z_in'] |Literal['e_mev','e_rest_mev','f_bunch_mhz','i_milli_a','q_adim','sigma','inv_e_rest_mev','gamma_init','omega_0_bunch','lambda_bunch','q_over_m','m_over_q'] |Literal['cumulated','individual','n_points','r_xx','r_yy','r_zdelta','r_zz','r_zdelta_11','r_zdelta_12','r_zdelta_21','r_zdelta_22'] |Literal['eps_t','eps_x','eps_y','mismatch_factor_t','mismatch_factor_x','mismatch_factor_y'] |Literal['eps_phiw99','eps_x99','eps_y99','pow_lost'])
- __init__(name, weight, get_key, get_kwargs, limits, descriptor=None, loss_function=None)[source]
Set complementary
SimulationOutput.get()flags, reference value.- Parameters:
name (
str) – A short string to describe the objective and access to it.weight (
float) – A scaling constant to set the weight of current objective.get_key (
Literal['acceptance_energy','acceptance_phi','beam_parameters','element_to_index','elt_idx','mismatch_factor_zdelta','phi_s','set_of_cavity_settings','synch_trajectory','v_cav_mv','z_abs'] |Literal['alpha_phiw','beta_phiw','envelope_energy_phiw','envelope_pos_phiw','eps_phiw','eps_no_normalization_phiw','eps_normalized_phiw','gamma_phiw','sigma_phiw','twiss_phiw','alpha_phiw99','beta_phiw99','envelope_energy_phiw99','envelope_pos_phiw99','eps_phiw99','eps_no_normalization_phiw99','eps_normalized_phiw99','gamma_phiw99','sigma_phiw99','twiss_phiw99','alpha_t','beta_t','envelope_energy_t','envelope_pos_t','eps_t','eps_no_normalization_t','eps_normalized_t','gamma_t','sigma_t','twiss_t','alpha_x','beta_x','envelope_energy_x','envelope_pos_x','eps_x','eps_no_normalization_x','eps_normalized_x','gamma_x','sigma_x','twiss_x','alpha_x99','beta_x99','envelope_energy_x99','envelope_pos_x99','eps_x99','eps_no_normalization_x99','eps_normalized_x99','gamma_x99','sigma_x99','twiss_x99','alpha_y','beta_y','envelope_energy_y','envelope_pos_y','eps_y','eps_no_normalization_y','eps_normalized_y','gamma_y','sigma_y','twiss_y','alpha_y99','beta_y99','envelope_energy_y99','envelope_pos_y99','eps_y99','eps_no_normalization_y99','eps_normalized_y99','gamma_y99','sigma_y99','twiss_y99','alpha_z','beta_z','envelope_energy_z','envelope_pos_z','eps_z','eps_no_normalization_z','eps_normalized_z','gamma_z','sigma_z','twiss_z','alpha_zdelta','beta_zdelta','envelope_energy_zdelta','envelope_pos_zdelta','eps_zdelta','eps_no_normalization_zdelta','eps_normalized_zdelta','gamma_zdelta','sigma_zdelta','twiss_zdelta'] |Literal['alpha','beta','beta_kin','envelope_energy','envelope_pos','eps','eps_no_normalization','eps_normalized','gamma','gamma_kin','sigma','twiss','z_abs'] |Literal['phiw','phiw99','t','x','x99','y','y99','z','zdelta'] |Literal['beta','gamma','phi_abs','synchronous','w_kin','z_in'] |Literal['e_mev','e_rest_mev','f_bunch_mhz','i_milli_a','q_adim','sigma','inv_e_rest_mev','gamma_init','omega_0_bunch','lambda_bunch','q_over_m','m_over_q'] |Literal['cumulated','individual','n_points','r_xx','r_yy','r_zdelta','r_zz','r_zdelta_11','r_zdelta_12','r_zdelta_21','r_zdelta_22'] |Literal['eps_t','eps_x','eps_y','mismatch_factor_t','mismatch_factor_x','mismatch_factor_y'] |Literal['eps_phiw99','eps_x99','eps_y99','pow_lost']) – Name of the quantity to get.get_kwargs (
dict[str,Any]) – Keyword arguments for theSimulationOutput.get()method. We do not check its validity, but in general you will want to define the keyseltandpos. If objective concerns a phase, you may want to precise theto_degkey. You also should explicit theto_numpykey.limits (
tuple[float,float]) – Lower and upper bound for the value.loss_function (
str|None, default:None) – Indicates how the residuals are handled when the quantity is outside the limits. Currently not implemented.
- Return type:
None
- classmethod relative_to_reference(name, weight, get_key, get_kwargs, relative_limits, reference_value, descriptor=None, loss_function=None)[source]
Set complementary
SimulationOutput.get()flags, reference value.- Parameters:
name (
str) – A short string to describe the objective and access to it.weight (
float) – A scaling constant to set the weight of current objective.get_key (
Literal['acceptance_energy','acceptance_phi','beam_parameters','element_to_index','elt_idx','mismatch_factor_zdelta','phi_s','set_of_cavity_settings','synch_trajectory','v_cav_mv','z_abs'] |Literal['alpha_phiw','beta_phiw','envelope_energy_phiw','envelope_pos_phiw','eps_phiw','eps_no_normalization_phiw','eps_normalized_phiw','gamma_phiw','sigma_phiw','twiss_phiw','alpha_phiw99','beta_phiw99','envelope_energy_phiw99','envelope_pos_phiw99','eps_phiw99','eps_no_normalization_phiw99','eps_normalized_phiw99','gamma_phiw99','sigma_phiw99','twiss_phiw99','alpha_t','beta_t','envelope_energy_t','envelope_pos_t','eps_t','eps_no_normalization_t','eps_normalized_t','gamma_t','sigma_t','twiss_t','alpha_x','beta_x','envelope_energy_x','envelope_pos_x','eps_x','eps_no_normalization_x','eps_normalized_x','gamma_x','sigma_x','twiss_x','alpha_x99','beta_x99','envelope_energy_x99','envelope_pos_x99','eps_x99','eps_no_normalization_x99','eps_normalized_x99','gamma_x99','sigma_x99','twiss_x99','alpha_y','beta_y','envelope_energy_y','envelope_pos_y','eps_y','eps_no_normalization_y','eps_normalized_y','gamma_y','sigma_y','twiss_y','alpha_y99','beta_y99','envelope_energy_y99','envelope_pos_y99','eps_y99','eps_no_normalization_y99','eps_normalized_y99','gamma_y99','sigma_y99','twiss_y99','alpha_z','beta_z','envelope_energy_z','envelope_pos_z','eps_z','eps_no_normalization_z','eps_normalized_z','gamma_z','sigma_z','twiss_z','alpha_zdelta','beta_zdelta','envelope_energy_zdelta','envelope_pos_zdelta','eps_zdelta','eps_no_normalization_zdelta','eps_normalized_zdelta','gamma_zdelta','sigma_zdelta','twiss_zdelta'] |Literal['alpha','beta','beta_kin','envelope_energy','envelope_pos','eps','eps_no_normalization','eps_normalized','gamma','gamma_kin','sigma','twiss','z_abs'] |Literal['phiw','phiw99','t','x','x99','y','y99','z','zdelta'] |Literal['beta','gamma','phi_abs','synchronous','w_kin','z_in'] |Literal['e_mev','e_rest_mev','f_bunch_mhz','i_milli_a','q_adim','sigma','inv_e_rest_mev','gamma_init','omega_0_bunch','lambda_bunch','q_over_m','m_over_q'] |Literal['cumulated','individual','n_points','r_xx','r_yy','r_zdelta','r_zz','r_zdelta_11','r_zdelta_12','r_zdelta_21','r_zdelta_22'] |Literal['eps_t','eps_x','eps_y','mismatch_factor_t','mismatch_factor_x','mismatch_factor_y'] |Literal['eps_phiw99','eps_x99','eps_y99','pow_lost']) – Name of the quantity to get.get_kwargs (
dict[str,Any]) – Keyword arguments for theSimulationOutput.get()method. We do not check its validity, but in general you will want to define the keyseltandpos. If objective concerns a phase, you may want to precise theto_degkey. You also should explicit theto_numpykey.relative_limits (
tuple[float,float]) – Lower and upper bound for the value, in \(\mathrm{%}\) wrtreference_value. First value should be lower than \(100\%\), second value higher than \(100\%\).reference_value (
float) – Ideal value.loss_function (
str|None, default:None) – Indicates how the residuals are handled when the quantity is outside the limits. Currently not implemented.
- Return type:
Self
- _compute_residuals(objective_value)[source]
Compute residual (loss), ie what we want to minimize.
This method applies a quadratic penalty if the value lies outside the target interval defined by
self.ideal_value. No penalty is applied when the value is within the interval.- Parameters:
objective_value (
float) – Value ofObjective.name, taken from aSimulationOutput.- Return type:
- Returns:
residual for current objective, scaled by
Objective.weight. The loss function is defined as:\(0\) if \(x_l \leq x \leq x_u\), ie if
objective_valueis within the bounds defined byObjective.ideal_value\(w \times (x - x_{l\,u})^2\) otherwise, where \(x_{l,u}\) is the violated boundary and \(w\) is
Objective.weight.
- _abc_impl = <_abc._abc_data object at 0x7318f921b1c0>
- class RemainBelow(name, weight, get_key, get_kwargs, limit, descriptor=None, loss_function=None)[source]
Bases:
ObjectiveMaximum of quantity must remain below some value.
- Parameters:
name (
str)weight (
float)get_key (
Literal['acceptance_energy','acceptance_phi','beam_parameters','element_to_index','elt_idx','mismatch_factor_zdelta','phi_s','set_of_cavity_settings','synch_trajectory','v_cav_mv','z_abs'] |Literal['alpha_phiw','beta_phiw','envelope_energy_phiw','envelope_pos_phiw','eps_phiw','eps_no_normalization_phiw','eps_normalized_phiw','gamma_phiw','sigma_phiw','twiss_phiw','alpha_phiw99','beta_phiw99','envelope_energy_phiw99','envelope_pos_phiw99','eps_phiw99','eps_no_normalization_phiw99','eps_normalized_phiw99','gamma_phiw99','sigma_phiw99','twiss_phiw99','alpha_t','beta_t','envelope_energy_t','envelope_pos_t','eps_t','eps_no_normalization_t','eps_normalized_t','gamma_t','sigma_t','twiss_t','alpha_x','beta_x','envelope_energy_x','envelope_pos_x','eps_x','eps_no_normalization_x','eps_normalized_x','gamma_x','sigma_x','twiss_x','alpha_x99','beta_x99','envelope_energy_x99','envelope_pos_x99','eps_x99','eps_no_normalization_x99','eps_normalized_x99','gamma_x99','sigma_x99','twiss_x99','alpha_y','beta_y','envelope_energy_y','envelope_pos_y','eps_y','eps_no_normalization_y','eps_normalized_y','gamma_y','sigma_y','twiss_y','alpha_y99','beta_y99','envelope_energy_y99','envelope_pos_y99','eps_y99','eps_no_normalization_y99','eps_normalized_y99','gamma_y99','sigma_y99','twiss_y99','alpha_z','beta_z','envelope_energy_z','envelope_pos_z','eps_z','eps_no_normalization_z','eps_normalized_z','gamma_z','sigma_z','twiss_z','alpha_zdelta','beta_zdelta','envelope_energy_zdelta','envelope_pos_zdelta','eps_zdelta','eps_no_normalization_zdelta','eps_normalized_zdelta','gamma_zdelta','sigma_zdelta','twiss_zdelta'] |Literal['alpha','beta','beta_kin','envelope_energy','envelope_pos','eps','eps_no_normalization','eps_normalized','gamma','gamma_kin','sigma','twiss','z_abs'] |Literal['phiw','phiw99','t','x','x99','y','y99','z','zdelta'] |Literal['beta','gamma','phi_abs','synchronous','w_kin','z_in'] |Literal['e_mev','e_rest_mev','f_bunch_mhz','i_milli_a','q_adim','sigma','inv_e_rest_mev','gamma_init','omega_0_bunch','lambda_bunch','q_over_m','m_over_q'] |Literal['cumulated','individual','n_points','r_xx','r_yy','r_zdelta','r_zz','r_zdelta_11','r_zdelta_12','r_zdelta_21','r_zdelta_22'] |Literal['eps_t','eps_x','eps_y','mismatch_factor_t','mismatch_factor_x','mismatch_factor_y'] |Literal['eps_phiw99','eps_x99','eps_y99','pow_lost'])limit (
float)
- _advised_get_kwargs: set[str] = {'elt', 'to_numpy'}
get_kwargs that should raise a warning if they are not present.
- __init__(name, weight, get_key, get_kwargs, limit, descriptor=None, loss_function=None)[source]
Set complementary
SimulationOutput.get()flags, reference value.- Parameters:
name (
str) – A short string to describe the objective and access to it.weight (
float) – A scaling constant to set the weight of current objective.get_key (
Literal['acceptance_energy','acceptance_phi','beam_parameters','element_to_index','elt_idx','mismatch_factor_zdelta','phi_s','set_of_cavity_settings','synch_trajectory','v_cav_mv','z_abs'] |Literal['alpha_phiw','beta_phiw','envelope_energy_phiw','envelope_pos_phiw','eps_phiw','eps_no_normalization_phiw','eps_normalized_phiw','gamma_phiw','sigma_phiw','twiss_phiw','alpha_phiw99','beta_phiw99','envelope_energy_phiw99','envelope_pos_phiw99','eps_phiw99','eps_no_normalization_phiw99','eps_normalized_phiw99','gamma_phiw99','sigma_phiw99','twiss_phiw99','alpha_t','beta_t','envelope_energy_t','envelope_pos_t','eps_t','eps_no_normalization_t','eps_normalized_t','gamma_t','sigma_t','twiss_t','alpha_x','beta_x','envelope_energy_x','envelope_pos_x','eps_x','eps_no_normalization_x','eps_normalized_x','gamma_x','sigma_x','twiss_x','alpha_x99','beta_x99','envelope_energy_x99','envelope_pos_x99','eps_x99','eps_no_normalization_x99','eps_normalized_x99','gamma_x99','sigma_x99','twiss_x99','alpha_y','beta_y','envelope_energy_y','envelope_pos_y','eps_y','eps_no_normalization_y','eps_normalized_y','gamma_y','sigma_y','twiss_y','alpha_y99','beta_y99','envelope_energy_y99','envelope_pos_y99','eps_y99','eps_no_normalization_y99','eps_normalized_y99','gamma_y99','sigma_y99','twiss_y99','alpha_z','beta_z','envelope_energy_z','envelope_pos_z','eps_z','eps_no_normalization_z','eps_normalized_z','gamma_z','sigma_z','twiss_z','alpha_zdelta','beta_zdelta','envelope_energy_zdelta','envelope_pos_zdelta','eps_zdelta','eps_no_normalization_zdelta','eps_normalized_zdelta','gamma_zdelta','sigma_zdelta','twiss_zdelta'] |Literal['alpha','beta','beta_kin','envelope_energy','envelope_pos','eps','eps_no_normalization','eps_normalized','gamma','gamma_kin','sigma','twiss','z_abs'] |Literal['phiw','phiw99','t','x','x99','y','y99','z','zdelta'] |Literal['beta','gamma','phi_abs','synchronous','w_kin','z_in'] |Literal['e_mev','e_rest_mev','f_bunch_mhz','i_milli_a','q_adim','sigma','inv_e_rest_mev','gamma_init','omega_0_bunch','lambda_bunch','q_over_m','m_over_q'] |Literal['cumulated','individual','n_points','r_xx','r_yy','r_zdelta','r_zz','r_zdelta_11','r_zdelta_12','r_zdelta_21','r_zdelta_22'] |Literal['eps_t','eps_x','eps_y','mismatch_factor_t','mismatch_factor_x','mismatch_factor_y'] |Literal['eps_phiw99','eps_x99','eps_y99','pow_lost']) – Name of the quantity to get.get_kwargs (
dict[str,Any]) – Keyword arguments for theSimulationOutput.get()method. We do not check its validity, but in general you will want to define the keyseltandpos. If objective concerns a phase, you may want to precise theto_degkey. You also should explicit theto_numpykey.limit (
float) – Upper bound for the value.loss_function (
str|None, default:None) – Indicates how the residuals are handled when the quantity is outside the limits. Currently not implemented.
- Return type:
None
- _value_getter(simulation_output, handle_missing_elt=False)[source]
Get desired value using
SimulationOutput.get()method.See also
- Parameters:
simulation_output (
SimulationOutput) – Object togetself.get_keyfrom.handle_missing_elt (
bool, default:False) – Automatically look for an equivalentElementwhen the current one is not inSimulationOutput. Set it toTruewhen calculating reference value (referenceElementis not in compensating list of elements).
- Return type:
- _compute_residuals(objective_value)[source]
Compute residual (loss), ie what we want to minimize.
This method applies a quadratic penalty if the value is above the limit .
- Parameters:
objective_value (
float) – Value ofObjective.name, taken from aSimulationOutput.- Return type:
- Returns:
residual for current objective, scaled by
Objective.weight. The loss function is defined as:\(0\) if \(x \leq x_u\), ie if
objective_valueis underObjective.ideal_value\(w \times (x - x_{u})^2\) otherwise, where \(w\) is
Objective.weight.
- _abc_impl = <_abc._abc_data object at 0x7318f921af40>
- class RetrieveArbitrary(name, weight, get_key, get_kwargs, ideal_value, descriptor=None)[source]
Bases:
ObjectiveRetrieve arbitrary value given by user.
You can also use it to minimize or maximize an objective.
- Parameters:
name (
str)weight (
float)get_key (
Literal['acceptance_energy','acceptance_phi','beam_parameters','element_to_index','elt_idx','mismatch_factor_zdelta','phi_s','set_of_cavity_settings','synch_trajectory','v_cav_mv','z_abs'] |Literal['alpha_phiw','beta_phiw','envelope_energy_phiw','envelope_pos_phiw','eps_phiw','eps_no_normalization_phiw','eps_normalized_phiw','gamma_phiw','sigma_phiw','twiss_phiw','alpha_phiw99','beta_phiw99','envelope_energy_phiw99','envelope_pos_phiw99','eps_phiw99','eps_no_normalization_phiw99','eps_normalized_phiw99','gamma_phiw99','sigma_phiw99','twiss_phiw99','alpha_t','beta_t','envelope_energy_t','envelope_pos_t','eps_t','eps_no_normalization_t','eps_normalized_t','gamma_t','sigma_t','twiss_t','alpha_x','beta_x','envelope_energy_x','envelope_pos_x','eps_x','eps_no_normalization_x','eps_normalized_x','gamma_x','sigma_x','twiss_x','alpha_x99','beta_x99','envelope_energy_x99','envelope_pos_x99','eps_x99','eps_no_normalization_x99','eps_normalized_x99','gamma_x99','sigma_x99','twiss_x99','alpha_y','beta_y','envelope_energy_y','envelope_pos_y','eps_y','eps_no_normalization_y','eps_normalized_y','gamma_y','sigma_y','twiss_y','alpha_y99','beta_y99','envelope_energy_y99','envelope_pos_y99','eps_y99','eps_no_normalization_y99','eps_normalized_y99','gamma_y99','sigma_y99','twiss_y99','alpha_z','beta_z','envelope_energy_z','envelope_pos_z','eps_z','eps_no_normalization_z','eps_normalized_z','gamma_z','sigma_z','twiss_z','alpha_zdelta','beta_zdelta','envelope_energy_zdelta','envelope_pos_zdelta','eps_zdelta','eps_no_normalization_zdelta','eps_normalized_zdelta','gamma_zdelta','sigma_zdelta','twiss_zdelta'] |Literal['alpha','beta','beta_kin','envelope_energy','envelope_pos','eps','eps_no_normalization','eps_normalized','gamma','gamma_kin','sigma','twiss','z_abs'] |Literal['phiw','phiw99','t','x','x99','y','y99','z','zdelta'] |Literal['beta','gamma','phi_abs','synchronous','w_kin','z_in'] |Literal['e_mev','e_rest_mev','f_bunch_mhz','i_milli_a','q_adim','sigma','inv_e_rest_mev','gamma_init','omega_0_bunch','lambda_bunch','q_over_m','m_over_q'] |Literal['cumulated','individual','n_points','r_xx','r_yy','r_zdelta','r_zz','r_zdelta_11','r_zdelta_12','r_zdelta_21','r_zdelta_22'] |Literal['eps_t','eps_x','eps_y','mismatch_factor_t','mismatch_factor_x','mismatch_factor_y'] |Literal['eps_phiw99','eps_x99','eps_y99','pow_lost'])ideal_value (
float)
- __init__(name, weight, get_key, get_kwargs, ideal_value, descriptor=None)[source]
Set complementary
SimulationOutput.get()flags, reference value.- Parameters:
name (
str) – A short string to describe the objective and access to it.weight (
float) – A scaling constant to set the weight of current objective.get_key (
Literal['acceptance_energy','acceptance_phi','beam_parameters','element_to_index','elt_idx','mismatch_factor_zdelta','phi_s','set_of_cavity_settings','synch_trajectory','v_cav_mv','z_abs'] |Literal['alpha_phiw','beta_phiw','envelope_energy_phiw','envelope_pos_phiw','eps_phiw','eps_no_normalization_phiw','eps_normalized_phiw','gamma_phiw','sigma_phiw','twiss_phiw','alpha_phiw99','beta_phiw99','envelope_energy_phiw99','envelope_pos_phiw99','eps_phiw99','eps_no_normalization_phiw99','eps_normalized_phiw99','gamma_phiw99','sigma_phiw99','twiss_phiw99','alpha_t','beta_t','envelope_energy_t','envelope_pos_t','eps_t','eps_no_normalization_t','eps_normalized_t','gamma_t','sigma_t','twiss_t','alpha_x','beta_x','envelope_energy_x','envelope_pos_x','eps_x','eps_no_normalization_x','eps_normalized_x','gamma_x','sigma_x','twiss_x','alpha_x99','beta_x99','envelope_energy_x99','envelope_pos_x99','eps_x99','eps_no_normalization_x99','eps_normalized_x99','gamma_x99','sigma_x99','twiss_x99','alpha_y','beta_y','envelope_energy_y','envelope_pos_y','eps_y','eps_no_normalization_y','eps_normalized_y','gamma_y','sigma_y','twiss_y','alpha_y99','beta_y99','envelope_energy_y99','envelope_pos_y99','eps_y99','eps_no_normalization_y99','eps_normalized_y99','gamma_y99','sigma_y99','twiss_y99','alpha_z','beta_z','envelope_energy_z','envelope_pos_z','eps_z','eps_no_normalization_z','eps_normalized_z','gamma_z','sigma_z','twiss_z','alpha_zdelta','beta_zdelta','envelope_energy_zdelta','envelope_pos_zdelta','eps_zdelta','eps_no_normalization_zdelta','eps_normalized_zdelta','gamma_zdelta','sigma_zdelta','twiss_zdelta'] |Literal['alpha','beta','beta_kin','envelope_energy','envelope_pos','eps','eps_no_normalization','eps_normalized','gamma','gamma_kin','sigma','twiss','z_abs'] |Literal['phiw','phiw99','t','x','x99','y','y99','z','zdelta'] |Literal['beta','gamma','phi_abs','synchronous','w_kin','z_in'] |Literal['e_mev','e_rest_mev','f_bunch_mhz','i_milli_a','q_adim','sigma','inv_e_rest_mev','gamma_init','omega_0_bunch','lambda_bunch','q_over_m','m_over_q'] |Literal['cumulated','individual','n_points','r_xx','r_yy','r_zdelta','r_zz','r_zdelta_11','r_zdelta_12','r_zdelta_21','r_zdelta_22'] |Literal['eps_t','eps_x','eps_y','mismatch_factor_t','mismatch_factor_x','mismatch_factor_y'] |Literal['eps_phiw99','eps_x99','eps_y99','pow_lost']) – Name of the quantity to get.get_kwargs (
dict[str,Any]) – Keyword arguments for theSimulationOutput.get()method. We do not check its validity, but in general you will want to define the keyseltandpos. If objective concerns a phase, you may want to precise theto_degkey. You also should explicit theto_numpykey.ideal_value (
float) – The value to retrieve.descriptor (
str|None, default:None) – A longer string to explain the objective.
- Return type:
None
- _compute_residuals(objective_value)[source]
Compute residual (loss), ie what we want to minimize.
In general, you will want to call this function from
Objective.evaluate().- Parameters:
objective_value (
float) – Value ofObjective.name, taken from aSimulationOutput.- Return type:
- Returns:
residual for current objective, scaled by
Objective.weight.
- _abc_impl = <_abc._abc_data object at 0x7318f9219140>