objective module
Define a class to hold optimisation objective with its ideal value.
- class Objective(name, weight, descriptor=None, ideal_value=None)[source]
Bases:
ABCHold 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.descriptor (
str|None, default:None) – A longer string to explain the objective.ideal_value (
Any|None, default:None) – The ideal value or range of values that we should tend to.
- abstract evaluate(simulation_output)[source]
Compute residuals of this objective.
- Parameters:
simulation_output (
SimulationOutput) – Object containing simulation results of the broken linac.- Return type:
- Returns:
Difference between current evaluation and
ideal_valuevalue forself.name, scaled byself.weight.
- _compute_residuals(*args, **kwargs)[source]
Compute residual (loss), for a given value.
In general, you will want to call this function from
Objective.evaluate().- 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.
- __init__(name, weight, descriptor=None, ideal_value=None)
- _abc_impl = <_abc._abc_data object at 0x75e5156ac980>