culebra.fitness_function.svc_optimization.C class

class C(index: int | None = None)

Bases: SVCScorer

Construct the fitness function.

Parameters:

index (int) – Index of this objective when it is used for multi-objective fitness functions, optional

Raises:

Class methods

classmethod C.load(filename: str) Base

Load a serialized object from a file.

Parameters:

filename (str) – The file name.

Returns:

The loaded object

Raises:

Properties

property C.fitness_cls: type[Fitness]

Fitness class.

Return type:

type[Fitness]

property C.index: int

Objective index.

Return type:

int

Setter:

Set a new index

Parameters:

value (int) – The new index. If set to None, _default_index is chosen

Raises:
property C.num_obj: int

Number of objectives.

Return type:

int

property C.obj_names: tuple[str, ...]

Objective names.

Returns:

(“C”,)

Return type:

tuple[str]

property C.obj_thresholds: list[float]

Objective similarity thresholds.

Return type:

list[float]

Setter:

Set new thresholds.

Parameters:

values (float | Sequence[float]) – The new values. If only a single value is provided, the same threshold will be used for all the objectives. Different thresholds can be provided in a Sequence. If set to None, all the thresholds are set to _default_similarity_threshold

Raises:
  • TypeError – If neither a real number nor a Sequence of real numbers is provided

  • ValueError – If any value is negative

  • ValueError – If the length of the thresholds sequence does not match the number of objectives

property C.obj_weights: tuple[int, ...]

Objective weights.

Minimize C.

Returns:

(-1, )

Return type:

tuple[int]

Private properties

property C._default_index: int

Default index.

Returns:

DEFAULT_INDEX

Return type:

int

property C._default_similarity_threshold: float

Default similarity threshold for fitnesses.

Returns:

DEFAULT_SIMILARITY_THRESHOLD

Return type:

float

Methods

C.dump(filename: str) None

Serialize this object and save it to a file.

Parameters:

filename (str) – The file name.

Raises:
C.evaluate(sol: Solution, index: int | None = None, representatives: Sequence[Solution] | None = None) Fitness

Evaluate a solution.

Parameters:
  • sol (Solution) – Solution to be evaluated.

  • index (int) – Index where sol should be inserted in the representatives sequence to form a complete solution for the problem. Only used by cooperative problems

  • representatives (Sequence[Solution]) – Representative solutions of each species being optimized. Only used by cooperative problems

Returns:

The fitness for sol

Return type:

Fitness

Raises:

ValueError – If sol is not evaluable

C.is_evaluable(sol: Solution) bool

Assess the evaluability of a solution.

Parameters:

sol (Solution) – Solution to be evaluated.

Returns:

True if the solution can be evaluated

Return type:

bool

Raises:

NotImplementedError – If has not been overridden