public class SubtourSeparator<V,E> extends Object
G(V,E)
be a undirected graph with vertex set V
, edge set E
. A valid TSP solution (i.e. a solution without subtours) should satisfy
the following constraint: \sum_{e\in \delta{S}} x_e >=2
for all S\subset V, S \noteq \emptyset
. Here \delta{S}\subset E
is the set of
edges where each edge has exactly one endpoint in S
, and one endpoint in V\setminus S
. x_e
is a binary variable indicating
whether edge e\in E
is used in the TSP solution. Obviously, if there is a set S'\subset V, S' \noteq \emptyset
such that
\sum_{e\in \delta{S'}} x_e <2
, then there is a subtour through the vertices in set S'. It may be the case that multiple subtours exist
within a fractional TSP solution. This class identifies the subtour with the highest amount of violation, i.e
\min_{S\subset V, S \noteq \emptyset} \sum_{e\in \delta{S}} x_e
Note: the graph must be provided as a JgraphT graph. The graph representing the problem can be directed, undirected, or mixed, complete or incomplete, weighted or without weights. The directed graphs are often useful to model cases where a vehicle can only drive from one city to the other in a particular direction.
Note2: To separate the subtours, we rely on the StoerWagnerMinimumCut implementation from the JgraphT package.
This implementation deterministically computes the minimum cut in a graph in O(|V||E| + |V|log|V|)
time, see
M. Stoer and F. Wagner, "A Simple Min-Cut Algorithm", Journal of the ACM, volume 44, number 4. pp 585-591, 1997.
WARNING: if the input graph is modified, i.e. edges or vertices are added/removed then the behavior of this class is undefined! A new instance should of this class should be made if this happens! A future extension of this class could add a graph listener.
Modifier and Type | Field and Description |
---|---|
static double |
PRECISION
Precision 0.000001
|
Constructor and Description |
---|
SubtourSeparator(org.jgrapht.Graph<V,E> inputGraph)
This method instantiates the Subtour Separator.
|
Modifier and Type | Method and Description |
---|---|
Set<V> |
getCutSet()
Returns the set S' where
\sum_{e\in \delta{S'}} x_e <2, S'\subset V, S' \noteq \emptyset |
double |
getCutValue()
Returns \sum_{e\in \delta{S'}} x_e for the separated subtour through S'.
|
boolean |
hasSubtour()
Returns whether a subtour exists in the fractional TSP solution
|
void |
separateSubtour(Map<E,Double> edgeValueMap)
Starts the subtour separation.
|
public static final double PRECISION
public SubtourSeparator(org.jgrapht.Graph<V,E> inputGraph)
inputGraph
- input graphpublic void separateSubtour(Map<E,Double> edgeValueMap)
edgeValueMap
- Mapping of edges to their corresponding values, i.e. the x_e variable values for all e \in E. It suffices to provide the values
of the non-zero edges. All other edges are presumed to have the value 0.public boolean hasSubtour()
public double getCutValue()
Copyright © 2016. All rights reserved.