aux¶
Auxliary functions to load and operate on couplings.
-
tnac4o.auxx.Jij_f2p(J)[source]¶ Change 1-base indexig to 0-base indexing in a list of Jij couplings.
Class tnac4o expects 0-based indexing.
Parameters: J (list) – a list of couplings with elements in the format [i, j, Jij]. Returns: a list of [i-1, j-1, Jij].
-
tnac4o.auxx.energy_Jij(J, states)[source]¶ Calculate energies from bit_strings for Ising model.
Parameters: - J (list) – a list of couplings with elements in the format [i, j, Jij]
- states (nparray) – used encoding: 1 (spin up \(s_i=+1\)), 0 (spin down \(s_i=-1\))
Returns: 1d numpy array with energies of all states.
-
tnac4o.auxx.energy_RMF(J, states)[source]¶ Calculate cost function for bit_string for RMF.
Parameters: - J (dict) – dictionary encoding the cost function as factored graph on 2d rectangular lattice,
see
tnac4o.tnac4o()for used conventions. - states (nparray) – configurations
Returns: 1d numpy array with energies for all states.
- J (dict) – dictionary encoding the cost function as factored graph on 2d rectangular lattice,
see
-
tnac4o.auxx.load_Jij(file_name)[source]¶ Loads couplings of the Ising model/problem from a file.
Parameters: file_name (str) – a path to file with coupling written in the format where each line contains i, j, Jij. Returns: a list of couplings with elements in the format [i, j, Jij].