Skip to content

Commit 8285afd

Browse files
committed
symmetric_search_space(): deprecate
use RangePerDimSearchSpace instead
1 parent 3dc05ef commit 8285afd

15 files changed

+33
-31
lines changed

examples/multiobjective.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ res = bboptimize(schaffer1; Method=:borg_moea,
1111
# N is the number of the problem (not fitness) dimensions
1212
pareto_curve_func(t, ::Type{Val{N}}) where {N} = (N*t[1]^2, N*(2-t[1])^2)
1313
pareto_curve = BlackBoxOptim.Hypersurface(pareto_curve_func,
14-
symmetric_search_space(1, (0.0, 2.0)))
14+
RectSearchSpace(1, (0.0, 2.0)))
1515

1616
# generate the set of ϵ-indexed points on the exact Pareto frontier
1717
pareto_pts = BlackBoxOptim.generate(pareto_curve,

src/BlackBoxOptim.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ export Optimizer, AskTellOptimizer, SteppingOptimizer, PopulationOptimizer,
6060

6161
# Search spaces
6262
ParamBounds, Individual, SearchSpace, FixedDimensionSearchSpace,
63-
RectSearchSpace, ContinuousRectSearchSpace, symmetric_search_space,
63+
RectSearchSpace, ContinuousRectSearchSpace,
6464
numdims, dimmin, dimmax, dimdelta, dimrange,
6565
rand_individual, rand_individuals, rand_individuals_lhs,
6666

src/adaptive_differential_evolution.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const ADE_DefaultOptions = chain(DE_DefaultOptions, ParamsDict(
44
# Distributions we will use to generate new F and CR values.
55
:fdistr => BimodalCauchy(0.65, 0.1, 1.0, 0.1, clampBelow0 = false),
66
:crdistr => BimodalCauchy(0.1, 0.1, 0.95, 0.1, clampBelow0 = false),
7-
:SearchSpace => symmetric_search_space(1)
7+
:SearchSpace => RectSearchSpace(1)
88
))
99

1010
"""

src/default_parameters.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ function check_and_create_search_space(params::Parameters)
6464
if ndim == :NotSpecified
6565
throw(ArgumentError("You MUST specify NumDimensions= in a solution when giving a SearchRange=$(sr)"))
6666
end
67-
return symmetric_search_space(params[:NumDimensions], sr)
67+
return RectSearchSpace(params[:NumDimensions], sr)
6868
elseif isa(sr, typeof([(0.0, 1.0)]))
6969
return RectSearchSpace(sr)
7070
else

src/problems/multi_objective.jl

+3-3
Original file line numberDiff line numberDiff line change
@@ -148,13 +148,13 @@ See http://dces.essex.ac.uk/staff/zhang/MOEAcompetition/cec09testproblem0904.pdf
148148
const CEC09_Unconstrained_Set = Dict{Int,FunctionBasedProblemFamily}(
149149
8 => FunctionBasedProblemFamily(CEC09_UP8, "CEC09 UP8", ParetoFitnessScheme{3}(is_minimizing=true),
150150
(-2.0, 2.0),
151-
Hypersurface(CEC09_UP8_PF, symmetric_search_space(2, (0.0, 1.0))),
152-
symmetric_search_space(2, (0.0, 1.0)))
151+
Hypersurface(CEC09_UP8_PF, RectSearchSpace(2, (0.0, 1.0))),
152+
RectSearchSpace(2, (0.0, 1.0)))
153153
)
154154

155155
schaffer1(x) = (sum(abs2, x), sum(xx -> abs2(xx - 2.0), x))
156156
schaffer1_PF(t, ::Type{Val{NP}}) where {NP} = (NP*t[1]^2, NP*(2-t[1])^2)
157157

158158
const Schaffer1Family = FunctionBasedProblemFamily(schaffer1, "Schaffer1", ParetoFitnessScheme{2}(is_minimizing=true),
159159
(-10.0, 10.0),
160-
Hypersurface(schaffer1_PF, symmetric_search_space(1, (0.0, 2.0))))
160+
Hypersurface(schaffer1_PF, RectSearchSpace(1, (0.0, 2.0))))

src/problems/problem_family.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ Construct search space for `FunctionBasedProblem` with the given number of dimen
4444
function instantiate_search_space(family::FunctionBasedProblemFamily, ndim::Int)
4545
ndim >= numdims(family.reserved_ss) ||
4646
throw(ArgumentError("Cannot create $ndim-problem: number of dimensions less than reserved dimensions"))
47-
vcat(family.reserved_ss, symmetric_search_space(ndim - numdims(family.reserved_ss), family.range_per_dim))
47+
vcat(family.reserved_ss, RectSearchSpace(ndim - numdims(family.reserved_ss), family.range_per_dim))
4848
end
4949

5050
"""

src/search_space.jl

+3-1
Original file line numberDiff line numberDiff line change
@@ -179,5 +179,7 @@ RectSearchSpace(ranges::AbstractVector) =
179179
Create `RectSearchSpace` with given number of dimensions
180180
and given range of valid values for each dimension.
181181
"""
182-
symmetric_search_space(numdims::Integer, range=(0.0, 1.0)) =
182+
RectSearchSpace(numdims::Integer, range=(0.0, 1.0)) =
183183
RectSearchSpace(fill(range, numdims))
184+
185+
@deprecate symmetric_search_space(numdims, range=(0.0, 1.0)) RectSearchSpace(numdims, range)

test/problems/test_problem.jl

+6-6
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ fsum_abs_and_sq(x) = (sum(abs, x), sum(abs2, x))
99
@test fitness_scheme(p) == MinimizingFitnessScheme
1010
@test numobjectives(p) == 1
1111
@test numdims(p) == 1
12-
@test search_space(p) == symmetric_search_space(1, (-1.0, 1.0))
12+
@test search_space(p) == RectSearchSpace(1, (-1.0, 1.0))
1313

1414
@test fitness([0.0], p) == 0.0
1515
@test fitness([1.2], p) == 1.2
@@ -22,14 +22,14 @@ end
2222
@test fitness_scheme(p) == MinimizingFitnessScheme
2323
@test numobjectives(p) == 1
2424
@test numdims(p) == 3
25-
@test search_space(p) == symmetric_search_space(3, (-1.0, 1.0))
25+
@test search_space(p) == RectSearchSpace(3, (-1.0, 1.0))
2626

2727
@test fitness([0.0, 1.0, 2.0], p) == 3.0
2828
@test fitness([-1.0, 1.0, 2.0], p) == 4.0
2929
end
3030

3131
@testset "1-dimensional, multi-objective sumabs_sumsq" begin
32-
ss = symmetric_search_space(1)
32+
ss = RectSearchSpace(1)
3333
p = FunctionBasedProblem(fsum_abs_and_sq, "sumabs_sumsq",
3434
ParetoFitnessScheme{2}(), ss, (0.0, 0.0))
3535

@@ -73,7 +73,7 @@ end
7373
@test BlackBoxOptim.orig_problem(sp) === p
7474
@test numobjectives(sp) == 1
7575
@test numdims(sp) == 1
76-
@test search_space(sp) == symmetric_search_space(1, (-1.0, 1.0))
76+
@test search_space(sp) == RectSearchSpace(1, (-1.0, 1.0))
7777
xs = sp.xshift
7878
@test xs == [0.5]
7979
@test sp.fitshift == 0.0
@@ -84,7 +84,7 @@ end
8484
end
8585

8686
@testset "Shifted and biased 2-dim" begin
87-
ss = symmetric_search_space(2, (-0.5, 1.0))
87+
ss = RectSearchSpace(2, (-0.5, 1.0))
8888
p = minimization_problem(fsabs, "sumabs", (-0.5, 1.0), 2, 0.0)
8989
sp = BlackBoxOptim.ShiftedAndBiasedProblem(p; fitshift = 1.3)
9090

@@ -93,7 +93,7 @@ end
9393
@test numdims(sp) == 2
9494
@test sp.xshift == [0.0, 0.0]
9595
@test sp.fitshift == 1.3
96-
@test search_space(sp) == symmetric_search_space(2, (-0.5, 1.0))
96+
@test search_space(sp) == RectSearchSpace(2, (-0.5, 1.0))
9797

9898
xs = sp.xshift
9999
@test fitness([0.0, 1.0], sp) == 1.0 + 1.3

test/test_adaptive_differential_evolution.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ NumTestRepetitions = 100
22

33
@testset "Adaptive differential evolution optimizer" begin
44

5-
ss = symmetric_search_space(1, (0.0, 10.0))
5+
ss = RectSearchSpace(1, (0.0, 10.0))
66
fake_problem = FunctionBasedProblem(x -> 0.0, "test_problem", MinimizingFitnessScheme, ss)
77

88
ade = adaptive_de_rand_1_bin(fake_problem, ParamsDict(

test/test_crossover_operators.jl

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
@testset "Crossover operators" begin
22

3-
ss = symmetric_search_space(1, (0.0, 10.0))
3+
ss = RectSearchSpace(1, (0.0, 10.0))
44
fake_problem = FunctionBasedProblem(x -> 0.0, "test_problem", MinimizingFitnessScheme, ss)
55
DE = de_rand_1_bin(fake_problem, ParamsDict(
66
:Population => reshape(collect(1.0:10.0), (1, 10)),
@@ -63,7 +63,7 @@ DE = de_rand_1_bin(fake_problem, ParamsDict(
6363
end
6464

6565
@testset "MutationWrapper" begin
66-
ss = symmetric_search_space(2, (0.0, 10.0))
66+
ss = RectSearchSpace(2, (0.0, 10.0))
6767
pop = reshape(collect(1.0:8.0), 2, 4)
6868
gibbs = UniformMutation(ss)
6969
gibbs_wrapper = BlackBoxOptim.MutationWrapper(gibbs)

test/test_differential_evolution.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
@testset "Differential evolution optimizer" begin
22

3-
ss = symmetric_search_space(1, (0.0, 10.0))
3+
ss = RectSearchSpace(1, (0.0, 10.0))
44
fake_problem = FunctionBasedProblem(x -> 0.0, "test_problem", MinimizingFitnessScheme, ss)
55
DE = de_rand_1_bin(fake_problem, ParamsDict(
66
:Population => reshape(collect(1.0:10.0), (1, 10)),

test/test_generating_set_search.jl

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
@testset "Generating set search" begin
22

3-
ss = symmetric_search_space(3, (0.0, 1.0))
3+
ss = RectSearchSpace(3, (0.0, 1.0))
44
@test BlackBoxOptim.calc_initial_step_size(ss) == (0.5 * (1.0 - 0.0))
55

6-
ss = symmetric_search_space(3, (-1.2, 42.0))
6+
ss = RectSearchSpace(3, (-1.2, 42.0))
77
@test BlackBoxOptim.calc_initial_step_size(ss, 0.80) == (0.80 * (42.0 + 1.2))
88

99
end

test/test_random_search.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
min = rand(1:123)
77
range = (min * rand(), min + rand() * min)
88

9-
ss = BlackBoxOptim.symmetric_search_space(dims, range)
9+
ss = RectSearchSpace(dims, range)
1010
opt = BlackBoxOptim.random_search(ss)
1111

1212
res1 = BlackBoxOptim.ask(opt)

test/test_search_space.jl

+8-8
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
@testset "in()" begin
33
for i in 1:NumTestRepetitions
44
reps = rand(1:10)
5-
ss1 = symmetric_search_space(reps, (0.0, 1.0))
5+
ss1 = RectSearchSpace(reps, (0.0, 1.0))
66
ind = rand_individual(ss1)
77
for j in 1:reps
88
@test (dimmin(ss1, j) <= ind[j] <= dimmax(ss1, j))
@@ -11,7 +11,7 @@
1111
end
1212

1313
@testset "Symmetric search space with default range" begin
14-
ss1 = symmetric_search_space(1)
14+
ss1 = RectSearchSpace(1)
1515
@test numdims(ss1) == 1
1616
@test dimmin(ss1) == [0.0]
1717
@test dimmin(ss1, 1) == 0.0
@@ -28,7 +28,7 @@
2828
@test in(ind, ss1)
2929
end
3030

31-
ss3 = symmetric_search_space(3)
31+
ss3 = RectSearchSpace(3)
3232
@test numdims(ss3) == 3
3333
@test dimmin(ss3) == [0.0, 0.0, 0.0]
3434
@test dimmin(ss3, 2) == 0.0
@@ -49,8 +49,8 @@
4949
end
5050

5151
@testset "ContinuousRectSearchSpace with given range" begin
52-
ss1 = symmetric_search_space(1, (-1.0, 1.0))
53-
@test_throws ArgumentError symmetric_search_space(1, (0.0, -1.0))
52+
ss1 = RectSearchSpace(1, (-1.0, 1.0))
53+
@test_throws ArgumentError RectSearchSpace(1, (0.0, -1.0))
5454
@test ss1 isa ContinuousRectSearchSpace
5555
@test numdims(ss1) == 1
5656
@test dimrange(ss1) == [(-1.0, 1.0)]
@@ -60,7 +60,7 @@
6060
reps = rand(1:100)
6161
a = rand()
6262
range = (a, a + (1-a)*rand())
63-
ss = symmetric_search_space(reps, range)
63+
ss = RectSearchSpace(reps, range)
6464
@test numdims(ss) == reps
6565
@test all(dr -> dr == range, dimrange(ss))
6666
end
@@ -71,7 +71,7 @@
7171
reps = rand(1:100)
7272
mm = sort(rand(2,1), dims=1)
7373
range = (mm[1], mm[2])
74-
ss = symmetric_search_space(reps, range)
74+
ss = RectSearchSpace(reps, range)
7575
ind = rand_individual(ss)
7676
@test length(ind) == numdims(ss)
7777
@test in(ind, ss)
@@ -83,7 +83,7 @@
8383
reps = rand(1:10)
8484
mm = sort(rand(2,1), dims=1)
8585
range = (mm[1], mm[2])
86-
ss = symmetric_search_space(reps, range)
86+
ss = RectSearchSpace(reps, range)
8787
numinds = rand(1:10)
8888
inds = rand_individuals(ss, numinds)
8989
@test size(inds,1) == numdims(ss)

test/test_selectors.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
@testset "Selection operators" begin
22

3-
ss = symmetric_search_space(1, (0.0, 10.0))
3+
ss = RectSearchSpace(1, (0.0, 10.0))
44
fake_problem = FunctionBasedProblem(x -> 0.0, "test_problem", MinimizingFitnessScheme, ss)
55
fake_pop = reshape(collect(1.0:10.0), (1, 10))
66

0 commit comments

Comments
 (0)