Skip to content

Commit 7d918c9

Browse files
committed
chore: address comments
1 parent 68bfe48 commit 7d918c9

File tree

5 files changed

+8
-25
lines changed

5 files changed

+8
-25
lines changed

core/src/main/java/ai/timefold/solver/core/impl/exhaustivesearch/DefaultExhaustiveSearchPhase.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,6 @@ private void phaseEnded(ExhaustiveSearchPhaseScope<Solution_> phaseScope) {
113113

114114
private void stepStarted(ExhaustiveSearchStepScope<Solution_> stepScope) {
115115
super.stepStarted(stepScope);
116-
// Skip entitySelector.stepStarted(stepScope)
117116
decider.stepStarted(stepScope);
118117
}
119118

core/src/main/java/ai/timefold/solver/core/impl/exhaustivesearch/DefaultExhaustiveSearchPhaseFactory.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,6 @@ protected EntityDescriptor<Solution_> deduceEntityDescriptor(SolutionDescriptor<
162162
BestSolutionRecaller<Solution_> bestSolutionRecaller, PhaseTermination<Solution_> termination,
163163
boolean scoreBounderEnabled, boolean isListVariable) {
164164
var manualEntityMimicRecorder = new ManualEntityMimicRecorder<>(sourceEntitySelector);
165-
// TODO mimicSelectorId must be a field?
166165
var mimicSelectorId = ConfigUtils.addRandomSuffix(sourceEntitySelector.getEntityDescriptor().getEntityClass().getName(),
167166
configPolicy.getRandom());
168167
configPolicy.addEntityMimicRecorder(mimicSelectorId, manualEntityMimicRecorder);

core/src/main/java/ai/timefold/solver/core/impl/exhaustivesearch/decider/AbstractExhaustiveSearchDecider.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ private void processMoverWithoutBounder(ExhaustiveSearchStepScope<Solution_> ste
151151
if (assertMoveScoreFromScratch) {
152152
phaseScope.assertWorkingScoreFromScratch(score, moveNode.getMove());
153153
}
154-
bestSolutionRecaller.processWorkingSolutionDuringMove(score, stepScope, acceptUninitializedSolutions);
154+
bestSolutionRecaller.processWorkingSolutionDuringMove(score, stepScope);
155155
} else {
156156
phaseScope.addExpandableNode(moveNode);
157157
}
@@ -167,7 +167,7 @@ private void processMoverWithBounder(ExhaustiveSearchStepScope<Solution_> stepSc
167167
if (isSolutionComplete) {
168168
// There is no point in bounding a fully initialized score
169169
phaseScope.registerPessimisticBound(score);
170-
bestSolutionRecaller.processWorkingSolutionDuringMove(score, stepScope, acceptUninitializedSolutions);
170+
bestSolutionRecaller.processWorkingSolutionDuringMove(score, stepScope);
171171
} else {
172172
var scoreDirector = phaseScope.<Score_> getScoreDirector();
173173
var castScoreBounder = this.getScoreBounder();

core/src/main/java/ai/timefold/solver/core/impl/exhaustivesearch/decider/MixedVariableExhaustiveSearchDecider.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import ai.timefold.solver.core.impl.solver.scope.SolverScope;
99

1010
/**
11-
* Deciders for mixed models depend on the basic and list variable deciders.
11+
* Decider for mixed models depends on the basic and lists variable deciders.
1212
* The optimization process begins by solving the basic variables before moving on to the list variables.
1313
* The process optimizes each variable separately and stops when the list variable optimization is complete.
1414
*

core/src/main/java/ai/timefold/solver/core/impl/solver/recaller/BestSolutionRecaller.java

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -97,28 +97,8 @@ public <Score_ extends Score<Score_>> void processWorkingSolutionDuringStep(Abst
9797
}
9898
}
9999

100-
/**
101-
* Differs from {@link #processWorkingSolutionDuringMove(InnerScore, AbstractStepScope, boolean)}
102-
* as it does not accept partially initialized solutions.
103-
*/
104100
public <Score_ extends Score<Score_>> void processWorkingSolutionDuringMove(InnerScore<Score_> moveScore,
105101
AbstractStepScope<Solution_> stepScope) {
106-
processWorkingSolutionDuringMove(moveScore, stepScope, false);
107-
}
108-
109-
/**
110-
* The solution for mixed models can generate a partially solved solution,
111-
* as the complete solution will only be achieved when all variable types are assigned.
112-
* The method allows acceptance of partially initialized solutions
113-
* if {@code acceptUnassigned} is set to true.
114-
*
115-
* @param moveScore the move score
116-
* @param stepScope the step scope
117-
* @param acceptUnassigned flag to accept partially initialized solutions
118-
* @param <Score_> the score type
119-
*/
120-
public <Score_ extends Score<Score_>> void processWorkingSolutionDuringMove(InnerScore<Score_> moveScore,
121-
AbstractStepScope<Solution_> stepScope, boolean acceptUnassigned) {
122102
var phaseScope = stepScope.getPhaseScope();
123103
var solverScope = phaseScope.getSolverScope();
124104
var bestScoreImproved = moveScore.compareTo(solverScope.getBestScore()) > 0;
@@ -131,6 +111,11 @@ public <Score_ extends Score<Score_>> void processWorkingSolutionDuringMove(Inne
131111
phaseScope.setBestSolutionStepIndex(stepScope.getStepIndex());
132112
var newBestSolution = solverScope.getScoreDirector().cloneWorkingSolution();
133113
InnerScore<Score_> innerScore;
114+
// The solution for mixed models can generate a partially solved solution,
115+
// as the complete solution will only be achieved when all variable types are assigned.
116+
// The flag allows acceptance of partially initialized solutions for mixed models.
117+
var acceptUnassigned = stepScope.getScoreDirector().getWorkingInitScore() < 0
118+
&& stepScope.getScoreDirector().getSolutionDescriptor().hasBothBasicAndListVariables();
134119
if (acceptUnassigned) {
135120
innerScore =
136121
InnerScore.withUnassignedCount(moveScore.raw(), -stepScope.getScoreDirector().getWorkingInitScore());

0 commit comments

Comments
 (0)