Skip to content

Commit

Permalink
chore: adapt to latest changes in the solver (#31)
Browse files Browse the repository at this point in the history
  • Loading branch information
triceo authored Nov 7, 2024
1 parent 4c75200 commit 8a162cc
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import ai.timefold.solver.core.impl.localsearch.scope.LocalSearchPhaseScope;
import ai.timefold.solver.core.impl.localsearch.scope.LocalSearchStepScope;
import ai.timefold.solver.core.impl.move.director.MoveDirector;
import ai.timefold.solver.core.impl.score.constraint.ConstraintMatchPolicy;
import ai.timefold.solver.core.impl.score.director.InnerScoreDirector;
import ai.timefold.solver.core.impl.score.director.InnerScoreDirectorFactory;
import ai.timefold.solver.core.impl.solver.DefaultSolver;
Expand Down Expand Up @@ -102,7 +103,8 @@ public final void setupTrial() {
public final void setupIteration() {
// We only care about incremental performance; therefore calculate the entire solution outside of invocation.
scoreDirector = scoreDirectorFactory.buildScoreDirector(false,
scoreDirectorType == ScoreDirectorType.CONSTRAINT_STREAMS_JUSTIFIED);
scoreDirectorType == ScoreDirectorType.CONSTRAINT_STREAMS_JUSTIFIED ? ConstraintMatchPolicy.ENABLED
: ConstraintMatchPolicy.DISABLED);
scoreDirector.setWorkingSolution(scoreDirector.cloneSolution(originalSolution)); // Use fresh solution again.
scoreDirector.triggerVariableListeners();
scoreDirector.calculateScore();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import ai.timefold.solver.core.impl.constructionheuristic.DefaultConstructionHeuristicPhaseFactory;
import ai.timefold.solver.core.impl.domain.solution.descriptor.SolutionDescriptor;
import ai.timefold.solver.core.impl.heuristic.HeuristicConfigPolicy;
import ai.timefold.solver.core.impl.score.constraint.ConstraintMatchPolicy;
import ai.timefold.solver.core.impl.score.director.InnerScoreDirectorFactory;
import ai.timefold.solver.core.impl.solver.ClassInstanceCache;
import ai.timefold.solver.core.impl.solver.DefaultSolver;
Expand Down Expand Up @@ -60,7 +61,7 @@ public static synchronized <Solution_> Solution_ getSolution(Example example,

private static <Solution_> Solution_ initialize(Example example, Solution_ uninitializedSolution,
InnerScoreDirectorFactory<Solution_, ?> scoreDirectorFactory) {
try (var scoreDirector = scoreDirectorFactory.buildScoreDirector(false, false)) {
try (var scoreDirector = scoreDirectorFactory.buildScoreDirector(false, ConstraintMatchPolicy.DISABLED)) {
scoreDirector.setWorkingSolution(uninitializedSolution);
scoreDirector.triggerVariableListeners();
var score = scoreDirector.calculateScore();
Expand Down

0 comments on commit 8a162cc

Please sign in to comment.