Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -72,34 +72,36 @@ public static void loadConfig(String yamlPath){
Yaml yaml = new Yaml();
HOLDER.scheduleConfig = yaml.loadAs(inputStream, ScheduleConfig.class);

//BitSet setup for times we want to compress into
EnumSet<Days> MTWRF = EnumSet.allOf(Days.class);
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("h:mma");
LocalTime startTime = LocalTime.parse(HOLDER.scheduleConfig.compressStart, formatter);
LocalTime endTime = LocalTime.parse(HOLDER.scheduleConfig.compressEnd, formatter);
//normalize times
startTime = roundToNearestHalfHour(startTime);
endTime = roundToNearestHalfHour(endTime);
if(startTime.isAfter(endTime)){
LOGGER.error("The start time for the compressed start is after the end time; Exiting program");
System.exit(1);
if(HOLDER.scheduleConfig.compressStart != null && HOLDER.scheduleConfig.compressEnd != null) {//BitSet setup for times we want to compress into
EnumSet<Days> MTWRF = EnumSet.allOf(Days.class);
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("h:mma");
LocalTime startTime = LocalTime.parse(HOLDER.scheduleConfig.compressStart, formatter);
LocalTime endTime = LocalTime.parse(HOLDER.scheduleConfig.compressEnd, formatter);
//normalize times
startTime = roundToNearestHalfHour(startTime);
endTime = roundToNearestHalfHour(endTime);
if (startTime.isAfter(endTime)) {
LOGGER.error("The start time for the compressed start is after the end time; Exiting program");
System.exit(1);
}
//get number of 30 minute blocks
long numBlcks = Duration.between(startTime, endTime).toMinutes() / 30;
final int bsSizeRep = 150;
BitSet buildCmprsIn = new BitSet(bsSizeRep);
buildCmprsIn.or(BitSetHelper.timeSlotBitSet(startTime, (int) numBlcks, MTWRF));
BitSet buildCmprsOut = (BitSet) buildCmprsIn.clone();
buildCmprsOut.flip(0, bsSizeRep);

HOLDER.scheduleConfig.cpmrsInBs = buildCmprsIn;
HOLDER.scheduleConfig.cmprsOutBs = buildCmprsOut;
}
//get number of 30 minute blocks
long numBlcks = Duration.between(startTime,endTime).toMinutes() / 30;
final int bsSizeRep = 150;
BitSet buildCmprsIn = new BitSet(bsSizeRep);
buildCmprsIn.or(BitSetHelper.timeSlotBitSet(startTime, (int) numBlcks, MTWRF));
BitSet buildCmprsOut = (BitSet) buildCmprsIn.clone();
buildCmprsOut.flip(0, bsSizeRep);

HOLDER.scheduleConfig.cpmrsInBs = buildCmprsIn;
HOLDER.scheduleConfig.cmprsOutBs = buildCmprsOut;
} catch (Exception e){
final int PROGRAM_FAILURE = 1;
LOGGER.error("Program is terminating. Couldn't read the yaml file");
LOGGER.error(String.format("Program assumes yaml file is located at '%s' int the resources directory",
yamlPath));
LOGGER.error(String.format("Related error: %s", e.getMessage()));
e.printStackTrace();
System.exit(PROGRAM_FAILURE);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -575,13 +575,23 @@ Constraint inPrimeTime(ConstraintFactory constraintFactory){
.asConstraint("Penalizing for being in prime time");
}


/**
* This constraint is used when we choose the "Aggressive" version of the solver that aims to compress and REWARD
* time that is in the time interval specified in the configuration file
*/
Constraint inBestTime(ConstraintFactory constraintFactory){
return constraintFactory.forEach(Lesson.class)
.filter(lesson -> lesson.maskInCmprs().cardinality() > 0)
.reward(HardMediumSoftScore.ONE_SOFT)
.asConstraint("Reward time in preferred time interval");
}


/**
* This constraint is used when we choose the "Aggressive" version of the solver that aims to compress and PENALIZE
* time that is in the time interval specified in the configuration file
*/
Constraint outBestTime(ConstraintFactory constraintFactory){
return constraintFactory.forEach(Lesson.class)
.filter(lesson -> lesson.maskOutCmprs().cardinality() > 0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ prevTerm: "2264"
seasonTerm: "fall"
testing: false
useApi: true
aggressiveChoice: "AGGRESSIVE_PENALTY"
# ------- Optional -------
# this setting changes how we model the PrimeTime constraint
aggressiveChoice: "AGGRESSIVE_PENALTY"
compressStart: "7:00AM"
compressEnd: "6:00PM"
prescheduledFileName: "PrescheduledTimes_ExampleFile.example.json"
Loading