Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create overloadable utilities: AbstractOptions, AbstractRuntimeOptions, AbstractMutationWeights, AbstractSearchState, and mutate! #353

Merged
merged 16 commits into from
Oct 14, 2024

Conversation

MilesCranmer
Copy link
Owner

@MilesCranmer MilesCranmer commented Oct 12, 2024

@atharvas this should help simplify LaSR and make it compatible with future versions of SymbolicRegression.jl

Basically the trick is to do the following:

struct LaSROptions{O<:SR.Options} <: SR.AbstractOptions
    lm_options::LLMOptions
    sr_options::O
end
const LLM_OPTIONS_KEYS = fieldnames(LLMOptions)
@inline function Base.getproperty(options::LaSROptions, k)
    if k in LLM_OPTIONS_KEYS
        return getproperty(getfield(options, :lm_options), k)
    else
        return getproperty(getfield(options, :sr_options), k)
    end
end

Then you can pass any instance of LaSROptions directly to equation_search.

Furthermore, it lets you overload the behavior of any function inside SymbolicRegression.jl that has an input argument options – simply declare a new method for ::LaSROptions.

What do you think?

You can also create a function LaSROptions that checks which keys are in LLMOptions, and uses those to instantiate it, and the other ones to instantiate SR.Options.

@coveralls
Copy link

coveralls commented Oct 12, 2024

Pull Request Test Coverage Report for Build 11319225574

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 150 of 173 (86.71%) changed or added relevant lines in 13 files are covered.
  • 29 unchanged lines in 10 files lost coverage.
  • Overall coverage decreased (-0.2%) to 94.757%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/Configure.jl 4 5 80.0%
src/OptionsStruct.jl 0 1 0.0%
src/SymbolicRegression.jl 8 9 88.89%
src/SearchUtils.jl 52 61 85.25%
src/Mutate.jl 71 82 86.59%
Files with Coverage Reduction New Missed Lines %
src/SingleIteration.jl 1 98.48%
src/AdaptiveParsimony.jl 1 97.06%
src/OptionsStruct.jl 1 89.8%
src/HallOfFame.jl 1 95.96%
src/MLJInterface.jl 1 95.48%
src/Utils.jl 2 97.58%
src/Population.jl 3 95.89%
src/Options.jl 4 92.49%
src/Configure.jl 7 89.03%
src/SearchUtils.jl 8 88.68%
Totals Coverage Status
Change from base Build 11273371497: -0.2%
Covered Lines: 2693
Relevant Lines: 2842

💛 - Coveralls

Copy link
Contributor

github-actions bot commented Oct 12, 2024

Benchmark Results

master 2cd8b10... master/2cd8b1006e43eb...
search/multithreading 23.4 ± 0.39 s 23.6 ± 3.4 s 0.99
search/serial 34.1 ± 0.25 s 33.1 ± 0.06 s 1.03
utils/best_of_sample 1.13 ± 0.41 μs 1.06 ± 0.44 μs 1.07
utils/check_constraints_x10 11.3 ± 2.8 μs 11.3 ± 2.8 μs 1
utils/compute_complexity_x10/Float64 2.08 ± 0.11 μs 2.07 ± 0.14 μs 1.01
utils/compute_complexity_x10/Int64 2.08 ± 0.12 μs 2.03 ± 0.12 μs 1.02
utils/compute_complexity_x10/nothing 1.45 ± 0.11 μs 1.47 ± 0.11 μs 0.987
utils/insert_random_op_x10 5.74 ± 1.9 μs 5.91 ± 1.9 μs 0.971
utils/next_generation_x100 0.343 ± 0.12 ms 0.423 ± 0.12 ms 0.811
utils/optimize_constants_x10 0.0371 ± 0.009 s 0.0375 ± 0.0083 s 0.988
utils/randomly_rotate_tree_x10 5.23 ± 0.59 μs 5.36 ± 0.66 μs 0.976
time_to_load 1.92 ± 0.0081 s 1.91 ± 0.032 s 1

Benchmark Plots

A plot of the benchmark results have been uploaded as an artifact to the workflow run for this PR.
Go to "Actions"->"Benchmark a pull request"->[the most recent run]->"Artifacts" (at the bottom).

src/Mutate.jl Outdated Show resolved Hide resolved
@MilesCranmer MilesCranmer changed the title feat: create AbstractOptions, AbstractRuntimeOptions, AbstractMutationWeights feat: create AbstractOptions, AbstractRuntimeOptions, AbstractMutationWeights, AbstractSearchState Oct 14, 2024
@MilesCranmer MilesCranmer changed the title feat: create AbstractOptions, AbstractRuntimeOptions, AbstractMutationWeights, AbstractSearchState Create overloadable utilities: AbstractOptions, AbstractRuntimeOptions, AbstractMutationWeights, AbstractSearchState, and mutate! Oct 14, 2024
@MilesCranmer
Copy link
Owner Author

@atharvas let me know if there’s anything else missing for LaSR and I can add it in another PR.

@MilesCranmer MilesCranmer merged commit 4f7e681 into master Oct 14, 2024
17 checks passed
@MilesCranmer MilesCranmer deleted the abstract-options branch October 14, 2024 01:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants