Commit c6875495 authored by Nguyen, Thien Minh's avatar Nguyen, Thien Minh
Browse files

Boiler-plate for Qsim adapt



Signed-off-by: default avatarThien Nguyen <nguyentm@ornl.gov>
parent 9f4e096d
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -10,6 +10,7 @@
#include "workflow/qite.hpp"
#include "workflow/time_dependent.hpp"
#include "workflow/vqe.hpp"
#include "workflow/adapt.hpp"

namespace qcor {
namespace qsim {
@@ -48,6 +49,8 @@ public:
        std::make_shared<qsim::QiteWorkflow>());
    context.RegisterService<qsim::QuantumSimulationWorkflow>(
        std::make_shared<qsim::IterativeQpeWorkflow>());
    context.RegisterService<qsim::QuantumSimulationWorkflow>(
        std::make_shared<qsim::AdaptVqeWorkflow>());
    // Cost evaluators
    context.RegisterService<qsim::CostFunctionEvaluator>(
        std::make_shared<qsim::PartialTomoObjFuncEval>());
+24 −0
Original line number Diff line number Diff line
#include "qsim_utils.hpp"
#include "adapt.hpp"

namespace qcor {
namespace qsim {
bool AdaptVqeWorkflow::initialize(const HeterogeneousMap &params) {
  const std::string DEFAULT_OPTIMIZER = "nlopt";
  optimizer.reset();
  if (params.pointerLikeExists<Optimizer>("optimizer")) {
    optimizer =
        xacc::as_shared_ptr(params.getPointerLike<Optimizer>("optimizer"));
  } else {
    optimizer = createOptimizer(DEFAULT_OPTIMIZER);
  }
  config_params = params;
  return (optimizer != nullptr);
}

QuantumSimulationResult
AdaptVqeWorkflow::execute(const QuantumSimulationModel &model) {
  return {};
}
} // namespace qsim
} // namespace qcor
 No newline at end of file
+20 −0
Original line number Diff line number Diff line
#pragma once
#include "qcor_qsim.hpp"

namespace qcor {
namespace qsim {
class AdaptVqeWorkflow : public QuantumSimulationWorkflow {
public:
  virtual bool initialize(const HeterogeneousMap &params) override;
  virtual QuantumSimulationResult
  execute(const QuantumSimulationModel &model) override;

  virtual const std::string name() const override { return "adapt"; }
  virtual const std::string description() const override { return ""; }

private:
  std::shared_ptr<Optimizer> optimizer;
  HeterogeneousMap config_params;
};
} // namespace qsim
} // namespace qcor
 No newline at end of file
+14 −0
Original line number Diff line number Diff line
#include "qcor.hpp"
#include "qcor_qsim.hpp"
#include "xacc.hpp"
#include <gtest/gtest.h>

TEST(AdaptVqeWorkflowTester, checkSimple) {}

int main(int argc, char **argv) {
  xacc::Initialize();
  ::testing::InitGoogleTest(&argc, argv);
  auto ret = RUN_ALL_TESTS();
  xacc::Finalize();
  return ret;
}
 No newline at end of file
+6 −1
Original line number Diff line number Diff line
@@ -14,3 +14,8 @@ add_executable(QiteWorkflowTester QiteWorkflowTester.cpp)
add_test(NAME QiteWorkflowTester COMMAND QiteWorkflowTester)
target_include_directories(QiteWorkflowTester PRIVATE ../../ ../../../base ${XACC_ROOT}/include/gtest)
target_link_libraries(QiteWorkflowTester ${XACC_TEST_LIBRARIES} xacc::xacc xacc::quantum_gate qcor-qsim)

add_executable(AdaptVqeWorkflowTester AdaptVqeWorkflowTester.cpp)
add_test(NAME AdaptVqeWorkflowTester COMMAND AdaptVqeWorkflowTester)
target_include_directories(AdaptVqeWorkflowTester PRIVATE ../../ ../../../base ${XACC_ROOT}/include/gtest)
target_link_libraries(AdaptVqeWorkflowTester ${XACC_TEST_LIBRARIES} xacc::xacc xacc::quantum_gate qcor-qsim)
 No newline at end of file