Closed xgdgsc closed 5 years ago
Which backend search algorithm do you use? I think this can be added fairly easily by using the alg_result
field of ExprOptResult
that is provisioned for algorithm-specific results. BoundedPriorityQueues.jl can be used to do the tracking of the top expressions.
GeneticProgram and GrammaticalEvolution for now.
The GP, GE, MC, and CE backends on latest master 7034248d37 can now return the top k expressions. Activate it using the track_method
keyword argument and retrieve the results from ExprOptResult.alg_result
.
p = GeneticProgram(10,5,4,0.3,0.3; track_method=GeneticPrograms.TopKTracking(5)) #top 5
result = optimize(p, grammar, :R, loss)
result.alg_result[:top_k]
Can you see if that works for you?
Great. Thanks, it works for me.
Currently from my understanding optimize() of algorithms return only the best expression, right? It should be possible and useful to some to add a parameter to specify the number of top expressions to return.