From d7745803b420e7b18bdd3a4e26a1d5a7537f3f22 Mon Sep 17 00:00:00 2001 From: Noah Gearhart Date: Sun, 25 Dec 2022 13:24:12 -0500 Subject: [PATCH 1/4] Upgrade to optaplanner 8.32 --- pom.xml | 41 +++++++++++++++++------------------------ 1 file changed, 17 insertions(+), 24 deletions(-) diff --git a/pom.xml b/pom.xml index fb15733..cb97508 100644 --- a/pom.xml +++ b/pom.xml @@ -11,7 +11,7 @@ 11 UTF-8 - 8.13.0.Final + 8.32.0.Final 1.2.3 3.8.1 @@ -90,29 +90,22 @@ - org.apache.maven.plugins - maven-assembly-plugin - - - package - - single - - - - - - org.thon.sleepshiftsolver.SleepShiftSolverApp - - - - - jar-with-dependencies - - - - - + org.apache.maven.plugins + maven-shade-plugin + 3.4.1 + + + + shade + + + + + + + + + From 7cee0b4579bf9731909d1db8c48a3ecf531fa735 Mon Sep 17 00:00:00 2001 From: Noah Gearhart Date: Sun, 25 Dec 2022 13:41:18 -0500 Subject: [PATCH 2/4] Add more severe error message if a static shift can't find a bed --- .../java/org/thon/sleepshiftsolver/io/ZipCsvFileIo.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/main/java/org/thon/sleepshiftsolver/io/ZipCsvFileIo.java b/src/main/java/org/thon/sleepshiftsolver/io/ZipCsvFileIo.java index 60ffe32..03a95a4 100644 --- a/src/main/java/org/thon/sleepshiftsolver/io/ZipCsvFileIo.java +++ b/src/main/java/org/thon/sleepshiftsolver/io/ZipCsvFileIo.java @@ -21,6 +21,8 @@ import java.util.zip.ZipEntry; import java.util.zip.ZipFile; +import javax.swing.JOptionPane; + import org.optaplanner.persistence.common.api.domain.solution.SolutionFileIO; import org.thon.sleepshiftsolver.Constants; import org.thon.sleepshiftsolver.constraints.BedCannotBeUsedRange; @@ -224,6 +226,11 @@ public int compare(StaticShift o1, StaticShift o2) { // Find free bed for this shift u.setBed(Bed.findFreeBed(bedList, userList, staticShift.startTime)); if (u.getBed() == null) { + JOptionPane.showMessageDialog( + null, + "Invalid static shift. No free bed found for " + u.getUsername() + " at " + staticShift.startTime + " (" + Constants.convertTimeToPrettyPrint(staticShift.startTime) + ")", + "This solution will probably fail!", + JOptionPane.ERROR_MESSAGE); System.out.println("Warning: No free bed found for " + u.getUsername() + " at " + staticShift.startTime + " (" + Constants.convertTimeToPrettyPrint(staticShift.startTime) + ")"); } } From 0a9952e59e4a74e4d764f8993aa5addf3f358682 Mon Sep 17 00:00:00 2001 From: Noah Gearhart Date: Sun, 25 Dec 2022 13:43:42 -0500 Subject: [PATCH 3/4] Remove build.gradle --- build.gradle | 49 ------------------------------------------------- 1 file changed, 49 deletions(-) delete mode 100644 build.gradle diff --git a/build.gradle b/build.gradle deleted file mode 100644 index 910de57..0000000 --- a/build.gradle +++ /dev/null @@ -1,49 +0,0 @@ -plugins { - id "java" - id "application" -} - -def optaplannerVersion = "8.13.0.Final" -def logbackVersion = "1.2.3" - -group = "org.thon" -version = "0.1.0-SNAPSHOT" - -repositories { - mavenCentral() - mavenLocal() -} - -dependencies { - implementation platform ("org.optaplanner:optaplanner-bom:${optaplannerVersion}") - implementation "org.optaplanner:optaplanner-core" - implementation "org.optaplanner:optaplanner-examples" - runtimeOnly "ch.qos.logback:logback-classic:${logbackVersion}" - - testImplementation "org.optaplanner:optaplanner-test" -} - -java { - sourceCompatibility = JavaVersion.VERSION_11 - targetCompatibility = JavaVersion.VERSION_11 -} - -compileJava { - options.encoding = "UTF-8" - options.compilerArgs << "-parameters" -} - -compileTestJava { - options.encoding = "UTF-8" -} - -application { - mainClass = "org.thon.sleepshiftsolver.SleepShiftSolverApp" -} - -test { - // Log the test execution results. - testLogging { - events "passed", "skipped", "failed" - } -} From 51e700ce14706860e520776e3ddf46f985eb5831 Mon Sep 17 00:00:00 2001 From: Mitch Wagner Date: Sat, 31 Dec 2022 13:22:35 -0500 Subject: [PATCH 4/4] Adjust output solved file format --- dependency-reduced-pom.xml | 97 +++++++++++++++++++ .../sleepshiftsolver/io/ZipCsvFileIo.java | 17 +++- 2 files changed, 112 insertions(+), 2 deletions(-) create mode 100644 dependency-reduced-pom.xml diff --git a/dependency-reduced-pom.xml b/dependency-reduced-pom.xml new file mode 100644 index 0000000..294dafe --- /dev/null +++ b/dependency-reduced-pom.xml @@ -0,0 +1,97 @@ + + + 4.0.0 + org.thon + sleepshiftsolver + 1.0-2022 + + + + maven-compiler-plugin + ${version.compiler.plugin} + + + maven-surefire-plugin + ${version.surefire.plugin} + + + maven-jar-plugin + 3.2.2 + + + + org.thon.sleepshiftsolver.SleepShiftSolverApp + + + + + + org.codehaus.mojo + exec-maven-plugin + ${version.exec.plugin} + + org.thon.sleepshiftsolver.SleepShiftSolverApp + + + + maven-shade-plugin + 3.4.1 + + + + shade + + + + + + + + + + + + + + org.optaplanner + optaplanner-test + 8.32.0.Final + test + + + junit-jupiter-api + org.junit.jupiter + + + assertj-core + org.assertj + + + + + + + + org.optaplanner + optaplanner-bom + ${version.org.optaplanner} + pom + import + + + ch.qos.logback + logback-classic + ${version.org.logback} + + + + + 11 + 3.8.1 + 1.2.3 + UTF-8 + 3.0.0-M5 + 8.32.0.Final + 3.0.0 + + diff --git a/src/main/java/org/thon/sleepshiftsolver/io/ZipCsvFileIo.java b/src/main/java/org/thon/sleepshiftsolver/io/ZipCsvFileIo.java index 03a95a4..26345d1 100644 --- a/src/main/java/org/thon/sleepshiftsolver/io/ZipCsvFileIo.java +++ b/src/main/java/org/thon/sleepshiftsolver/io/ZipCsvFileIo.java @@ -283,15 +283,28 @@ public int compare(StaticShift o1, StaticShift o2) { @Override public void write(SleepShiftSchedule solution, File outputSolutionFile) { - DateTimeFormatter formatter = DateTimeFormatter.ofPattern("eee HH:mm"); + //DateTimeFormatter formatter = DateTimeFormatter.ofPattern("eee HH:mm"); + DateTimeFormatter formatterDay = DateTimeFormatter.ofPattern("EEEE"); + DateTimeFormatter formatterTime = DateTimeFormatter.ofPattern("HH:mm"); try { BufferedWriter writer = new BufferedWriter(new FileWriter(outputSolutionFile)); + writer.write("PSU ID,Start Day,Start Time,End Day,End Time,Bed Assignment"); + writer.newLine(); for (User u : solution.getUserList()) { if (u.getSleepShift() != null && u.getBed() != null) { LocalDateTime shiftStart = Constants.START_TIME.plus(Duration.of(30*u.getSleepShiftStartTime(), ChronoUnit.MINUTES)); + LocalDateTime shiftEnd = Constants.START_TIME.plus(Duration.of(30*u.getSleepShiftEndTime(), ChronoUnit.MINUTES)); writer.write(u.getUsername()); writer.write(","); - writer.write(formatter.format(shiftStart).toUpperCase()); + writer.write(formatterDay.format(shiftStart)); + writer.write(","); + writer.write(formatterTime.format(shiftStart)); + writer.write(":00"); + writer.write(","); + writer.write(formatterDay.format(shiftEnd)); + writer.write(","); + writer.write(formatterTime.format(shiftEnd)); + writer.write(":00"); writer.write(","); writer.write(String.valueOf(u.getBed().getName())); writer.newLine();