Class VQEE
Defined in File vqee.hpp
Class Documentation
-
class VQEE
Variational Quantum Eigensolver (VQE) hybrid quantum-classical algorithm.
Public Functions
-
inline VQEE(Params ¶ms)
Constructor that accepts qb::vqee::Params.
-
void optimize()
Private Functions
-
std::shared_ptr<xacc::Accelerator> getAccelerator(const std::string &accName) const
-
std::shared_ptr<xacc::CompositeInstruction> getAnsatz() const
-
std::shared_ptr<xacc::Observable> getObservable()
-
size_t getOptimumIterationE()
Subroutines for visualising VQE convergence.
Locate the iteration that produced the optimum theta
- Returns
Index that matches the optimum iteration found by XACC
-
void generateThetaEnergyVis(const std::string in_title, const size_t in_start_elem = 0, const int in_scale = 20, const int in_width = 2, const int in_precision = 2)
Create a text-art bar graph for energy and each element of theta. The resultant visualisation is stored in params_.vis. The iteration corresponding to the optimum is marked ‘**’.
Colour markings: Red - indicates the optimum iteration identified by XACC Green - indicates an iteration with the same energy of the optimum energy
Example output:
Iteration 96 Energy |################# -0.95 Theta Element 0 |####################### 0.33*pi Element 1 |##################### 0.19*pi Element 2 |################### -0.12*pi Element 3 |######################### 0.55*pi Iteration 97 Energy **|################ -0.98 Theta Element 0 **|####################### 0.3*pi Element 1 **|##################### 0.19*pi Element 2 **|#################### -0.059*pi Element 3 **|######################### 0.5*pi Iteration 98 Energy |################# -0.97 Theta Element 0 |###################### 0.29*pi Element 1 |##################### 0.14*pi Element 2 |#################### 0.061*pi Element 3 |######################### 0.55*pi
- Parameters
in_title – A string to be used as a title before the text-art output
in_start_elem – Index for the starting element within theta for which the next in_elem_n elements will be visualised
in_scale – A scaling factor to adjust the size of the visual bar output
in_width – The size of a blank separator between bar labels and bars
in_precision – The precision for printing a value at the right extremity of a bar
-
std::string generateEnergyVis(const std::vector<double> in_val, const std::string in_title, const int in_stride = 1, const int in_scale = 20, const int in_width = 2, const int in_precision = 2)
Create a text-art bar graph for energy. The resultant visualisation is stored in params_.vis. The iteration corresponding to the optimum is marked ‘**’. Values are displayed at the right extremity of each bar. The scaling of bars is based on the energy at the first iteration, and rescales as soon as the size of a bar in any iteration is zero.
- Parameters
in_val – An array with consecutive iterations separated by in_stride elements
in_title – A string to be used as a title before the text-art output
in_stride – The stride separating consecutive iterations
in_scale – A scaling factor to adjust the size of the visual bar output
in_width – The size of a blank separator between bar labels and bars
in_precision – The precision for printing a value at the right extremity of a bar
- Returns
String representation of energy convergence trace
-
inline VQEE(Params ¶ms)