Skip to content
Merged
Show file tree
Hide file tree
Changes from 30 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
bc66f31
refactor: remove lib/SurrogateAbstractGPs and SurrogatesFlux
sathvikbhagavan Jul 23, 2025
2bf1c19
build: add weakdeps for extensions
sathvikbhagavan Jul 23, 2025
478a548
refactor: add extensions for SurrogatesAbstractGPs and SurrogatesFlux
sathvikbhagavan Jul 23, 2025
8b459f8
test: move tests for SurrogatesAbstractGPs and SurrogatesFlux
sathvikbhagavan Jul 23, 2025
37f432c
refactor: delete SurrogatesPolyChaos, SVM, RandomForest
sathvikbhagavan Jul 25, 2025
6f79976
refactor: convert SurrogatesPolyChaos, SVM, RandomForest into extensions
sathvikbhagavan Jul 25, 2025
658a2cd
build: add extensions in Project.toml
sathvikbhagavan Jul 25, 2025
4e8be11
test: add tests for SurrogatesPolyChaos, SVM, RandomForest
sathvikbhagavan Jul 25, 2025
6c10b4b
refactor: delete remaining
sathvikbhagavan Jul 25, 2025
c5c6d40
refactor: make SurrogatesMOE into ext
sathvikbhagavan Jul 25, 2025
cbd60a8
build: add MOE into extensions
sathvikbhagavan Jul 25, 2025
ac5817f
test: add tests for MOE
sathvikbhagavan Jul 25, 2025
039452f
test: fix optimization test import
sathvikbhagavan Jul 25, 2025
e693b62
build: add compat for StableRNGs
sathvikbhagavan Jul 25, 2025
636601c
ci: remove mention of lib/*
sathvikbhagavan Jul 25, 2025
e1961ef
build: fix weak deps of MOE ext
sathvikbhagavan Jul 26, 2025
97d2e05
refactor: remove unneeded packages
sathvikbhagavan Jul 26, 2025
9157483
docs: remove mention of packages in lib/
sathvikbhagavan Jul 31, 2025
729f8f4
build: make Random as a dep
sathvikbhagavan Jul 31, 2025
605943b
refactor: RandomForest -> XGBoost
sathvikbhagavan Jul 31, 2025
73f8fa1
build(docs): remove lib/ packages
sathvikbhagavan Aug 1, 2025
c2dfedf
docs: remove mention of SurrogatesAbstractGPs
sathvikbhagavan Aug 1, 2025
5548631
docs: remove mention of SurrogatesFlux
sathvikbhagavan Aug 3, 2025
c136d23
docs: remove mention of SurrogatesPolyChaos
sathvikbhagavan Aug 3, 2025
bf6544a
ci: fix Downgrade
sathvikbhagavan Aug 4, 2025
2b98e3a
chore: format
sathvikbhagavan Aug 4, 2025
50afe88
Merge branch 'master' into sb/extensions
sathvikbhagavan Aug 4, 2025
7f205da
build: bump compats
sathvikbhagavan Aug 4, 2025
30dd139
Update Project.toml
ChrisRackauckas Aug 5, 2025
9617300
Update ext/SurrogatesFluxExt.jl
ChrisRackauckas Aug 5, 2025
289fe32
Update ext/SurrogatesFluxExt.jl
ChrisRackauckas Aug 5, 2025
8468d1c
Update ext/SurrogatesFluxExt.jl
ChrisRackauckas Aug 5, 2025
62df9b7
Update ext/SurrogatesFluxExt.jl
ChrisRackauckas Aug 5, 2025
cad6f14
Update ext/SurrogatesFluxExt.jl
ChrisRackauckas Aug 5, 2025
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
8 changes: 1 addition & 7 deletions .github/workflows/CompatHelper.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,4 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: >
julia -e 'using CompatHelper; CompatHelper.main(;subdirs=["", "docs",
"lib/SurrogatesAbstractGPs",
"lib/SurrogatesFlux",
"lib/SurrogatesMOE",
"lib/SurrogatesPolyChaos",
"lib/SurrogatesRandomForest",
"lib/SurrogatesSVM"])'
julia -e 'using CompatHelper; CompatHelper.main(;subdirs=["", "docs"])'
8 changes: 1 addition & 7 deletions .github/workflows/Documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,6 @@ jobs:
- name: Install dependencies
run: julia --project=docs/ -e 'using Pkg;
Pkg.develop(PackageSpec(path=pwd()));
Pkg.develop(PackageSpec(path=joinpath(pwd(), "lib", "SurrogatesAbstractGPs")));
Pkg.develop(PackageSpec(path=joinpath(pwd(), "lib", "SurrogatesFlux")));
Pkg.develop(PackageSpec(path=joinpath(pwd(), "lib", "SurrogatesPolyChaos")));
Pkg.develop(PackageSpec(path=joinpath(pwd(), "lib", "SurrogatesRandomForest")));
Pkg.develop(PackageSpec(path=joinpath(pwd(), "lib", "SurrogatesMOE")));
Pkg.develop(PackageSpec(path=joinpath(pwd(), "lib", "SurrogatesSVM")));
Pkg.instantiate()'
- name: Build and deploy
env:
Expand All @@ -32,7 +26,7 @@ jobs:
run: julia --project=docs/ --code-coverage=user docs/make.jl
- uses: julia-actions/julia-processcoverage@v1
with:
directories: src,lib/SurrogatesAbstractGPs/src,lib/SurrogatesFlux/src,lib/SurrogatesMOE/src,lib/SurrogatesPolyChaos/src,lib/SurrogatesRandomForest/src,lib/SurrogatesSVM/src
directories: src,ext
- uses: codecov/codecov-action@v5
with:
file: lcov.info
Expand Down
5 changes: 0 additions & 5 deletions .github/workflows/Downgrade.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
group:
- Core
downgrade_mode: ['alldeps']
julia-version: ['1.10']
steps:
Expand All @@ -25,12 +23,9 @@ jobs:
with:
version: ${{ matrix.julia-version }}
- uses: julia-actions/julia-downgrade-compat@v2
# if: ${{ matrix.version == '1.6' }}
with:
skip: Pkg,TOML
- uses: julia-actions/julia-buildpkg@v1
- uses: julia-actions/julia-runtest@v1
with:
ALLOW_RERESOLVE: false
env:
GROUP: ${{ matrix.group }}
2 changes: 1 addition & 1 deletion .github/workflows/Tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,5 @@ jobs:
with:
julia-version: "${{ matrix.version }}"
group: "${{ matrix.group }}"
coverage-directories: "src,lib/SurrogatesAbstractGPs/src,lib/SurrogatesFlux/src,lib/SurrogatesMOE/src,lib/SurrogatesPolyChaos/src,lib/SurrogatesRandomForest/src,lib/SurrogatesSVM/src"
coverage-directories: "src,ext"
secrets: "inherit"
42 changes: 37 additions & 5 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,44 +11,76 @@ GLM = "38e38edf-8417-5370-95a0-9cbb8c7f171a"
IterativeSolvers = "42fd0dbc-a981-5370-80f2-aaf504508153"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
QuasiMonteCarlo = "8a4e6c94-4038-4cdc-81c3-7e6ffdb2a71b"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
SurrogatesBase = "89f642e6-4179-4274-8202-c11f4bd9a72c"
Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f"

[weakdeps]
AbstractGPs = "99985d1d-32ba-4be9-9821-2ec096f28918"
Flux = "587475ba-b771-5e3f-ad9e-33799f191a9c"
GaussianMixtures = "cc18c42c-b769-54ff-9e2a-b28141a64aae"
LIBSVM = "b1bec4e5-fd48-53fe-b0cb-9723c09d164b"
Optimisers = "3bd65402-5787-11e9-1adc-39752487f4e2"
PolyChaos = "8d666b04-775d-5f6e-b778-5ac7c70f65a3"
XGBoost = "009559a3-9522-5dbb-924b-0b6ed2b22bb9"

[extensions]
SurrogatesAbstractGPsExt = "AbstractGPs"
SurrogatesFluxExt = ["Flux"]
SurrogatesPolyChaosExt = "PolyChaos"
SurrogatesXGBoostExt = "XGBoost"
SurrogatesSVMExt = "LIBSVM"
SurrogatesMOEExt = "GaussianMixtures"

[compat]
AbstractGPs = "0.5"
Aqua = "0.8"
ChainRulesCore = "1.19.1"
Cubature = "1.5"
Distributions = "0.25.71"
Distributions = "0.25.120"
ExtendableSparse = "1"
Flux = "0.15, 0.16"
ForwardDiff = "0.10.19"
GLM = "1.5"
ForwardDiff = "0.10.38"
GaussianMixtures = "0.3.13"
GLM = "1.9"
IterativeSolvers = "0.9"
LIBSVM = "0.8"
LinearAlgebra = "1.10"
Optimisers = "0.4.4"
Pkg = "1.10"
PolyChaos = "0.2.5"
QuadGK = "2.4"
QuasiMonteCarlo = "0.3.1"
QuasiMonteCarlo = "0.3.3"
Random = "1.10"
SafeTestsets = "0.1"
SparseArrays = "1.10"
StableRNGs = "1"
Statistics = "1.10"
SurrogatesBase = "1.1.0"
Test = "1.10"
XGBoost = "2"
Zygote = "0.7"
julia = "1.10"

[extras]
AbstractGPs = "99985d1d-32ba-4be9-9821-2ec096f28918"
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
Cubature = "667455a9-e2ce-5579-9412-b964f529a492"
Flux = "587475ba-b771-5e3f-ad9e-33799f191a9c"
ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210"
GaussianMixtures = "cc18c42c-b769-54ff-9e2a-b28141a64aae"
LIBSVM = "b1bec4e5-fd48-53fe-b0cb-9723c09d164b"
Optimisers = "3bd65402-5787-11e9-1adc-39752487f4e2"
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
PolyChaos = "8d666b04-775d-5f6e-b778-5ac7c70f65a3"
QuadGK = "1fd47b50-473d-5c70-9696-f719f8f3bcdc"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
SafeTestsets = "1bc83da4-3b8d-516f-aca4-4fe02f6d838f"
StableRNGs = "860ef19b-820b-49d6-a774-d7a799459cd3"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
XGBoost = "009559a3-9522-5dbb-924b-0b6ed2b22bb9"

[targets]
test = ["Aqua", "Cubature", "SafeTestsets", "Flux", "ForwardDiff", "PolyChaos", "QuadGK", "Test", "Pkg"]
test = ["AbstractGPs", "Aqua", "Cubature", "SafeTestsets", "Flux", "ForwardDiff", "GaussianMixtures", "LIBSVM", "Optimisers", "PolyChaos", "QuadGK", "Random", "StableRNGs", "Test", "Pkg", "XGBoost"]
16 changes: 4 additions & 12 deletions docs/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,22 @@
AbstractGPs = "99985d1d-32ba-4be9-9821-2ec096f28918"
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
Flux = "587475ba-b771-5e3f-ad9e-33799f191a9c"
GaussianMixtures = "cc18c42c-b769-54ff-9e2a-b28141a64aae"
PolyChaos = "8d666b04-775d-5f6e-b778-5ac7c70f65a3"
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
QuadGK = "1fd47b50-473d-5c70-9696-f719f8f3bcdc"
Surrogates = "6fc51010-71bc-11e9-0e15-a3fcc6593c49"
SurrogatesAbstractGPs = "78aa1720-c2af-471b-b307-964fd38f9b5f"
SurrogatesFlux = "4f55584b-dac4-4b1c-802a-b7c47b72cb4c"
SurrogatesMOE = "778709c9-3595-4497-80d4-d1077d5b9fbf"
SurrogatesPolyChaos = "50679fc6-c85c-4a6e-ac63-dc3c8bd8cb1c"
SurrogatesRandomForest = "3fee2672-df33-422b-aa65-d915eeac013a"
SurrogatesSVM = "eb0c118b-dd0a-445a-b996-82088348ceb1"
XGBoost = "009559a3-9522-5dbb-924b-0b6ed2b22bb9"
Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f"

[compat]
AbstractGPs = "0.5.13"
Documenter = "1"
Flux = "0.15, 0.16"
GaussianMixtures = "0.3.6"
PolyChaos = "0.2.5"
Plots = "1.36.2"
QuadGK = "2.6.0"
Surrogates = "6"
SurrogatesAbstractGPs = "0.1.0"
SurrogatesFlux = "0.1.0"
SurrogatesMOE = "0.1.0"
SurrogatesPolyChaos = "0.1.0"
SurrogatesRandomForest = "0.1.0"
SurrogatesSVM = "0.1.0"
XGBoost = "2"
Zygote = "0.6.49, 0.7"
2 changes: 1 addition & 1 deletion docs/pages.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ pages = ["index.md"
"Lobachevsky" => "lobachevsky.md",
"Linear" => "LinearSurrogate.md",
"InverseDistance" => "InverseDistance.md",
"RandomForest" => "randomforest.md",
"XGBoost" => "xgboost.md",
"SecondOrderPolynomial" => "secondorderpoly.md",
"NeuralSurrogate" => "neural.md",
"Wendland" => "wendland.md",
Expand Down
11 changes: 2 additions & 9 deletions docs/src/abstractgps.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
# Gaussian Process Surrogate Tutorial

!!! note

This surrogate requires the 'SurrogatesAbstractGPs' module, which can be added by inputting "]add SurrogatesAbstractGPs" from the Julia command line.

Gaussian Process regression in Surrogates.jl is implemented as a simple wrapper around the [AbstractGPs.jl](https://github.com/JuliaGaussianProcesses/AbstractGPs.jl) package. AbstractGPs comes with a variety of covariance functions (kernels). See [KernelFunctions.jl](https://github.com/JuliaGaussianProcesses/KernelFunctions.jl/) for examples.

!!! tip
Expand All @@ -19,8 +15,7 @@ In the example below, the 'gp_surrogate' assignment code can be commented / unco
```@example gp_tutorial1d
using Surrogates
using Plots
using AbstractGPs #required to access different types of kernels
using SurrogatesAbstractGPs
using AbstractGPs

f(x) = (6 * x - 2)^2 * sin(12 * x - 4)
n_samples = 100
Expand All @@ -46,7 +41,6 @@ This example shows the use of AbstractGP Surrogates to find the minima of a func
using Surrogates
using Plots
using AbstractGPs
using SurrogatesAbstractGPs

f(x) = (x - 2)^2
n_samples = 100
Expand All @@ -65,7 +59,7 @@ Plotting the function and the sampled points:
scatter(gp_surrogate.x, gp_surrogate.y, label = "Sampled points",
ylims = (-1.0, 5.0), legend = :top)
plot!(xs, gp_surrogate.(xs), label = "Surrogate function",
ribbon = p -> SurrogatesAbstractGPs.std_error_at_point(gp_surrogate, p), legend = :top)
ribbon = p -> Surrogates.std_error_at_point(gp_surrogate, p), legend = :top)
plot!(xs, f.(xs), label = "True function", legend = :top)
```

Expand All @@ -76,7 +70,6 @@ using Plots
default(c = :matter, legend = false, xlabel = "x", ylabel = "y")
using Surrogates
using AbstractGPs
using SurrogatesAbstractGPs

hypot_func = z -> 3 * hypot(z...) + 1
n_samples = 100
Expand Down
2 changes: 1 addition & 1 deletion docs/src/cantilever.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Let's import Surrogates and Plots:

```@example beam
using Surrogates
using SurrogatesPolyChaos
using PolyChaos
using Plots
```

Expand Down
2 changes: 1 addition & 1 deletion docs/src/gramacylee.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Let's import these two packages `Surrogates` and `Plots`:

```@example gramacylee1D
using Surrogates
using SurrogatesPolyChaos
using PolyChaos
using Plots
```

Expand Down
2 changes: 1 addition & 1 deletion docs/src/lp.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Let's import Surrogates and Plots:

```@example lp
using Surrogates
using SurrogatesPolyChaos
using PolyChaos
using Plots
using LinearAlgebra
```
Expand Down
10 changes: 3 additions & 7 deletions docs/src/moe.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
# Mixture of Experts (MOE) Surrogate Tutorial

!!! note

This surrogate requires the 'SurrogatesMOE' module, which can be added by inputting "]add SurrogatesMOE" from the Julia command line.

The Mixture of Experts (MOE) Surrogate model represents the interpolating function as a combination of other surrogate models. SurrogatesMOE is a Julia implementation of the [Python version from SMT](https://smt.readthedocs.io/en/latest/_src_docs/applications/moe.html).

MOE is most useful when we have a discontinuous function. For example, let's say we want to build a surrogate for the following function:
Expand All @@ -20,11 +16,11 @@ function discont_1D(x)
end
```

Let's choose the MOE Surrogate for 1D. Note that we have to import the `SurrogatesMOE` package in addition to `Surrogates` and `Plots`.
Let's choose the MOE Surrogate for 1D. Note that we have to import the `GaussianMixtures` in addition to `Surrogates` and `Plots`.

```@example MOE_1D
using Surrogates
using SurrogatesMOE
using GaussianMixtures
using Plots

lb = -1.0
Expand Down Expand Up @@ -66,7 +62,7 @@ First, we create Gaussian Mixture Models for the number of expert types provided

```@example MOE_ND
using Surrogates
using SurrogatesMOE
using GaussianMixtures

# helper to test accuracy of predictors
function rmse(a, b)
Expand Down
5 changes: 0 additions & 5 deletions docs/src/neural.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
# Neural Network Surrogate Tutorial

!!! note

This surrogate requires the 'SurrogatesFlux' module, which can be added by inputting "]add SurrogatesFlux" from the Julia command line.

It's possible to define a neural network as a surrogate, using Flux.
This is useful because we can call optimization methods on it.

Expand All @@ -14,7 +10,6 @@ using Plots
default(c = :matter, legend = false, xlabel = "x", ylabel = "y")
using Surrogates
using Flux
using SurrogatesFlux

function schaffer(x)
x1 = x[1]
Expand Down
8 changes: 2 additions & 6 deletions docs/src/polychaos.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
# Polynomial Chaos Surrogate Tutorial

!!! note

This surrogate requires the 'SurrogatesPolyChaos' module which can be added by inputting "]add SurrogatesPolyChaos" from the Julia command line.

We can create a surrogate using a polynomial expansion, with a different polynomial basis depending on the distribution of the data we are trying to fit. Under the hood, PolyChaos.jl has been used. It is possible to specify a type of polynomial for each dimension of the problem.

## Sampling
Expand All @@ -12,7 +8,7 @@ We choose to sample f in 100 points between 0 and 10 using the `sample` function

```@example polychaos
using Surrogates
using SurrogatesPolyChaos
using PolyChaos
using Plots

n = 100
Expand All @@ -30,7 +26,7 @@ plot!(f, label = "True function", xlims = (lower_bound, upper_bound), legend = :
```@example polychaos
poly1 = PolynomialChaosSurrogate(x, y, lower_bound, upper_bound)
poly2 = PolynomialChaosSurrogate(
x, y, lower_bound, upper_bound, orthopolys = SurrogatesPolyChaos.GaussOrthoPoly(5))
x, y, lower_bound, upper_bound, orthopolys = GaussOrthoPoly(5))
plot(x, y, seriestype = :scatter, label = "Sampled points",
xlims = (lower_bound, upper_bound), legend = :top)
plot!(f, label = "True function", xlims = (lower_bound, upper_bound), legend = :top)
Expand Down
2 changes: 1 addition & 1 deletion docs/src/rosenbrock.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Let's import Surrogates and Plots:

```@example rosen
using Surrogates
using SurrogatesPolyChaos
using PolyChaos
using Plots
```

Expand Down
8 changes: 4 additions & 4 deletions docs/src/surrogate.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,19 @@ LobachevskySurrogate(x,y,lb,ub; alpha = collect(one.(x[1])),n::Int = 4, sparse =
lobachevsky_integral(loba::LobachevskySurrogate,lb,ub)
```

- Support vector machine surrogate, requires `using LIBSVM` and `using SurrogatesSVM`
- Support vector machine surrogate, requires `using LIBSVM`.

```
SVMSurrogate(x,y,lb::Number,ub::Number)
```

- Random forest surrogate, requires `using XGBoost` and `using SurrogatesRandomForest`
- Random forest surrogate, requires `using XGBoost`.

```
RandomForestSurrogate(x,y,lb,ub;num_round::Int = 1)
XGBoostSurrogate(x,y,lb,ub;num_round::Int = 1)
```

- Neural network surrogate, requires `using Flux` and `using SurrogatesFlux`
- Neural network surrogate, requires `using Flux`.

```
NeuralSurrogate(x,y,lb,ub; model = Chain(Dense(length(x[1]),1), first), loss = (x,y) -> Flux.mse(model(x), y),opt = Descent(0.01),n_echos::Int = 1)
Expand Down
1 change: 0 additions & 1 deletion docs/src/tutorials.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ Basic example of fitting a neural network on a simple function of two variables.
using Surrogates
using Flux
using Statistics
using SurrogatesFlux

f = x -> x[1]^2 + x[2]^2
# Flux models are in single precision by default.
Expand Down
2 changes: 1 addition & 1 deletion docs/src/water_flow.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ It has 8 dimensions.

```@example water
using Surrogates
using SurrogatesPolyChaos
using PolyChaos
using Plots
using LinearAlgebra
```
Expand Down
Loading
Loading