You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 4 Next »

The root page 15DOTs60ia13:Tutorial could not be found in space 15.S60 SSIM: Software Tools for Operations Research.

Solver Input

The problem data is organized and passed to the solver in an instance of the class TspInstance<V,E>. Note the use of generics. Here V is the type of the objects that will correspond to vertices and E is the type of the objects that will correspond to edges. The point of generics is that our code will not really depend on what the types of our nodes and edges are. Lets take a quick look at the highlights of the public interface to this class.

public UndirectedGraph<V, E> getGraph() {
	...
}
public Function<E, Integer> getEdgeWeights() {
	...
}

The UndirectedGraph<V,E> returned by getGraph() is from the JUNG library. You can view the complete documentation here (this page might be more helpful), but some important highlights are

Name

Return Type

Arguments

Description

addVertex

boolean

V vertex

Adds vertex to this graph. Fails if vertex is null or already in the graph.

addEdge

boolean

E e, V v1, V v2

Adds edge e to this graph such that it connects vertex v1 to v2.

findEdge

E

V v1, V v2

Returns an edge that connects this vertex to v. Returns null if either v2 is not connected to v1 or either v1 or v2 are not present in this graph.

Solver Interface

Open the file src/solver/TspIpSolver.java by double clicking it from the Project Explorer. This is the file we will be primarily editing. It should contain the following (after the imports):
Toggle TspIpSolver.java

public class TspIpSolver<V,E> {
	
	public static enum Option{
		lazy,userCut, randomizedUserCut, christofidesApprox, christofidesHeuristic,twoOpt,incumbent;
	}
	
	public TspIpSolver(TspInstance<V,E> tspInstance) throws IloException{
		this(tspInstance,EnumSet.of(Option.lazy, Option.userCut, 
		Option.christofidesApprox, Option.christofidesHeuristic));
	}
	
	public TspIpSolver(TspInstance<V,E> tspInstance, EnumSet<Option> options) throws IloException{}
	
	public void solve() throws IloException{		
	}
	
	public ImmutableSet<E> getEdgesInOpt(){
		return null;
	}
	
	public double getOptVal(){
		return 0;
	}	
}
  • No labels