Skip to content

Commit 8cdb0c9

Browse files
updated example file and code to line up
1 parent c26ff9e commit 8cdb0c9

2 files changed

Lines changed: 24 additions & 22 deletions

File tree

java/hello-world/src/main/java/org/acme/schooltimetabling/helperClasses/ScheduleConfig.java

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -72,34 +72,36 @@ public static void loadConfig(String yamlPath){
7272
Yaml yaml = new Yaml();
7373
HOLDER.scheduleConfig = yaml.loadAs(inputStream, ScheduleConfig.class);
7474

75-
//BitSet setup for times we want to compress into
76-
EnumSet<Days> MTWRF = EnumSet.allOf(Days.class);
77-
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("h:mma");
78-
LocalTime startTime = LocalTime.parse(HOLDER.scheduleConfig.compressStart, formatter);
79-
LocalTime endTime = LocalTime.parse(HOLDER.scheduleConfig.compressEnd, formatter);
80-
//normalize times
81-
startTime = roundToNearestHalfHour(startTime);
82-
endTime = roundToNearestHalfHour(endTime);
83-
if(startTime.isAfter(endTime)){
84-
LOGGER.error("The start time for the compressed start is after the end time; Exiting program");
85-
System.exit(1);
75+
if(HOLDER.scheduleConfig.compressStart != null && HOLDER.scheduleConfig.compressEnd != null) {//BitSet setup for times we want to compress into
76+
EnumSet<Days> MTWRF = EnumSet.allOf(Days.class);
77+
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("h:mma");
78+
LocalTime startTime = LocalTime.parse(HOLDER.scheduleConfig.compressStart, formatter);
79+
LocalTime endTime = LocalTime.parse(HOLDER.scheduleConfig.compressEnd, formatter);
80+
//normalize times
81+
startTime = roundToNearestHalfHour(startTime);
82+
endTime = roundToNearestHalfHour(endTime);
83+
if (startTime.isAfter(endTime)) {
84+
LOGGER.error("The start time for the compressed start is after the end time; Exiting program");
85+
System.exit(1);
86+
}
87+
//get number of 30 minute blocks
88+
long numBlcks = Duration.between(startTime, endTime).toMinutes() / 30;
89+
final int bsSizeRep = 150;
90+
BitSet buildCmprsIn = new BitSet(bsSizeRep);
91+
buildCmprsIn.or(BitSetHelper.timeSlotBitSet(startTime, (int) numBlcks, MTWRF));
92+
BitSet buildCmprsOut = (BitSet) buildCmprsIn.clone();
93+
buildCmprsOut.flip(0, bsSizeRep);
94+
95+
HOLDER.scheduleConfig.cpmrsInBs = buildCmprsIn;
96+
HOLDER.scheduleConfig.cmprsOutBs = buildCmprsOut;
8697
}
87-
//get number of 30 minute blocks
88-
long numBlcks = Duration.between(startTime,endTime).toMinutes() / 30;
89-
final int bsSizeRep = 150;
90-
BitSet buildCmprsIn = new BitSet(bsSizeRep);
91-
buildCmprsIn.or(BitSetHelper.timeSlotBitSet(startTime, (int) numBlcks, MTWRF));
92-
BitSet buildCmprsOut = (BitSet) buildCmprsIn.clone();
93-
buildCmprsOut.flip(0, bsSizeRep);
94-
95-
HOLDER.scheduleConfig.cpmrsInBs = buildCmprsIn;
96-
HOLDER.scheduleConfig.cmprsOutBs = buildCmprsOut;
9798
} catch (Exception e){
9899
final int PROGRAM_FAILURE = 1;
99100
LOGGER.error("Program is terminating. Couldn't read the yaml file");
100101
LOGGER.error(String.format("Program assumes yaml file is located at '%s' int the resources directory",
101102
yamlPath));
102103
LOGGER.error(String.format("Related error: %s", e.getMessage()));
104+
e.printStackTrace();
103105
System.exit(PROGRAM_FAILURE);
104106
}
105107
}

java/hello-world/src/main/resources/constants/config.example.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ prevTerm: "2264"
44
seasonTerm: "fall"
55
testing: false
66
useApi: true
7+
aggressiveChoice: "AGGRESSIVE_PENALTY"
78
# ------- Optional -------
89
# this setting changes how we model the PrimeTime constraint
9-
aggressiveChoice: "AGGRESSIVE_PENALTY"
1010
compressStart: "7:00AM"
1111
compressEnd: "6:00PM"
1212
prescheduledFileName: "PrescheduledTimes_ExampleFile.example.json"

0 commit comments

Comments
 (0)