entropicalabs / openqaoa

Multi-backend SDK for quantum optimisation
MIT License
116 stars 58 forks source link

Better elimination_rules keys #168

Closed raulconchello closed 1 year ago

raulconchello commented 1 year ago

The format of the results object for RQAOA when calling r.results['elimination_rules'] was:

[[{'pair': (0, 1), 'correlation': -1.0}],
 [{'pair': (None, 1), 'correlation': -1.0}],
 [{'pair': (None, 1), 'correlation': 1.0},
  {'pair': (None, 2), 'correlation': -1.0}],
 [{'pair': (None, 1), 'correlation': 1.0},
  {'pair': (None, 2), 'correlation': -1.0}],
 [{'pair': (None, 1), 'correlation': 1.0},
  {'pair': (None, 2), 'correlation': -1.0}]]

This convention is a bit misleading as (None,i) it is not a pair but instead a single spin that is getting fixed to some state according to its single spin expectation value (not a correlation!).

New format:

[[{'pair': (0, 1), 'correlation': -1.0}],
 [{'singlet': (1,), 'bias': -1.0}],
 [{'singlet': (1,), 'bias': 1.0},
  {'singlet': (2,), 'bias': -1.0}],
 [{'singlet': (1,), 'bias': 1.0},
  {'singlet': (2,), 'bias': -1.0}],
 [{'singlet': (1,), 'bias': 1.0},
  {'singlet': (2,), 'bias': -1.0}]]
codecov[bot] commented 1 year ago

Codecov Report

Merging #168 (6718f37) into dev (e375233) will decrease coverage by 0.46%. The diff coverage is 34.82%.

@@            Coverage Diff             @@
##              dev     #168      +/-   ##
==========================================
- Coverage   82.06%   81.60%   -0.46%     
==========================================
  Files         103      103              
  Lines       12035    12128      +93     
==========================================
+ Hits         9876     9897      +21     
- Misses       2159     2231      +72     
Impacted Files Coverage Δ
openqaoa/backends/qpus/qaoa_qiskit_qpu.py 19.56% <0.00%> (-1.62%) :arrow_down:
openqaoa/backends/simulators/qaoa_pyquil_sim.py 86.27% <ø> (ø)
setup.py 100.00% <ø> (ø)
openqaoa/devices.py 41.57% <21.42%> (-6.61%) :arrow_down:
tests/test_qpu_devices.py 31.90% <31.81%> (-0.60%) :arrow_down:
openqaoa/backends/qaoa_backend.py 78.37% <100.00%> (ø)
openqaoa/optimizers/logger_vqa.py 98.36% <100.00%> (ø)
openqaoa/rqaoa/rqaoa.py 96.98% <100.00%> (+0.03%) :arrow_up:
openqaoa/workflows/optimizer.py 93.81% <100.00%> (ø)
tests/test_results.py 100.00% <100.00%> (ø)
... and 4 more

:mega: We’re building smart automated test selection to slash your CI/CD build times. Learn more

vishal-ph commented 1 year ago

This convention is a bit misleading as (None,i) it is not a pair but instead a single spin that is getting fixed to some state according to its single spin expectation value (not a correlation!).

New format:

[[{'singlet': (0, 1), 'exp_val': -1.0}],
 [{'singlet': (None, 1), 'exp_val': -1.0}],
 [{'singlet': (None, 1), 'exp_val': 1.0},
  {'singlet': (None, 2), 'exp_val': -1.0}],
 [{'singlet': (None, 1), 'exp_val': 1.0},
  {'singlet': (None, 2), 'exp_val': -1.0}],
 [{'singlet': (None, 1), 'exp_val': 1.0},
  {'singlet': (None, 2), 'exp_val': -1.0}]]

@raulconchello, shouldn't the first entry still be pair though? Can you confirm this is just a typo?