Skip to content

Commit

Permalink
Merge branch 'master' into compathelper/new_version/2024-10-07-00-11-…
Browse files Browse the repository at this point in the history
…36-542-01562492202
  • Loading branch information
MilesCranmer authored Oct 14, 2024
2 parents e769d64 + 3892a66 commit f9c57fe
Show file tree
Hide file tree
Showing 46 changed files with 1,210 additions and 586 deletions.
12 changes: 1 addition & 11 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ jobs:
- "part2"
- "part3"
julia-version:
- "1.6"
- "1.8"
- "1.10"
- "1"
os:
- ubuntu-latest
Expand All @@ -54,15 +53,6 @@ jobs:
- os: macOS-latest
julia-version: "1"
test: "part3"
- os: ubuntu-latest
julia-version: "~1.11.0-0"
test: "part1"
- os: ubuntu-latest
julia-version: "~1.11.0-0"
test: "part2"
- os: ubuntu-latest
julia-version: "~1.11.0-0"
test: "part3"

steps:
- uses: actions/checkout@v4
Expand Down
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ ci:

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
rev: v5.0.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-added-large-files
- repo: https://github.com/domluna/JuliaFormatter.jl
rev: v1.0.56
rev: v1.0.61
hooks:
- id: julia-formatter
- repo: https://github.com/pre-commit/mirrors-prettier
Expand Down
8 changes: 3 additions & 5 deletions 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 = "0.25.0"
version = "1.0.0-beta1"

[deps]
ADTypes = "47edcb42-4c32-4615-8424-f2b9edc5f35b"
Expand All @@ -18,7 +18,6 @@ LossFunctions = "30fc2ffe-d236-52d8-8643-a9d8f7c094a7"
MLJModelInterface = "e80e1ace-859a-464e-9ed9-23947d8ae3ea"
MacroTools = "1914dd2f-81c6-5fcd-8719-6d5c9610ff09"
Optim = "429524aa-4258-5aef-a3af-852621145aeb"
PackageExtensionCompat = "65ce6f38-6b18-4e1d-a461-8949797d7930"
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
PrecompileTools = "aea7be01-6a6a-4083-8856-8a6e6704d82a"
Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"
Expand All @@ -44,7 +43,7 @@ ADTypes = "^1.4.0"
Compat = "^4.2"
ConstructionBase = "<1.5.7"
Dates = "1"
DifferentiationInterface = "0.5"
DifferentiationInterface = "0.5, 0.6"
DispatchDoctor = "0.4"
Distributed = "<0.0.1, 1"
DynamicExpressions = "1"
Expand All @@ -56,7 +55,6 @@ LossFunctions = "0.10, 0.11"
MLJModelInterface = "~1.5, ~1.6, ~1.7, ~1.8, ~1.9, ~1.10, ~1.11"
MacroTools = "0.4, 0.5"
Optim = "~1.8, ~1.9"
PackageExtensionCompat = "1"
Pkg = "<0.0.1, 1"
PrecompileTools = "1"
Printf = "<0.0.1, 1"
Expand All @@ -67,7 +65,7 @@ SpecialFunctions = "0.10.1, 1, 2"
StatsBase = "0.33, 0.34"
SymbolicUtils = "0.19, ^1.0.5, 2, 3"
TOML = "<0.0.1, 1"
julia = "1.6"
julia = "1.10"

[extras]
Enzyme = "7da242da-08ed-463a-9acd-ee780be4f1d9"
Expand Down
48 changes: 43 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ with the following function:
```julia
import SymbolicRegression: node_to_symbolic

eqn = node_to_symbolic(dominating[end].tree, options)
eqn = node_to_symbolic(dominating[end].tree)
println(simplify(eqn*5 + 3))
```

Expand Down Expand Up @@ -358,27 +358,35 @@ stateDiagram-v2
AdaptiveParsimony --> Mutate
AdaptiveParsimony --> Population
AdaptiveParsimony --> RegularizedEvolution
AdaptiveParsimony --> SearchUtils
AdaptiveParsimony --> SingleIteration
AdaptiveParsimony --> SymbolicRegression
CheckConstraints --> Mutate
CheckConstraints --> SymbolicRegression
Complexity --> CheckConstraints
Complexity --> HallOfFame
Complexity --> LossFunctions
Complexity --> MLJInterface
Complexity --> Mutate
Complexity --> PopMember
Complexity --> Population
Complexity --> SearchUtils
Complexity --> SingleIteration
Complexity --> SymbolicRegression
ConstantOptimization --> ExpressionBuilder
ConstantOptimization --> Mutate
ConstantOptimization --> SingleIteration
Core --> AdaptiveParsimony
Core --> CheckConstraints
Core --> Complexity
Core --> ConstantOptimization
Core --> DimensionalAnalysis
Core --> ExpressionBuilder
Core --> ExpressionBuilder
Core --> HallOfFame
Core --> InterfaceDynamicExpressions
Core --> LossFunctions
Core --> MLJInterface
Core --> Migration
Core --> Mutate
Core --> MutationFunctions
Expand All @@ -390,42 +398,63 @@ stateDiagram-v2
Core --> SingleIteration
Core --> SymbolicRegression
Dataset --> Core
DimensionalAnalysis --> LossFunctions
ExpressionBuilder --> SymbolicRegression
HallOfFame --> ExpressionBuilder
HallOfFame --> MLJInterface
HallOfFame --> SearchUtils
HallOfFame --> SingleIteration
HallOfFame --> SymbolicRegression
HallOfFame --> deprecates
InterfaceDynamicExpressions --> ExpressionBuilder
InterfaceDynamicExpressions --> HallOfFame
InterfaceDynamicExpressions --> LossFunctions
InterfaceDynamicExpressions --> SymbolicRegression
InterfaceDynamicQuantities --> Dataset
InterfaceDynamicQuantities --> MLJInterface
LossFunctions --> ConstantOptimization
LossFunctions --> HallOfFame
LossFunctions --> ExpressionBuilder
LossFunctions --> ExpressionBuilder
LossFunctions --> Mutate
LossFunctions --> PopMember
LossFunctions --> Population
LossFunctions --> SingleIteration
LossFunctions --> SymbolicRegression
MLJInterface --> SymbolicRegression
Migration --> SymbolicRegression
Mutate --> RegularizedEvolution
MutationFunctions --> ExpressionBuilder
MutationFunctions --> Mutate
MutationFunctions --> Population
MutationFunctions --> SymbolicRegression
MutationFunctions --> deprecates
MutationWeights --> Core
MutationWeights --> Options
MutationWeights --> OptionsStruct
Operators --> Core
Operators --> Options
Options --> Core
OptionsStruct --> Core
OptionsStruct --> Options
OptionsStruct --> Options
PopMember --> ConstantOptimization
PopMember --> ExpressionBuilder
PopMember --> HallOfFame
PopMember --> Migration
PopMember --> Mutate
PopMember --> Population
PopMember --> RegularizedEvolution
PopMember --> SearchUtils
PopMember --> SingleIteration
PopMember --> SymbolicRegression
Population --> ExpressionBuilder
Population --> Migration
Population --> RegularizedEvolution
Population --> SearchUtils
Population --> SingleIteration
Population --> SymbolicRegression
ProgramConstants --> Core
ProgramConstants --> Dataset
ProgramConstants --> Operators
ProgressBars --> SearchUtils
ProgressBars --> SymbolicRegression
Recorder --> Mutate
Expand All @@ -435,10 +464,19 @@ stateDiagram-v2
RegularizedEvolution --> SingleIteration
SearchUtils --> SymbolicRegression
SingleIteration --> SymbolicRegression
Utils --> CheckConstraints
Utils --> ConstantOptimization
Utils --> Dataset
Utils --> DimensionalAnalysis
Utils --> HallOfFame
Utils --> InterfaceDynamicExpressions
Utils --> MLJInterface
Utils --> Migration
Utils --> Operators
Utils --> Options
Utils --> PopMember
Utils --> Population
Utils --> RegularizedEvolution
Utils --> SearchUtils
Utils --> SingleIteration
Utils --> SymbolicRegression
```
Expand All @@ -449,7 +487,7 @@ Bash command to generate dependency structure from `src` directory (requires `vi
echo 'stateDiagram-v2'
IFS=$'\n'
for f in *.jl; do
for line in $(cat $f | grep -e 'import \.\.' -e 'import \.'); do
for line in $(cat $f | grep -e 'import \.\.' -e 'import \.' -e 'using \.' -e 'using \.\.'); do
echo $(echo $line | vims -s 'dwf:d$' -t '%s/^\.*//g' '%s/Module//g') $(basename "$f" .jl);
done;
done | vims -l 'f a--> ' | sort
Expand Down
53 changes: 53 additions & 0 deletions benchmark/benchmarks.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using BenchmarkTools
using SymbolicRegression, BenchmarkTools, Random
using SymbolicRegression.AdaptiveParsimonyModule: RunningSearchStatistics
using SymbolicRegression.MutateModule: next_generation
using SymbolicRegression.RecorderModule: RecordType
using SymbolicRegression.PopulationModule: best_of_sample
using SymbolicRegression.ConstantOptimizationModule: optimize_constants
using SymbolicRegression.CheckConstraintsModule: check_constraints
Expand Down Expand Up @@ -93,6 +95,57 @@ function create_utils_benchmark()
)
)

suite["next_generation_x100"] = @benchmarkable(
let
for member in members
next_generation(
dataset,
member,
temperature,
curmaxsize,
rss,
options;
tmp_recorder=recorder,
)
end
end,
setup = (
nfeatures = 1;
dataset = Dataset(randn(nfeatures, 32), randn(32));
mutation_weights = MutationWeights(;
mutate_constant=1.0,
mutate_operator=1.0,
swap_operands=1.0,
rotate_tree=1.0,
add_node=1.0,
insert_node=1.0,
simplify=0.0,
randomize=0.0,
do_nothing=0.0,
form_connection=0.0,
break_connection=0.0,
);
options = Options(;
unary_operators=[sin, cos], binary_operators=[+, -, *, /], mutation_weights
);
recorder = RecordType();
temperature = 1.0;
curmaxsize = 20;
rss = RunningSearchStatistics(; options);
trees = [
gen_random_tree_fixed_size(15, options, nfeatures, Float64) for _ in 1:100
];
expressions = [
Expression(tree; operators=options.operators, variable_names=["x1"]) for
tree in trees
];
members = [
PopMember(dataset, expression, options; deterministic=false) for
expression in expressions
]
)
)

ntrees = 10
suite["optimize_constants_x10"] = @benchmarkable(
foreach(members) do member
Expand Down
1 change: 1 addition & 0 deletions docs/Project.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[deps]
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
DynamicExpressions = "a40a106e-89c9-4ca8-8020-a735e8728b6b"
Gumbo = "708ec375-b3d6-5a57-a7ce-8257bf98657a"
SymbolicUtils = "d1185830-fcd6-423d-90d6-eec64667417b"

Expand Down
27 changes: 18 additions & 9 deletions docs/make.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,21 @@
using Documenter
using SymbolicUtils
using SymbolicRegression
using SymbolicRegression: Dataset, update_baseline_loss!
using SymbolicRegression:
AbstractExpression,
ExpressionInterface,
Dataset,
update_baseline_loss!,
AbstractMutationWeights,
AbstractOptions,
mutate!,
condition_mutation_weights!,
sample_mutation,
MutationResult,
AbstractRuntimeOptions,
AbstractSearchState,
@extend_operators
using DynamicExpressions

DocMeta.setdocmeta!(
SymbolicRegression, :DocTestSetup, :(using LossFunctions); recursive=true
Expand Down Expand Up @@ -40,14 +54,8 @@ readme = replace(

# We prepend the `<table>` with a ```@raw html
# and append the `</table>` with a ```:
readme = replace(
readme,
r"<table>" => s"```@raw html\n<table>",
)
readme = replace(
readme,
r"</table>" => s"</table>\n```",
)
readme = replace(readme, r"<table>" => s"```@raw html\n<table>")
readme = replace(readme, r"</table>" => s"</table>\n```")

# Then, we surround ```mermaid\n...\n``` snippets
# with ```@raw html\n<div class="mermaid">\n...\n</div>```:
Expand Down Expand Up @@ -96,6 +104,7 @@ makedocs(;
"API" => "api.md",
"Losses" => "losses.md",
"Types" => "types.md",
"Customization" => "customization.md",
],
)

Expand Down
2 changes: 1 addition & 1 deletion docs/src/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ SRRegressor
MultitargetSRRegressor
```

## equation_search
## Low-Level API

```@docs
equation_search
Expand Down
2 changes: 1 addition & 1 deletion docs/src/assets/logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit f9c57fe

Please sign in to comment.