Skip to content

Commit 015a0ed

Browse files
authored
Merge pull request #91 from jmejia8/fix-issues
Fix #86 #89
2 parents 24732ed + db11809 commit 015a0ed

File tree

6 files changed

+11
-6
lines changed

6 files changed

+11
-6
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "Metaheuristics"
22
uuid = "bcdb8e00-2c21-11e9-3065-2b553b22f898"
33
authors = ["Jesus Mejia <jesusmejded@gmail.com>"]
4-
version = "3.3.1"
4+
version = "3.3.2"
55

66
[deps]
77
Distances = "b4f34e82-e78d-54a5-968a-f98e89d6e8f7"

src/common/compare.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ end
7878
"""
7979
function compare(a::Vector, b::Vector)
8080
k = length(a)
81-
@assert k == length(b)
81+
@assert k == length(b) "Seems that objective function returns vectors of different sizes."
8282

8383
i = 1
8484
while i <= k && a[i] == b[i]

src/externals.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ using Reexport
1313

1414
@reexport import SearchSpaces
1515
@reexport import SearchSpaces: BoxConstrainedSpace, PermutationSpace, BitArraySpace
16+
@reexport import SearchSpaces: cardinality
1617
using SearchSpaces
1718
import SearchSpaces: AbstractSearchSpace,getdim
1819
import SearchSpaces: AtomicSearchSpace, AbstractSampler, Sampler

src/operators/crossover/sbx.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ mutable struct SBX
1010
rng
1111
end
1212

13-
SBX(;η=15, p=0.9, bounds=zeros(0,0), rng = default_rng_mh()) = SBX(η, p, bounds, rng)
13+
SBX(;η=15, p=0.9, bounds=zeros(0,0), rng = default_rng_mh()) = SBX(η, p, _mat_to_bounds(bounds), rng)
1414

1515

1616
function crossover(population, parameters::SBX)

src/operators/mutation/polynomial.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ end
1313
function PolynomialMutation(;
1414
η = 15.0,
1515
bounds = zeros(0,0),
16-
p=1/getdim(bounds),
16+
p=1/getdim(_mat_to_bounds(bounds)),
1717
rng = default_rng_mh()
1818
)
19-
PolynomialMutation(η, isfinite(p) ? p : 1e-2, bounds, rng)
19+
PolynomialMutation(η, isfinite(p) ? p : 1e-2, _mat_to_bounds(bounds), rng)
2020
end
2121

2222
function mutation!(Q, parameters::PolynomialMutation)

test/common-methods.jl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,8 @@ import Random: seed!
186186
pop1 = Metaheuristics.create_child(rand(N,D), rand(N))
187187
pop2 = Metaheuristics.create_child(rand(N,D), (rand(N), -ones(N,2), zeros(N,2)))
188188

189-
problem = Metaheuristics.Problem(x -> rand(), [zeros(D)'; ones(D)'])
189+
bounds = [zeros(D)'; ones(D)']
190+
problem = Metaheuristics.Problem(x -> rand(), bounds)
190191
for pop in [pop1, pop2]
191192
status = State(pop[1], pop)
192193
X = Metaheuristics.reproduction(status, ECA(N=N,K=3).parameters, problem)
@@ -195,6 +196,9 @@ import Random: seed!
195196
end
196197

197198
v = Metaheuristics.GA_reproduction_half(rand(D), rand(D), problem.bounds)
199+
@test PolynomialMutation(;bounds) isa PolynomialMutation
200+
@test SBX(;bounds) isa SBX
201+
198202
@test length(v) == D
199203
end
200204

0 commit comments

Comments
 (0)