execute_graph

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.

Parameters

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

Returns

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

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

metadata : 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

dict

SEE ALSO

boulderopal.closed_loop.optimize : Run a closed-loop optimization to find a minimum of the given cost function.

boulderopal.closed_loop.step : Perform a single step in a closed-loop optimization.

boulderopal.run_gradient_free_optimization : Perform model-based optimization without using gradient values.

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

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

Notes

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 {sj}\{s_j\} as the outputs to be evaluated.

Examples

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

Was this useful?