Skip to content

Quadratic terms of input spin glass have flipped quadratic energy (bug) #1

@yannick-couzinie

Description

@yannick-couzinie

Hey, thanks for providing this code. To get it to compile I had to make some changes to the cmake file and I had to switch to the master branch on the pybind11 module, but I managed to get it compiled.

I then take the following file

import siquan
dtsqa = siquan.DTSQA()
dtsqa.setHSchedule("[10,iF,0.01]")
dtsqa.setTSchedule("[0.01, 0.01]")

resultDict = dtsqa.minimize( [(-0.1, [0]), (-0.01, [1]), (-0.001, [2]),  (1.5, [0,1]), (1., [0, 1, 2])],  3)

which, if I understand correctly, corresponds to finding the minimum energy of a spin glass -1 s1 - 0.01 s2 - 0.001 s3 + 1.5 s1*s2 + s1*s2*s3 where si can take values of +1 or -1. The resulting resultDict is

{'H': '[10, iF, 0.01]',
 'T': '[0.01,  0.01]',
 'energy': '-2.609000',
 'energy_distr': '{0: -2.609, 1: -0.109, 2: -1.5, 3: -1}',
 'first_in': '0',
 'maxcut': '0.110000',
 'nt': '100',
 'periodic': '1',
 'remap': 'sorted,fill,0',
 'runtime_cycles': '9018166',
 'runtime_sec': '0.009023',
 'seed': '0',
 'state': '[2]',
 'steps': '1000',
 'trotter_degen': '54',
 'trotter_min_index': '0'}

I struggle to understand this output. Following the linear energies (resultDict['energy_distr'][1]) it is apparent that s1=1, s2=1 and s3=-1 to get -0.1-0.01+0.001=-0.109. This would also agree with resultDict['state'] if we assume that it gives a list of spins that are -1 in the output (here 2, i.e. the third spin). For the quadratic term resultDict['energy_distr'][2]=-1.5 we need s1*s2 = -1 to get the contribution of 1.5.s1*s2=-1.5, which violates what we found for the linear term, for the cubic term resultDict['energy_distr'][3]=-1 we need s1*s2*s3 = -1 which agrees with the linear term if we take s1 = s2 = -s3 = 1.

Running some of these smaller experiments it seems like the quadratic terms in the spin glass are multiplied by -1 in the optimization so that for example for the above example we optimized -1 s1 - 0.01 s2 - 0.001 s3 - 1.5 s1*s2 + s1*s2*s3 and not the original input.

Am I misunderstanding the way to use this library or is this a bug?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions