We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
def crossover_2point_bit(self): ''' 3 times faster than crossover_2point, but only use for 0/1 type of Chrom :param self: :return: ''' Chrom, size_pop, len_chrom = self.Chrom, self.size_pop, self.len_chrom half_size_pop = int(size_pop / 2) Chrom1, Chrom2 = Chrom[:half_size_pop], Chrom[half_size_pop:] mask = np.zeros(shape=(half_size_pop, len_chrom), dtype=int) for i in range(half_size_pop): n1, n2 = np.random.randint(0, self.len_chrom, 2) if n1 > n2: n1, n2 = n2, n1 mask[i, n1:n2] = 1 mask2 = (Chrom1 ^ Chrom2) & mask Chrom1 ^= mask2 Chrom2 ^= mask2 return self.Chrom
def crossover_2point_bit(self): ''' 3 times faster than
, but only use for 0/1 type of Chrom :param self: :return: ''' Chrom, size_pop, len_chrom = self.Chrom, self.size_pop, self.len_chrom half_size_pop = int(size_pop / 2) Chrom1, Chrom2 = Chrom[:half_size_pop], Chrom[half_size_pop:] mask = np.zeros(shape=(half_size_pop, len_chrom), dtype=int) for i in range(half_size_pop): n1, n2 = np.random.randint(0, self.len_chrom, 2) if n1 > n2: n1, n2 = n2, n1 mask[i, n1:n2] = 1 mask2 = (Chrom1 ^ Chrom2) & mask Chrom1 ^= mask2 Chrom2 ^= mask2 return self.Chrom
该函数似乎并没有改变self.Chrom,未起到交叉变异的作用
The text was updated successfully, but these errors were encountered:
No branches or pull requests
def crossover_2point_bit(self): ''' 3 times faster than
crossover_2point, but only use for 0/1 type of Chrom :param self: :return: ''' Chrom, size_pop, len_chrom = self.Chrom, self.size_pop, self.len_chrom half_size_pop = int(size_pop / 2) Chrom1, Chrom2 = Chrom[:half_size_pop], Chrom[half_size_pop:] mask = np.zeros(shape=(half_size_pop, len_chrom), dtype=int) for i in range(half_size_pop): n1, n2 = np.random.randint(0, self.len_chrom, 2) if n1 > n2: n1, n2 = n2, n1 mask[i, n1:n2] = 1 mask2 = (Chrom1 ^ Chrom2) & mask Chrom1 ^= mask2 Chrom2 ^= mask2 return self.Chrom
该函数似乎并没有改变self.Chrom,未起到交叉变异的作用
The text was updated successfully, but these errors were encountered: