Skip to content

Commit 4350008

Browse files
author
Jack Dunham
committed
region_plan now takes the previous region plan as a second argument
Upon construction, this defaults to `nothing`.
1 parent 7440149 commit 4350008

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/iterators.jl

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ mutable struct RegionIterator{Problem, RegionPlan} <: AbstractNetworkIterator
5454
end
5555
end
5656

57-
function RegionIterator(problem; sweep, sweep_kwargs...)
58-
plan = region_plan(problem; sweep_kwargs...)
57+
function RegionIterator(problem, prevplan; sweep, sweep_kwargs...)
58+
plan = region_plan(problem, prevplan; sweep_kwargs...)
5959
return RegionIterator(problem, plan, sweep)
6060
end
6161

@@ -109,6 +109,8 @@ function compute!(iter::RegionIterator)
109109
return iter
110110
end
111111

112+
# Default behaviour:
113+
region_plan(problem, ::Any; sweep_kwargs...) = region_plan(problem; sweep_kwargs...)
112114
region_plan(problem; sweep_kwargs...) = euler_sweep(state(problem); sweep_kwargs...)
113115

114116
#
@@ -129,7 +131,7 @@ mutable struct SweepIterator{Problem, Iter} <: AbstractNetworkIterator
129131
end
130132

131133
first_kwargs, _ = first_state
132-
region_iter = RegionIterator(problem; sweep = 1, first_kwargs...)
134+
region_iter = RegionIterator(problem, nothing; sweep = 1, first_kwargs...)
133135

134136
return new{Prob, Iter}(region_iter, stateful_sweep_kwargs, 1)
135137
end
@@ -151,7 +153,10 @@ end
151153

152154
function update_region_iterator!(iterator::SweepIterator; kwargs...)
153155
sweep = state(iterator)
154-
iterator.region_iter = RegionIterator(problem(iterator); sweep, kwargs...)
156+
157+
previous_plan = iterator.region_iter.region_plan
158+
159+
iterator.region_iter = RegionIterator(problem(iterator), previous_plan; sweep, kwargs...)
155160
return iterator
156161
end
157162

0 commit comments

Comments
 (0)