XACC
qite.hpp
1 /*******************************************************************************
2  * Copyright (c) 2019 UT-Battelle, LLC.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * and Eclipse Distribution License v1.0 which accompanies this
6  * distribution. The Eclipse Public License is available at
7  * http://www.eclipse.org/legal/epl-v10.html and the Eclipse Distribution
8  *License is available at https://eclipse.org/org/documents/edl-v10.php
9  *
10  * Contributors:
11  * Thien Nguyen - initial API and implementation
12  *******************************************************************************/
13 #pragma once
14 
15 #include "Algorithm.hpp"
16 
17 namespace xacc {
18 namespace algorithm {
19 class QITE : public Algorithm {
20 public:
21  bool initialize(const HeterogeneousMap &parameters) override;
22  const std::vector<std::string> requiredParameters() const override;
23 
24  void execute(const std::shared_ptr<AcceleratorBuffer> buffer) const override;
25  std::vector<double> execute(const std::shared_ptr<AcceleratorBuffer> buffer,
26  const std::vector<double> &parameters) override;
27  const std::string name() const override { return "qite"; }
28  const std::string description() const override { return ""; }
29  DEFINE_ALGORITHM_CLONE(QITE)
30 private:
31  // Construct the Trotter propagate circuit up to current time step.
32  std::shared_ptr<CompositeInstruction> constructPropagateCircuit() const;
33  // Calculate the current energy, i.e.
34  // the value of the observable at the current Trotter step.
35  double calcCurrentEnergy(int in_nbQubits) const;
36 
37  // Calculate approximate A operator observable at the current Trotter step.
38  // Params:
39  // in_kernel: the kernel to evolve the system to this time step
40  // in_hmTerm: the H term to be approximate by the A term
41  // i.e. emulate the imaginary time evolution of that H term.
42  std::shared_ptr<Observable> calcAOps(const std::shared_ptr<AcceleratorBuffer>& in_buffer, std::shared_ptr<CompositeInstruction> in_kernel, std::shared_ptr<Observable> in_hmTerm) const;
43 
44 private:
45  // Number of Trotter steps
46  int m_nbSteps;
47  // dBeta, i.e. step size
48  double m_dBeta;
49  // Accelerator
50  std::shared_ptr<Accelerator> m_accelerator;
51  // Hamiltonian Observable, i.e. H = Sum(h_i)
52  std::shared_ptr<Observable> m_observable;
53  // Ansatz circuit (apply before Trotter steps)
54  CompositeInstruction* m_ansatz;
55  // List of A operators for each time step
56  // which approximates the imaginary-time step
57  // of the Hamiltonian observable
58  // i.e. exp(-iAt) -> exp(-Ht)
59  mutable std::vector<std::shared_ptr<Observable>> m_approxOps;
60  // Energy value achieved at a Trotter step
61  mutable std::vector<double> m_energyAtStep;
62  // If a pure analytical run is requested.
63  bool m_analytical;
64  // For analytical solver only: the initial state
65  // For accelerator-based simulation, the Ansatz is used to
66  // prepare the initial state.
67  int m_initialState;
68 };
69 } // namespace algorithm
70 } // namespace xacc
Definition: Algorithm.hpp:34
const std::string description() const override
Definition: qite.hpp:28
Definition: Accelerator.hpp:25
const std::string name() const override
Definition: qite.hpp:27
Definition: qite.hpp:19
Definition: heterogeneous.hpp:45
Definition: CompositeInstruction.hpp:72