qilisdk.core.parameterizable

Classes

Parameterizable

Mixin for objects that expose tunable parameters and constraints.

Module Contents

class Parameterizable[fuente]

Bases: abc.ABC

Mixin for objects that expose tunable parameters and constraints.

Subclasses can compose parameter interfaces by yielding child Parameterizable instances from _iter_parameter_children().

property nparameters: int[fuente]

Number of tunable parameters defined by the object.

set_prefix(prefix: str, where: collections.abc.Callable[[qilisdk.core.variables.Parameter], bool] | None = None) None[fuente]

Set a prefix on parameter labels.

Parámetros:
  • prefix (str) – Prefix to prepend to selected parameter labels.

  • where (Callable[[Parameter], bool] | None) – Optional predicate selecting local parameters.

Notas

The where predicate is applied to local parameters only. Child parameterizable objects always receive the same prefix operation recursively.

get_prefix() str[fuente]

Return the currently configured parameter prefix for this object.

add_parameter_constraint(constraint: qilisdk.core.variables.ComparisonTerm) None[fuente]

Add a constraint on a single or a set of parameters

Parámetros:

constraint (ComparisonTerm) – The comparison term to specify the constraint. Only Parameter objects are allowed in the constraint.

Muestra:

ValueError – If Generic Variables are present in the constraint.

get_parameter_values(where: collections.abc.Callable[[qilisdk.core.variables.Parameter], bool] | None = None) list[float][fuente]

Return the current numerical values of the parameters.

Parámetros:

where (Callable[[Parameter], bool] | None) – Optional predicate over Parameter objects.

get_parameter_names(where: collections.abc.Callable[[qilisdk.core.variables.Parameter], bool] | None = None) list[str][fuente]

Return the ordered list of parameter labels.

Parámetros:

where (Callable[[Parameter], bool] | None) – Optional predicate over Parameter objects.

get_parameters(where: collections.abc.Callable[[qilisdk.core.variables.Parameter], bool] | None = None) dict[str, qilisdk.core.types.RealNumber][fuente]

Return a mapping from parameter labels to their current numerical values.

Parámetros:

where (Callable[[Parameter], bool] | None) – Optional predicate over Parameter objects.

set_parameter_values(values: list[float], where: collections.abc.Callable[[qilisdk.core.variables.Parameter], bool] | None = None) None[fuente]

Update all parameter values at once.

Parámetros:
  • values (list[float]) – New parameter values ordered consistently with get_parameter_names().

  • where (Callable[[Parameter], bool] | None) – Optional predicate over Parameter objects.

Muestra:

ValueError – If values does not match the number of parameters selected by where.

set_parameters(parameters: dict[str, float]) None[fuente]

Update a subset of parameters by label.

Parámetros:

parameters (dict[str, float]) – Mapping from parameter labels to updated numeric values.

Muestra:

ValueError – If an unknown parameter label is provided or constraints are violated.

get_parameter_bounds(where: collections.abc.Callable[[qilisdk.core.variables.Parameter], bool] | None = None) dict[str, tuple[float, float]][fuente]

Return the (lower, upper) bounds associated with each parameter.

Parámetros:

where (Callable[[Parameter], bool] | None) – Optional predicate over Parameter objects.

set_parameter_bounds(ranges: dict[str, tuple[float, float]]) None[fuente]

Update the allowable ranges for the specified parameters.

Parámetros:

ranges (dict[str, tuple[float, float]]) – Mapping from parameter label to (lower, upper) bounds.

Muestra:

ValueError – If an unknown parameter label is provided.

get_constraints() list[qilisdk.core.variables.ComparisonTerm][fuente]

Get all constraints on the parameters.

Devuelve:

Comparison terms defined locally and by child parameterizable objects.

Tipo del valor devuelto:

list[ComparisonTerm]

check_constraints(parameters: dict[str, float]) bool[fuente]

Validate that proposed parameter updates satisfy all constraints.

Parámetros:

parameters (dict[str, float]) – Candidate updates keyed by parameter label.

Devuelve:

True if every constraint evaluates to True for the provided values.

Tipo del valor devuelto:

bool

Muestra:

ValueError – If an unknown parameter label is provided.