|
50 | 50 | import ai.timefold.solver.core.config.heuristic.selector.list.SubListSelectorConfig; |
51 | 51 | import ai.timefold.solver.core.config.heuristic.selector.move.MoveSelectorConfig; |
52 | 52 | import ai.timefold.solver.core.config.heuristic.selector.move.composite.UnionMoveSelectorConfig; |
| 53 | +import ai.timefold.solver.core.config.heuristic.selector.move.factory.MoveIteratorFactoryConfig; |
53 | 54 | import ai.timefold.solver.core.config.heuristic.selector.move.generic.ChangeMoveSelectorConfig; |
54 | 55 | import ai.timefold.solver.core.config.heuristic.selector.move.generic.PillarChangeMoveSelectorConfig; |
55 | 56 | import ai.timefold.solver.core.config.heuristic.selector.move.generic.PillarSwapMoveSelectorConfig; |
|
118 | 119 | import ai.timefold.solver.core.testdomain.mixed.multientity.TestdataMixedMultiEntityFirstEntity; |
119 | 120 | import ai.timefold.solver.core.testdomain.mixed.multientity.TestdataMixedMultiEntitySecondEntity; |
120 | 121 | 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; |
121 | 124 | import ai.timefold.solver.core.testdomain.mixed.singleentity.TestdataMixedEasyScoreCalculator; |
122 | 125 | import ai.timefold.solver.core.testdomain.mixed.singleentity.TestdataMixedEntity; |
123 | 126 | import ai.timefold.solver.core.testdomain.mixed.singleentity.TestdataMixedOtherValue; |
@@ -1682,6 +1685,49 @@ void solveMixedModel() { |
1682 | 1685 | .isTrue(); |
1683 | 1686 | } |
1684 | 1687 |
|
| 1688 | + @Test |
| 1689 | + void solveMixedModelCustomMove() { |
| 1690 | + var solverConfig = PlannerTestUtils.buildSolverConfig( |
| 1691 | + TestdataMixedSolution.class, TestdataMixedEntity.class, TestdataMixedValue.class, |
| 1692 | + TestdataMixedOtherValue.class) |
| 1693 | + .withPreviewFeature(DECLARATIVE_SHADOW_VARIABLES) |
| 1694 | + .withPhases(new ConstructionHeuristicPhaseConfig(), |
| 1695 | + new LocalSearchPhaseConfig() |
| 1696 | + .withMoveSelectorConfig(new MoveIteratorFactoryConfig() |
| 1697 | + .withMoveIteratorFactoryClass(MixedCustomBasicVariableFactory.class)) |
| 1698 | + .withTerminationConfig(new TerminationConfig().withStepCountLimit(16))) |
| 1699 | + .withEasyScoreCalculatorClass(TestdataMixedEasyScoreCalculator.class); |
| 1700 | + |
| 1701 | + var problem = TestdataMixedSolution.generateUninitializedSolution(2, 2, 2); |
| 1702 | + var solution = PlannerTestUtils.solve(solverConfig, problem); |
| 1703 | + |
| 1704 | + // Check the solution |
| 1705 | + assertThat(solution.getEntityList().stream() |
| 1706 | + .filter(e -> e.getBasicValue() == null || e.getSecondBasicValue() == null || e.getValueList().isEmpty())) |
| 1707 | + .isEmpty(); |
| 1708 | + } |
| 1709 | + |
| 1710 | + @Test |
| 1711 | + void solveMixedModelCustomPhase() { |
| 1712 | + var solverConfig = PlannerTestUtils.buildSolverConfig( |
| 1713 | + TestdataMixedSolution.class, TestdataMixedEntity.class, TestdataMixedValue.class, |
| 1714 | + TestdataMixedOtherValue.class) |
| 1715 | + .withPreviewFeature(DECLARATIVE_SHADOW_VARIABLES) |
| 1716 | + .withPhases(new ConstructionHeuristicPhaseConfig(), |
| 1717 | + new CustomPhaseConfig() |
| 1718 | + .withCustomPhaseCommands(new MixedCustomPhase()) |
| 1719 | + .withTerminationConfig(new TerminationConfig().withStepCountLimit(16))) |
| 1720 | + .withEasyScoreCalculatorClass(TestdataMixedEasyScoreCalculator.class); |
| 1721 | + |
| 1722 | + var problem = TestdataMixedSolution.generateUninitializedSolution(2, 2, 2); |
| 1723 | + var solution = PlannerTestUtils.solve(solverConfig, problem); |
| 1724 | + |
| 1725 | + // Check the solution |
| 1726 | + assertThat(solution.getEntityList().stream() |
| 1727 | + .filter(e -> e.getBasicValue() == null || e.getSecondBasicValue() == null || e.getValueList().isEmpty())) |
| 1728 | + .isEmpty(); |
| 1729 | + } |
| 1730 | + |
1685 | 1731 | private static List<Pair<EntitySorterManner, ValueSorterManner>> getSortMannerList() { |
1686 | 1732 | var sortMannerList = new ArrayList<Pair<EntitySorterManner, ValueSorterManner>>(); |
1687 | 1733 | for (var valueSortManner : ValueSorterManner.values()) { |
|
0 commit comments