11package ai .timefold .solver .benchmarks .examples .conferencescheduling .score ;
22
3+ import static ai .timefold .solver .benchmarks .examples .conferencescheduling .domain .ConferenceConstraintProperties .*;
34import static ai .timefold .solver .benchmarks .examples .conferencescheduling .domain .ConferenceConstraintProperties .AUDIENCE_LEVEL_DIVERSITY ;
45import static ai .timefold .solver .benchmarks .examples .conferencescheduling .domain .ConferenceConstraintProperties .AUDIENCE_TYPE_DIVERSITY ;
56import static ai .timefold .solver .benchmarks .examples .conferencescheduling .domain .ConferenceConstraintProperties .AUDIENCE_TYPE_THEME_TRACK_CONFLICT ;
1011import static ai .timefold .solver .benchmarks .examples .conferencescheduling .domain .ConferenceConstraintProperties .LANGUAGE_DIVERSITY ;
1112import static ai .timefold .solver .benchmarks .examples .conferencescheduling .domain .ConferenceConstraintProperties .POPULAR_TALKS ;
1213import static ai .timefold .solver .benchmarks .examples .conferencescheduling .domain .ConferenceConstraintProperties .ROOM_CONFLICT ;
13- import static ai .timefold .solver .benchmarks .examples .conferencescheduling .domain .ConferenceConstraintProperties .SAME_DAY_TALKS ;
1414import static ai .timefold .solver .benchmarks .examples .conferencescheduling .domain .ConferenceConstraintProperties .SECTOR_CONFLICT ;
1515import static ai .timefold .solver .benchmarks .examples .conferencescheduling .domain .ConferenceConstraintProperties .SPEAKER_CONFLICT ;
1616import static ai .timefold .solver .benchmarks .examples .conferencescheduling .domain .ConferenceConstraintProperties .SPEAKER_MAKESPAN ;
@@ -92,7 +92,8 @@ public Constraint[] defineConstraints(ConstraintFactory factory) {
9292 contentAudienceLevelFlowViolation (factory ),
9393 contentConflict (factory ),
9494 languageDiversity (factory ),
95- sameDayTalks (factory ),
95+ contentConflictSameDay (factory ),
96+ themeTrackConflictSameDay (factory ),
9697 popularTalks (factory ),
9798 speakerPreferredTimeslotTags (factory ),
9899 speakerUndesiredTimeslotTags (factory ),
@@ -303,11 +304,10 @@ Constraint contentAudienceLevelFlowViolation(ConstraintFactory factory) {
303304
304305 Constraint contentConflict (ConstraintFactory factory ) {
305306 return factory .forEachUniquePair (Talk .class ,
306- overlapping (t -> t .getTimeslot ().getStartDateTime (), t -> t .getTimeslot ().getEndDateTime ()))
307- .expand ((talk1 , talk2 ) -> talk2 .overlappingContentCount (talk1 ))
308- .filter ((talk1 , talk2 , overlappingContentCount ) -> overlappingContentCount > 0 )
307+ overlapping (t -> t .getTimeslot ().getStartDateTime (), t -> t .getTimeslot ().getEndDateTime ()),
308+ intersecting (Talk ::getContentTagSet ))
309309 .penalize (HardSoftScore .ofSoft (100 ),
310- (talk1 , talk2 , overlappingContentCount ) -> overlappingContentCount
310+ (talk1 , talk2 ) -> talk2 . overlappingContentCount ( talk1 )
311311 * talk1 .overlappingDurationInMinutes (talk2 ))
312312 .asConstraint (CONTENT_CONFLICT );
313313 }
@@ -320,18 +320,20 @@ Constraint languageDiversity(ConstraintFactory factory) {
320320 .asConstraint (LANGUAGE_DIVERSITY );
321321 }
322322
323- Constraint sameDayTalks (ConstraintFactory factory ) {
324- return factory .forEachUniquePair (Talk .class )
323+ Constraint contentConflictSameDay (ConstraintFactory factory ) {
324+ return factory .forEachUniquePair (Talk .class , intersecting ( Talk :: getContentTagSet ) )
325325 .filter ((talk1 , talk2 ) -> !talk1 .getTimeslot ().isOnSameDayAs (talk2 .getTimeslot ()))
326- .expand ((talk1 , talk2 ) -> {
327- var overlappingContentCount = talk2 .overlappingContentCount (talk1 );
328- var overlappingThemeTrackCount = talk2 .overlappingThemeTrackCount (talk1 );
329- return overlappingContentCount + overlappingThemeTrackCount ;
330- })
331- .filter ((talk1 , talk2 , overlap ) -> overlap > 0 )
332326 .penalize (HardSoftScore .ofSoft (10 ),
333- (talk1 , talk2 , overlap ) -> overlap * talk1 .combinedDurationInMinutes (talk2 ))
334- .asConstraint (SAME_DAY_TALKS );
327+ (talk1 , talk2 ) -> talk2 .overlappingContentCount (talk1 ) * talk1 .combinedDurationInMinutes (talk2 ))
328+ .asConstraint (CONTENT_CONFLICT_SAME_DAY_TALKS );
329+ }
330+
331+ Constraint themeTrackConflictSameDay (ConstraintFactory factory ) {
332+ return factory .forEachUniquePair (Talk .class , intersecting (Talk ::getThemeTrackTagSet ))
333+ .filter ((talk1 , talk2 ) -> !talk1 .getTimeslot ().isOnSameDayAs (talk2 .getTimeslot ()))
334+ .penalize (HardSoftScore .ofSoft (10 ),
335+ (talk1 , talk2 ) -> talk2 .overlappingThemeTrackCount (talk1 ) * talk1 .combinedDurationInMinutes (talk2 ))
336+ .asConstraint (THEME_TRACK_CONFLICT_SAME_DAY_TALKS );
335337 }
336338
337339 Constraint popularTalks (ConstraintFactory factory ) {
0 commit comments