Skip to content

Commit

Permalink
switch to ProximalAlgorithms.jl v0.7
Browse files Browse the repository at this point in the history
also drop ProximalOperators and ProximalCore weak deps
  • Loading branch information
alyst committed Jan 6, 2025
1 parent b839635 commit 1f45fda
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 13 deletions.
5 changes: 2 additions & 3 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ NLSolversBase = "7"
NLopt = "0.6, 1"
Optim = "1"
PrettyTables = "2"
ProximalAlgorithms = "0.7"
StatsBase = "0.33, 0.34"
Symbolics = "4, 5, 6"
SymbolicUtils = "1.4 - 1.5, 1.7, 2, 3"
Expand All @@ -47,9 +48,7 @@ test = ["Test"]
[weakdeps]
NLopt = "76087f3c-5699-56af-9a33-bf431cd00edd"
ProximalAlgorithms = "140ffc9f-1907-541a-a177-7475e0a401e9"
ProximalCore = "dc4f5ac2-75d1-4f31-931e-60435d74994b"
ProximalOperators = "f3b72e0c-5f3e-4b3e-8f3e-3f4f3e3e3e3e"

[extensions]
SEMNLOptExt = "NLopt"
SEMProximalOptExt = ["ProximalCore", "ProximalAlgorithms", "ProximalOperators"]
SEMProximalOptExt = "ProximalAlgorithms"
11 changes: 8 additions & 3 deletions ext/SEMProximalOptExt/ProximalAlgorithms.jl
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,14 @@ function Base.show(io::IO, struct_inst::SemOptimizerProximal)
print_field_types(io, struct_inst)
end

## connect do ProximalAlgorithms.jl as backend
ProximalCore.gradient!(grad, model::AbstractSem, parameters) =
objective_gradient!(grad, model::AbstractSem, parameters)
## connect to ProximalAlgorithms.jl
function ProximalAlgorithms.value_and_gradient(model::AbstractSem, params)
grad = similar(params)
obj = SEM.evaluate!(zero(eltype(params)), grad, nothing, model, params)
return obj, grad
end

#ProximalCore.prox!(y, f, x, gamma) = ProximalOperators.prox!(y, f, x, gamma)

mutable struct ProximalResult
result::Any
Expand Down
4 changes: 1 addition & 3 deletions ext/SEMProximalOptExt/SEMProximalOptExt.jl
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
module SEMProximalOptExt

using StructuralEquationModels
using ProximalCore, ProximalAlgorithms, ProximalOperators
using ProximalAlgorithms

export SemOptimizerProximal

SEM = StructuralEquationModels

#ProximalCore.prox!(y, f, x, gamma) = ProximalOperators.prox!(y, f, x, gamma)

include("ProximalAlgorithms.jl")

end
1 change: 0 additions & 1 deletion test/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ NLopt = "76087f3c-5699-56af-9a33-bf431cd00edd"
Optim = "429524aa-4258-5aef-a3af-852621145aeb"
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
ProximalAlgorithms = "140ffc9f-1907-541a-a177-7475e0a401e9"
ProximalCore = "dc4f5ac2-75d1-4f31-931e-60435d74994b"
ProximalOperators = "a725b495-10eb-56fe-b38b-717eba820537"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
SafeTestsets = "1bc83da4-3b8d-516f-aca4-4fe02f6d838f"
Expand Down
2 changes: 1 addition & 1 deletion test/examples/proximal/l0.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using StructuralEquationModels, Test, ProximalCore, ProximalAlgorithms, ProximalOperators
using StructuralEquationModels, Test, ProximalAlgorithms, ProximalOperators

# load data
dat = example_data("political_democracy")
Expand Down
2 changes: 1 addition & 1 deletion test/examples/proximal/lasso.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using StructuralEquationModels, Test, ProximalCore, ProximalAlgorithms, ProximalOperators
using StructuralEquationModels, Test, ProximalAlgorithms, ProximalOperators

# load data
dat = example_data("political_democracy")
Expand Down
2 changes: 1 addition & 1 deletion test/examples/proximal/ridge.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using StructuralEquationModels, Test, ProximalCore, ProximalAlgorithms, ProximalOperators
using StructuralEquationModels, Test, ProximalAlgorithms, ProximalOperators

# load data
dat = example_data("political_democracy")
Expand Down

0 comments on commit 1f45fda

Please sign in to comment.