Skip to content

Commit 3a52b0d

Browse files
committed
Inner iteration to improve choice of point of expansion
1 parent b6de4a3 commit 3a52b0d

File tree

2 files changed

+27
-8
lines changed

2 files changed

+27
-8
lines changed

src/linear_eq.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,12 +153,17 @@ function linear_hull(M::AbstractMatrix, r::AbstractArray)
153153
n = size(M, 1)
154154

155155
((M, r) = preconditioner(M, r))
156+
M = interval.((2*eye(n) - sup.(M)), sup.(M))
156157
M_lo = inf.(M)
157158
M_hi = sup.(M)
159+
P = eye(n)
158160
if all(.≤(M_lo, zero(M_lo)))
159161
return M \ r
160162
end
161163
P = inv(M_lo)
164+
if any(isinf.(P)) || any(isnan.(P))
165+
return gauss_seidel_interval(M, r, precondition=false, maxiter=2)
166+
end
162167
if all(.≤(eye(n), (P)))
163168
H1 = P * sup.(r)
164169
C = 1 ./ (2diag(P) - 1)

src/newtonnd.jl

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Preconditions the matrix A and b with the inverse of mid(A)
44
function preconditioner(A::AbstractMatrix, b::AbstractArray)
55

66
Aᶜ = mid.(A)
7-
B = pinv(Aᶜ) # TODO If Aᶜ is singular
7+
B = inv(Aᶜ) # TODO If Aᶜ is singular
88

99
return B*A, B*b
1010

@@ -23,7 +23,10 @@ function newtonnd(f::Function, deriv::Function, x::IntervalBox{NUM, T}; reltol=e
2323
if !all(0 .∈ f(Xᴵ))
2424
continue
2525
end
26+
2627
Xᴵ¹ = copy(Xᴵ)
28+
use_B = false
29+
2730
debug && (print("Current interval popped: "); println(Xᴵ))
2831

2932
if (isempty(Xᴵ))
@@ -45,22 +48,33 @@ function newtonnd(f::Function, deriv::Function, x::IntervalBox{NUM, T}; reltol=e
4548

4649
while true
4750

48-
use_B = false
4951
next_iter = false
5052

5153
initial_width = diam(Xᴵ)
5254
debug && (print("Current interval popped: "); println(Xᴵ))
55+
X = mid(Xᴵ)
5356
if use_B
54-
# TODO Compute X using B in Step 19
55-
else
56-
X = mid(Xᴵ)
57+
for i in 1:3
58+
z = X .- B * f(X)
59+
if all(z .∈ Xᴵ)
60+
if max(abs.(f(z))...) max(abs.(f(X))...)
61+
break
62+
end
63+
X = z
64+
else
65+
break
66+
end
67+
end
68+
if any(X .∉ Xᴵ)
69+
X = mid.(Xᴵ)
70+
end
5771
end
5872

5973
J = SMatrix{n}{n}(deriv(Xᴵ)) # either jacobian or calculated using slopes
60-
61-
# Xᴵ = IntervalBox((X + linear_hull(J, -f(interval.(X)))) .∩ Xᴵ)
74+
B, r = preconditioner(J, -f(interval.(X)))
75+
# Xᴵ = IntervalBox((X + linear_hull(B, r, precondition=false)) .∩ Xᴵ)
6276
Xᴵ = IntervalBox((X + (J \ -f(interval.(X)))) .∩ Xᴵ)
63-
77+
use_B = true
6478
if (isempty(Xᴵ))
6579
next_iter = true
6680
break

0 commit comments

Comments
 (0)