`BOPESSampler` does not support `MinimumEigensolverFactories`
See original GitHub issueInformation
- Qiskit Nature version: cb05d69661a9d467aed9d3f208ea5630f7dc9fbf
- Python version: 3.9.7
- Operating system: Linux
What is the current behavior?
Traceback (most recent call last):
File "/home/oss/Files/Qiskit/src/qiskit-nature/main/tmp10.py", line 32, in <module>
bs = BOPESSampler(VQEUCCFactory)
File "/home/oss/Files/Qiskit/src/qiskit-nature/main/qiskit_nature/algorithms/pes_samplers/bopes_sampler.py", line 95, in __init__
if isinstance(self._gss.solver, VariationalAlgorithm): # type: ignore
AttributeError: type object 'VQEUCCFactory' has no attribute 'solver'
Steps to reproduce the problem
from functools import partial
import numpy as np
from qiskit_nature.algorithms.ground_state_solvers.minimum_eigensolver_factories import (
VQEUCCFactory,
)
from qiskit_nature.algorithms.pes_samplers import BOPESSampler
from qiskit_nature.converters.second_quantization import QubitConverter
from qiskit_nature.drivers import Molecule
from qiskit_nature.drivers.second_quantization import (
ElectronicStructureDriverType,
ElectronicStructureMoleculeDriver,
)
from qiskit_nature.mappers.second_quantization import ParityMapper
from qiskit_nature.problems.second_quantization.electronic import ElectronicStructureProblem
stretch = partial(Molecule.absolute_distance, atom_pair=(0, 1))
molecule = Molecule(
geometry=[
["H", [0.0, 0.0, 0.0]],
["H", [0.0, 0.0, 1.0]],
],
degrees_of_freedom=[stretch],
)
driver = ElectronicStructureMoleculeDriver(molecule, "sto3g", ElectronicStructureDriverType.PYSCF)
problem = ElectronicStructureProblem(driver)
converter = QubitConverter(ParityMapper())
bs = BOPESSampler(VQEUCCFactory)
res = bs.sample(problem, np.linspace(0.5, 3.0, 20))
print(res)
What is the expected behavior?
The BOPESSampler
should support MininmumEigensolverFactory
classes.
Suggested solutions
Add a check similar to the one in the GroundStateEigensolver
: https://github.com/Qiskit/qiskit-nature/blob/main/qiskit_nature/algorithms/ground_state_solvers/ground_state_eigensolver.py#L103-L105
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
qiskit-nature/ground_state_eigensolver.py at main - GitHub
according to a mapper it is initialized with. solver: Minimum Eigensolver or MESFactory object, e.g. the VQEUCCSDFactory.
Read more >One Size Doesn't Fit All: Using Factor Analysis to Gather ...
In our study, the total sample size was 796 students. Considering the number of factors (two) and the relatively large number of items...
Read more >Code Examples - oj! Algorithms
All code examples regardless of where or when they were published can be found here (further down on this page). The individual code...
Read more >Exploratory Factor Analysis: A Guide to Best Practice
An eigenvalue is computed for each of the resulting factors to indicate the amount of variance accounted for by that factor independent of...
Read more >Msbte Sample Question Paper 2nd Sem G Scheme Mechanical
scheme mechanical that we will categorically offer. It is not not far off from the costs. Its virtually what you craving currently.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@mrossinek Yes, I’ll check this next week. It makes more sense. There was an issue with this approach, but I don’t remember it right now. It’s about the second quantisation/ solver creation and the problem which is provided only when solve method is called. I’ll keep you updated.
I’ve had an offline discussion with @woodsp-ibm regarding PR #457. The question arose whether we really want to support a syntax like the one proposed there:
gss: Union[GroundStateSolver, MinimumEigensolverFactory]
+ require aQubitConverter
in the latter case… Or whether instead we should stick to the (arguably more obvious) solution of doing:I.e. instead of adding support for the factory directly inside of the
BopesSampler
, we should instead make sure that it knows how to handle a GSS which was initialized with a factory.Unfortunately the code snippet in my original description of this issue at the top here is not valid (I don’t quite know how that happened), but this latter case is still flawed as it does not work as intended today either. Here is a new snippet:
It produces the following error when using the latest
main
installations of Qiskit Nature and Terra:I believe if we try to fix that error instead, we do not need the proposal of #457 as it is potentially too convoluted.
@iuliazidaru I am sorry that you have already put so much work into that PR. Would you still be interested in attempting this new approach, instead? 🙂