Skip to content

Commit

Permalink
Merge pull request #206 from starquakee/evoxtorch-dev-fcc
Browse files Browse the repository at this point in the history
Fixed an array out of bounds bug in SHADE when pop_size>100
  • Loading branch information
BillHuang2001 authored Jan 16, 2025
2 parents 0af47f7 + 464eab8 commit 41fd8c0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/evox/algorithms/de_variants/sade.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,8 @@ def step(self):
current_vec = self.population[indices]
vector_merge = torch.stack([rand_vec, best_vec, pbest_vec, current_vec])

base_vector_prim = torch.zeros(self.pop_size, 4, device=device)
base_vector_sec = torch.zeros(self.pop_size, 4, device=device)
base_vector_prim = torch.zeros(self.pop_size, self.dim, device=device)
base_vector_sec = torch.zeros(self.pop_size, self.dim, device=device)

for i in range(4):
base_vector_prim = torch.where(base_vec_prim_type.unsqueeze(1) == i, vector_merge[i], base_vector_prim)
Expand Down
4 changes: 2 additions & 2 deletions src/evox/algorithms/de_variants/shade.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ def __init__(
self.diff_padding_num = diff_padding_num
# setup
self.best_index = Mutable(torch.tensor(0, device=device))
self.Memory_FCR = Mutable(torch.full((2, 100), fill_value=0.5, device=device))
self.Memory_FCR = Mutable(torch.full((2, pop_size), fill_value=0.5, device=device))
self.population = Mutable(torch.randn(pop_size, dim, device=device) * (ub - lb) + lb)
self.fitness = Mutable(torch.full((self.pop_size,), fill_value=torch.inf, device=device))
self.fitness = Mutable(torch.full((pop_size,), fill_value=torch.inf, device=device))

def step(self):
"""
Expand Down

0 comments on commit 41fd8c0

Please sign in to comment.