Open rdprins opened 2 months ago
In the eval_energy()
function it looks like you're subtracting the energy rather than adding it. Try with
def eval_energy(merged_dict, X):
''' evaluate energy of PUSO/BUSO '''
energy = 0.
for idx, val in merged_dict.items():
energy += val * np.prod([X[int(i)] for i in idx]) # <--- change here
return energy
and you should get agreement in the energies.
That's also why flipping the sign of the strength gets agreement.
You are totally right, thanks a lot for looking at this!
If you don't mind, I would like to add an additional question:
Could I check with you that the number of auxiliaries added by dimod.make_quadratic
does not increase with strength
?
(I think that number is determined by reduce_binary_polynomial
which does not depend on strength
)
_A bit more context if you have time:
The following paper used this software to quadratize 3-SAT problems: https://arxiv.org/pdf/2212.03426. Maybe just take a look at Fig. 2 and Section 4.5 (only a few lines).
It seems to me that their data(E_min)
refers to the strength
argument of dimod.make_quadratic
. However, they write that the number of auxiliaries increases with data(Emin). Do you know by any chance wether this is another quadratization method in dimod?
Could I check with you that the number of auxiliaries added by dimod.make_quadratic does not increase with
strength
?
Correct. Though be aware the the variable type does affect the number of aux variables. See https://github.com/dwavesystems/dimod/blob/23c4b52606e076e1aa1f22a2d540c6342cdd208e/dimod/higherorder/utils.py#L321
It seems to me that their data(E_min) refers to the strength argument of dimod.make_quadratic. However, they write that the number of auxiliaries increases with data(E_min). Do you know by any chance wether this is another quadratization method in dimod?
Yeah, there are many different methods. They cite a few in that paper. I don't know of an inclusive list.
My guess is that they are using additional aux variables to keep the total bias applied to any one variable low. You can "spread out" the bias with additional aux variables. We don't do that in dimod
though.
Hope this helps!
Description dimod.make_quadratic has a keyword argument
strength
. According to the docs, this variable should take positive values. However, positive values seem to return incorrect results, while negative values do work.To Reproduce
Expected behavior The 2 plots generated by the code above should be similar (as they represent the energy landscape before and after quadratization). This isn't the case for positive values of
strength
, while it is for negative valuesEnvironment: