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

Compare with Current View Page History

« Previous Version 15 Next »

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

Problem Formulation

First, we will add the following fields to the class so we can easily reference our problem data from any method. Add

private EnumSet<Option> options;
private IloCplex cplex;
private TspInstance<V,E> tspInstance;
private ImmutableBiMap<E,IloIntVar> edgeVariables;

and initialize them, as below.

	public TspIpSolver(TspInstance<V,E> tspInstance, EnumSet<Option> options) throws IloException{
		this.options = options;
		this.tspInstance = tspInstance;
		this.cplex = new IloCplex();
		UndirectedGraph<V,E> graph = tspInstance.getGraph(); //for convenience, we will be using this a lot
		this.edgeVariables = Util.makeBinaryVariables(cplex, graph.getEdges());
		//the degree constraints
		//the objective		
	}

Next, we need to add the objective and the degree constraints to the IloCplex instance. Try adding them yourself! The following methods (as defined in Solver Specification and Java Style for CPLEX) should be useful for making the degree constraints:

  • From Util, the static method integerSum(IloCplex cplex, BiMap<T,IloIntVar> variables, Iterable<T> set)
  • From IloCplex, the method addEq(IloNumExpr e, double v)
  • From UndirectedGraph<V,E>, the method getIncidentEdges(V vertex)

Solution

For the objective, we need the functions:

  • From Util, the static method sum(IloCplex cplex, BiMap<T,IloIntVar> variables, Iterable<T> set, Function<? super T,? extends Number> coefficients)
  • From UndirectedGraph<V,E>, the method getEdges()
  • From TspInstance, the method getEdgeWeights

Solution

Solving and Extracting the Solution

  • No labels