-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
33 lines (26 loc) · 1.17 KB
/
Main.java
File metadata and controls
33 lines (26 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package mmis;
import java.io.IOException;
import java.nio.file.Path;
import java.util.List;
public class Main {
public static void main(String[] args) throws IOException {
if (args.length < 4) {
System.out.println("Usage: java mmis.Main <input.csv> <machine-count> <schedule-output.csv> <unassigned-output.csv>");
return;
}
Path inputPath = Path.of(args[0]);
int machineCount = Integer.parseInt(args[1]);
Path scheduleOutputPath = Path.of(args[2]);
Path unassignedOutputPath = Path.of(args[3]);
CsvJobReader reader = new CsvJobReader();
List<Job> jobs = reader.read(inputPath);
GreedyScheduler scheduler = new GreedyScheduler();
SolverResult result = scheduler.solve(jobs, machineCount);
CsvScheduleWriter writer = new CsvScheduleWriter();
writer.writeSchedule(scheduleOutputPath, result.getScheduledJobs());
writer.writeUnassigned(unassignedOutputPath, result.getUnassignedJobs());
System.out.printf("Scheduled %d jobs and left %d unassigned.%n",
result.getScheduledJobs().size(),
result.getUnassignedJobs().size());
}
}