Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/DataDrivenSR/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ SymbolicRegression = "8254be44-1295-4e6a-a16d-46603ac705cb"
[compat]
Reexport = "1.2"
DataDrivenDiffEq = "1"
SymbolicRegression = "0.17"
SymbolicRegression = "1"
julia = "1.6"

[extras]
Expand Down
10 changes: 5 additions & 5 deletions lib/DataDrivenSR/src/DataDrivenSR.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ using Reexport
"""
$(TYPEDEF)
Options for using SymbolicRegression.jl within the `solve` function.
Automatically creates [`Options`](https://astroautomata.com/SymbolicRegression.jl/stable/api/#Options) with the given specification.
Automatically creates [`Options`](https://ai.damtp.cam.ac.uk/symbolicregression/stable/api/#Options) with the given specification.
Sorts the operators stored in `functions` into unary and binary operators on conversion.
# Fields
$(FIELDS)
"""
@with_kw struct EQSearch <: AbstractDataDrivenAlgorithm
"Optionally weight the loss for each y by this value (same shape as y)"
weights::Union{AbstractMatrix, AbstractVector, Nothing} = nothing
"The number of processes to use, if you want EquationSearch to set this up automatically."
"The number of processes to use, if you want `equation_search` to set this up automatically."
numprocs = nothing
"If you have set up a distributed run manually with procs = addprocs() and @everywhere, pass the procs to this keyword argument."
procs::Union{Vector{Int}, Nothing} = nothing
Expand All @@ -40,7 +40,7 @@ $(FIELDS)
parallelism::Union{String, Symbol} = :serial
"Whether to run (quick) tests before starting the search, to see if there will be any problems during the equation search related to the host environment"
runtests::Bool = true
"Options for 'EquationSearch'"
"Options for `equation_search`"
eq_options::SymbolicRegression.Options = SymbolicRegression.Options()
end

Expand Down Expand Up @@ -184,7 +184,7 @@ function (x::EQSearch)(ps::InternalDataDrivenProblem{EQSearch}, X, Y)
@unpack maxiters, abstol = options
@unpack weights, eq_options, numprocs, procs, parallelism, runtests = x

hofs = SymbolicRegression.EquationSearch(X, Y,
hofs = SymbolicRegression.equation_search(X, Y;
niterations = maxiters,
weights = weights,
options = eq_options,
Expand All @@ -197,7 +197,7 @@ function (x::EQSearch)(ps::InternalDataDrivenProblem{EQSearch}, X, Y)

# Evaluate over the full training data
paretos = map(enumerate(hofs)) do (i, hof)
SymbolicRegression.calculate_pareto_frontier(X, Y[i, :], hof, eq_options)
SymbolicRegression.calculate_pareto_frontier(hof)
end

return SRResult(ps, hofs, paretos)
Expand Down
3 changes: 3 additions & 0 deletions lib/DataDrivenSR/test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ X = rand(rng, 2, 50)
@testset "Simple" begin
alg = DataDrivenSR.EQSearch(eq_options = Options(unary_operators = [sin, exp],
binary_operators = [*], maxdepth = 1,
seed = 42,
verbosity = -1, progress = false))
f(x) = [sin(x[1]); exp(x[2])]
Y = hcat(map(f, eachcol(X))...)
Expand All @@ -21,6 +22,7 @@ end
@testset "Univariate" begin
alg = DataDrivenSR.EQSearch(eq_options = Options(unary_operators = [sin, exp],
binary_operators = [*], maxdepth = 1,
seed = 42,
verbosity = -1, progress = false))

Y = sin.(X[1:1, :])
Expand All @@ -33,6 +35,7 @@ end
@testset "Lifted" begin
alg = DataDrivenSR.EQSearch(eq_options = Options(unary_operators = [sin, exp],
binary_operators = [+], maxdepth = 1,
seed = 42,
verbosity = -1, progress = false))

f(x) = [sin(x[1] .^ 2); exp(x[2] * x[1])]
Expand Down
3 changes: 1 addition & 2 deletions lib/DataDrivenSparse/src/DataDrivenSparse.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ abstract type AbstractProximalOperator end

abstract type AbstractSparseRegressionCache <: StatsBase.StatisticalModel end

function _set!(x::AbstractSparseRegressionCache,
y::AbstractSparseRegressionCache) where {T <: Number}
function _set!(x::AbstractSparseRegressionCache, y::AbstractSparseRegressionCache)
begin
foreach(eachindex(x.X)) do i
x.X[i] = y.X[i]
Expand Down
4 changes: 2 additions & 2 deletions lib/DataDrivenSparse/test/sparse_linear_solve.jl
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ end
cos.(0.5 .* t .^ 2 .- 0.1), exp.(-t))))
Y = permutedims(0.5 * X[1, :] + 0.22 * X[4, :] - 2.0 * X[3, :])
X = vcat(X, Y)
for alg in [STLSQ, ADMM, SR3]
opt = ImplicitOptimizer(alg())
for alg in [STLSQ(0.1, 1.0), ADMM(), SR3()]
opt = ImplicitOptimizer(alg)
rescoeff, _... = opt(X, Y, options = DataDrivenCommonOptions(maxiters = 2000))
@test vec(rescoeff)≈[0.25; 0.0; -1.0; 0.11; 0.0; -0.5] atol=5e-2
end
Expand Down
2 changes: 1 addition & 1 deletion src/utils/build_basis.jl
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ function _implicit_build_eqs(basis, eqs, p, prob)
eqs = eqs .~ 0
try
# Try to solve the eq for the implicits
eqs = ModelingToolkit.solve_for(eqs, implicits)
eqs = ModelingToolkit.symbolic_linear_solve(eqs, implicits)
eqs = implicits .~ eqs
implicits = Num[]
catch
Expand Down
Loading