Skip to content

Commit ef2e929

Browse files
committed
chore: address comments
1 parent 014d677 commit ef2e929

File tree

9 files changed

+47
-74
lines changed

9 files changed

+47
-74
lines changed

core/src/main/java/ai/timefold/solver/core/impl/constructionheuristic/placer/QueuedValuePlacer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public Iterator<Placement<Solution_>> iterator() {
3232
return new QueuedValuePlacingIterator();
3333
}
3434

35-
public boolean isListChangeMoveSelector() {
35+
public boolean hasListChangeMoveSelector() {
3636
return moveSelector instanceof ListChangeMoveSelector<Solution_>;
3737
}
3838

core/src/main/java/ai/timefold/solver/core/impl/move/PlacerBasedMoveRepository.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public boolean hasListVariable() {
8686
// However, in certain cases, such as ALLOCATE_TO_VALUE_FROM_QUEUE,
8787
// a QueuedValuePlacer can be created for a basic planning variable,
8888
// and in these cases, the move selector does not rely on a list variable.
89-
return placer instanceof QueuedValuePlacer<Solution_> queuedValuePlacer && queuedValuePlacer.isListChangeMoveSelector();
89+
return placer instanceof QueuedValuePlacer<Solution_> queuedValuePlacer && queuedValuePlacer.hasListChangeMoveSelector();
9090
}
9191

9292
}

core/src/test/java/ai/timefold/solver/core/impl/solver/DefaultSolverTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,8 @@
119119
import ai.timefold.solver.core.testdomain.mixed.multientity.TestdataMixedMultiEntityFirstEntity;
120120
import ai.timefold.solver.core.testdomain.mixed.multientity.TestdataMixedMultiEntitySecondEntity;
121121
import ai.timefold.solver.core.testdomain.mixed.multientity.TestdataMixedMultiEntitySolution;
122-
import ai.timefold.solver.core.testdomain.mixed.singleentity.MixedCustomBasicVariableFactory;
123-
import ai.timefold.solver.core.testdomain.mixed.singleentity.MixedCustomPhase;
122+
import ai.timefold.solver.core.testdomain.mixed.singleentity.MixedCustomMoveIteratorFactory;
123+
import ai.timefold.solver.core.testdomain.mixed.singleentity.MixedCustomPhaseCommand;
124124
import ai.timefold.solver.core.testdomain.mixed.singleentity.TestdataMixedEasyScoreCalculator;
125125
import ai.timefold.solver.core.testdomain.mixed.singleentity.TestdataMixedEntity;
126126
import ai.timefold.solver.core.testdomain.mixed.singleentity.TestdataMixedOtherValue;
@@ -1760,7 +1760,7 @@ void solveMixedModelCustomMove() {
17601760
.withValueSelectorConfig(new ValueSelectorConfig().withVariableName("valueList"))),
17611761
new LocalSearchPhaseConfig()
17621762
.withMoveSelectorConfig(new MoveIteratorFactoryConfig()
1763-
.withMoveIteratorFactoryClass(MixedCustomBasicVariableFactory.class))
1763+
.withMoveIteratorFactoryClass(MixedCustomMoveIteratorFactory.class))
17641764
.withTerminationConfig(new TerminationConfig().withStepCountLimit(16)))
17651765
.withEasyScoreCalculatorClass(TestdataMixedEasyScoreCalculator.class);
17661766

@@ -1783,7 +1783,7 @@ void solveMixedModelCustomPhase() {
17831783
new ConstructionHeuristicPhaseConfig().withEntityPlacerConfig(new QueuedValuePlacerConfig()
17841784
.withValueSelectorConfig(new ValueSelectorConfig().withVariableName("valueList"))),
17851785
new CustomPhaseConfig()
1786-
.withCustomPhaseCommands(new MixedCustomPhase())
1786+
.withCustomPhaseCommands(new MixedCustomPhaseCommand())
17871787
.withTerminationConfig(new TerminationConfig().withStepCountLimit(16)))
17881788
.withEasyScoreCalculatorClass(TestdataMixedEasyScoreCalculator.class);
17891789

core/src/test/java/ai/timefold/solver/core/testdomain/mixed/singleentity/MixedCustomBasicVariableFactory.java

Lines changed: 0 additions & 32 deletions
This file was deleted.

core/src/test/java/ai/timefold/solver/core/testdomain/mixed/singleentity/MixedCustomBasicVariableSwapMove.java

Lines changed: 0 additions & 31 deletions
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package ai.timefold.solver.core.testdomain.mixed.singleentity;
2+
3+
import java.util.Iterator;
4+
import java.util.Random;
5+
import java.util.stream.Stream;
6+
7+
import ai.timefold.solver.core.api.score.director.ScoreDirector;
8+
import ai.timefold.solver.core.impl.heuristic.selector.move.factory.MoveIteratorFactory;
9+
import ai.timefold.solver.core.impl.heuristic.selector.move.generic.ChangeMove;
10+
11+
public class MixedCustomMoveIteratorFactory
12+
implements MoveIteratorFactory<TestdataMixedSolution, ChangeMove<TestdataMixedSolution>> {
13+
@Override
14+
public long getSize(ScoreDirector<TestdataMixedSolution> scoreDirector) {
15+
return scoreDirector.getWorkingSolution().getEntityList().size();
16+
}
17+
18+
@Override
19+
public Iterator<ChangeMove<TestdataMixedSolution>>
20+
createOriginalMoveIterator(ScoreDirector<TestdataMixedSolution> scoreDirector) {
21+
throw new UnsupportedOperationException();
22+
}
23+
24+
@Override
25+
public Iterator<ChangeMove<TestdataMixedSolution>>
26+
createRandomMoveIterator(ScoreDirector<TestdataMixedSolution> scoreDirector, Random workingRandom) {
27+
var solutionDescriptor = TestdataMixedSolution.buildSolutionDescriptor();
28+
var variableDescriptor =
29+
solutionDescriptor.findEntityDescriptor(TestdataMixedEntity.class).getGenuineVariableDescriptor("basicValue");
30+
var move1 = new ChangeMove<>(variableDescriptor, scoreDirector.getWorkingSolution().getEntityList().get(0),
31+
scoreDirector.getWorkingSolution().getOtherValueList().get(0));
32+
var move2 = new ChangeMove<>(variableDescriptor, scoreDirector.getWorkingSolution().getEntityList().get(0),
33+
scoreDirector.getWorkingSolution().getOtherValueList().get(1));
34+
return Stream.of(move1, move2).iterator();
35+
}
36+
}

core/src/test/java/ai/timefold/solver/core/testdomain/mixed/singleentity/MixedCustomPhase.java renamed to core/src/test/java/ai/timefold/solver/core/testdomain/mixed/singleentity/MixedCustomPhaseCommand.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@
55
import ai.timefold.solver.core.api.score.director.ScoreDirector;
66
import ai.timefold.solver.core.api.solver.phase.PhaseCommand;
77

8-
public class MixedCustomPhase implements PhaseCommand<TestdataMixedSolution> {
8+
public class MixedCustomPhaseCommand implements PhaseCommand<TestdataMixedSolution> {
99

1010
@Override
1111
public void changeWorkingSolution(ScoreDirector<TestdataMixedSolution> scoreDirector, BooleanSupplier isPhaseTerminated) {
12-
var moveIteratorFactory = new MixedCustomBasicVariableFactory();
12+
var moveIteratorFactory = new MixedCustomMoveIteratorFactory();
1313
var moveIterator = moveIteratorFactory.createRandomMoveIterator(scoreDirector, null);
1414
var move = moveIterator.next();
15-
move.doMoveOnGenuineVariables(scoreDirector);
15+
move.doMoveOnly(scoreDirector);
1616
scoreDirector.triggerVariableListeners();
1717
}
1818
}

core/src/test/java/ai/timefold/solver/core/testdomain/mixed/singleentity/TestdataMixedValue.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public class TestdataMixedValue extends TestdataObject {
2525
@IndexShadowVariable(sourceVariableName = "valueList")
2626
private Integer index;
2727

28-
@ShadowVariable(variableListenerClass = TestdataMixedValueListener.class, sourceVariableName = "index")
28+
@ShadowVariable(variableListenerClass = TestdataMixedVariableListener.class, sourceVariableName = "index")
2929
private Integer shadowVariableListenerValue;
3030

3131
@CascadingUpdateShadowVariable(targetMethodName = "updateCascadingShadowValue")
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
import org.jspecify.annotations.NonNull;
77

8-
public class TestdataMixedValueListener implements VariableListener<TestdataMixedSolution, TestdataMixedValue> {
8+
public class TestdataMixedVariableListener implements VariableListener<TestdataMixedSolution, TestdataMixedValue> {
99
@Override
1010
public void beforeVariableChanged(@NonNull ScoreDirector<TestdataMixedSolution> scoreDirector,
1111
@NonNull TestdataMixedValue value) {

0 commit comments

Comments
 (0)