pygsti.objectivefns.objectivefns.CachedObjectiveFunction

pygsti.objectivefns.objectivefns.CachedObjectiveFunction#

class CachedObjectiveFunction(objective_function)#

Bases: object

Holds various values of an objective function at a particular point.

This object is meant to be serializable, and not to facilitate computing the objective function anywhere else. It doesn’t contain or rely on comm objects. It does contain a serial or “global” layout that allows us to make sense of the elements of various probability vectors, etc., but we demand that this layout not depend on comm objects.

Notes

  • The serialization mechanism is the .write and .from_dir API pattern that’s used throughout the codebase for serializing objects to disk.

  • We don’t necessarily exploit this class for improved efficiency anywhere. This is largely an artifact from an incomplete feature. It’s fair game in the future to either (1) try and extend the use case of this class in a material way, or (2) remove this class altogether.

Methods

__init__(objective_function)

from_dir(dirname[, quick_load])

Initialize a new CachedObjectiveFunction object from dirname.

write(dirname)

Write this CachedObjectiveFunction to a directory.

Attributes

collection_name

classmethod from_dir(dirname, quick_load=False)#

Initialize a new CachedObjectiveFunction object from dirname.

quick_loadbool, optional

Setting this to True skips the loading of components that may take a long time to load.

Parameters:
  • dirname (str) – The directory name.

  • quick_load (bool, optional) – Setting this to True skips the loading of components that may take a long time to load.

Return type:

CachedObjectiveFunction

write(dirname)#

Write this CachedObjectiveFunction to a directory.

Parameters:

dirname (str) – The directory name to write. This directory will be created if needed, and the files in an existing directory will be overwritten.

Return type:

None