Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade Optaplanner and Increase Static Shift Bed Not Found Warning #1

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 0 additions & 49 deletions build.gradle

This file was deleted.

97 changes: 97 additions & 0 deletions dependency-reduced-pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.thon</groupId>
<artifactId>sleepshiftsolver</artifactId>
<version>1.0-2022</version>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>${version.compiler.plugin}</version>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>${version.surefire.plugin}</version>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>3.2.2</version>
<configuration>
<archive>
<manifest>
<mainClass>org.thon.sleepshiftsolver.SleepShiftSolverApp</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>${version.exec.plugin}</version>
<configuration>
<mainClass>org.thon.sleepshiftsolver.SleepShiftSolverApp</mainClass>
</configuration>
</plugin>
<plugin>
<artifactId>maven-shade-plugin</artifactId>
<version>3.4.1</version>
<executions>
<execution>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer />
</transformers>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.optaplanner</groupId>
<artifactId>optaplanner-test</artifactId>
<version>8.32.0.Final</version>
<scope>test</scope>
<exclusions>
<exclusion>
<artifactId>junit-jupiter-api</artifactId>
<groupId>org.junit.jupiter</groupId>
</exclusion>
<exclusion>
<artifactId>assertj-core</artifactId>
<groupId>org.assertj</groupId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.optaplanner</groupId>
<artifactId>optaplanner-bom</artifactId>
<version>${version.org.optaplanner}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>${version.org.logback}</version>
</dependency>
</dependencies>
</dependencyManagement>
<properties>
<maven.compiler.release>11</maven.compiler.release>
<version.compiler.plugin>3.8.1</version.compiler.plugin>
<version.org.logback>1.2.3</version.org.logback>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<version.surefire.plugin>3.0.0-M5</version.surefire.plugin>
<version.org.optaplanner>8.32.0.Final</version.org.optaplanner>
<version.exec.plugin>3.0.0</version.exec.plugin>
</properties>
</project>
41 changes: 17 additions & 24 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<maven.compiler.release>11</maven.compiler.release>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

<version.org.optaplanner>8.13.0.Final</version.org.optaplanner>
<version.org.optaplanner>8.32.0.Final</version.org.optaplanner>
<version.org.logback>1.2.3</version.org.logback>

<version.compiler.plugin>3.8.1</version.compiler.plugin>
Expand Down Expand Up @@ -90,29 +90,22 @@
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<archive>
<manifest>
<mainClass>
org.thon.sleepshiftsolver.SleepShiftSolverApp
</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</execution>
</executions>
</plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.4.1</version>
<executions>
<execution>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

Expand Down
24 changes: 22 additions & 2 deletions src/main/java/org/thon/sleepshiftsolver/io/ZipCsvFileIo.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) + ")");
}
}
Expand Down Expand Up @@ -276,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();
Expand Down