qaoa.hpp 1.99 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
/*******************************************************************************
 * Copyright (c) 2019 UT-Battelle, LLC.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * and Eclipse Distribution License v1.0 which accompanies this
 * distribution. The Eclipse Public License is available at
 * http://www.eclipse.org/legal/epl-v10.html and the Eclipse Distribution
 *License is available at https://eclipse.org/org/documents/edl-v10.php
 *
 * Contributors:
 *   Thien Nguyen - initial API and implementation
 *******************************************************************************/
#pragma once

#include "Algorithm.hpp"
16
#include "IRProvider.hpp"
17
18
#include "CompositeInstruction.hpp"
#include "AlgorithmGradientStrategy.hpp"
19
20

namespace xacc {
Nguyen, Thien's avatar
Nguyen, Thien committed
21
22
class IRTransformation;

23
24
25
26
27
28
29
30
31
32
33
namespace algorithm {
class QAOA : public Algorithm 
{
public:
    bool initialize(const HeterogeneousMap& parameters) override;
    const std::vector<std::string> requiredParameters() const override;
    void execute(const std::shared_ptr<AcceleratorBuffer> buffer) const override;
    std::vector<double> execute(const std::shared_ptr<AcceleratorBuffer> buffer, const std::vector<double> &parameters) override;
    const std::string name() const override { return "QAOA"; }
    const std::string description() const override { return ""; }
    DEFINE_ALGORITHM_CLONE(QAOA)
Nguyen, Thien's avatar
Nguyen, Thien committed
34
private:
Nguyen, Thien's avatar
Nguyen, Thien committed
35
    Observable* m_costHamObs;
Nguyen, Thien's avatar
Nguyen, Thien committed
36
    Observable* m_refHamObs;
Nguyen, Thien's avatar
Nguyen, Thien committed
37
38
    Accelerator* m_qpu;
    Optimizer* m_optimizer;
39
    std::shared_ptr<AlgorithmGradientStrategy> gradientStrategy;
40
    std::shared_ptr<CompositeInstruction> externalAnsatz;
41
    std::shared_ptr<CompositeInstruction> m_single_exec_kernel;
Nguyen, Thien's avatar
Nguyen, Thien committed
42
    int m_nbSteps;
43
    std::string m_parameterizedMode;
44
    bool m_maximize = false;
45
    CompositeInstruction* m_initial_state = nullptr;
46
    bool m_shuffleTerms = false;
Nguyen, Thien's avatar
Nguyen, Thien committed
47
    std::shared_ptr<xacc::IRTransformation> m_irTransformation;
48
49
50
};
} // namespace algorithm
} // namespace xacc