c3.parametermap

ParameterMap class

Module Contents

exception c3.parametermap.ParameterMapOOBUpdateException[source]

Bases: Exception

Inheritance diagram of c3.parametermap.ParameterMapOOBUpdateException

Common base class for all non-exit exceptions.

class __cause__

exception cause

class __context__

exception context

__delattr__()

Implement delattr(self, name).

__dir__()

Default dir() implementation.

__eq__()

Return self==value.

__format__()

Default object formatter.

__ge__()

Return self>=value.

__getattribute__()

Return getattr(self, name).

__gt__()

Return self>value.

__hash__()

Return hash(self).

__le__()

Return self<=value.

__lt__()

Return self<value.

__ne__()

Return self!=value.

__reduce__()

Helper for pickle.

__reduce_ex__()

Helper for pickle.

__repr__()

Return repr(self).

__setattr__()

Implement setattr(self, name, value).

__sizeof__()

Size of object in memory, in bytes.

__str__()

Return str(self).

__subclasshook__()

Abstract classes can override this to customize issubclass().

This is invoked early on by abc.ABCMeta.__subclasscheck__(). It should return True, False or NotImplemented. If it returns NotImplemented, the normal algorithm is used. Otherwise, it overrides the normal algorithm (and the outcome is cached).

with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

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(init_point, extend_bounds=False)[source]

Load a previous parameter point to start the optimization from.

Parameters
  • init_point (str) – File location of the initial point

  • extend_bounds (bool) – Whether or not to allow the loaded parameters’ bounds to be extended if they exceed those specified.

store_values(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(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(filepath: str) None[source]

Write dictionary to a HJSON file.

asdict(instructions_only=True) dict[source]

Return a dictionary compatible with config files.

__str__() str[source]

Return str(self).

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

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

get_opt_units() List[str][source]

Returns a list of the units of the optimized quantities.

check_limits(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(par_id: Tuple[str, Ellipsis]) c3.c3objs.Quantity[source]

Return one the current parameters.

Parameters

par_id (tuple) – Hierarchical identifier for parameter.

Return type

Quantity

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

Return the current parameters.

Parameters

opt_map (list) – Hierarchical identifier for parameters.

Return type

list of Quantity

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

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

Return type

Dictionary with Quantities

set_parameters(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(opt_map=None) tensorflow.Tensor[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.

Return type

list of Quantity

get_key_from_scaled_index(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(opt_map) None[source]

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

str_parameters(opt_map: Union[List[List[Tuple[str]]], List[List[str]]] = None, human=False) 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(opt_map=None) None[source]

Print current parameters to stdout.