Our simultaneous placement algorithm is a dynamic programming algorithm that visits each node exactly once
to determine the best use of caches in its subtree. The algorithm discovers the optimal
placement of all values of
caches from
to
so as to minimize the total cost of traffic.
The result of running the evaluation
on any node is a
matrix
containing the total
costs of the subtree where
is the number of caches and
is the distance to the nearest source of the data.
For each element of the matrix, the node must choose how many pebbles to give to each of its children
and whether or not to keep a pebble for itself.
Leaf nodes can compute their cost matrix easily. If they are given one or more pebbles, their cost
is simply the number of bytes of replies needed by that AS.
Assume
is that number of local traffic bytes at node
.
If a leaf is given zero pebbles, his cost is
. In the implementation, we used a matrix that
is 15 rows high, representing values
of
from 0 to 14.
In our study, the maximum number of pebbles,
,
is set to 50 but could be increased at the cost
of running time and memory consumed by the algorithm.
Define
to be the cost of a daughter subtree of
, where
is
one of the
daughters of node
.
Each row of
is computed using row
from the daughters. Start with the first daughter's
row intact.
Then for each subsequent daughter, test all distributions of
pebbles in which
pebbles
are given to the prior daughters and
pebbles are given to the new child.
Now we construct
. The first element,
is
, because no pebble is available.
To find the rest of
, take the first row of
and shift it
down by 1 pebble because the children
will only have
pebbles to distribute. Note that all other rows of the matrix are copies of row
.
Finally, each element is the minimum of
and
.
To compute the best placement for the whole tree, we compute the cost matrix of the root,
.
The row
contains the minimum cost for the whole tree for values
of
.