def make_fully_connected_binary(self):
"""
Transforms the existing Ising couplings into an mathematically
equivalent QUBO model via s = 2x - 1.
"""
shape_of_J = (self.n_spins, self.n_spins)
J_np = np.round(np.random.normal(0, 1, shape_of_J), decimals=4)
J_np = np.tril(J_np, -1) + np.tril(J_np, -1).transpose()
h_np = np.round(np.random.normal(0, 1, self.n_spins), decimals=4)
Q_binary_np = 4 * J_np
q_binary_np = 2 * h_np - 2 * np.sum(J_np, axis=1)
q_dict = {(i,): float(np.round(q_binary_np[i], 4)) for i in range(self.n_spins) if q_binary_np[i] != 0}
Q_dict = {(i, j): float(np.round(Q_binary_np[i, j], 4)) for i in range(self.n_spins) for j in range(i + 1, self.n_spins) if Q_binary_np[i, j] != 0}
q_binary = dimod.BinaryPolynomial(q_dict, dimod.BINARY)
Q_binary = dimod.BinaryPolynomial(Q_dict, dimod.BINARY)
binary_couplings = [q_binary, Q_binary]
self.model = EnergyModel(
n=self.n_spins,
couplings=binary_couplings,
name=self.name,
cost_function_signs=[-1, -1],
model_type="binary"
)