Skip to content

Commit

Permalink
clean-up
Browse files Browse the repository at this point in the history
  • Loading branch information
erwanlecarpentier committed Jun 18, 2021
1 parent d3ff835 commit 1620a5b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 17 deletions.
12 changes: 2 additions & 10 deletions src/individual.jl
Expand Up @@ -63,7 +63,7 @@ cfg_from_info(nodes::Array{Node}, n_in::Int64, outputs::Array{Int16},
Deduce config from given information.
"""
function cfg_from_info(nodes::Array{Node}, n_in::Int64, outputs::Array{Int16},
function_module::Module, d_fitness::Int64; kwargs...)
function_module::Module, d_fitness::Int64)
# Create the appropriate cfg
functions = Function[]
two_arity = BitVector()
Expand All @@ -78,7 +78,7 @@ function cfg_from_info(nodes::Array{Node}, n_in::Int64, outputs::Array{Int16},
n_out = length(outputs)
R = 1
C = length(nodes)
cfg = (
(
two_arity=two_arity,
n_in=n_in,
#m_rate=0, # Not used in handcrafter CGP
Expand All @@ -90,7 +90,6 @@ function cfg_from_info(nodes::Array{Node}, n_in::Int64, outputs::Array{Int16},
rows=R,
columns=C
)
cfg
end

"""
Expand Down Expand Up @@ -142,13 +141,6 @@ function CGPInd(nodes::Array{Node}, cfg::NamedTuple, outputs::Array{Int16};
chromosome = vcat(xs, ys, fs, ps, outs)
# Create individual
CGPInd(cfg, chromosome; kwargs...)
#=
if img_proc
CartesianGeneticProgramming.CGPInd(cfg, chromosome; buffer=buffer)
else
CGPInd(cfg, chromosome; kwargs...)
end
=#
end

function CGPInd(cfg::NamedTuple, chromosome::Array{Float64},
Expand Down
14 changes: 7 additions & 7 deletions test/individual.jl
Expand Up @@ -232,13 +232,13 @@ end
@test ind.n_in == n_in
@test ind.n_out == length(outputs)
@test ind.n_parameters == length(my_nodes[1].p)
@test length(ind.nodes) == 6
for i in 1:3
@test ind.nodes[i+3].f == my_nodes[i].f
@test ind.nodes[i+3].p == my_nodes[i].p
@test ind.nodes[i+3].x == my_nodes[i].x
@test ind.nodes[i+3].y == my_nodes[i].y
@test ind.nodes[i+3].active == [true, false, false][i]
@test length(ind.nodes) == n_in + length(my_nodes)
for i in eachindex(my_nodes)
@test ind.nodes[i+n_in].f == my_nodes[i].f
@test ind.nodes[i+n_in].p == my_nodes[i].p
@test ind.nodes[i+n_in].x == my_nodes[i].x
@test ind.nodes[i+n_in].y == my_nodes[i].y
@test ind.nodes[i+n_in].active == [true, false, false][i]
end
@test length(ind.fitness) == d_fitness
@test length(ind.chromosome) == (1 * length(my_nodes) * (3 + length(my_nodes[1].p)) + length(outputs))
Expand Down

0 comments on commit 1620a5b

Please sign in to comment.