entropica_qaoa icon indicating copy to clipboard operation
entropica_qaoa copied to clipboard

How to get result bitstring data in case of QAOACostFunctionOnQVM?

Open eswarthammana opened this issue 3 years ago • 4 comments

this module is really helpful. Could you please let me know how to capture the measured results in case of using QAOACostFunctionOnQVM. In the case of Wavefunction simulator there is a get_wavefunction method helps to retrieve the data. But how to see the results incase of QAOACostFunctionOnQVM like the minimum energy related bit string

eswarthammana avatar Feb 17 '22 12:02 eswarthammana

QAOACostFunctionOnQVM works fine with the pyquil 2.x.x ... with pyquil 3.x.x need to update bitstring capture as qvm.run return QAMExecutionResult

eswarthammana avatar Feb 18 '22 05:02 eswarthammana

updated the class PrepareAndMeasureOnQVM as

`def __call__(self, params, nshots):
        if nshots is None:
            nshots = self.nshots
        bitstrings = []
        for exe in self.exes:
            result = self.qvm.run(exe)
            bitstring = result.readout_data.get('ro')
            for i in range(nshots - 1):
                result = self.qvm.run(exe)
                new_bits = result.readout_data.get('ro')
                bitstring = np.append(bitstring, new_bits, axis=0)
            bitstrings.append(bitstring)
        out = sampling_expectation(self.hams, bitstrings)
        if self.scalar:
            return out[0]
        else:
            return out`

works with out errors as mentioned in the pyquil migration docs

Please help me how to capture the bitstring with highest amplitudes or probability...

eswarthammana avatar Feb 18 '22 06:02 eswarthammana

Hi @eswarthammana ! Apologies for the delay with which I answer you. This repository is not actively maintained, and that is the reason why entropica_qaoa does not work well with pyquil 3.x.x

However, could you please reach us at [email protected] ? We could tell you a bit more about our upcoming open source project which is soon going to replace entropica_qaoa.

Thanks and take care!

Q-lds avatar May 12 '22 00:05 Q-lds

@eswarthammana, this project has effectively been incorporated into OpenQAOA.

Head over there if you are still working with QAOA and Rigetti's backends :)

Q-lds avatar Sep 20 '22 09:09 Q-lds