Commit 159ce1f5 authored by Daniel Claudino's avatar Daniel Claudino
Browse files

Print circuit and number of terms in commutator


Signed-off-by: default avatarDaniel Claudino <6d3@ornl.gov>
parent 2b073add
......@@ -20,6 +20,6 @@ adapt = xacc.getAlgorithm('adapt-vqe', {'accelerator': qpu,
'threshold': 1.0e-2,
'print-threshold': 1.0e-10,
'maxiter': 2,
'pool': "uccsd"})
'pool': "singlet-adapted-uccsd"})
# execute
adapt.execute(buffer)
......@@ -217,7 +217,12 @@ void ADAPT_VQE::execute(const std::shared_ptr<AcceleratorBuffer> buffer) const {
for (int operatorIdx = 0; operatorIdx < commutators.size(); operatorIdx++){
// only compute commutators if they aren't zero
if(std::dynamic_pointer_cast<PauliOperator>(commutators[operatorIdx])->getTerms().size() != 0){
int nTermsCommutator = std::dynamic_pointer_cast<PauliOperator>(commutators[operatorIdx])->getTerms().size();
if(nTermsCommutator != 0){
// Print number of instructions for computing <observable>
xacc::info("Number of instructions for commutator calculation: "
+ std::to_string(nTermsCommutator));
// observe the commutators with the updated circuit ansatz
auto grad_vqe = xacc::getAlgorithm(
"vqe", {std::make_pair("observable", commutators[operatorIdx]),
......@@ -266,6 +271,8 @@ void ADAPT_VQE::execute(const std::shared_ptr<AcceleratorBuffer> buffer) const {
xacc::info(ss.str() + "\n");
ss.str(std::string());
xacc::info("Final ADAPT-VQE circuit\n" + ansatzInstructions->toString());
return;
} else if (iter < _maxIter) { // Add operator and reoptimize
......
......@@ -126,7 +126,7 @@ public:
return pool;
}
const std::string name() const override { return "uccsd"; }
const std::string name() const override { return "singlet-adapted-uccsd"; }
const std::string description() const override { return ""; }
};
......
......@@ -61,7 +61,7 @@ TEST(AdaptVQETester, checkSimple) {
EXPECT_TRUE(adapt_vqe->initialize({std::make_pair("accelerator",acc),
std::make_pair("observable", H),
std::make_pair("optimizer", optimizer),
std::make_pair("pool", "uccsd"),
std::make_pair("pool", "singlet-adapted-uccsd"),
std::make_pair("gradient-strategy", "parameter-shift-gradient"),
std::make_pair("nElectrons", 2)}));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment