Skip to content

Conversation

@ge0ffrey
Copy link
Contributor

@ge0ffrey ge0ffrey commented Jan 2, 2026

School timetabling scheduling POC benchmark of contains vs filtering
From 9236/sec to 22056/sec on only 100 entities.

Before

Constraint softTagOld(ConstraintFactory constraintFactory) {
    // A teacher prefers to teach sequential lessons and dislikes gaps between lessons.
    return constraintFactory
            .forEach(Lesson.class)
            .join(Lesson.class, Joiners.filtering((a, b) -> a.getTags().contains(b.getReqTag())))
            .reward(HardSoftScore.ONE_SOFT)
            .asConstraint("Soft tag");
}

2026-01-02 17:31:42,151 INFO Problem scale: entity count (100), variable count (200), approximate value count (31), approximate problem scale (4.065119 × 10^217).
2026-01-02 17:31:42,416 INFO Construction Heuristic phase (0) ended: time spent (267), best score (-6hard/5946soft), move evaluation speed (56818/sec), step total (100).
2026-01-02 17:32:12,154 INFO Local Search phase (1) ended: time spent (30005), best score (-4hard/5946soft), move evaluation speed (8815/sec), step total (41832).
2026-01-02 17:32:12,156 INFO Solving ended: time spent (30007), best score (-4hard/5946soft), move evaluation speed (9236/sec), phase total (2), environment mode (PHASE_ASSERT), move thread count (NONE).

After

Constraint softTagNew(ConstraintFactory constraintFactory) {
    // A teacher prefers to teach sequential lessons and dislikes gaps between lessons.
    return constraintFactory
            .forEach(Lesson.class)
            .join(Lesson.class, Joiners.contain(Lesson::getTags, Lesson::getReqTag))
            .reward(HardSoftScore.ONE_SOFT)
            .asConstraint("Soft tag");
}

2026-01-02 17:32:46,053 INFO Problem scale: entity count (100), variable count (200), approximate value count (31), approximate problem scale (4.065119 × 10^217).
2026-01-02 17:32:46,284 INFO Construction Heuristic phase (0) ended: time spent (233), best score (-6hard/5946soft), move evaluation speed (65217/sec), step total (100).
2026-01-02 17:33:16,057 INFO Local Search phase (1) ended: time spent (30006), best score (-4hard/5946soft), move evaluation speed (21727/sec), step total (103137).
2026-01-02 17:33:16,059 INFO Solving ended: time spent (30008), best score (-4hard/5946soft), move evaluation speed (22056/sec), phase total (2), environment mode (PHASE_ASSERT), move thread count (NONE).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant