boulderopal.execute_graph(graph, output_node_names, execution_mode=ExecutionMode.COMPILED)

Evaluate 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.

  • graph (Graph) – The graph describing the outputs. It must contain nodes with names (giving the output functions).

  • output_node_names (str or list[str]) – The names of the graph nodes that define the output functions. The function evaluates these and returns them in the output. You can pass a string for a single node or a list of node names.

  • execution_mode (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.


A dictionary containing the graph execution result, with the following keys:


The dictionary giving the value of each requested output node. The keys of the dictionary are the names of the output nodes.


Metadata associated with the calculation. No guarantees are made about the contents of this metadata dictionary; the contained information is intended purely to help interpret the results of the calculation on a one-off basis.

Return type:


See also


Run a closed-loop optimization to find a minimum of the given cost function.


Perform a single step in a closed-loop optimization.


Perform model-based optimization without using gradient values.


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


Perform gradient-based stochastic optimization of generic real-valued functions.


This function computes arbitrary functions represented by a graph.

The graph is made up of primitive nodes, where each node represents a function of the output of the nodes (or constant values) it depends on. You can assign a name to any node and request a list of named nodes \(\{s_j\}\) as the outputs to be evaluated.


See the How to represent quantum systems using graphs user guide.