objective module

Define a class to hold optimisation objective with its ideal value.

class Objective(name: str, weight: float, descriptor: str | None = None, ideal_value: tuple[float, float] | float | None = None)

Bases: ABC

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.

  • descriptor (str | None, optional) – A longer string to explain the objective. The default is None.

  • ideal_value (float | tuple[float], optional) – The ideal value or range of values that we should tend to.

name: str
weight: float
descriptor: str | None = None
ideal_value: tuple[float, float] | float | None = None
__post_init__() None

Avoid line jumps in the descriptor.

abstract __str__() str

Output info on what is this objective about.

abstract base_str() str

Tell nature and position of objective.

static str_header() str

Give a header to explain what __str__() returns.

abstract evaluate(simulation_output: SimulationOutput | float) 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 by self.weight.

Return type:

float

__init__(name: str, weight: float, descriptor: str | None = None, ideal_value: tuple[float, float] | float | None = None) None
_abc_impl = <_abc._abc_data object at 0x7f36f784e880>