_
{cloak:id=TspIpSolverStart|visible=true}
{code}
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;
}
}
{code}
{cloak}
For now, nothing in this class does much. Below, we summarize how all the parts _should_ work. The enum {{Option}} is a collection of flags that can be passed in to the solver indicating what special techniques the solver should use. We now briefly summarize what each option indicates:
||Option Name||Description||
|lazy|Add a LazyConstraintCallback to check potential integer solutions to ensure that the _cutset_ constraints are satisfied. Without this option, there is no guarantee that cutset constraints are checked.|
|userCut|Add a UserCutCallback to check fractional solutions to ensure that the _cutset_ constraints are satisfied.|
|randomizedUserCut|A variant of userCut where only a random subset of the _cutset_ constraints are checked. If flagged, userCut should not be flagged|
|christofidesApprox|Use Christofides Algorithm to give an initial solution to CPLEX.|
|christofidesHeuristic|Use a variant of Christofides Algorithm to generate integer solutions from fractional solutions.|
|twoOpt|Use the Two-Opt local search heuristic to improve solutions generated by christofidesApprox, christofidesHeuristic, or incumbent, if any are selected.|
|incumbent|Collect integer solutions found by CPLEX to have Two-Opt applied. Requires that twoOpt is flagged.|
Next, the constructors for class {{TspIpSolver}}:
||Arguments||Description||
|TspInstance<V,E> tspInstance, EnumSet<Option> options| Creates an instance of the solver according to options|
|TspInstance<V,E> tspInstance|Creates an instance of the solver with the default options {lazy, userCut, christofidesApprox, christofidesHeuristic}|
Finally, the methods of the class should behave as follows:
||Name||Return Type||Arguments||Description||
|solve|void| |Runs CPLEX to solve the TSP with problem data given by TspInstance. Do not call more than once.|
|getEdgesInOpt|ImmutableSet<E>| |Returns the subset of the edges of the TspInstance that are in the optimal solution. Do not call until solve() has finished. Behavior is undefined otherwise.|
|getOptVal|double| |Returns the value of the optimal solution. Do not call until solve() has finished. Behavior is undefined otherwise.|
Now that we understand the problem, we can begin implementing a solution!
|