-
Notifications
You must be signed in to change notification settings - Fork 210
fix: Update looped status of entity even if no variables changed #1616
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
Merged
Merged
Changes from all commits
Commits
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
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
47 changes: 47 additions & 0 deletions
47
core/src/test/java/ai/timefold/solver/core/impl/solver/MoveAssertScoreDirector.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,47 @@ | ||
| package ai.timefold.solver.core.impl.solver; | ||
|
|
||
| import java.util.Map; | ||
|
|
||
| import ai.timefold.solver.core.api.score.Score; | ||
| import ai.timefold.solver.core.api.score.constraint.ConstraintMatchTotal; | ||
| import ai.timefold.solver.core.api.score.constraint.Indictment; | ||
| import ai.timefold.solver.core.impl.score.constraint.ConstraintMatchPolicy; | ||
| import ai.timefold.solver.core.impl.score.director.AbstractScoreDirector; | ||
| import ai.timefold.solver.core.impl.score.director.InnerScore; | ||
|
|
||
| public class MoveAssertScoreDirector<Solution_, Score_ extends Score<Score_>> | ||
| extends AbstractScoreDirector<Solution_, Score_, MoveAssertScoreDirectorFactory<Solution_, Score_>> { | ||
|
|
||
| protected MoveAssertScoreDirector(MoveAssertScoreDirectorFactory<Solution_, Score_> scoreDirectorFactory, | ||
| boolean lookUpEnabled, | ||
| ConstraintMatchPolicy constraintMatchPolicy, | ||
| boolean expectShadowVariablesInCorrectState) { | ||
| super(scoreDirectorFactory, lookUpEnabled, constraintMatchPolicy, expectShadowVariablesInCorrectState); | ||
| } | ||
|
|
||
| @Override | ||
| public void setWorkingSolution(Solution_ workingSolution) { | ||
| super.setWorkingSolution(workingSolution, ignored -> { | ||
| }); | ||
| } | ||
|
|
||
| @Override | ||
| public InnerScore<Score_> calculateScore() { | ||
| return InnerScore.fullyAssigned(scoreDirectorFactory.getScoreDefinition().getZeroScore()); | ||
| } | ||
|
|
||
| @Override | ||
| public Map<String, ConstraintMatchTotal<Score_>> getConstraintMatchTotalMap() { | ||
| return Map.of(); | ||
| } | ||
|
|
||
| @Override | ||
| public Map<Object, Indictment<Score_>> getIndictmentMap() { | ||
| return Map.of(); | ||
| } | ||
|
|
||
| @Override | ||
| public boolean requiresFlushing() { | ||
| return false; | ||
| } | ||
| } |
38 changes: 38 additions & 0 deletions
38
core/src/test/java/ai/timefold/solver/core/impl/solver/MoveAssertScoreDirectorFactory.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,38 @@ | ||
| package ai.timefold.solver.core.impl.solver; | ||
|
|
||
| import ai.timefold.solver.core.api.score.Score; | ||
| import ai.timefold.solver.core.impl.domain.solution.descriptor.SolutionDescriptor; | ||
| import ai.timefold.solver.core.impl.score.director.AbstractScoreDirector; | ||
| import ai.timefold.solver.core.impl.score.director.AbstractScoreDirectorFactory; | ||
|
|
||
| import org.jspecify.annotations.NullMarked; | ||
|
|
||
| @NullMarked | ||
| public class MoveAssertScoreDirectorFactory<Solution_, Score_ extends Score<Score_>> | ||
| extends AbstractScoreDirectorFactory<Solution_, Score_, MoveAssertScoreDirectorFactory<Solution_, Score_>> { | ||
| public MoveAssertScoreDirectorFactory( | ||
| SolutionDescriptor<Solution_> solutionDescriptor) { | ||
| super(solutionDescriptor); | ||
| } | ||
|
|
||
| @Override | ||
| public AbstractScoreDirector.AbstractScoreDirectorBuilder<Solution_, Score_, ?, ?> createScoreDirectorBuilder() { | ||
| return new MoveAssertScoreDirectorBuilder(this); | ||
| } | ||
|
|
||
| public class MoveAssertScoreDirectorBuilder extends | ||
| AbstractScoreDirector.AbstractScoreDirectorBuilder<Solution_, Score_, MoveAssertScoreDirectorFactory<Solution_, Score_>, MoveAssertScoreDirectorBuilder> { | ||
|
|
||
| protected MoveAssertScoreDirectorBuilder(MoveAssertScoreDirectorFactory<Solution_, Score_> scoreDirectorFactory) { | ||
| super(scoreDirectorFactory); | ||
| } | ||
|
|
||
| @Override | ||
| public MoveAssertScoreDirector<Solution_, Score_> build() { | ||
| return new MoveAssertScoreDirector<>(scoreDirectorFactory, | ||
| lookUpEnabled, | ||
| constraintMatchPolicy, | ||
| expectShadowVariablesInCorrectState); | ||
| } | ||
| } | ||
| } |
37 changes: 37 additions & 0 deletions
37
core/src/test/java/ai/timefold/solver/core/impl/solver/MoveAsserter.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.impl.solver; | ||
|
|
||
| import ai.timefold.solver.core.api.score.Score; | ||
| import ai.timefold.solver.core.impl.domain.solution.descriptor.SolutionDescriptor; | ||
| import ai.timefold.solver.core.impl.score.director.InnerScore; | ||
| import ai.timefold.solver.core.preview.api.move.Move; | ||
|
|
||
| public class MoveAsserter<Solution_> { | ||
| private final SolutionDescriptor<Solution_> solutionDescriptor; | ||
|
|
||
| private MoveAsserter(SolutionDescriptor<Solution_> solutionDescriptor) { | ||
| this.solutionDescriptor = solutionDescriptor; | ||
| } | ||
|
|
||
| public static <Solution_> MoveAsserter<Solution_> create(SolutionDescriptor<Solution_> solutionDescriptor) { | ||
| return new MoveAsserter<>(solutionDescriptor); | ||
| } | ||
|
|
||
| public void assertMove(Solution_ solution, Move<Solution_> move) { | ||
| var scoreDirectorFactory = new MoveAssertScoreDirectorFactory<>(solutionDescriptor); | ||
| scoreDirectorFactory.setTrackingWorkingSolution(true); | ||
| try (var scoreDirector = scoreDirectorFactory.createScoreDirectorBuilder() | ||
| .withLookUpEnabled(false) | ||
| .buildDerived()) { | ||
| var innerScore = InnerScore.fullyAssigned((Score) scoreDirector.getScoreDefinition().getZeroScore()); | ||
| scoreDirector.setWorkingSolution(solution); | ||
| scoreDirector.executeTemporaryMove(move, true); | ||
| var corruptionResult = scoreDirector.getSolutionCorruptionAfterUndo(move, innerScore); | ||
| if (corruptionResult.isCorrupted()) { | ||
| throw new AssertionError(""" | ||
| Solution corruption caused by move (%s) or its undo. | ||
| Analysis: | ||
| %s""".formatted(move, corruptionResult.message())); | ||
| } | ||
| } | ||
| } | ||
| } |
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.
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.