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;
import modsched.Node;
import modsched.Schedule;
import java.io.OutputStream;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedList;
......@@ -103,35 +101,13 @@ public class SchedulingUtils {
*/
public static Schedule schedule(Set<ResourceNode> nodes, Set<Edge<ResourceNode>> edges, String problemName,
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
* output suppression flag can be toggled to suppress the output of CPLEX. 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 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.
* Schedules the provided sets of nodes and edges using the specified formulation and the given II bounds. 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 edges the set of edges
......@@ -140,27 +116,16 @@ public class SchedulingUtils {
* @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
* @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)
* @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, Long maxTotalTime) {
Long maxTotalTime) {
if (minII > maxII)
if (minII > 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,
......@@ -187,10 +152,6 @@ public class SchedulingUtils {
service.shutdown();
}
if (suppressOutput) {
System.setOut(sysout);
}
for (Node node : nodes) {
node.setStartTime(f.getStartTime(node.getId()));
}
......@@ -436,7 +397,7 @@ public class SchedulingUtils {
ModuloSchedulingFormulation formulation,
int solutionsLimit) {
Formulation<Object, Resource, ? extends Node> f = null;
Formulation<Object, Resource, ? extends Node> f;
switch (formulation) {
case MOOVAC:
......@@ -445,6 +406,8 @@ public class SchedulingUtils {
case EICHENBERGER:
f = new EichenbergerFormulation<>(problemName);
break;
default:
throw new UnsupportedOperationException(formulation.toString());
}
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