Skip to content

feat: implement direct testing of score/impact of constraints#2306

Merged
triceo merged 3 commits into
TimefoldAI:mainfrom
PatrickDiallo23:feature/score-generated-by-constraint
May 14, 2026
Merged

feat: implement direct testing of score/impact of constraints#2306
triceo merged 3 commits into
TimefoldAI:mainfrom
PatrickDiallo23:feature/score-generated-by-constraint

Conversation

@PatrickDiallo23
Copy link
Copy Markdown
Contributor

This PR is introducing the capability to get the score/impact of the constraints given a set of entities or an entire solution addressing the #2007 .

Even though it was proposed to add in ConstraintVerifier the getScore and getImpact methods, I observed that it was counterintuitive for the user to use such methods because it would change the chaining method (also making the implementation more complex than it should be) to constraintVerifier.getScore().forConstraint(constraint).given(entities).

I was thinking of providing a new chaining to obtain the score like constraintVerifier.evaluate(constraint).given(entities).score(), where evaluate() would be the same as verifyThat() resulting in duplicated code which is not a good idea.

So I used the solution provided by the author of the issue, which is the most efficient and straightforward solution that allows writing custom assertions to compare different solutions or subsets of solutions.

Copy link
Copy Markdown
Collaborator

@triceo triceo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that the solution presented here is the better of the proposals.

Let's mention this feature in the docs where we talk about constraint testing - I envision a new subsection, something to the tune to "Employing custom assertions", showing how to use this feature with AssertJ. (Much like the Javadoc snippets already do.)

@triceo triceo added this to the v2.2.0 milestone May 14, 2026
@triceo triceo changed the title feat: implement score/impact generated by a single constraint or by multi constraints feat: implement direct testing of score/impact of constraints May 14, 2026
@triceo triceo merged commit f36b713 into TimefoldAI:main May 14, 2026
20 checks passed
@triceo
Copy link
Copy Markdown
Collaborator

triceo commented May 14, 2026

Thanks, @PatrickDiallo23!

@sonarqubecloud
Copy link
Copy Markdown

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.

Constraint testing: score generated by a single contraint

2 participants