calculate_graph

static FunctionNamespace.calculate_graph(*, graph, output_node_names, execution_mode=None, **kwargs)

Evaluates a graph corresponding to a set of generic functions.

Use this function to carry out computations expressed as a graph representing a collection of arbitrary functions.

Parameters
  • graph (qctrlcommons.graph.Graph) – The graph describing the outputs. It must contain nodes with names \(\{s_j\}\) (giving the output functions).

  • output_node_names (List[str]) – The names \(\{s_j\}\) of the graph nodes that define the output functions. The function evaluates these and returns them in the output.

  • execution_mode (qctrl.dynamic.types.graph.ExecutionMode, optional) – The execution mode to use for the calculation. Choosing a custom execution mode can lead to faster computations in certain cases. Defaults to compiled execution mode.

Returns

The result of a graph evaluation. It includes the evaluated outputs.

Return type

qctrl.dynamic.types.graph.Result

See also

calculate_optimization()

Performs gradient-based deterministic optimization of generic real-valued functions.

Notes

This function computes arbitrary functions represented by a graph.

The graph is made up of primitive nodes defined in the operations namespace of the Q-CTRL Python package, where each node represents a function of previous nodes (or constant values). You can assign a name to any node and request a list of named nodes \(\{s_j\}\) as the outputs to be evaluated.

Examples

See the Set up quantum systems user guide.