Skip to content

Commit

Permalink
fix: add missing condition_mutation_weights! to fix #378
Browse files Browse the repository at this point in the history
  • Loading branch information
MilesCranmer committed Dec 8, 2024
1 parent 36acbc3 commit f0027f4
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "SymbolicRegression"
uuid = "8254be44-1295-4e6a-a16d-46603ac705cb"
authors = ["MilesCranmer <[email protected]>"]
version = "1.1.0"
version = "1.1.1"

[deps]
ADTypes = "47edcb42-4c32-4615-8424-f2b9edc5f35b"
Expand Down
22 changes: 20 additions & 2 deletions src/TemplateExpression.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ using DynamicExpressions:
get_variable_names,
get_tree,
node_type,
count_nodes
count_nodes,
preserve_sharing
using DynamicExpressions.InterfacesModule:
ExpressionInterface, Interfaces, @implements, all_ei_methods_except, Arguments

Expand Down Expand Up @@ -372,7 +373,24 @@ function MM.condition_mutation_weights!(
@nospecialize(options::AbstractOptions),
curmaxsize::Int,
) where {T,L,N<:TemplateExpression,P<:PopMember{T,L,N}}
# HACK TODO
if !preserve_sharing(typeof(member.tree))
weights.form_connection = 0.0
weights.break_connection = 0.0
end

MM.condition_mutate_constant!(typeof(member.tree), weights, member, options, curmaxsize)

complexity = ComplexityModule.compute_complexity(member, options)

if complexity >= curmaxsize
# If equation is too big, don't add new operators
weights.add_node = 0.0
weights.insert_node = 0.0
end

if !options.should_simplify
weights.simplify = 0.0
end
return nothing
end

Expand Down

0 comments on commit f0027f4

Please sign in to comment.