-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
GUI and jump options are now extensions
- Loading branch information
Showing
7 changed files
with
91 additions
and
169 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
module tikhonov_jump_ext | ||
|
||
using NMRInversions, JuMP, LinearAlgebra, SparseArrays | ||
|
||
# import JuMP: @variable | ||
# import JuMP: @variables | ||
# import JuMP: @constraint | ||
# import JuMP: @constraints | ||
# import JuMP: @objective | ||
|
||
function NMRInversions.solve_regularization(K::AbstractMatrix, g::AbstractVector, α::Real, solver::Symbol, order::Int=0) | ||
|
||
A = sparse([K; √(α) .* NMRInversions.Γ(size(K, 2), order)]) | ||
b = sparse([g; zeros(size(A, 1) - size(g, 1))]) | ||
|
||
@eval model = JuMP.Model($(solver).Optimizer) | ||
set_silent(model) | ||
@variable(model, f[1:size(K, 2)] >= 0) | ||
@variable(model, z[1:size(b, 1)]) | ||
@constraint(model, z .== A * f - b) | ||
@objective(model, Min, sum(z .^ 2)) | ||
|
||
JuMP.optimize!(model) | ||
|
||
return JuMP.value.(f), vec(K * JuMP.value.(f) .- g) | ||
|
||
end | ||
|
||
|
||
# other qp formulations | ||
|
||
|
||
# # set_silent(model) | ||
# # @variable(model, f[1:size(K, 2)] >= 0) | ||
# # @variable(model, r[1:size(K, 1)]) | ||
# # @constraint(model, r .== g .- K * f) | ||
# # @objective(model, Min, LinearAlgebra.dot(r, r) + α * LinearAlgebra.dot(f, f)) | ||
# # optimize!(model) | ||
# # @assert is_solved_and_feasible(model) | ||
# # return value.(f), value.(r) | ||
|
||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.