Commit 152176dd authored by Sebastian Vollbrecht's avatar Sebastian Vollbrecht

Removed broken suppression of scheduling output.

Also added a missing default case.
parent 71c480b9
...@@ -34,8 +34,6 @@ import modsched.MoovacFormulation; ...@@ -34,8 +34,6 @@ import modsched.MoovacFormulation;
import modsched.Node; import modsched.Node;
import modsched.Schedule; import modsched.Schedule;
import java.io.OutputStream;
import java.io.PrintStream;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.LinkedList; import java.util.LinkedList;
...@@ -103,35 +101,13 @@ public class SchedulingUtils { ...@@ -103,35 +101,13 @@ public class SchedulingUtils {
*/ */
public static Schedule schedule(Set<ResourceNode> nodes, Set<Edge<ResourceNode>> edges, String problemName, public static Schedule schedule(Set<ResourceNode> nodes, Set<Edge<ResourceNode>> edges, String problemName,
ModuloSchedulingFormulation formulation, int solutionsLimit, int minII, int maxII) { ModuloSchedulingFormulation formulation, int solutionsLimit, int minII, int maxII) {
return schedule(nodes, edges, problemName, formulation, solutionsLimit, minII, maxII, false, null); return schedule(nodes, edges, problemName, formulation, solutionsLimit, minII, maxII, null);
} }
/** /**
* Schedules the provided sets of nodes and edges using the specified formulation and the given II bounds. The * Schedules the provided sets of nodes and edges using the specified formulation and the given II bounds. If the
* output suppression flag can be toggled to suppress the output of CPLEX. The solution limit specifies how many * maximum total time parameter is non-null, it will be used to cancel scheduling if the time limit is exceeded. The
* solutions should be computed by CPLEX before the best one will be returned. * solution limit specifies how many solutions should be computed by CPLEX before the best one will be returned.
*
* @param nodes the set of nodes
* @param edges the set of edges
* @param problemName the problem name
* @param formulation the formulation to use for scheduling
* @param solutionsLimit how many solutions to compute
* @param minII the minimum II of the sets
* @param maxII the maximum II of the sets
* @param suppressOutput true to suppress CPLEX output, otherwise false
* @return the best schedule with regard to the provided parameters
*/
public static Schedule schedule(Set<ResourceNode> nodes, Set<Edge<ResourceNode>> edges, String problemName,
ModuloSchedulingFormulation formulation, int solutionsLimit, int minII, int maxII,
boolean suppressOutput) {
return schedule(nodes, edges, problemName, formulation, solutionsLimit, minII, maxII, suppressOutput, null);
}
/**
* Schedules the provided sets of nodes and edges using the specified formulation and the given II bounds. The
* output suppression flag can be toggled to suppress the output of CPLEX. If the maximum total time parameter is
* non-null, it will be used to cancel scheduling if the time limit is exceeded. The solution limit specifies how
* many solutions should be computed by CPLEX before the best one will be returned.
* *
* @param nodes the set of nodes * @param nodes the set of nodes
* @param edges the set of edges * @param edges the set of edges
...@@ -140,27 +116,16 @@ public class SchedulingUtils { ...@@ -140,27 +116,16 @@ public class SchedulingUtils {
* @param solutionsLimit how many solutions to compute * @param solutionsLimit how many solutions to compute
* @param minII the minimum II of the sets * @param minII the minimum II of the sets
* @param maxII the maximum II of the sets * @param maxII the maximum II of the sets
* @param suppressOutput true to suppress CPLEX output, otherwise false
* @param maxTotalTime specifies the maximum time in seconds that will be spent altogether for the scheduling * @param maxTotalTime specifies the maximum time in seconds that will be spent altogether for the scheduling
* attempts (or null to not impose an overall time limit) * attempts (or null to not impose an overall time limit)
* @return the best schedule with regard to the provided parameters * @return the best schedule with regard to the provided parameters
*/ */
public static Schedule schedule(Set<ResourceNode> nodes, Set<Edge<ResourceNode>> edges, String problemName, public static Schedule schedule(Set<ResourceNode> nodes, Set<Edge<ResourceNode>> edges, String problemName,
ModuloSchedulingFormulation formulation, int solutionsLimit, int minII, int maxII, ModuloSchedulingFormulation formulation, int solutionsLimit, int minII, int maxII,
boolean suppressOutput, Long maxTotalTime) { Long maxTotalTime) {
if (minII > maxII) if (minII > maxII) {
throw new IllegalArgumentException("MinII > MaxII.\nMinII " + minII + "\nMaxII: " + maxII); throw new IllegalArgumentException("MinII > MaxII.\nMinII " + minII + "\nMaxII: " + maxII);
PrintStream sysout = System.out;
if (suppressOutput) {
System.setOut(new PrintStream(new OutputStream() {
@Override
public void write(int b) {
// Do nothing.
}
}));
} }
Formulation<Object, Resource, ? extends Node> f = asFormulation(nodes, edges, problemName, formulation, Formulation<Object, Resource, ? extends Node> f = asFormulation(nodes, edges, problemName, formulation,
...@@ -187,10 +152,6 @@ public class SchedulingUtils { ...@@ -187,10 +152,6 @@ public class SchedulingUtils {
service.shutdown(); service.shutdown();
} }
if (suppressOutput) {
System.setOut(sysout);
}
for (Node node : nodes) { for (Node node : nodes) {
node.setStartTime(f.getStartTime(node.getId())); node.setStartTime(f.getStartTime(node.getId()));
} }
...@@ -436,7 +397,7 @@ public class SchedulingUtils { ...@@ -436,7 +397,7 @@ public class SchedulingUtils {
ModuloSchedulingFormulation formulation, ModuloSchedulingFormulation formulation,
int solutionsLimit) { int solutionsLimit) {
Formulation<Object, Resource, ? extends Node> f = null; Formulation<Object, Resource, ? extends Node> f;
switch (formulation) { switch (formulation) {
case MOOVAC: case MOOVAC:
...@@ -445,6 +406,8 @@ public class SchedulingUtils { ...@@ -445,6 +406,8 @@ public class SchedulingUtils {
case EICHENBERGER: case EICHENBERGER:
f = new EichenbergerFormulation<>(problemName); f = new EichenbergerFormulation<>(problemName);
break; break;
default:
throw new UnsupportedOperationException(formulation.toString());
} }
for (ResourceNode node : nodes) { for (ResourceNode node : nodes) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment