TimefoldAI / TimefoldAI/timefold-solver

perf: Node unlinking in Constraint Streams when it can be determined a constraint can never fire.

Open
#1,925 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

process/needs triage
Dominant language
Java
Stars
1.8k
Forks
228
Avg merge
1d 13h
Merged PRs (30d)
46

Description

Consider the following constraint:

constraintFactory.forEach(Rule.class)
    .join(Shift.class, Joiners.equal(Shift::getRuleProperty, Rule::getProperty))
    .penalize(HardSoftScore.ONE_HARD)
    .asConstraint("Rule violated");

Assume Shift::getRuleProperty is an expensive method to evaluate.

If a problem has no Rule instances, this constraint can never fire, since one side of the join is empty.
However, Shift::getRuleProperty is pointless re-evaluated whenever a Shift changes.

If we can detect if a root node (precompute and forEach variants) is empty, we can disable all constraints (set their weight to 0) that can never fire.

When a constraint is disabled this way, it should be reported somewhere, potentially in the logs.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue names no files or tests. Start by tracing the Constraint Streams implementation for root-node emptiness and constraint weighting; done means impossible constraints stop evaluating expensive joins and the disabled constraints are reported, potentially through logs.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
backend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.