File tree Expand file tree Collapse file tree 3 files changed +35
-1
lines changed
main/java/ai/timefold/solver/core/impl/localsearch
test/java/ai/timefold/solver/core/impl Expand file tree Collapse file tree 3 files changed +35
-1
lines changed Original file line number Diff line number Diff line change @@ -219,7 +219,7 @@ private UnionMoveSelectorConfig determineDefaultMoveSelectorConfig(HeuristicConf
219219 .withMoveSelectors (new ListChangeMoveSelectorConfig (), new ListSwapMoveSelectorConfig (),
220220 new KOptListMoveSelectorConfig ());
221221 } else if (listVariableDescriptor == null ) { // We only have basic variables.
222- if (hasChainedVariable ) {
222+ if (hasChainedVariable && basicVariableDescriptorList . size () == 1 ) {
223223 return new UnionMoveSelectorConfig ()
224224 .withMoveSelectors (new ChangeMoveSelectorConfig (), new SwapMoveSelectorConfig (),
225225 new TailChainSwapMoveSelectorConfig ());
Original file line number Diff line number Diff line change 1414import ai .timefold .solver .core .impl .testdata .domain .TestdataEntity ;
1515import ai .timefold .solver .core .impl .testdata .domain .TestdataSolution ;
1616import ai .timefold .solver .core .impl .testdata .domain .TestdataValue ;
17+ import ai .timefold .solver .core .impl .testdata .domain .chained .TestdataChainedEntity ;
18+ import ai .timefold .solver .core .impl .testdata .domain .chained .TestdataChainedSolution ;
1719import ai .timefold .solver .core .impl .testdata .domain .list .TestdataListEntity ;
1820import ai .timefold .solver .core .impl .testdata .domain .list .TestdataListSolution ;
1921import ai .timefold .solver .core .impl .testdata .domain .list .TestdataListValue ;
@@ -244,6 +246,16 @@ void solveListVariable() {
244246 assertThat (solution ).isNotNull ();
245247 }
246248
249+ @ Test
250+ void solveMultiVarChainedVariable () {
251+ var solverConfig = PlannerTestUtils .buildSolverConfig (TestdataChainedSolution .class , TestdataChainedEntity .class );
252+
253+ var solution = TestdataChainedSolution .generateUninitializedSolution (6 , 2 );
254+
255+ solution = PlannerTestUtils .solve (solverConfig , solution );
256+ assertThat (solution ).isNotNull ();
257+ }
258+
247259 @ Test
248260 void solveListVariableWithExternalizedInverseAndIndexSupplies () {
249261 var solverConfig = PlannerTestUtils .buildSolverConfig (
Original file line number Diff line number Diff line change 11package ai .timefold .solver .core .impl .testdata .domain .chained ;
22
33import java .util .List ;
4+ import java .util .stream .IntStream ;
45
56import ai .timefold .solver .core .api .domain .solution .PlanningEntityCollectionProperty ;
67import ai .timefold .solver .core .api .domain .solution .PlanningScore ;
@@ -74,4 +75,25 @@ public void setScore(SimpleScore score) {
7475 // Complex methods
7576 // ************************************************************************
7677
78+ public static TestdataChainedSolution generateUninitializedSolution (int valueCount , int entityCount ) {
79+ return generateSolution (valueCount , entityCount );
80+ }
81+
82+ private static TestdataChainedSolution generateSolution (int valueCount , int entityCount ) {
83+ List <TestdataChainedEntity > entityList = IntStream .range (0 , entityCount )
84+ .mapToObj (i -> new TestdataChainedEntity ("Generated Entity " + i ))
85+ .toList ();
86+ List <TestdataChainedAnchor > anchorList = IntStream .range (0 , entityCount )
87+ .mapToObj (i -> new TestdataChainedAnchor ("Generated Anchor " + i ))
88+ .toList ();
89+ List <TestdataValue > valueList = IntStream .range (0 , valueCount )
90+ .mapToObj (i -> new TestdataValue ("Generated Value " + i ))
91+ .toList ();
92+ TestdataChainedSolution solution = new TestdataChainedSolution ();
93+ solution .setChainedEntityList (entityList );
94+ solution .setChainedAnchorList (anchorList );
95+ solution .setUnchainedValueList (valueList );
96+ return solution ;
97+ }
98+
7799}
You can’t perform that action at this time.
0 commit comments