def __init__(
        self,
        distance_computable,
        cycles_num=100,
        inverse_temperature_beta=50,
        gammma=1.0,
        fractional_reduction=0.99,
        trotter_dimention=None,
        mc_step=None,
        point_num=None,
        spin_arr=None,
        tolerance_diff_e=None
    ):
        '''
        Init.
        
        Args:
            cycles_num:                  The number of annealing cycles.
            inverse_temperature_beta:    Inverse temperature (Beta).
            gammma:                      Gamma.
            fractional_reduction:        Attenuation rate.
            trotter_dimention:           The dimention of Trotter.
            mc_step:                     The number of Monte Carlo steps.
            point_num:                   The number of parameters.
            spin_arr:                    `np.ndarray` of 2-D spin glass in Ising model.
            tolerance_diff_e:            Tolerance for the optimization.
                                         When the ΔE is not improving by at least `tolerance_diff_e`
                                         for two consecutive iterations, annealing will stops.

        '''
        if isinstance(distance_computable, DistanceComputable):
            self.__distance_computable = distance_computable
        else:
            raise TypeError()

        self.__cycles_num = cycles_num
        self.__inverse_temperature_beta = inverse_temperature_beta
        self.__gammma = gammma
        self.__fractional_reduction = fractional_reduction
        self.__tolerance_diff_e = tolerance_diff_e
        
        if spin_arr is not None:
            if isinstance(spin_arr, np.ndarray):
                self.__spin_arr = spin_arr
            else:
                raise TypeError()

            self.__trotter_dimention = self.__spin_arr.shape[0]
            self.__mc_step = self.__spin_arr.shape[1]
            self.__point_num = self.__spin_arr.shape[2]
        else:
            if isinstance(trotter_dimention, int):
                self.__trotter_dimention = trotter_dimention
            else:
                raise TypeError()
            if isinstance(mc_step, int):
                self.__mc_step = mc_step
            else:
                raise TypeError()
            if isinstance(point_num, int):
                self.__point_num = point_num
            else:
                raise TypeError()

            arr = np.diag([1] * self.__point_num)
            arr[arr == 0] = -1
            key_arr = np.arange(self.__mc_step) % self.__point_num
            np.random.shuffle(key_arr)
            spin_arr_list = [None] * self.__trotter_dimention
            for i in range(self.__trotter_dimention):
                spin_arr_list[i] = arr[key_arr]
            self.__spin_arr = np.array(spin_arr_list)
def __init__ ( self , distance_computable , cycles_num = 100 , inverse_temperature_beta = 50 , gammma = 1.0 , fractional_reduction = 0.99 , trotter_dimention = None , mc_step = None , point_num = None , spin_arr = None , tolerance_diff_e = None ) : if isinstance ( distance_computable , DistanceComputable ) : self . __distance_computable = distance_computable else : raise TypeError ( ) self . __cycles_num = cycles_num self . __inverse_temperature_beta = inverse_temperature_beta self . __gammma = gammma self . __fractional_reduction = fractional_reduction self . __tolerance_diff_e = tolerance_diff_e if spin_arr is not None : if isinstance ( spin_arr , np . ndarray ) : self . __spin_arr = spin_arr else : raise TypeError ( ) self . __trotter_dimention = self . __spin_arr . shape [ 0 ] self . __mc_step = self . __spin_arr . shape [ 1 ] self . __point_num = self . __spin_arr . shape [ 2 ] else : if isinstance ( trotter_dimention , int ) : self . __trotter_dimention = trotter_dimention else : raise TypeError ( ) if isinstance ( mc_step , int ) : self . __mc_step = mc_step else : raise TypeError ( ) if isinstance ( point_num , int ) : self . __point_num = point_num else : raise TypeError ( ) arr = np . diag ( [ 1 ] * self . __point_num ) arr [ arr == 0 ] = - 1 key_arr = np . arange ( self . __mc_step ) % self . __point_num np . random . shuffle ( key_arr ) spin_arr_list = [ None ] * self . __trotter_dimention for i in range ( self . __trotter_dimention ) : spin_arr_list [ i ] = arr [ key_arr ] self . __spin_arr = np . array ( spin_arr_list )
Init.
        
        Args:
            cycles_num:                  The number of annealing cycles.
            inverse_temperature_beta:    Inverse temperature (Beta).
            gammma:                      Gamma.
            fractional_reduction:        Attenuation rate.
            trotter_dimention:           The dimention of Trotter.
            mc_step:                     The number of Monte Carlo steps.
            point_num:                   The number of parameters.
            spin_arr:                    `np.ndarray` of 2-D spin glass in Ising model.
            tolerance_diff_e:            Tolerance for the optimization.
                                         When the ΔE is not improving by at least `tolerance_diff_e`
                                         for two consecutive iterations, annealing will stops.