sisl / ExprOptimization.jl

Algorithms for optimization of Julia expressions
Other
44 stars 11 forks source link

Feature: Return top expressions #13

Closed xgdgsc closed 5 years ago

xgdgsc commented 5 years ago

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.

rcnlee commented 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.

xgdgsc commented 5 years ago

GeneticProgram and GrammaticalEvolution for now.

rcnlee commented 5 years ago

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?

xgdgsc commented 5 years ago

Great. Thanks, it works for me.