Skip to content

Commit

Permalink
Test reverse sort in probPickFirst test
Browse files Browse the repository at this point in the history
  • Loading branch information
MilesCranmer committed Feb 12, 2022
1 parent 6d240c4 commit 9ad8b40
Showing 1 changed file with 21 additions and 15 deletions.
36 changes: 21 additions & 15 deletions test/test_prob_pick_first.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,29 @@ options = Options(
unary_operators=(cos, sin),
probPickFirst=0.999,
)
members = PopMember{Float32}[]

# Generate members with scores from 0 to 1:
for i=1:n
tree = Node("x1") * 3.2f0
score = Float32(i-1)/(n-1)
push!(members, PopMember(tree, score))
end
for reverse in [false, true]
members = PopMember{Float32}[]

pop = Population(members, n)
# Generate members with scores from 0 to 1:
for i=1:n
tree = Node("x1") * 3.2f0
score = Float32(i-1)/(n-1)
if reverse
score = 1 - score
end
push!(members, PopMember(tree, score))
end

best_pop_member = [
SymbolicRegression.bestOfSample(pop, options).score
for j=1:100
]
pop = Population(members, n)

mean_value = sum(best_pop_member)/length(best_pop_member)
best_pop_member = [
SymbolicRegression.bestOfSample(pop, options).score
for j=1:100
]

# Make sure average score is small
@test mean_value < 0.1
mean_value = sum(best_pop_member)/length(best_pop_member)

# Make sure average score is small
@test mean_value < 0.1
end

0 comments on commit 9ad8b40

Please sign in to comment.