# Size balancing

### Description

Functions for size balancing.

### Usage

1 2 3 | ```
clusterSplitSB(cl, seq, size = 1)
parLapplySB(cl, x, size = 1, fun, ...)
parLapplySLB(cl, x, size = 1, fun, ...)
``` |

### Arguments

`cl` |
A cluster object created by |

`x, seq` |
A vector to split. |

`fun` |
A function or character string naming a function. |

`size` |
Vector of problem sizes (approximate processing times)
corresponding to elements of |

`...` |
Other arguments of |

### Details

`clusterSplitSB`

splits `seq`

into subsets,
with respect to `size`

.
In size balancing, the problem is re-ordered from
largest to smallest, and then subsets are
determined by minimizing the total approximate processing time.
This splitting is deterministic (reproducible).

`parLapplySB`

and `parLapplySLB`

evaluates `fun`

on elements of `x`

in parallel, similarly to
`parLapply`

. `parLapplySB`

uses size balancing (via `clusterSplitSB`

).
`parLapplySLB`

uses size and load balancing.
This means that the problem is re-ordered from largest to smallest,
and then undeterministic load balancing
is used (see `clusterApplyLB`

). If `size`

is
correct, this is identical to size balancing.
This splitting is non-deterministic (might not be reproducible).

### Value

`clusterSplitSB`

returns a list of subsets
splitted with respect to `size`

.

`parLapplySB`

and `parLapplySLB`

evaluates
`fun`

on elements of `x`

, and return a result
corresponding to `x`

. Usually a list with results
returned by the cluster.

### Author(s)

Peter Solymos, solymos@ualberta.ca

### See Also

Related functions without size balancing:
`clusterSplit`

, `parLapply`

.

Underlying functions: `clusterApply`

,
`clusterApplyLB`

.

Optimizing the number of workers: `clusterSize`

,
`plotClusterSize`

.

### Examples

1 2 3 4 5 6 7 8 9 10 11 | ```
## Not run:
cl <- makePSOCKcluster(2)
## equal sizes, same as clusterSplit(cl, 1:5)
clusterSplitSB(cl, 1:5)
## different sizes
clusterSplitSB(cl, 1:5, 5:1)
x <- list(1, 2, 3, 4)
parLapplySB(cl, x, function(z) z^2, size=1:4)
stopCluster(cl)
## End(Not run)
``` |