Skip to content

Commit

Permalink
merge
Browse files Browse the repository at this point in the history
  • Loading branch information
montyvesselinov committed Nov 12, 2024
2 parents 2754ab8 + 6a8a67c commit 0958f7c
Show file tree
Hide file tree
Showing 8 changed files with 119 additions and 38 deletions.
45 changes: 45 additions & 0 deletions .github/workflows/CompatHelper.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: CompatHelper
on:
schedule:
- cron: 0 0 * * *
workflow_dispatch:
permissions:
contents: write
pull-requests: write
jobs:
CompatHelper:
runs-on: ubuntu-latest
steps:
- name: Check if Julia is already available in the PATH
id: julia_in_path
run: which julia
continue-on-error: true
- name: Install Julia, but only if it is not already available in the PATH
uses: julia-actions/setup-julia@v1
with:
version: '1'
# arch: ${{ runner.arch }}
if: steps.julia_in_path.outcome != 'success'
- name: "Add the General registry via Git"
run: |
import Pkg
ENV["JULIA_PKG_SERVER"] = ""
Pkg.Registry.add("General")
shell: julia --color=yes {0}
- name: "Install CompatHelper"
run: |
import Pkg
name = "CompatHelper"
uuid = "aa819f21-2bde-4658-8897-bab36330d9b7"
version = "3"
Pkg.add(; name, uuid, version)
shell: julia --color=yes {0}
- name: "Run CompatHelper"
run: |
import CompatHelper
CompatHelper.main()
shell: julia --color=yes {0}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COMPATHELPER_PRIV: ${{ secrets.DOCUMENTER_KEY }}
# COMPATHELPER_PRIV: ${{ secrets.COMPATHELPER_PRIV }}
33 changes: 33 additions & 0 deletions .github/workflows/TagBot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: TagBot
on:
issue_comment:
types:
- created
workflow_dispatch:
inputs:
lookback:
default: 3
permissions:
actions: read
checks: read
contents: write
deployments: read
issues: read
discussions: read
packages: read
pages: read
pull-requests: read
repository-projects: read
security-events: read
statuses: read
jobs:
TagBot:
if: github.event_name == 'workflow_dispatch' || github.actor == 'JuliaTagBot'
runs-on: ubuntu-latest
steps:
- uses: JuliaRegistries/TagBot@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
# Edit the following line to reflect the actual name of the GitHub Secret containing your private key
ssh: ${{ secrets.DOCUMENTER_KEY }}
# ssh: ${{ secrets.NAME_OF_MY_SSH_PRIVATE_KEY_SECRET }}
9 changes: 5 additions & 4 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "GeostatInversion"
uuid = "acd30bff-8734-59b1-86d1-c3ef2efb63d6"
authors = ["Daniel O'Malley <[email protected]>", "Velimir V Vesselinov <[email protected]>"]
version = "1.0.0"
version = "1.2.0"

[deps]
Distributed = "8ba89e20-285c-5b6f-9357-94700520ee1b"
Expand All @@ -15,10 +15,11 @@ Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"

[compat]
FFTW = "1"
IterativeSolvers = "0.8, 0.9"
Interpolations = "0.12, 0.14"
IterativeSolvers = "0.9"
Interpolations = "0.14, 0.15"
RobustPmap = "1"
julia = "1.5"
Statistics = "1"
julia = "1.11"

[extras]
Distributed = "8ba89e20-285c-5b6f-9357-94700520ee1b"
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Randomized Geostatistical Approach (RGA) references:
Two versions of PCGA are implemented in this package

- `pcgadirect`, which uses full matrices and direct solvers during iterations
- `pcgalsqr`, which uses low rank representations of the matrices combined with iterative solvers during iterations
- `pcgalsqr`, which uses low-rank representations of the matrices combined with iterative solvers during iterations

The RGA method, `rga`, can use either of these approaches using the keyword argument. That is, by doing `rga(...; pcgafunc=GeostatInversion.pcgadirect)` or `rga(...; pcgafunc=GeostatInversion.pcgalsqr)`.

Expand Down Expand Up @@ -54,9 +54,9 @@ MADS can execute a wide range of data- and model-based analyses:
* Machine Learning and Blind Source Separation
* Decision Analysis and Support

MADS has been tested to perform HPC simulations on a wide-range multi-processor clusters and parallel environments (Moab, Slurm, etc.).
MADS has been tested to perform HPC simulations on a wide-range of multi-processor clusters and parallel environments (Moab, Slurm, etc.).
MADS utilizes adaptive rules and techniques which allows the analyses to be performed with a minimum user input.
The code provides a series of alternative algorithms to execute each type of data- and model-based analyses.
The code provides a series of alternative algorithms to execute each type of data- and model-based analysis.

Documentation
=============
Expand All @@ -73,7 +73,7 @@ Pkg.add("GeostatInversion")
Installation behind a firewall
------------------------------

Julia uses git for the package management.
Julia uses git for package management.
To install Julia packages behind a firewall, add the following lines in the `.gitconfig` file in your home directory:

```git
Expand Down
6 changes: 3 additions & 3 deletions test/testfd.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ import Random
end
testjacobianf = GeostatInversion.FDDerivatives.makejacobian(f)
x = [1., 2.]
@Test.test isapprox(jacobianf(x), testjacobianf(x), atol=1e-4)
Test.@test isapprox(jacobianf(x), testjacobianf(x), atol=1e-4)
for i = 1:10000
x = 10 * randn(2)
@Test.test isapprox(jacobianf(x), testjacobianf(x), atol=1e-4)
Test.@test isapprox(jacobianf(x), testjacobianf(x), atol=1e-4)
end
end

Random.seed!(2017)
@Test.testset "Basic" begin
Test.@testset "Basic" begin
basictest()
end
10 changes: 5 additions & 5 deletions test/testfftrf.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import Statistics
dk = rand()
beta = -2 - rand()
k = GeostatInversion.FFTRF.powerlaw_structuredgrid(Ns, k0, dk, beta)
@Test.test Statistics.mean(k) k0
@Test.test Statistics.std(k) dk
@Test.test collect(size(k)) == Ns
Test.@test Statistics.mean(k) k0
Test.@test Statistics.std(k) dk
Test.@test collect(size(k)) == Ns
end

@stderrcapture function testunstructured(N)
Expand All @@ -21,11 +21,11 @@ end
dk = rand()
beta = -2 - rand()
k = GeostatInversion.FFTRF.powerlaw_unstructuredgrid(points, Ns, k0, dk, beta)
@Test.test length(k) == size(points, 2)
Test.@test length(k) == size(points, 2)
end

Random.seed!(2017)
@Test.testset "FTRF" begin
Test.@testset "FTRF" begin
for i = 1:10
testunstructured(2)
testunstructured(3)
Expand Down
12 changes: 6 additions & 6 deletions test/testrmf.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ end
@stderrcapture function test_rangefinder(n, m)
A = makeA(n, m)
Q = GeostatInversion.RandMatFact.rangefinder(A)
@Test.test isapprox(m, size(Q, 2), atol=1)
@Test.test isapprox(LinearAlgebra.norm(A - Q * Q' * A), 0., atol=1e-8)
Test.@test isapprox(m, size(Q, 2), atol=1)
Test.@test isapprox(LinearAlgebra.norm(A - Q * Q' * A), 0., atol=1e-8)
Q = GeostatInversion.RandMatFact.rangefinder(A, m, 2)
@Test.test isapprox(m, size(Q, 2), atol=1)
@Test.test isapprox(LinearAlgebra.norm(A - Q * Q' * A), 0., atol=1e-8)
Test.@test isapprox(m, size(Q, 2), atol=1)
Test.@test isapprox(LinearAlgebra.norm(A - Q * Q' * A), 0., atol=1e-8)
end

@stderrcapture function test_eig_nystrom()
Expand All @@ -25,10 +25,10 @@ end
Sigma = LinearAlgebra.Diagonal(Sigmavec)
Lambda = Sigma * Sigma
eigvals, eigvecs = LinearAlgebra.eigen(A)
@Test.test isapprox(LinearAlgebra.norm(sort(eigvals, rev=true) - LinearAlgebra.diag(Lambda)), 0., atol=1e-8)
Test.@test isapprox(LinearAlgebra.norm(sort(eigvals, rev=true) - LinearAlgebra.diag(Lambda)), 0., atol=1e-8)
end

@Test.testset "RMF" begin
Test.@testset "RMF" begin
test_rangefinder(10, 2)
test_rangefinder(10, 5)
test_rangefinder(100, 5)
Expand Down
34 changes: 18 additions & 16 deletions test/testrpcga.jl
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import GeostatInversion
import Random
import RobustPmap
import Test
import SparseArrays
import LinearAlgebra
import Random
using Distributed
using SparseArrays

Expand All @@ -12,7 +12,7 @@ using SparseArrays
HX = rand(10)
R = spzeros(10, 10)
A = GeostatInversion.PCGALowRankMatrix(etas, HX, R)
@Test.test size(A) == (size(A, 1), size(A, 2))
Test.@test size(A) == (size(A, 1), size(A, 2))
end

@stderrcapture function simplepcgalowranktest(numetas=10, numobs=20)
Expand All @@ -36,7 +36,7 @@ end
for i = 1:numobs + 1
x = zeros(numobs + 1)
x[i] = 1.
@Test.test isapprox(bigA * x, lrbigA * x)
Test.@test isapprox(bigA * x, lrbigA * x)
end
end
end
Expand All @@ -47,13 +47,13 @@ end
samples = Array{Float64, 1}[[-.5, 0., .5], [1., -1., 0.], [-.5, 1., -.5]]
lrcm = GeostatInversion.LowRankCovMatrix(samples)
fullcm = LinearAlgebra.Matrix{Float64}(LinearAlgebra.I, 3, 3) * lrcm
@Test.test isapprox(fullcm, lrcm * LinearAlgebra.Matrix{Float64}(LinearAlgebra.I, 3, 3))
@Test.test isapprox(sum(map(x->x * x', samples)) / (length(samples) - 1), fullcm)
@Test.test isapprox(sum(map(x->x * x', samples)) / (length(samples) - 1), fullcm)
Test.@test isapprox(fullcm, lrcm * LinearAlgebra.Matrix{Float64}(LinearAlgebra.I, 3, 3))
Test.@test isapprox(sum(map(x->x * x', samples)) / (length(samples) - 1), fullcm)
Test.@test isapprox(sum(map(x->x * x', samples)) / (length(samples) - 1), fullcm)
for i = 1:100
x = randn(3, 3)
@Test.test isapprox(fullcm * x, lrcm * x)
@Test.test isapprox(fullcm' * x, lrcm' * x)
Test.@test isapprox(fullcm * x, lrcm * x)
Test.@test isapprox(fullcm' * x, lrcm' * x)
end
end

Expand All @@ -73,9 +73,10 @@ end
lrcm = GeostatInversion.LowRankCovMatrix(samples)
lrcmfull = lrcm * LinearAlgebra.Matrix{Float64}(LinearAlgebra.I, M, M)
@Test.test isapprox(LinearAlgebra.norm(lrcmfull - covmatrix, 2), 0.; atol=M ^ 2 / sqrt(N) + 10)
# Test.@test isapprox(LinearAlgebra.norm(lrcmfull - covmatrix, 2), 0.; atol=M ^ 2 / sqrt(N))
for i = 1:100
x = randn(M)
@Test.test isapprox(lrcm * x, lrcmfull * x)
Test.@test isapprox(lrcm * x, lrcmfull * x)
end
end

Expand All @@ -96,7 +97,7 @@ end
we get from the full matrix.
=#
#This test is also tricky because the randsvd's in the two getxis calls need to be generating the same random numbers
@Test.test isapprox(0., min(LinearAlgebra.norm(fullxis[i] - lrcmxis[i]), LinearAlgebra.norm(fullxis[i] + lrcmxis[i])), atol=1e-6)
Test.@test isapprox(0., min(LinearAlgebra.norm(fullxis[i] - lrcmxis[i]), LinearAlgebra.norm(fullxis[i] + lrcmxis[i])), atol=1e-6)
end
end

Expand All @@ -122,29 +123,30 @@ end
@stderrcapture function simpletestpcga(M::Int, N::Int, mu::Float64=0.)
forward, p0, X, xis, R, yobs, truep = setupsimpletest(M, N, mu)
popt = GeostatInversion.pcgadirect(forward, p0, X, xis, R, yobs)
@Test.test isapprox(LinearAlgebra.norm(popt - truep) / LinearAlgebra.norm(truep), 0., atol=2e-2)
Test.@test isapprox(LinearAlgebra.norm(popt - truep) / LinearAlgebra.norm(truep), 0., atol=2e-2)
if M < N / 6
popt = GeostatInversion.pcgalsqr(forward, p0, X, xis, R, yobs)
@Test.test isapprox(LinearAlgebra.norm(popt - truep) / LinearAlgebra.norm(truep), 0., atol=2e-2)
Test.@test isapprox(LinearAlgebra.norm(popt - truep) / LinearAlgebra.norm(truep), 0., atol=2e-2)
end
end

@stderrcapture function simpletestrga(M::Int, N::Int, Nreduced::Int, mu::Float64=0.)
forward, p0, X, xis, R, yobs, truep = setupsimpletest(M, N, mu)
S = randn(Nreduced, N) * (1 / sqrt(N))
popt = GeostatInversion.rga(forward, p0, X, xis, R, yobs, S)
@Test.test isapprox(LinearAlgebra.norm(popt - truep) / LinearAlgebra.norm(truep), 0., atol=2e-2)
Test.@test isapprox(LinearAlgebra.norm(popt - truep) / LinearAlgebra.norm(truep), 0., atol=2e-2)
end

#=
function simpletestpcgalm(M, N, mu=0.)
forward, p0, X, xis, R, yobs, truep = setupsimpletest(M, N, mu)
popt = GeostatInversion.pcgalm(forward, p0, X, xis, diag(R), yobs)
@Test.test_approx_eq_eps LinearAlgebra.norm(popt - truep) / LinearAlgebra.norm(truep) 0. 2e-2
Test.@test_approx_eq_eps LinearAlgebra.norm(popt - truep) / LinearAlgebra.norm(truep) 0. 2e-2
end
=#

@Test.testset "RPSGA" begin
Test.@testset "RPSGA" begin
@everywhere import Random
@everywhere Random.seed!(2017)
pcgalowranksize()
simplepcgalowranktest()
Expand All @@ -168,4 +170,4 @@ end
end
end
end
:passed
:passed

0 comments on commit 0958f7c

Please sign in to comment.