You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
where $q_j$ is computed by the worker upon reception of $\textrm{answer}(q_i)$ from worker $j$ and where $connected$ are the list of workers that have answered.
264
264
265
-
The [`AggregationAlgorithm`](@ref) in this library requires you to specify three methods: query, answer, and aggregate. Here's an example showing the required signatures of these three methods:
265
+
The [`AggregationAlgorithm`](@ref) in this library requires you to define four methods: `initialize`, `query`, `answer`, and `aggregate`. Here's an example showing the required signatures of these three methods:
266
266
267
267
```julia
268
268
@everywherebegin
@@ -273,10 +273,10 @@ The [`AggregationAlgorithm`](@ref) in this library requires you to specify three
@@ -286,7 +286,7 @@ history = start(algorithm, distributed_problem, (epoch=100,));
286
286
287
287
**Memory limitation:** At any point in time, the central worker should have access must have access to the latest answers $a_i$ from *all* the connected workers. This means storing a lot of $a_i$ if we use many workers. There is a workaround when the aggregation operation is an *average*. In this case, only the equivalent of one answer needs to be saved on the central node, regardless of the number of workers.
288
288
289
-
[`AveragingAlgorithm`](@ref) implements this memory optimization. Here you only need to define `query`, the `answer`
289
+
[`AveragingAlgorithm`](@ref) implements this memory optimization. Here you only need to define `initialize`, `query`, the `answer`
290
290
291
291
```julia
292
292
@everywherebegin
@@ -295,9 +295,9 @@ history = start(algorithm, distributed_problem, (epoch=100,));
295
295
stepsize::Float64
296
296
end
297
297
298
-
(tba::ToBeAveragedGD)(problem::Any) = tba.q1
299
-
(tba::ToBeAveragedGD)(a::Vector{Float64}, problem::Any) = a
Copy file name to clipboardExpand all lines: src/algorithm_wrappers.jl
+40-34Lines changed: 40 additions & 34 deletions
Original file line number
Diff line number
Diff line change
@@ -1,18 +1,23 @@
1
1
export AggregationAlgorithm, AveragingAlgorithm
2
2
3
+
initialize(algorithm::AbstractAlgorithm, problem::Any) =throw(ArgumentError("Method initialize(::$(typeof(algorithm)), problem::Any) not implemented."))
4
+
aggregate(algorithm::AbstractAlgorithm{Q,A}, as::Vector{A}, workers::Vector{Int64}) where {Q,A} =throw(ArgumentError("Method aggregate(::$(typeof(algorithm)), problem::Any) not implemented."))
5
+
query(algorithm::AbstractAlgorithm, agg::AggregatedA, problem::Any) where {AggregatedA} =throw(ArgumentError("Method query(::$(typeof(algorithm)), problem::Any) not implemented."))
6
+
answer(algorithm::AbstractAlgorithm{Q,A}, q::Q, problem::Any) where {Q,A} =throw(ArgumentError("Method answer(::$(typeof(algorithm)), problem::Any) not implemented."))
7
+
3
8
"""
4
-
AggregationAlgorithm{Q,A,Alg<:AbstractAlgorithm{Q,A}}(arg; kwarg)::AbstractAlgorithm{Q,A} where {Q,A}
Distributed algorithm that writes: `q_j <- query(aggregate([answer(q_i) for i in connected]))`
7
12
Where a "connected" worker is a worker that has answered at least once.
8
13
(Not memory optimized: `length(pids)` answers are stored on the central worker at all times)
9
14
10
15
# Argument
11
-
- `algorithm<:AbstractAlgorithm{Q,A}` which should define the following
12
-
- `algorithm(problem::Any)::Q`: the initialization step that create the first query iterate
13
-
- `algorithm(as::Vector{A}, workers::Vector{Int64})::AggregatedA` where A: the answer aggregarion step performed by the central node when receiving the answers `as::Vector{A}` from the `workers`
14
-
- `algorithm(agg::AggregatedA, problem::Any)::Q`: the query step producing a query from the aggregated answer `agg::AggregatedA`, performed by the central node
15
-
- `algorithm(q::Q, problem::Any)::A`: the answer step perfromed by the wokers when they receive a query `q::Q` from the central node
16
+
- `algorithm<:AbstractAlgorithm{Q,A}` which should define the following (where `const AIA = AsynchronousIterativeAlgorithms`)
17
+
- `AIA.initialize(algorithm, problem::Any)::Q`: step that creates the first query iterate
18
+
- `AIA.aggregate(algorithm, as::Vector{A}, workers::Vector{Int64})::AggregatedA` where A: step performed by the central node when receiving the answers `as::Vector{A}` from the `workers`
19
+
- `AIA.query(algorithm, agg::AggregatedA, problem::Any)::Q`: step producing a query from the aggregated answer `agg::AggregatedA`, performed by the central node
20
+
- `AIA.answer(algorithm, q::Q, problem::Any)::A`: step perfromed by the wokers when they receive a query `q::Q` from the central node
0 commit comments