src/PET/AlgorithmZeroDual.jl

Wed, 24 Apr 2024 17:01:58 +0300

author
Neil Dizon <neil.dizon@helsinki.fi>
date
Wed, 24 Apr 2024 17:01:58 +0300
changeset 31
cbedcfcc0557
parent 16
98b79c837a30
permissions
-rw-r--r--

removed img folder

16
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
1 ####################################################################
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
2 # Predictive online PDPS for optical flow with known velocity field
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
3 ####################################################################
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
4
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
5 __precompile__()
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
6
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
7 module AlgorithmZeroDual
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
8
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
9 identifier = "pdps_known_zerodual"
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
10
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
11 using Printf
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
12
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
13 using AlgTools.Util
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
14 import AlgTools.Iterate
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
15 using ImageTools.Gradient
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
16 using ImageTools.Translate
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
17
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
18 using ..Radon
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
19 using ImageTransformations
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
20 using Images, CoordinateTransformations, Rotations, OffsetArrays
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
21 using ImageCore, Interpolations
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
22
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
23 using ..OpticalFlow: ImageSize,
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
24 Image,
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
25 petpdflow!
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
26
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
27 #########################
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
28 # Iterate initialisation
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
29 #########################
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
30
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
31 function init_rest(x::Image)
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
32 imdim=size(x)
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
33 y = zeros(2, imdim...)
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
34 Δx = copy(x)
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
35 Δy = copy(y)
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
36 x̄ = copy(x)
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
37 radonx = copy(x)
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
38 return x, y, Δx, Δy, x̄, radonx
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
39 end
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
40
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
41 function init_iterates(xinit::Image)
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
42 return init_rest(copy(xinit))
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
43 end
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
44
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
45 function init_iterates(dim::ImageSize)
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
46 return init_rest(zeros(dim...))
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
47 end
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
48
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
49 #########################
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
50 # PETscan related
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
51 #########################
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
52 function petvalue(x, b, c)
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
53 tmp = similar(b)
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
54 radon!(tmp, x)
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
55 return sum(@. tmp - b*log(tmp+c))
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
56 end
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
57
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
58 function petgrad!(res, x, b, c, S)
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
59 tmp = similar(b)
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
60 radon!(tmp, x)
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
61 @. tmp = S .- b/(tmp+c)
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
62 backproject!(res, S.*tmp)
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
63 end
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
64
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
65 function proj_nonneg!(y)
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
66 @inbounds @simd for i=1:length(y)
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
67 if y[i] < 0
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
68 y[i] = 0
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
69 end
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
70 end
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
71 return y
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
72 end
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
73
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
74 ############
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
75 # Algorithm
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
76 ############
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
77
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
78 function solve( :: Type{DisplacementT};
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
79 dim :: ImageSize,
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
80 iterate = AlgTools.simple_iterate,
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
81 params::NamedTuple) where DisplacementT
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
82
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
83 ################################
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
84 # Extract and set up parameters
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
85 ################################
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
86 α, ρ = params.α, params.ρ
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
87 R_K² = ∇₂_norm₂₂_est²
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
88 γ = 1
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
89 L = params.L
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
90 τ₀, σ₀ = params.τ₀, params.σ₀
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
91 τ = τ₀/L
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
92 σ = σ₀*(1-τ₀)/(R_K²*τ)
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
93
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
94 println("Step length parameters: τ=$(τ), σ=$(σ)")
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
95
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
96 λ = params.λ
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
97 c = params.c*ones(params.radondims...)
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
98
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
99
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
100 ######################
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
101 # Initialise iterates
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
102 ######################
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
103
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
104 x, y, Δx, Δy, x̄, r∇ = init_iterates(dim)
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
105
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
106 if params.L_experiment
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
107 oldpetgradx = zeros(size(x)...)
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
108 petgradx = zeros(size(x))
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
109 oldx = ones(size(x))
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
110 end
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
111
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
112 ####################
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
113 # Run the algorithm
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
114 ####################
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
115
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
116 v = iterate(params) do verbose :: Function,
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
117 b :: Image, # noisy_sinogram
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
118 v_known :: DisplacementT,
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
119 theta_known :: DisplacementT,
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
120 b_true :: Image,
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
121 S :: Image
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
122
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
123 ###################
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
124 # Prediction steps
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
125 ###################
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
126
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
127 petpdflow!(x, Δx, y, Δy, v_known, theta_known, false)
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
128 y .= zeros(size(y)...)
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
129
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
130 if params.L_experiment
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
131 @. oldx = x
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
132 end
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
133
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
134 ############
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
135 # PDPS step
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
136 ############
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
137
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
138 ∇₂ᵀ!(Δx, y) # primal step:
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
139 @. x̄ = x # | save old x for over-relax
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
140 petgrad!(r∇, x, b, c, S) # | Calculate gradient of fidelity term
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
141
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
142 @. x = x-(τ*λ)*r∇-τ*Δx # |
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
143 proj_nonneg!(x) # | non-negativity constaint prox
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
144 @. x̄ = 2x - x̄ # over-relax: x̄ = 2x-x_old
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
145 ∇₂!(Δy, x̄) # dual step:
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
146 @. y = y + σ*Δy # |
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
147 proj_norm₂₁ball!(y, α) # | prox
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
148
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
149 #####################
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
150 # L update if needed
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
151 #####################
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
152 if params.L_experiment
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
153 petgrad!(petgradx, x, b, c, S)
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
154 petgrad!(oldpetgradx, oldx, b, c, S)
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
155 if norm₂(x-oldx)>1e-12
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
156 L = max(0.9*norm₂(petgradx - oldpetgradx)/norm₂(x-oldx),L)
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
157 println("Step length parameters: L=$(L)")
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
158 τ = τ₀/L
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
159 σ = σ₀*(1-τ₀)/(R_K²*τ)
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
160 end
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
161 end
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
162
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
163 ################################
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
164 # Give function value if needed
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
165 ################################
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
166
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
167 v = verbose() do
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
168 ∇₂!(Δy, x)
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
169 value = λ*petvalue(x, b, c) + params.α*norm₂₁(Δy)
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
170 value, x, [NaN, NaN], nothing, τ, σ
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
171 end
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
172
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
173 v
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
174 end
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
175
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
176 return x, y, v
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
177 end
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
178
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
179 end # Module
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
180
98b79c837a30 added zero dual in PET
Neil Dizon <neil.dizon@helsinki.fi>
parents:
diff changeset
181

mercurial