The
LR‐dispersion problem
Toshihiro
Akagi
Department
of
Computer, Science,
Gunma
University
Tetsuya
Araki
Principles
of
Informatics Research
Division,
National Institute of
Informatics
Shin‐ichi
Nakano
Department
of
Computer Science,
Gunma
University
1
Introduction
The
facility
locationproblem
and many of its variants have beenstudied[6, 7].
\mathrm{A}typical problem
is to find a set of locations toplace
facilities with the desgnated
costminimized.
By
contrast,
in this paperweconsider thedispersion problem,
which finds aset of locationswith the
designed
costmaximized.Given aset P ofn
points,
and the distance dforeachpair
ofpoints,
and aninteger
kwith
k\leq n
,wewishtofind a subsetS\subset P with|S|=k
such that somedesignated
costis
maximized[1,
4, 5, 9, 10, 11, 12,
13].
Inoneof
typical
casesthe cost tobe maximizedisthe minimum distance betweentwopoints
inS. IfP isaset ofpoints
on theplane
then theproblem
isNP‐hard[ll, 13],
andifP is aset of
points
onthe line then theproblem
canbe solvedinO(\displaystyle \max\{n\log n, kn\})
time[ll, 13]
by
dynamic programming approach,
andin O(
nloglog
n)
time[1]
by
sortedmatrix search
method[3, 8].
In this paper we consider two variants of the
dispersion
problem
on the line. Let Pbe a set of
points
onthe horizontal \mathrm{h}\mathrm{n}\mathrm{e}. We wish to find asubset S\subset Pwith|S|
=kmaximizing
cost(S)
defined asfollows.Let the cost cost
(s)
of s \in S=\{s_{1}, s_{2}, . . . , s_{k}\}
be the sum of the distance to its left.neighbor
in S andthe distance to itsright neighbor
in S. We assume s_{1}, s_{2},...,s_{k} aresortedfrom left to
right.
Especially
theleftmostpoint s_{1}\in S
has noleftneighbor,
so wedefine thecost ofs_{1} is
d(s_{1}, s_{2})
.Similariy
thecost of therightmost point
s_{k}ig
d(s_{k-1}, s_{k})
.Andthecost
(S)
of Sistheminimum
cost among thecostscost(sl), cost(s2),
...,
cost(sk).
We call the
problem
above the LR‐dispersion problem.
AnO(kn^{2}\log n)
timealgorithm
In this paperwe
design
analgorithm
tosolve theLR‐dispersion problem.
Ouralgorithm
runsinO(n\log n)
time,
and based onmatrixsearchmethod[3, 8].
Theremainder of this paper is
organized
as follows. Section 2 contains analgorithm
for the decision version of the
LR‐dispersion problem.
Section 3gives
ouralgorithm
forthe
LR‐dispersion problem.
Section4 treats one morevariant of thedispersion
problem.
Finally
Section5 is aconclusion.2
( $\lambda$, k)-\mathrm{L}\mathrm{R}
‐dispersion
In this section we
give
a linear timealgorithm
to solve a decision version of the LR‐dispersion
problem.
Givenaset
P=\{p_{1}, p_{2}, . . . , p_{n}\}
ofpoints
on ahorizontalline,
andtwonumbers k and$\lambda$we wishtodecide ifthere existsasubset S\subset P with
|S|=k
andcost(S)\geq $\lambda$
. Wecallthe
problem
asthe( $\lambda$, k)-\mathrm{L}\mathrm{R}
‐dispersion problem.
We have the
following
lemma.Lemma 1. If
( $\lambda$, k)-\mathrm{L}\mathrm{R}
‐dispersion problem
has a solution S =\{s_{1}, s_{2}, . . . , s_{k}\}
\subsetP,
then
S'=\{p_{1}, s_{2}, s_{3}, . . . , s_{k-1},p_{n}\}
isalso asolution of the( $\lambda$, k)-\mathrm{L}\mathrm{R}
‐dispersion
problem.
Proof. Sincecost
(S)\leq cost(S')
,ifSisasolution thenS'
isalsoasolutionandcost(S)=
cost
(S')
holds. \squareThe
algorithm
below is agreedy algorithm
tosolve the( $\lambda$, k)-\mathrm{L}\mathrm{R}
‐dispersion problem.
Notethat
$\omega$ st(s_{i})
for i=3,4,
...,k-1 is
d(s_{i-2}, s_{i})
.By setting
adummy
point
s_{0}=s_{1},cost
(s_{2})
is alsod(s_{2-2}, s_{2})=d(s_{1}, s_{2})
. Also notethat cost(k)=d(s_{k-1}, s_{k})
.Nowwe prove the correctness ofthe
algorithm.
Assume for a contradiction that thealgorithm
output
NO for agiven problem
but it has asolution.Let G =
\{g_{1}, g_{2}, . . . , g_{k'}\}
with k' < k be thepoints
chosenby
thealgorithm,
andO=\{0_{1}, 0_{2}, . . . , 0_{k}\}
thepoints
ofa solution.By
Lemma 1 we can assume 0_{1} =p_{1} ando_{k}=p_{n}. Notethatg_{1}=0_{1}=p_{1} andg_{k'}=0_{k}=p_{n} hold. Wehavethe
following
twocases.Case 1 : For all
i,
1\leq i<k',
g_{i}\leq 0_{i}
holds.Then our
greedy algorithm
canchoose at least one morepoint
0_{k'} or moreleftpoint.
A contradiction.
Case 2 : Fojrsome
i,
1\leq i<k',
g_{i}>0_{i} holds.Sinceg_{2} is chosen in a
greedy
manner, we can assumeg_{2}\leq 0_{2}
. Letj
be the minimumsuch i. Since g_{j-2}
\leq 0_{j-2}
and g_{j-1}\leq 0_{j-1}
hold,
ourgreedy algorithm
choose 0_{i} or moreleft
point
asg_{i}. A contradiction.Theorem 1. One cansolve the decision versionofthe
LR‐dispersion
problem
inO(n)
Algorithm
1 find( $\lambda$, k)-\mathrm{L}\mathrm{R}
‐dispersion
(P, k, $\lambda$)
/*P=\{p_{1}, p_{2}, . . . , p_{n}\}
andp_{1},p_{2},...,p_{n} are sortedfromleft to
right
*/
/*
Choose s_{1} ands_{k}*/
s_{1}=p_{1}, s_{k}=p_{n} s_{0}=s_{1}/*
Choose s_{2}, s_{3},... ,s_{k-1^{*}}/
c=2 for i=2 to k-1 dowhile
d(s_{i-2},p_{\mathrm{c}})< $\lambda$
andd(p_{c},p_{n})\geq $\lambda$
do c++end while
if
d(p_{\mathrm{c}},p_{n})< $\lambda$
then/*_{\mathrm{n}\mathrm{o}}
solution sinced(p_{c},p_{n}) <$\lambda$^{*}/
return NO
else
/*d(s_{i-2},p_{\mathrm{c}})\geq $\lambda$
hold\mathrm{s}^{*}/
s_{i}=p_{c} c++ end if endfor/*\mathrm{O}_{\mathrm{u}\mathrm{t}\mathrm{p}\mathrm{u}\mathrm{t}^{*}}/
returnS=\{s_{1}, s_{2}, . . . , s_{k}\}
/*
Dumm\mathrm{y}^{*}/
3
LR‐dispersion
Onecan
design
anO(n\log n)
timealgorithm
tosolve theLR‐dispersion problem,
basedonthe sorted matrixsearch
method[3, 8].
First let M be the matrix in which each element m_{i,j} is
d(p_{i},p_{j})
ifi<j
, otherwise0. Then m_{i,j}
\leq m_{i,j+1}
and m_{i,j}\geq m_{i+1,j} always
holds,
so the elements inthe rows andcolumns are
sorted, respectively.
The cost cost(S)
ofasolution S of theLR‐dispersion
problem
issomeelement in the matrix. Wearegoing
tofind thelargest
$\lambda$ in Mforwhichthe
( $\lambda$, k)-\mathrm{L}\mathrm{R}
‐dispersion problem
has asolution.By
appending
a suitable number oflarge enough
elements to M as the elements inthe
topmost
rows and therightmost
columns we can assume n is a power of 2. Notethat the elements in the rows and columns are still
sorted,
respectively.
Let M be theresulting
matrix. Ouralgorithm
consists ofrounds s = 1,
2,
...,
\log n
, and maintains aset
L_{s}
of(non‐overlapping)
submatrices ofMpossibly
containing
theoptimal
value $\lambda$^{*}.Hypothetically
first wesetL_{0}=\{M\}
. Assumeweare nowstaring
round s.For each subset M in
L_{s-1}
we divide M into the four submatriceswithn/2^{\mathrm{S}}
rows andn/2^{S}
columns andput
them intoL_{s}
. We never copy these submatrices. Wejust update
the index ofthecornerelements ofeach submatrix.
Let
$\lambda$_{\min}
be the median of the lower left corner elements of the submatrices inL_{s}.
Then forthe
$\lambda$=$\lambda$_{\min}
wesolve the( $\lambda$, k)-\mathrm{L}\mathrm{R}
‐dispersion
problem, using
thealgorithm
inSection2. We have the
following
twocases.If the
( $\lambda$, k)-\mathrm{L}\mathrm{R}
‐dispersion problem
hasnosolution thenwe remove fromL_{s}
each sub‐matrixwith thelowerleft cornerelement
(the
smallestelement)
greater
than$\lambda$_{\min}
. Since$\lambda$_{\min}
> $\lambda$^{*}holds,
each removed submatrix has no chance to contain $\lambda$^{*}. Thus we canremove atleast
|L_{s}|/2
submatricesfromL_{s}.
Otherwise if the
( $\lambda$, k)-\mathrm{L}\mathrm{R}
‐dispersion
problem
has a solution then we removefromL_{s}
each submatrix with the upper
right
corner element(the
largest
element)
smaller than$\lambda$_{\min}
. Since$\lambda$_{\min}\leq$\lambda$^{*}
holds,
each removed submatrix has no chanceto contain $\lambda$^{*}. Alsoif
L_{s}
has several submatrices with the upperright
corner elementequal
to$\lambda$_{\min}
thenwe remove them
except
one fromL_{s}
. Now we can observethat,
for each chain ofsubmatrices,
which is the sequence of submatrices inL_{s}
with lower left to upperright
diagonals
on the sameline,
the number of submatrices(1)
having
the lower left cornerelementsmaller than
$\lambda$_{\min}(2)
butremaining
inL_{s}
, isat most one(since
the\cdotelements
on
the common
diagonal
line aresorted).
Thus,
if|L_{s}|/2
>D_{s}
, whereD_{s} =2^{s+1}
is thenumberof chains
plus
one, thenwe can removeat least|L_{s}|f2-D_{s}+1
submatrices fromL_{s}.
Similarly
let$\lambda$_{\max}
be the median ofthe upperright
corner elements of submatrices inL_{s}
, andforthe$\lambda$=$\lambda$_{\max}
we solve the( $\lambda$, k)-\mathrm{L}\mathrm{R}
‐dispersion problem
andsimilarly
removesomesubmatrices from
L_{s}
. This endsround s.Now after round
\log n
eachmatrix inL_{\log n}
hasjust
oneelement,
thenwe can find theWe can prove that at the end of round s the number of submatrices in
L_{s}
is at most2D_{s}
, asfollows.First
L_{0}
has 1submatrix,
which is less than2D_{0}=4
.By
induction assumethatL_{s-1}
has
2D_{s-1}=2\cdot 2^{S}
submatrices.Atroundswefirst
partite
each submatrix inL_{s-1}
into foursubmatrices thenput
theminto
L_{s}
. Nowthe numberofsubmatrices inL_{s}
is at most 4 \cdot2D_{s-1}=4D_{s}
. We havefourcases.
Ifthe
( $\lambda$, k)-\mathrm{L}\mathrm{R}
‐dispersion
problem
hasnosolution for$\lambda$=$\lambda$_{\min}
thenwe canremoveatleastahalf ofthesubmatricesin
L_{s}
isat most2D_{s}
,asdesired. Ifthe( $\lambda$, k)-\mathrm{L}\mathrm{R}
‐dispersion
problem
hasasolution for$\lambda$=$\lambda$_{\max}
thenwe can removeatleastahalfof the submatricesin
L_{s}
is at most2D_{s}
, as desired. Otherwise if|L_{s}|/2
\leqD_{s}
then the number of thesubmatrices in
L_{s}
(even
before theremoval)
is at most2D_{s}
, as desired. Otherwise(1)
afterthe check for
$\lambda$=$\lambda$_{\min}
we can removeat least|L_{s}|/2-D_{s}
submatrices(consisting
oftoosmall
elements)
fromL_{s}
, and(2)
after check for$\lambda$=$\lambda$_{\max}
we can remove at least|L_{s}|/2-D_{s}
submatrices(consisting
oftoolarge
elements)
fromL_{s}
, sothe numberof theremaining
submatrices inL_{s}
is at most|L_{s}|-2(|L_{s}|/2-D_{s})=2D_{s}
, as desired.Thus at the end of round s the number of submatrices in
L_{s}
isalways
at most2D_{s},
andat the endofround
\log n
the number of submatrices is at most2D_{\log n}=4n.
Now we consider the
running
time. Weimplicitly
treat each submatrix as the indexof the upper
right
element in M and the number of lows(
= the number ofcolumns).
Except
forthe.
calls of the linear time decisionalgorithm
for the( $\lambda$, k)-\mathrm{L}\mathrm{R}
‐dispersion
problem,
we needO(|L_{s-1}|)
=O(D_{s-1})
time for each round s = 1,
2,
...,
\log n
, andD_{0}+D_{1}+\cdots+D_{\log n-1}
=2+4+\cdots+2^{\log n}
<2\cdot 2^{\log n}=2n
holds,
so thispart
needsO(n)
time in total.(Here
we usethe linear timealgorithm
tofind themedian.)
Sinceeachround calls the lineartimedecision
algorithm
twiceandthenumberof roundis
\log n
thispart
needsO(n\log n)
time intotal.Afterround
s=\mathrm{l}\mathrm{o}\mathrm{g}.n
each matrix hasjust
oneelement. Thenwe canfind the $\lambda$^{*} amongthe
|L_{\log n}|
\leq 2D_{\log n}=4n
elementsby
(1)
sorting them,
then(2)
performing
binary
search withthe linear timedecisionalgorithm
at most\log 4n
times. Thispart
needsO(n\log n)
time.
Thus the total
running
time isO(n\log n)
. With asimilar method we have solved the(original)
dispersion
problem
inO(n\log n) time[1].
Theorem 2. One cansolve the
LR‐dispersion problem
inO(n\log n)
time.4
Generalization
In this section we consider one more variant of the
dispersion problem
andgive
analgorithm
tosolve theproblem,
whichrunsinO(n\log n)
time. Intheoriginal dispersion
problem
thecostisthe minimumdistance
betweentwopoints
s_{i} and s_{i+1}. Wegeneralize
Given a set P =
\{p_{1},p_{2}, . . . ,p_{n}\}
ofpoints
on a horizontalline,
and the distance dfor each
pair
ofpoints,
and twointegers k,
h withk,
h \leq n, we wish to find a subsetS=\{s_{1}, s_{2}, . . . , s_{k}\}\subset P
maximizing
cost(S)
defined as follows.Lcost
(S)=\displaystyle \min\{d(s_{1}, s_{2})
,d(s_{1}, s_{3})
,...,d(s_{1},
s_{h} Rcost(S)=\displaystyle \min\{d(s_{k-h+1}, s_{k})
,d(s_{k-h+2}, s_{k})
,...,
d(s_{k-1}, s_{k})\}
and Mcost(S)=\displaystyle \min\{d(s_{1}, s_{1+h}), d(s_{2}, s_{2+h}), \cdots, d(s_{k-h}, s_{k})\}
then cost
(S)=\displaystyle \min{ L $\omega$ st(S)
,Rcost(S)
,Mcost(S)}.
We call the
problem
above the h‐dispersion problem.
Theoriginal
dispersion problem
onthe lineis the h
‐dispersion problem
withh=1 and theLR‐dispersion
problem
is theh
‐dispersion
problem
with h=2.Lemma 2. If
( $\lambda$, k)-h
‐dispersion problem
hasasolutionS=\{s_{1}, s_{2}, . . . , s_{k}\}\subset P
, thenS'=\{p_{1}, s_{2}, s_{3}, . . . , s_{k-1},p_{n}\}
is also asolution ofthe( $\lambda$, k)-h
‐dispersion
problem.
Proof. Sincecost
(S)\leq cost(S')
,if Sisasolution thenS'isalsoasolutionandcost(S)=
cost
(S')
holds. \squareThe
algorithm
below is agreedy algorithm
to solve theproblem.
Now we prove thecorrectnessofthe
algorithm.
Assume for acontradiction that the
algorithm
output
NO for agiven
problem
but ithasasolution.
Let G =
\{g_{1}, g_{2}, . . . , g_{k'}\}
with k' < k be thepoints
chosenby
thealgorithm,
andO=\{0_{1}, 0_{2}, . . . , 0_{k}\}
thepoints
of asolution.By
Lemma 2 we can assume 0_{1} =p_{1} ando_{k}=p_{n}. Note that g_{1}=0_{1}=p_{1} andg_{k'}=0_{k}=p_{n} hold. Wehave the
following
two cases.Case 1 : For all
i,
1\leq i<k',
g_{i}\leq 0_{i}
holds.Thenour
greedy algorithm
canchoose atleast one morepoints
0_{k'} or more leftpoint.
Acontradiction.
Case 2 : Forsome
i,
1\leq i<k',
g_{i}>0_{i} holds. Sinceg_{2}, g_{3},...,g_{h}arechosen ina
greedy
manner, we can assume g_{j}
\leq 0_{j}
forj=2
,3,
...,h. Let
j
be the minimum suchi. Sinceg_{j-h} \leq 0_{j-h}, g_{j\cdot-h+1}
\leq
0_{j-h+1}, .. ., g_{\mathrm{j}-1} \leq 0_{\mathrm{j}-1}
hold,
ourgreedy algorithm
choose 0_{i} ormoreleft
point
as g_{i}. A contradiction.Theorem 3. One can solve the decision version ofthe
h-\mathrm{d}\mathrm{i}\mathrm{s}\mathrm{p}\mathrm{e}\mathrm{r}\mathrm{s}\mathrm{i}_{0}^{ $\eta$}\mathrm{n}
problem
ino(n)
time.
Therefore,
similartothealgorithm
inSection3,
we candesign
O(n\log n)
timealgorithm
tosolve the h
‐dispersion problem.
Theorem 4. Onecansolve the h
‐dispersion problem
inO(n\log n)
time.5
Conclusion
Inthispaperwehave
presented
twoalgorithms
tosolvetheLR‐dispersion problem
andthe h
‐dispersion problem.
Therunning
timeof thealgorithms
areO(n\log n)
.An O
(
nloglog
n)
timealgorithm
to solve theoriginal
dispersion problem
on the lineis
known[1].
Can wedesign
an O(
nloglog
n)
timealgorithm
to solve the h‐dispersion
\displaystyle \frac{\mathrm{A}1\mathrm{g}\mathrm{o}\mathrm{r}\mathrm{i}\mathrm{t}\mathrm{h}\mathrm{m}2\mathrm{f}\mathrm{i}\mathrm{n}\mathrm{d}( $\lambda$,k)-h-\mathrm{d}\mathrm{i}\mathrm{s}\mathrm{p}\mathrm{e}\mathrm{r}\mathrm{s}\mathrm{i}\mathrm{o}\mathrm{n}(P,h,k, $\lambda$)}{/^{*}\mathrm{C}\mathrm{h}\mathrm{o}\mathrm{o}\mathrm{s}\mathrm{e}s_{1}\mathrm{a}\mathrm{n}\mathrm{d}s_{k^{*}}/}
s_{1}=p_{1}, s_{k}=p_{n}/*
Dumm\mathrm{y}^{*}/
s_{0}=s_{1}, s_{-1}=s_{1}, s_{-2}=s_{1},... ,s_{-h+2}=s\mathrm{i}
/*
Chooses_{2}, s_{3},... ,s_{k-1}*/
c=2for i=2\mathrm{t}\mathrm{o}k —ldo
while
d(s_{i-h},p_{\mathrm{c}})
< $\lambda$andd(p_{c},p_{n})
\geq $\lambda$
doc++ end while
if
d(p_{c},p_{n})< $\lambda$
then/*_{\mathrm{n}\mathrm{o}}
solution sinced(p_{c},p_{n})<$\lambda$^{*}/
return NO
else
/*d(s_{i-h},p_{c})\geq $\lambda$ \mathrm{h}\mathrm{o}\mathrm{l}\mathrm{d}\mathrm{s}^{*}/
s_{i}=p_{c} c++ end if end for
/*\mathrm{O}_{\mathrm{u}\mathrm{t}\mathrm{p}\mathrm{u}\mathrm{t}^{*}}/
returnS=\{s_{1}, s_{2}, . . . , s_{k}\}
References
[1]
\mathrm{T}_{\mathrm{t}}Akagi
and S.Nakano, Dispersion problem
on theLine,
TechnicalReport,
2016‐AL‐158‐4,
IPSJ(2016).
[2]
T.Akagi,
T. Araki and S.Nakano,
Variants of theDispersion
Problem,
TechnicalReport,
2017‐AL‐I6I‐3,
IPSJ(2017).
[3]
P.Agarwal
and M.Sharir,
EfficientAlgorithms
for Geometricoptimization,
Com‐puting
Surveys,
30, pp.412‐458
(1998).
[4]
C. Baur and S. P.Feketee,
Approximation
of GeometricDispersion Problems,
Pro.of APPROX
98,
Page
63‐75(1998).
[5]
B.Chandraand M. M.Halldorsson,
Approximation Algorithms
forDispersion
Prob‐lems,
J. ofAlgorithms,
38, pp.438‐465
(2001).
[6]
Z.Drezner,
Facility
Location: ASurvey
ofApplications
andMethods,
Springer
(1995).
[7]
Z. Drezner and H. W.Hamacher, Facility
Location:Applications
andTheory,
Springer
(2004).
[8]
G.Frederickson,
Optimal
Algorithms
forTreePartitioning,
Proc. of SODA91Pages
168‐177
(1991).
[9]
R.Hassin,
S. Rubinstein and A.Tamir,
Approximation Algorithms
for MaximumDispersion,
Operation
ResearchLetters, 21, pp.133‐137
(1997).
[10]
T. L. Lei and R. L.Church,
Onthe unifieddispersion problem:
Efficient formulationsand exact
algorithms,
European
Journal ofOperational
Research, 241, pp.622‐630
(2015).
[11]
S. S.Ravi,
D. J. RosenkrantzandG. K.Tayi,
Heuristic andSpecial
CaseAlgorithms
forDispersion
Problems, Operations
Research, 42, pp.299‐310
(1994).
[12]
M.Sydow, Approximation
Gurantees for {\rm Max} Sum and MaxMinFacility Dispersion
with Parameterised
Triangle Inequality
andApplications
in ResultDiversification,
Mathematica