Skip to content

Commit

Permalink
conf scheduling: reorder constraints more logically - crowd control
Browse files Browse the repository at this point in the history
  • Loading branch information
ge0ffrey committed Nov 11, 2018
1 parent 3b0fa84 commit 0c71ec4
Show file tree
Hide file tree
Showing 9 changed files with 37 additions and 36 deletions.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public class ConferenceConstraintConfiguration extends AbstractPersistable {
public static final String TALK_PREREQUISITE_TALKS = "Talk prerequisite talks";
public static final String TALK_MUTUALLY_EXCLUSIVE_TALKS_TAGS = "Talk mutually-exclusive-talks tags";
public static final String CONSECUTIVE_TALKS_PAUSE = "Consecutive talks pause";
public static final String CROWD_CONTROL = "Crowd control";

public static final String SPEAKER_REQUIRED_TIMESLOT_TAGS = "Speaker required timeslot tags";
public static final String SPEAKER_PROHIBITED_TIMESLOT_TAGS = "Speaker prohibited timeslot tags";
Expand All @@ -55,7 +56,6 @@ public class ConferenceConstraintConfiguration extends AbstractPersistable {
public static final String LANGUAGE_DIVERSITY = "Language diversity";
public static final String SAME_DAY_TALKS = "Same day talks";
public static final String POPULAR_TALKS = "Popular talks";
public static final String CROWD_CONTROL = "Crowd control";

public static final String SPEAKER_PREFERRED_TIMESLOT_TAGS = "Speaker preferred timeslot tags";
public static final String SPEAKER_UNDESIRED_TIMESLOT_TAGS = "Speaker undesired timeslot tags";
Expand All @@ -69,19 +69,21 @@ public class ConferenceConstraintConfiguration extends AbstractPersistable {
private int minimumConsecutiveTalksPauseInMinutes = 30;

@ConstraintWeight(ROOM_UNAVAILABLE_TIMESLOT)
private HardMediumSoftScore roomUnavailableTimeslot = HardMediumSoftScore.ofHard(10_000);
private HardMediumSoftScore roomUnavailableTimeslot = HardMediumSoftScore.ofHard(100_000);
@ConstraintWeight(ROOM_CONFLICT)
private HardMediumSoftScore roomConflict = HardMediumSoftScore.ofHard(10);
private HardMediumSoftScore roomConflict = HardMediumSoftScore.ofHard(1_000);
@ConstraintWeight(SPEAKER_UNAVAILABLE_TIMESLOT)
private HardMediumSoftScore speakerUnavailableTimeslot = HardMediumSoftScore.ofHard(1);
private HardMediumSoftScore speakerUnavailableTimeslot = HardMediumSoftScore.ofHard(100);
@ConstraintWeight(SPEAKER_CONFLICT)
private HardMediumSoftScore speakerConflict = HardMediumSoftScore.ofHard(1);
private HardMediumSoftScore speakerConflict = HardMediumSoftScore.ofHard(10);
@ConstraintWeight(TALK_PREREQUISITE_TALKS)
private HardMediumSoftScore talkPrerequisiteTalks = HardMediumSoftScore.ofHard(1);
private HardMediumSoftScore talkPrerequisiteTalks = HardMediumSoftScore.ofHard(10);
@ConstraintWeight(TALK_MUTUALLY_EXCLUSIVE_TALKS_TAGS)
private HardMediumSoftScore talkMutuallyExclusiveTalksTags = HardMediumSoftScore.ofHard(1);
@ConstraintWeight(CONSECUTIVE_TALKS_PAUSE)
private HardMediumSoftScore consecutiveTalksPause = HardMediumSoftScore.ofHard(1);
@ConstraintWeight(CROWD_CONTROL)
private HardMediumSoftScore crowdControl = HardMediumSoftScore.ofHard(1);

@ConstraintWeight(SPEAKER_REQUIRED_TIMESLOT_TAGS)
private HardMediumSoftScore speakerRequiredTimeslotTags = HardMediumSoftScore.ofHard(1);
Expand Down Expand Up @@ -127,8 +129,6 @@ public class ConferenceConstraintConfiguration extends AbstractPersistable {
private HardMediumSoftScore sameDayTalks = HardMediumSoftScore.ofSoft(10);
@ConstraintWeight(POPULAR_TALKS)
private HardMediumSoftScore popularTalks = HardMediumSoftScore.ofSoft(10);
@ConstraintWeight(CROWD_CONTROL)
private HardMediumSoftScore crowdControl = HardMediumSoftScore.ofSoft(10);

@ConstraintWeight(SPEAKER_PREFERRED_TIMESLOT_TAGS)
private HardMediumSoftScore speakerPreferredTimeslotTags = HardMediumSoftScore.ofSoft(20);
Expand Down Expand Up @@ -222,6 +222,14 @@ public void setConsecutiveTalksPause(HardMediumSoftScore consecutiveTalksPause)
this.consecutiveTalksPause = consecutiveTalksPause;
}

public HardMediumSoftScore getCrowdControl() {
return crowdControl;
}

public void setCrowdControl(HardMediumSoftScore crowdControl) {
this.crowdControl = crowdControl;
}

public HardMediumSoftScore getSpeakerRequiredTimeslotTags() {
return speakerRequiredTimeslotTags;
}
Expand Down Expand Up @@ -390,14 +398,6 @@ public void setPopularTalks(HardMediumSoftScore popularTalks) {
this.popularTalks = popularTalks;
}

public HardMediumSoftScore getCrowdControl() {
return crowdControl;
}

public void setCrowdControl(HardMediumSoftScore crowdControl) {
this.crowdControl = crowdControl;
}

public HardMediumSoftScore getSpeakerPreferredTimeslotTags() {
return speakerPreferredTimeslotTags;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -603,4 +603,5 @@ public Talk withRoom(Room room) {
this.room = room;
return this;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ public class ConferenceSchedulingXlsxFileIO extends AbstractXlsxSolutionFileIO<C
private static final String TALK_PREREQUISITE_TALKS_DESCRIPTION = "Penalty per prerequisite talk of a talk that doesn't end before the second talk starts, per minute of either talk";
private static final String TALK_MUTUALLY_EXCLUSIVE_TALKS_TAGS_DESCRIPTION = "Penalty per common mutually exclusive talks tag of 2 talks with overlapping timeslots, per overlapping minute";
private static final String CONSECUTIVE_TALKS_PAUSE_DESCRIPTION = "Penalty per 2 consecutive talks for the same speaker with a pause less than the minimum pause, per minute of either talk";
private static final String CROWD_CONTROL_DESCRIPTION = "Penalty per talk with a non-zero crowd control risk that are not in paired with exactly one other such talk, per minute of either talk";

private static final String SPEAKER_REQUIRED_TIMESLOT_TAGS_DESCRIPTION = "Penalty per missing required tag in a talk's timeslot, per minute";
private static final String SPEAKER_PROHIBITED_TIMESLOT_TAGS_DESCRIPTION = "Penalty per prohibited tag in a talk's timeslot, per minute";
Expand All @@ -103,7 +104,6 @@ public class ConferenceSchedulingXlsxFileIO extends AbstractXlsxSolutionFileIO<C
private static final String LANGUAGE_DIVERSITY_DESCRIPTION = "Reward per 2 talks with a different language and the the same timeslot, per (overlapping) minute";
private static final String SAME_DAY_TALKS_DESCRIPTION = "Penalty per common content or theme track of 2 talks with a different day, per minute of either talk";
private static final String POPULAR_TALKS_DESCRIPTION = "Penalty per 2 talks where the less popular one (has lower favorite count) is assigned a larger room than the more popular talk";
private static final String CROWD_CONTROL_DESCRIPTION = "Penalty per talk with a non-zero crowd control risk that are not in paired with exactly one other such talk, per minute of either talk";

private static final String SPEAKER_PREFERRED_TIMESLOT_TAGS_DESCRIPTION = "Penalty per missing preferred tag in a talk's timeslot, per minute";
private static final String SPEAKER_UNDESIRED_TIMESLOT_TAGS_DESCRIPTION = "Penalty per undesired tag in a talk's timeslot, per minute";
Expand Down Expand Up @@ -196,6 +196,8 @@ private void readConfiguration() {
TALK_MUTUALLY_EXCLUSIVE_TALKS_TAGS_DESCRIPTION));
constraintConfiguration.setConsecutiveTalksPause(readScoreConstraintLine(CONSECUTIVE_TALKS_PAUSE,
CONSECUTIVE_TALKS_PAUSE_DESCRIPTION));
constraintConfiguration.setCrowdControl(readScoreConstraintLine(CROWD_CONTROL,
CROWD_CONTROL_DESCRIPTION));

constraintConfiguration.setSpeakerRequiredTimeslotTags(readScoreConstraintLine(SPEAKER_REQUIRED_TIMESLOT_TAGS,
SPEAKER_REQUIRED_TIMESLOT_TAGS_DESCRIPTION));
Expand Down Expand Up @@ -241,8 +243,6 @@ private void readConfiguration() {
SAME_DAY_TALKS_DESCRIPTION));
constraintConfiguration.setPopularTalks(readScoreConstraintLine(POPULAR_TALKS,
POPULAR_TALKS_DESCRIPTION));
constraintConfiguration.setCrowdControl(readScoreConstraintLine(CROWD_CONTROL,
CROWD_CONTROL_DESCRIPTION));

constraintConfiguration.setSpeakerPreferredTimeslotTags(readScoreConstraintLine(SPEAKER_PREFERRED_TIMESLOT_TAGS,
SPEAKER_PREFERRED_TIMESLOT_TAGS_DESCRIPTION));
Expand Down Expand Up @@ -834,6 +834,8 @@ private void writeConfiguration() {
TALK_MUTUALLY_EXCLUSIVE_TALKS_TAGS_DESCRIPTION);
writeScoreConstraintLine(CONSECUTIVE_TALKS_PAUSE, constraintConfiguration.getConsecutiveTalksPause(),
CONSECUTIVE_TALKS_PAUSE_DESCRIPTION);
writeScoreConstraintLine(CROWD_CONTROL, constraintConfiguration.getCrowdControl(),
CROWD_CONTROL_DESCRIPTION);

writeScoreConstraintLine(SPEAKER_REQUIRED_TIMESLOT_TAGS, constraintConfiguration.getSpeakerRequiredTimeslotTags(),
SPEAKER_REQUIRED_TIMESLOT_TAGS_DESCRIPTION);
Expand Down Expand Up @@ -881,8 +883,6 @@ private void writeConfiguration() {
SAME_DAY_TALKS_DESCRIPTION);
writeScoreConstraintLine(POPULAR_TALKS, constraintConfiguration.getPopularTalks(),
POPULAR_TALKS_DESCRIPTION);
writeScoreConstraintLine(CROWD_CONTROL, constraintConfiguration.getCrowdControl(),
CROWD_CONTROL_DESCRIPTION);

writeScoreConstraintLine(SPEAKER_PREFERRED_TIMESLOT_TAGS, constraintConfiguration.getSpeakerPreferredTimeslotTags(),
SPEAKER_PREFERRED_TIMESLOT_TAGS_DESCRIPTION);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,21 @@ rule "Consecutive talks pause"
$talk1.getDurationInMinutes() + $talk2.getDurationInMinutes());
end

rule "Crowd control"
when
$talk : Talk(timeslot != null, $timeslot : timeslot,
crowdControlRisk > 0)
Number(this != 1) from accumulate(
// Timeslot.overlaps() is deliberately not used
$otherTalk : Talk(timeslot == $timeslot,
crowdControlRisk > 0,
this != $talk),
count($otherTalk)
)
then
scoreHolder.penalize(kcontext, $timeslot.getDurationInMinutes());
end


rule "Speaker required timeslot tags"
when
Expand Down Expand Up @@ -354,21 +369,6 @@ rule "Popular talks"
$talk1.getDurationInMinutes() + $talk2.getDurationInMinutes());
end

rule "Crowd control"
when
$talk : Talk(timeslot != null, $timeslot : timeslot,
crowdControlRisk > 0)
Number(this != 1) from accumulate(
// Timeslot.overlaps() is deliberately not used
$otherTalk : Talk(timeslot == $timeslot,
crowdControlRisk > 0,
this != $talk),
count($otherTalk)
)
then
scoreHolder.penalize(kcontext, $timeslot.getDurationInMinutes());
end


rule "Speaker preferred timeslot tags"
when
Expand Down

0 comments on commit 0c71ec4

Please sign in to comment.