Commit 97446133 authored by Mccaskey, Alex's avatar Mccaskey, Alex
Browse files

adding vqe objective function tester

parent 15dd8ba2
Loading
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -4,4 +4,4 @@ run git clone --recursive https://github.com/eclipse/xacc && cd xacc && mkdir bu
    && make -j$(nproc) install 
run cd ../../ && git clone -b master https://github.com/ornl-qci/qcor && cd qcor && mkdir build && cd build \
    && cmake .. -DXACC_DIR=~/.xacc -DQCOR_BUILD_TESTS=TRUE \
    && make -j$(nproc) install 
 No newline at end of file
    && make -j$(nproc) install && ctest --output-on-failure
 No newline at end of file
+3 −3
Original line number Diff line number Diff line
@@ -10,11 +10,11 @@ int main(int argc, char **argv) {
  auto q = qalloc(2);

  // Create the Deuteron Hamiltonian
  auto H = qcor::getObservable(
  auto H = qcor::createObservable(
      "5.907 - 2.1433 X0X1 - 2.1433 Y0Y1 + .21829 Z0 - 6.125 Z1");

  // Create the Ansatz exponent Operator
  auto ansatz_exponent = qcor::getObservable("X0 Y1 - Y0 X1");
  auto ansatz_exponent = qcor::createObservable("X0 Y1 - Y0 X1");

  // Create an objective function to optimize
  // Each call evaluates E(theta) = <ansatz(theta) | H | ansatz(theta)>
@@ -31,7 +31,7 @@ int main(int argc, char **argv) {
      1);

  // Create a qcor Optimizer
  auto optimizer = qcor::getOptimizer();
  auto optimizer = qcor::createOptimizer("nlopt");

  // Optimize the above function
  auto result = optimizer->optimize(opt_func);
+2 −2
Original line number Diff line number Diff line
@@ -18,7 +18,7 @@ int main(int argc, char **argv) {
  qreg q = qalloc(2);

  // Create the Deuteron Hamiltonian (Observable)
  auto H = qcor::getObservable(
  auto H = qcor::createObservable(
      "5.907 - 2.1433 X0X1 - 2.1433 Y0Y1 + .21829 Z0 - 6.125 Z1");

  // Create the ObjectiveFunction, here we want to run VQE
@@ -34,7 +34,7 @@ int main(int argc, char **argv) {
      },
      10);

  auto optimizer = qcor::getOptimizer();
  auto optimizer = qcor::createOptimizer("nlopt");
  auto results = optimizer->optimize(f);

  // Print the result
+1 −1
Original line number Diff line number Diff line
@@ -30,7 +30,7 @@ int main(int argc, char **argv) {
  auto q = qalloc(2);

  // Create the Deuteron Hamiltonian (Observable)
  auto H = qcor::getObservable(
  auto H = qcor::createObservable(
      "5.907 - 2.1433 X0X1 - 2.1433 Y0Y1 + .21829 Z0 - 6.125 Z1");

  // Create the ObjectiveFunction, here we want to run VQE
+1 −1
Original line number Diff line number Diff line
@@ -11,7 +11,7 @@ int main(int argc, char **argv) {
  auto q = qalloc(2);

  // Create the Deuteron Hamiltonian (Observable)
  auto H = qcor::getObservable(
  auto H = qcor::createObservable(
      "5.907 - 2.1433 X0X1 - 2.1433 Y0Y1 + .21829 Z0 - 6.125 Z1");

  // Create the ObjectiveFunction, here we want to run VQE
Loading