Skip to content

Commit

Permalink
removed a temporary line in the example; readded the "sec" printing;
Browse files Browse the repository at this point in the history
bugfix, where unaops coudn't be empty
  • Loading branch information
viktmar committed Oct 16, 2024
1 parent 6360595 commit 97d520c
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 10 deletions.
1 change: 0 additions & 1 deletion example/example_main.jl
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ ops, data = Options(
fitting = fitting_params(
max_iter = 10,
),
meta_data = Dict("ones" => ones(5))
);

# ==================================================================================================
Expand Down
22 changes: 15 additions & 7 deletions src/genetic_ops.jl
Original file line number Diff line number Diff line change
Expand Up @@ -207,16 +207,24 @@ function point_mutation2!(node, ops)
node_elect = random_node(node, mode=0)

if node_elect.ari == 2
node_elect.ari = 1
node_elect.ind = rand(1:length(ops.unaops))
if rand(Bool)
node_elect.lef = copy(node_elect.rig)
if !isempty(ops.unaops)
node_elect.ari = 1
node_elect.ind = rand(1:length(ops.unaops))
if rand(Bool)
node_elect.lef = copy(node_elect.rig)
end
else
point_mutation1!(node, ops)
end

elseif node_elect.ari == 1
node_elect.ari = 2
node_elect.ind = rand(1:length(ops.binops))
node_elect.rig = grow_equation(1, ops, method = :asym)
if !isempty(ops.binops)
node_elect.ari = 2
node_elect.ind = rand(1:length(ops.binops))
node_elect.rig = grow_equation(1, ops, method = :asym)
else
point_mutation1!(node, ops)
end

elseif node_elect.ari == 0
node_elect.ari = -1
Expand Down
4 changes: 2 additions & 2 deletions src/nsga-II.jl
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ function generational_loop(
if ops.general.print_progress
display(cur_prog_dict)
# println("\n", round(Int64, t_since ÷ 60), " min ", round(Int64, t_since % 60), " sec | type :q and enter to finish early")
println("\n", round(Int64, t_since ÷ 60), " min ", round(Int64, t_since % 60))
println("\n", round(Int64, t_since ÷ 60), " min ", round(Int64, t_since % 60), " sec")
end

if ops.general.plot_hall_of_fame
Expand Down Expand Up @@ -399,7 +399,7 @@ function generational_loop(
if ops.general.print_progress
display(cur_prog_dict)
# println("\n", round(Int64, t_since ÷ 60), " min ", round(Int64, t_since % 60), " sec | type :q and enter to finish early")
println("\n", round(Int64, t_since ÷ 60), " min ", round(Int64, t_since % 60))
println("\n", round(Int64, t_since ÷ 60), " min ", round(Int64, t_since % 60), " sec")
end

# ==================================================================================================
Expand Down

0 comments on commit 97d520c

Please sign in to comment.