Loading lib/qsim/impls/qsim_impl.cpp +17 −0 Original line number Diff line number Diff line Loading @@ -120,6 +120,21 @@ VqeWorkflow::execute(const QuatumSimulationModel &model) { return {}; } bool IterativeQpeWorkflow::initialize(const HeterogeneousMap ¶ms) { // TODO: std::cout << "Howdy: initialize\n"; return true; } QuatumSimulationResult IterativeQpeWorkflow::execute(const QuatumSimulationModel &model) { // TODO: std::cout << "Howdy: execute\n"; return {}; } std::shared_ptr<QuatumSimulationWorkflow> getWorkflow(const std::string &name, const HeterogeneousMap &init_params) { auto qsim_workflow = xacc::getService<QuatumSimulationWorkflow>(name); Loading Loading @@ -161,6 +176,8 @@ public: std::make_shared<qsim::TimeDependentWorkflow>()); context.RegisterService<qsim::QuatumSimulationWorkflow>( std::make_shared<qsim::VqeWorkflow>()); context.RegisterService<qsim::QuatumSimulationWorkflow>( std::make_shared<qsim::IterativeQpeWorkflow>()); context.RegisterService<qsim::CostFunctionEvaluator>( std::make_shared<qsim::DefaultObjFuncEval>()); } Loading lib/qsim/impls/qsim_impl.hpp +16 −1 Original line number Diff line number Diff line Loading @@ -66,13 +66,28 @@ public: virtual const std::string description() const override { return ""; } private: static inline TimeDependentWorkflow *instance = nullptr; double t_0; double t_final; double dt; TdObservable ham_func; }; // Iterative QPE workflow to estimate the energy of a Hamiltonian operator. class IterativeQpeWorkflow : public QuatumSimulationWorkflow { public: virtual bool initialize(const HeterogeneousMap ¶ms) override; virtual QuatumSimulationResult execute(const QuatumSimulationModel &model) override; virtual const std::string name() const override { return "iqpe"; } virtual const std::string description() const override { return ""; } private: // Number of time slices (>=1) int num_steps; // Number of iterations (>=1) int num_iters; }; class DefaultObjFuncEval : public CostFunctionEvaluator { public: // Evaluate the cost Loading lib/qsim/impls/tests/IterativeQpeWorkflow.cpp 0 → 100644 +23 −0 Original line number Diff line number Diff line #include "qcor_qsim.hpp" // Solving the ground-state energy of a Hamiltonian operator by the iterative // QPE procedure. // Compile and run with: /// $ qcor -qpu qpp IterativeQpeWorkflow.cpp /// $ ./a.out int main(int argc, char **argv) { // Create the Deuteron Hamiltonian auto H = 5.907 - 2.1433 * X(0) * X(1) - 2.143 * Y(0) * Y(1) + 0.21829 * Z(0) - 6.125 * Z(1); auto problemModel = qsim::ModelBuilder::createModel(&H); // Instantiate an IQPE workflow. auto workflow = qsim::getWorkflow("iqpe", {}); // Result should contain the observable expectation value along Trotter steps. auto result = workflow->execute(problemModel); return 0; } No newline at end of file Loading
lib/qsim/impls/qsim_impl.cpp +17 −0 Original line number Diff line number Diff line Loading @@ -120,6 +120,21 @@ VqeWorkflow::execute(const QuatumSimulationModel &model) { return {}; } bool IterativeQpeWorkflow::initialize(const HeterogeneousMap ¶ms) { // TODO: std::cout << "Howdy: initialize\n"; return true; } QuatumSimulationResult IterativeQpeWorkflow::execute(const QuatumSimulationModel &model) { // TODO: std::cout << "Howdy: execute\n"; return {}; } std::shared_ptr<QuatumSimulationWorkflow> getWorkflow(const std::string &name, const HeterogeneousMap &init_params) { auto qsim_workflow = xacc::getService<QuatumSimulationWorkflow>(name); Loading Loading @@ -161,6 +176,8 @@ public: std::make_shared<qsim::TimeDependentWorkflow>()); context.RegisterService<qsim::QuatumSimulationWorkflow>( std::make_shared<qsim::VqeWorkflow>()); context.RegisterService<qsim::QuatumSimulationWorkflow>( std::make_shared<qsim::IterativeQpeWorkflow>()); context.RegisterService<qsim::CostFunctionEvaluator>( std::make_shared<qsim::DefaultObjFuncEval>()); } Loading
lib/qsim/impls/qsim_impl.hpp +16 −1 Original line number Diff line number Diff line Loading @@ -66,13 +66,28 @@ public: virtual const std::string description() const override { return ""; } private: static inline TimeDependentWorkflow *instance = nullptr; double t_0; double t_final; double dt; TdObservable ham_func; }; // Iterative QPE workflow to estimate the energy of a Hamiltonian operator. class IterativeQpeWorkflow : public QuatumSimulationWorkflow { public: virtual bool initialize(const HeterogeneousMap ¶ms) override; virtual QuatumSimulationResult execute(const QuatumSimulationModel &model) override; virtual const std::string name() const override { return "iqpe"; } virtual const std::string description() const override { return ""; } private: // Number of time slices (>=1) int num_steps; // Number of iterations (>=1) int num_iters; }; class DefaultObjFuncEval : public CostFunctionEvaluator { public: // Evaluate the cost Loading
lib/qsim/impls/tests/IterativeQpeWorkflow.cpp 0 → 100644 +23 −0 Original line number Diff line number Diff line #include "qcor_qsim.hpp" // Solving the ground-state energy of a Hamiltonian operator by the iterative // QPE procedure. // Compile and run with: /// $ qcor -qpu qpp IterativeQpeWorkflow.cpp /// $ ./a.out int main(int argc, char **argv) { // Create the Deuteron Hamiltonian auto H = 5.907 - 2.1433 * X(0) * X(1) - 2.143 * Y(0) * Y(1) + 0.21829 * Z(0) - 6.125 * Z(1); auto problemModel = qsim::ModelBuilder::createModel(&H); // Instantiate an IQPE workflow. auto workflow = qsim::getWorkflow("iqpe", {}); // Result should contain the observable expectation value along Trotter steps. auto result = workflow->execute(problemModel); return 0; } No newline at end of file