Skip to content
Snippets Groups Projects
Commit f6e9a42e authored by Paul A. Rubin's avatar Paul A. Rubin
Browse files

Added hot start to first MIP model using heuristic solution. Second MIP model always rejects it.

parent e4ce60d7
No related branches found
No related tags found
No related merge requests found
...@@ -5,6 +5,7 @@ import java.util.Collection; ...@@ -5,6 +5,7 @@ import java.util.Collection;
import solvers.GreedyConstruction; import solvers.GreedyConstruction;
import solvers.MIPModel; import solvers.MIPModel;
import solvers.MIPModel2; import solvers.MIPModel2;
import solvers.PairSwap;
/** /**
* XmtrClusters experiments with solutions to a problem of clustering * XmtrClusters experiments with solutions to a problem of clustering
...@@ -41,14 +42,23 @@ public final class XmtrClusters { ...@@ -41,14 +42,23 @@ public final class XmtrClusters {
if (g.isEmpty()) { if (g.isEmpty()) {
System.out.println("\nThe greedy heuristic failed."); System.out.println("\nThe greedy heuristic failed.");
} else { } else {
System.out.println("\nGreedy heuristic results:\n" + prob.report(g)); System.out.println("Greedy heuristic results:\n" + prob.report(g));
} }
System.out.println(""); System.out.println("");
// Try the swapping heuristic.
long tl = 10000; // run time limit (ms.)
PairSwap swap = new PairSwap(prob, g, tl);
Collection<Collection<Integer>> s = swap.getSolution();
System.out.println("Pairwise swapping results:\n" + prob.report(s));
System.out.println("");
// Create and solve a MIP model. // Create and solve a MIP model.
double timeLimit = 300; // time limit in seconds for CPLEX double timeLimit = 300; // time limit in seconds for CPLEX
try { try {
MIPModel mip = new MIPModel(prob); MIPModel mip = new MIPModel(prob);
// Add the heuristic solution as a starting solution.
mip.hotStart(s);
double obj = mip.solve(timeLimit); double obj = mip.solve(timeLimit);
System.out.println("\nFinal objective value = " + obj); System.out.println("\nFinal objective value = " + obj);
// Get and summarize the optimal transmitter clusters. // Get and summarize the optimal transmitter clusters.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment