-
Notifications
You must be signed in to change notification settings - Fork 229
chore: add indictment support to Bavet's Node Network #2528
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Christopher-Chianelli
wants to merge
30
commits into
TimefoldAI:main
Choose a base branch
from
Christopher-Chianelli:feat/729
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
8351135
feat: add plumbing for indictment support
Christopher-Chianelli 8a54863
chore: remove creating a new tuple for `ifExists` indictments
Christopher-Chianelli c0f24dd
chore: use a Map to store extra indicted objects from ifExists
Christopher-Chianelli dcc45cf
chore: make UniConstraintStream tests aware of indictments
Christopher-Chianelli 271cdf1
fix: remove old indicted objects from original group in GroupNode
Christopher-Chianelli 2cf2be9
chore: move indictment code for IfExists to IndictmentSource
Christopher-Chianelli 46d3960
chore: track support in indictment, not tuple
Christopher-Chianelli 244462c
chore: make getIndictedObjects() return null when indictments disable…
Christopher-Chianelli 3864218
test: add tests for BiConstraintStream indictments
Christopher-Chianelli fedde0d
test: make TriConstraintStream tests indictment aware
Christopher-Chianelli 46bb0f4
test: Make BavetQuadConstraintStreamTest aware of indictments
Christopher-Chianelli b68f7af
test: make AdvanceGroupByTest aware of indictments
Christopher-Chianelli 0ef72f7
test: make BavetRegressionTest aware of indictments
Christopher-Chianelli 9a07e31
fix: Propagate updates to indictments in ifExists even if left side d…
Christopher-Chianelli e4f096f
fix: update left indicted set even if its key not changed for indexed…
Christopher-Chianelli 7a85df1
test: make TriPrecompute test indictment aware
Christopher-Chianelli ddcaefb
test: make QuadPrecompute tests indictment aware
Christopher-Chianelli 0381238
chore: merge fixes
Christopher-Chianelli 235c351
chore: review comments
Christopher-Chianelli 2759a79
chore: merge fixes
Christopher-Chianelli 5333b08
chore: add preview feature to enable solving with indictments enabled
Christopher-Chianelli ec29271
chore: make regression tests aware of indictments
Christopher-Chianelli d5c7f93
chore: add IndictmentAnalysis API to ScoreAnalysis
Christopher-Chianelli 4a13b29
chore: remove ConstraintMatchPolicy changes
Christopher-Chianelli 835d50d
chore: update revapi
Christopher-Chianelli 01695d0
chore: review comments
Christopher-Chianelli 69ed896
chore: move to new API
Christopher-Chianelli 03ca38f
chore: review comments
Christopher-Chianelli c542057
docs: fix Javadocs
Christopher-Chianelli 5263dcb
docs: add indictments to docs
Christopher-Chianelli File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
core/src/main/java/ai/timefold/solver/core/api/score/analysis/Indictable.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| package ai.timefold.solver.core.api.score.analysis; | ||
|
|
||
| import org.jspecify.annotations.NullMarked; | ||
|
|
||
| /** | ||
| * An optional interface a class can implement to customize how it appears | ||
| * when indicted in a {@link ScoreAnalysis}. | ||
| * <p> | ||
| * When not implemented, the class' canonical name is used as the key in {@link ScoreAnalysis#indictmentMap()}} | ||
| * and {@link IndictmentAnalysis#indictee()} is the same instance. | ||
| * <p> | ||
| * The primary use case for implementing {@link Indictable} is if you have a separate | ||
| * solver and rest model, and don't want to expose your solver types in your REST API. | ||
| * <p> | ||
| * Note: {@link ScoreAnalysis} in general and indictments in particular | ||
| * are exclusive to Timefold Solver Enterprise Edition. | ||
| */ | ||
| @NullMarked | ||
| public interface Indictable { | ||
|
|
||
| /** | ||
| * Returns the indictment class id used by {@link ScoreAnalysis#indictmentMap()} | ||
| * when a class does not implement {@link Indictable}. | ||
| * | ||
| * @param clazz The type of class | ||
| * @return the key into {@link ScoreAnalysis#indictmentMap()} to get indicted objects of that type | ||
| */ | ||
| static String getIndictmentClassId(Class<?> clazz) { | ||
| if (Indictable.class.isAssignableFrom(clazz)) { | ||
| throw new IllegalArgumentException(""" | ||
| The class (%s) implements %s so its indictment map key cannot be determined statically. | ||
| Maybe check (%s) implementation of getIndictmentClassId()?""".formatted(clazz.getCanonicalName(), | ||
| Indictable.class.getSimpleName(), clazz.getCanonicalName())); | ||
| } | ||
| return clazz.getCanonicalName(); | ||
| } | ||
|
|
||
| /** | ||
| * An identifier that uniquely identifies the type returned by | ||
| * {@link #getIndictedObject()}. | ||
| * | ||
| * @return a string that can be used to identify the class of {@link #getIndictedObject()} | ||
| */ | ||
| String getIndictmentClassId(); | ||
|
|
||
| /** | ||
| * Optional method. It is used to calculate the {@link IndictmentAnalysis#indictee()} | ||
| * when this object is indicted. If not implemented, it will return this object. | ||
| * | ||
| * @return the object that {@link IndictmentAnalysis#indictee()} should return | ||
| */ | ||
| default Object getIndictedObject() { | ||
| return this; | ||
| } | ||
| } | ||
37 changes: 37 additions & 0 deletions
37
core/src/main/java/ai/timefold/solver/core/api/score/analysis/IndictmentAnalysis.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| package ai.timefold.solver.core.api.score.analysis; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| import ai.timefold.solver.core.api.score.Score; | ||
|
|
||
| /** | ||
| * Note: {@link ScoreAnalysis} is exclusive to Timefold Solver Enterprise Edition. | ||
| * | ||
| * @param <Score_> | ||
| * @see ScoreAnalysis Description of score analysis and the purpose of this class. | ||
| */ | ||
| public interface IndictmentAnalysis<Score_ extends Score<Score_>> { | ||
|
Christopher-Chianelli marked this conversation as resolved.
|
||
| /** | ||
| * The object that was indicted by constraints. | ||
| * Its type corresponds to the containing entry's key in {@link ScoreAnalysis#indictmentMap()}. | ||
| * | ||
| * @return the indicted object | ||
| */ | ||
| Object indictee(); | ||
|
triceo marked this conversation as resolved.
|
||
|
|
||
| /** | ||
| * The sum of score impacts of each constraint match the {@link #indictee()} | ||
| * is involved with. | ||
| * | ||
| * @return the total score impact of the indicted object | ||
| */ | ||
| Score_ score(); | ||
|
|
||
| /** | ||
| * A list of {@link MatchAnalysis} for each constraint match the | ||
| * {@link #indictee()} is involved with, sorted by absolute score impact | ||
| * | ||
| * @return a list of matches the indictee is involved with, sorted by absolute score impact | ||
| */ | ||
| List<MatchAnalysis<Score_>> matches(); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.