Minimum Cost Maximum Flow Algorithm with Restrictions
This algorithm allocatesc
clients to s
servers, such that the total distance travelled is minimized.
LOOP until stop
Loop over servers
SET closest = NULL
SET shortest = INFINITY
Loop over clients
IF client has server
CONTINUE
SET dist = distance from client to server
IF dist < shortest
SET closest = client
SET shortest = dist
ENDLOOP over clients
IF closest == NULL
STOP
Connect closest client to server
ENDLOOP over servers
ENDLOOP until stop
Alternatively, this problem can be modelled as a Mixed-Integer Linear Program (MIP):
Variables:
Loop over servers
SET closest = NULL
SET shortest = INFINITY
Loop over clients
IF client has server
CONTINUE
SET dist = distance from client to server
IF dist < shortest
SET closest = client
SET shortest = dist
ENDLOOP over clients
IF closest == NULL
STOP
Connect closest client to server
ENDLOOP over servers
ENDLOOP until stop
- xij = 1 if client i is assigned to server j; else 0
- yj = number of clients assigned to server j
- dij = distance between client i and server j
min Σi,jdijxij
Subject to:Σjxij = 1 for each client i
Σixij - yj = 0 for each server j
yj - f >= 0 for each server j
yj - f <= 1 for each server j
xij = 0 or 1
yj variables will be forced to equal integers.