c3.parametermap

ParameterMap class

Module Contents

class c3.parametermap.ParameterMap(instructions: List[c3.signal.gates.Instruction] = [], generator=None, model=None)[source]

Collects information about control and model parameters and provides different representations depending on use.

load_values(self, init_point)[source]

Load a previous parameter point to start the optimization from.

Parameters

init_point (str) – File location of the initial point

store_values(self, path: str, optim_status=None) None[source]

Write current parameter values to file. Stores the numeric values, as well as the names in form of the opt_map and physical units. If an optim_status is given that will be used.

Parameters
  • path (str) – Location of the resulting logfile.

  • optim_status (dict) – Dictionary containing current parameters and goal function value.

read_config(self, filepath: str) None[source]

Load a file and parse it to create a ParameterMap object.

Parameters

filepath (str) – Location of the configuration file

write_config(self, filepath: str) None[source]

Write dictionary to a HJSON file.

asdict(self, instructions_only=True) dict[source]

Return a dictionary compatible with config files.

__str__(self) str[source]

Return str(self).

get_full_params(self) Dict[str, c3.c3objs.Quantity][source]

Returns the full parameter vector, including model and control parameters.

get_opt_units(self) List[str][source]

Returns a list of the units of the optimized quantities.

check_limits(self, opt_map)[source]

Check if all elements of equal ids have the same limits. This has to be checked against if setting values optimizer friendly.

Parameters

opt_map

get_parameter(self, par_id: Tuple[str, Ellipsis]) c3.c3objs.Quantity[source]

Return one the current parameters.

Parameters

par_id (tuple) – Hierarchical identifier for parameter.

Returns

Return type

Quantity

get_parameters(self, opt_map=None) List[c3.c3objs.Quantity][source]

Return the current parameters.

Parameters

opt_map (list) – Hierarchical identifier for parameters.

Returns

Return type

list of Quantity

get_parameter_dict(self, opt_map=None) Dict[str, c3.c3objs.Quantity][source]

Return the current parameters in a dictionary including keys. :param opt_map:

Returns

Return type

Dictionary with Quantities

set_parameters(self, values: Union[List, numpy.ndarray], opt_map=None, extend_bounds=False) None[source]

Set the values in the original instruction class.

Parameters
  • values (list) – List of parameter values. Can be nested, if a parameter is matrix valued.

  • opt_map (list) – Corresponding identifiers for the parameter values.

  • extend_bounds (bool) – If true bounds of quantity objects will be extended.

get_parameters_scaled(self, opt_map=None) numpy.ndarray[source]

Return the current parameters. This fuction should only be called by an optimizer. Are you an optimizer?

Parameters

opt_map (tuple) – Hierarchical identifier for parameters.

Returns

Return type

list of Quantity

set_parameters_scaled(self, values: Union[tensorflow.constant, tensorflow.Variable], opt_map=None) None[source]

Set the values in the original instruction class. This fuction should only be called by an optimizer. Are you an optimizer?

Parameters

values (list) – List of parameter values. Matrix valued parameters need to be flattened.

get_key_from_scaled_index(self, idx, opt_map=None) str[source]

Get the key of the value at position ìdx of the scaled_parameters output :param idx: :param opt_map:

set_opt_map(self, opt_map) None[source]

Set the opt_map, i.e. which parameters will be optimized.

str_parameters(self, opt_map: Union[List[List[Tuple[str]]], List[List[str]]] = None) str[source]

Return a multi-line human-readable string of the optmization parameter names and current values.

Parameters

opt_map (list) – Optionally use only the specified parameters.

Returns

Parameters and their values

Return type

str

print_parameters(self, opt_map=None) None[source]

Print current parameters to stdout.