c3.optimizers.optimalcontrol
¶
Object that deals with the open loop optimal control.
Module Contents¶
- exception c3.optimizers.optimalcontrol.OptResultOOBError[source]¶
Bases:
Exception
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.optimizers.optimalcontrol.OptimalControl(fid_func, fid_subspace, pmap, dir_path=None, callback_fids=None, algorithm=None, initial_point: str = '', store_unitaries=False, options={}, run_name=None, interactive=True, include_model=False, logger=None, fid_func_kwargs={}, ode_solver=None, ode_step_function='schrodinger', only_final_state=False)[source]¶
Bases:
c3.optimizers.optimizer.Optimizer
Object that deals with the open loop optimal control.
- Parameters
dir_path (str) – Filepath to save results
fid_func (callable) – infidelity function to be minimized
fid_subspace (list) – Indeces identifying the subspace to be compared
pmap (ParameterMap) – Identifiers for the parameter vector
callback_fids (list of callable) – Additional fidelity function to be evaluated and stored for reference
algorithm (callable) – From the algorithm library Save plots of control signals
store_unitaries (boolean) – Store propagators as text and pickle
options (dict) – Options to be passed to the algorithm
run_name (str) – User specified name for the run, will be used as root folder
fid_func_kwargs (dict) – Additional kwargs to be passed to the main fidelity function.
- optimize_controls(setup_log: bool = True) None [source]¶
Apply a search algorithm to your gateset given a fidelity function.
- goal_run(current_params: tensorflow.Tensor) tensorflow.float64 [source]¶
Evaluate the goal function for current parameters.
- Parameters
current_params (tf.Tensor) – Vector representing the current parameter values.
- Returns
Value of the goal function
- Return type
tf.float64
- goal_run_ode(current_params: tensorflow.Tensor) tensorflow.float64 [source]¶
Evaluate the goal function using ode solver for current parameters.
- Parameters
current_params (tf.Tensor) – Vector representing the current parameter values.
- Returns
Value of the goal function
- Return type
tf.float64
- goal_run_ode_only_final(current_params: tensorflow.Tensor) tensorflow.float64 [source]¶
Evaluate the goal function using ode solver for current parameters.
- Parameters
current_params (tf.Tensor) – Vector representing the current parameter values.
- Returns
Value of the goal function
- Return type
tf.float64
- replace_logdir(new_logdir)¶
Specify a new filepath to store the log.
- Parameters
new_logdir –
- set_created_by(config) None ¶
Store the config file location used to created this optimizer.
- load_best(init_point, extend_bounds=False) None ¶
Load a previous parameter point to start the optimization from. Legacy wrapper. Method moved to Parametermap.
- Parameters
init_point (str) – File location of the initial point
extend_bounds (bool) – Whether or not to allow the loaded optimal parameters’ bounds to be extended if they exceed those specified.
- start_log() None ¶
Initialize the log with current time.
- end_log() None ¶
Finish the log by recording current time and total runtime.
- log_best_unitary() None ¶
Save the best unitary in the log.
- log_parameters(params) None ¶
Log the current status. Write parameters to log. Update the current best parameters. Call plotting functions as set up.
- lookup_gradient(x)¶
Return the stored gradient for a given parameter set.
- Parameters
x (np.array) – Parameter set.
- Returns
Value of the gradient.
- Return type
np.array
- fct_to_min(input_parameters: Union[numpy.ndarray, tensorflow.constant]) Union[numpy.ndarray, tensorflow.constant] ¶
Wrapper for the goal function.
- Parameters
input_parameters ([np.array, tf.constant]) – Vector of parameters in the optimizer friendly way.
- Returns
Value of the goal function. Float if input is np.array else tf.constant
- Return type
[np.ndarray, tf.constant]
- fct_to_min_autograd(x)¶
Wrapper for the goal function, including evaluation and storage of the gradient.
- Parameters
- xnp.array
Vector of parameters in the optimizer friendly way.
- float
Value of the goal function.