qilisdk.core.parameterizable

Classes

Parameterizable

Mixin for objects that expose tunable parameters and constraints.

Module Contents

class Parameterizable[source]

Bases: abc.ABC

Mixin for objects that expose tunable parameters and constraints.

property nparameters: int[source]

Number of tunable parameters defined by the object.

get_parameter_values() list[float][source]

Return the current numerical values of the parameters.

get_parameter_names() list[str][source]

Return the ordered list of parameter labels.

get_parameters() dict[str, float][source]

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

set_parameter_values(values: list[float]) None[source]

Update all parameter values at once.

Parameters:

values (list[float]) – New parameter values ordered consistently with get_parameter_names().

Raises:

ValueError – If values does not contain exactly nparameters entries.

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

Update a subset of parameters by label.

Parameters:

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

Raises:

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

get_parameter_bounds() dict[str, tuple[float, float]][source]

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

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

Update the allowable ranges for the specified parameters.

Parameters:

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

Raises:

ValueError – If an unknown parameter label is provided.

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

Get all constraints on the parameters.

Returns:

A list of comparison terms involving the parameters of the Object.

Return type:

list[ComparisonTerm]

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

Validate that proposed parameter updates satisfy all constraints.

Parameters:

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

Returns:

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

Return type:

bool

Raises:

ValueError – If an unknown parameter label is provided.