Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
DualTVDD.jl
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Stephan Hilb
DualTVDD.jl
Commits
1b15e99a
Commit
1b15e99a
authored
4 years ago
by
Stephan Hilb
Browse files
Options
Downloads
Patches
Plain Diff
fixup surrogate algorithm
parent
a98a2430
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/surrogate.jl
+28
-14
28 additions, 14 deletions
src/surrogate.jl
with
28 additions
and
14 deletions
src/surrogate.jl
+
28
−
14
View file @
1b15e99a
...
...
@@ -3,16 +3,18 @@ using LinearAlgebra: I
struct
SurrogateAlgorithm
{
P
}
<:
Algorithm
{
P
}
problem
::
P
subalg
::
Function
"number of inner iterations"
ninner
::
Int
τ
::
Float64
function
SurrogateAlgorithm
(
problem
::
DualTVL1ROFOpProblem
;
τ
=
2
*
normB
(
problem
),
subalg
=
x
->
ProjectedGradient
(
x
))
return
new
{
typeof
(
problem
)}(
problem
,
subalg
,
τ
)
ninner
=
1
,
τ
=
2
*
normB
(
problem
),
subalg
=
x
->
ProjGradAlgorithm
(
x
))
return
new
{
typeof
(
problem
)}(
problem
,
subalg
,
ninner
,
τ
)
end
end
struct
SurrogateState
{
A
,
SP
,
SS
,
Wv
,
R
,
S
,
K1
}
<:
State
struct
SurrogateState
{
A
,
SS
,
Wv
,
R
,
S
,
K1
}
<:
State
algorithm
::
A
subproblem
::
SP
substate
::
SS
"scalar temporary 1"
...
...
@@ -43,33 +45,45 @@ function init(alg::SurrogateAlgorithm)
@inline
kf1
(
pw
)
=
@inbounds
-
divergence
(
pw
)
k1
=
Kernel
{
ntuple
(
_
->-
1
:
1
,
d
)}(
kf1
)
subprob
=
DualTVL1ROFOpProblem
(
copy
(
prob
.
g
),
I
,
prob
.
λ
)
substate
=
init
(
alg
.
subalg
(
subprob
))
subg
=
copy
(
g
)
subprob
=
DualTVL1ROFOpProblem
(
subg
,
I
,
prob
.
λ
)
subalg
=
alg
.
subalg
(
subprob
)
substate
=
init
(
subalg
)
return
SurrogateState
(
alg
,
subprob
,
substate
,
rv
,
sv
,
r
,
s
,
k1
)
# we don't want to modify ourselves if alg.subalg gives us a bad reference
@assert
subalg
.
problem
.
g
!==
g
return
SurrogateState
(
alg
,
substate
,
rv
,
sv
,
r
,
s
,
k1
)
end
function
update_g!
(
subg
,
st
::
SurrogateState
)
alg
=
st
.
algorithm
g
=
alg
.
problem
.
g
p
=
extend
(
fetch
(
st
.
substate
),
StaticKernels
.
ExtensionReplicate
())
p
=
extend
(
fetch
(
st
.
substate
),
StaticKernels
.
ExtensionNothing
())
sv
=
vec
(
parent
(
st
.
s
))
rv
=
vec
(
st
.
r
)
# r = Λ*p
map!
(
st
.
k1
,
st
.
r
,
p
)
# s = r - g
st
.
s
.=
st
.
r
-
g
# r = r
+
1/τ * B * s
mul!
(
st
.
rv
,
alg
.
problem
.
B
,
st
.
sv
,
-
1.
/
alg
.
τ
,
1.
)
st
.
s
.=
st
.
r
.
-
g
# r = r
-
1/τ * B * s
mul!
(
rv
,
alg
.
problem
.
B
,
sv
,
-
1.
/
alg
.
τ
,
1.
)
subg
.=
st
.
r
end
function
step!
(
st
::
SurrogateState
)
update_g!
(
st
.
subproblem
.
g
,
st
)
subst
=
st
.
substate
# update data g of the subproblem
update_g!
(
subst
.
algorithm
.
problem
.
g
,
st
)
for
i
in
1
:
10
step!
(
st
.
subst
ate
)
for
i
in
1
:
st
.
algorithm
.
ninner
step!
(
subst
)
end
return
st
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment