Skip to content

Commit 185e79c

Browse files
committed
chore: mixed model as preview feature
1 parent db846a8 commit 185e79c

File tree

5 files changed

+20
-7
lines changed

5 files changed

+20
-7
lines changed

benchmark/src/main/resources/benchmark.xsd

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2612,6 +2612,9 @@
26122612
<xs:enumeration value="PLANNING_SOLUTION_DIFF"/>
26132613

26142614

2615+
<xs:enumeration value="MIXED_MODEL"/>
2616+
2617+
26152618
<xs:enumeration value="MOVE_STREAMS"/>
26162619

26172620

core/src/main/java/ai/timefold/solver/core/config/solver/PreviewFeature.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ public enum PreviewFeature {
2222
DECLARATIVE_SHADOW_VARIABLES,
2323
DIVERSIFIED_LATE_ACCEPTANCE,
2424
PLANNING_SOLUTION_DIFF,
25+
MIXED_MODEL,
2526
/**
2627
* Unlike other preview features, Move Streams are an active research project.
2728
* It is intended to simplify the creation of custom moves, eventually replacing move selectors.

core/src/main/java/ai/timefold/solver/core/impl/solver/DefaultSolverFactory.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,9 @@ public <Score_ extends Score<Score_>> ScoreDirectorFactory<Solution_, Score_> ge
142142
.withSolutionDescriptor(solutionDescriptor)
143143
.withClassInstanceCache(ClassInstanceCache.create())
144144
.build();
145+
if (solutionDescriptor.hasBothBasicAndListVariables()) {
146+
configPolicy.ensurePreviewFeature(PreviewFeature.MIXED_MODEL);
147+
}
145148
var basicPlumbingTermination = new BasicPlumbingTermination<Solution_>(isDaemon);
146149
var termination = buildTermination(basicPlumbingTermination, configPolicy, configOverride);
147150
var phaseList = buildPhaseList(configPolicy, bestSolutionRecaller, termination);

core/src/main/resources/solver.xsd

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1593,6 +1593,8 @@
15931593

15941594
<xs:enumeration value="PLANNING_SOLUTION_DIFF"/>
15951595

1596+
<xs:enumeration value="MIXED_MODEL"/>
1597+
15961598
<xs:enumeration value="MOVE_STREAMS"/>
15971599

15981600
</xs:restriction>

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

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import static ai.timefold.solver.core.config.heuristic.selector.entity.EntitySorterManner.DECREASING_DIFFICULTY;
44
import static ai.timefold.solver.core.config.heuristic.selector.entity.EntitySorterManner.DECREASING_DIFFICULTY_IF_AVAILABLE;
55
import static ai.timefold.solver.core.config.solver.PreviewFeature.DECLARATIVE_SHADOW_VARIABLES;
6+
import static ai.timefold.solver.core.config.solver.PreviewFeature.MIXED_MODEL;
67
import static org.assertj.core.api.Assertions.assertThat;
78
import static org.assertj.core.api.Assertions.assertThatCode;
89
import static org.assertj.core.api.Assertions.fail;
@@ -1648,7 +1649,7 @@ void solveMixedModel() {
16481649
var solverConfig = PlannerTestUtils.buildSolverConfig(
16491650
TestdataMixedSolution.class, TestdataMixedEntity.class, TestdataMixedValue.class,
16501651
TestdataMixedOtherValue.class)
1651-
.withPreviewFeature(DECLARATIVE_SHADOW_VARIABLES)
1652+
.withPreviewFeature(DECLARATIVE_SHADOW_VARIABLES, MIXED_MODEL)
16521653
.withPhases(new ConstructionHeuristicPhaseConfig(),
16531654
new LocalSearchPhaseConfig().withTerminationConfig(new TerminationConfig().withStepCountLimit(16)))
16541655
.withEasyScoreCalculatorClass(TestdataMixedEasyScoreCalculator.class);
@@ -1690,7 +1691,7 @@ void solveMixedModelCustomMove() {
16901691
var solverConfig = PlannerTestUtils.buildSolverConfig(
16911692
TestdataMixedSolution.class, TestdataMixedEntity.class, TestdataMixedValue.class,
16921693
TestdataMixedOtherValue.class)
1693-
.withPreviewFeature(DECLARATIVE_SHADOW_VARIABLES)
1694+
.withPreviewFeature(DECLARATIVE_SHADOW_VARIABLES, MIXED_MODEL)
16941695
.withPhases(new ConstructionHeuristicPhaseConfig(),
16951696
new LocalSearchPhaseConfig()
16961697
.withMoveSelectorConfig(new MoveIteratorFactoryConfig()
@@ -1712,7 +1713,7 @@ void solveMixedModelCustomPhase() {
17121713
var solverConfig = PlannerTestUtils.buildSolverConfig(
17131714
TestdataMixedSolution.class, TestdataMixedEntity.class, TestdataMixedValue.class,
17141715
TestdataMixedOtherValue.class)
1715-
.withPreviewFeature(DECLARATIVE_SHADOW_VARIABLES)
1716+
.withPreviewFeature(DECLARATIVE_SHADOW_VARIABLES, MIXED_MODEL)
17161717
.withPhases(new ConstructionHeuristicPhaseConfig(),
17171718
new CustomPhaseConfig()
17181719
.withCustomPhaseCommands(new MixedCustomPhase())
@@ -1743,7 +1744,7 @@ void solveMixedModelWithSortManner(Pair<EntitySorterManner, ValueSorterManner> s
17431744
var solverConfig = PlannerTestUtils.buildSolverConfig(
17441745
TestdataMixedSolution.class, TestdataMixedEntity.class, TestdataMixedValue.class,
17451746
TestdataMixedOtherValue.class)
1746-
.withPreviewFeature(DECLARATIVE_SHADOW_VARIABLES)
1747+
.withPreviewFeature(DECLARATIVE_SHADOW_VARIABLES, MIXED_MODEL)
17471748
.withPhases(new ConstructionHeuristicPhaseConfig(),
17481749
new LocalSearchPhaseConfig()
17491750
.withMoveSelectorConfig(
@@ -1774,7 +1775,7 @@ void solvePinnedMixedModel() {
17741775
var solverConfig = PlannerTestUtils.buildSolverConfig(
17751776
TestdataMixedSolution.class, TestdataMixedEntity.class, TestdataMixedValue.class,
17761777
TestdataMixedOtherValue.class)
1777-
.withPreviewFeature(DECLARATIVE_SHADOW_VARIABLES)
1778+
.withPreviewFeature(DECLARATIVE_SHADOW_VARIABLES, MIXED_MODEL)
17781779
.withPhases(new ConstructionHeuristicPhaseConfig())
17791780
.withEasyScoreCalculatorClass(TestdataMixedEasyScoreCalculator.class);
17801781

@@ -1793,6 +1794,7 @@ void solvePinnedMixedModel() {
17931794
void solveUnassignedMixedModel() {
17941795
var solverConfig = PlannerTestUtils.buildSolverConfig(
17951796
TestdataUnassignedMixedSolution.class, TestdataUnassignedMixedEntity.class)
1797+
.withPreviewFeature(MIXED_MODEL)
17961798
.withPhases(new ConstructionHeuristicPhaseConfig(),
17971799
new LocalSearchPhaseConfig().withTerminationConfig(new TerminationConfig().withStepCountLimit(16)))
17981800
.withEasyScoreCalculatorClass(TestdataUnassignedMixedEasyScoreCalculator.class);
@@ -1819,6 +1821,7 @@ void solveUnassignedMixedModel() {
18191821
void solvePinnedAndUnassignedMixedModel() {
18201822
var solverConfig = PlannerTestUtils.buildSolverConfig(
18211823
TestdataUnassignedMixedSolution.class, TestdataUnassignedMixedEntity.class)
1824+
.withPreviewFeature(MIXED_MODEL)
18221825
.withPhases(new ConstructionHeuristicPhaseConfig(),
18231826
new LocalSearchPhaseConfig().withTerminationConfig(new TerminationConfig().withStepCountLimit(16)))
18241827
.withEasyScoreCalculatorClass(TestdataUnassignedMixedEasyScoreCalculator.class);
@@ -1881,7 +1884,7 @@ void solveCustomConfigMixedModel() {
18811884
var solverConfig = PlannerTestUtils.buildSolverConfig(
18821885
TestdataMixedSolution.class, TestdataMixedEntity.class, TestdataMixedValue.class,
18831886
TestdataMixedOtherValue.class)
1884-
.withPreviewFeature(DECLARATIVE_SHADOW_VARIABLES)
1887+
.withPreviewFeature(DECLARATIVE_SHADOW_VARIABLES, MIXED_MODEL)
18851888
.withPhases(new ConstructionHeuristicPhaseConfig()
18861889
.withEntityPlacerConfigList(valuePlacerConfig, entityPlacerConfig),
18871890
new LocalSearchPhaseConfig().withTerminationConfig(new TerminationConfig().withStepCountLimit(16)))
@@ -1943,7 +1946,7 @@ void solveMoveConfigMixedModel(MoveSelectorConfig moveSelectionConfig) {
19431946
var solverConfig = PlannerTestUtils.buildSolverConfig(
19441947
TestdataMixedSolution.class, TestdataMixedEntity.class, TestdataMixedValue.class,
19451948
TestdataMixedOtherValue.class)
1946-
.withPreviewFeature(DECLARATIVE_SHADOW_VARIABLES)
1949+
.withPreviewFeature(DECLARATIVE_SHADOW_VARIABLES, MIXED_MODEL)
19471950
.withPhases(new ConstructionHeuristicPhaseConfig(), localSearchConfig)
19481951
.withEasyScoreCalculatorClass(TestdataMixedEasyScoreCalculator.class);
19491952

@@ -2016,6 +2019,7 @@ void solveMultiEntityMoveConfigMixedModel(MoveSelectorConfig moveSelectionConfig
20162019
var solverConfig = PlannerTestUtils.buildSolverConfig(
20172020
TestdataMixedMultiEntitySolution.class, TestdataMixedMultiEntityFirstEntity.class,
20182021
TestdataMixedMultiEntitySecondEntity.class)
2022+
.withPreviewFeature(MIXED_MODEL)
20192023
.withPhases(constructionHeuristicConfig, localSearchConfig)
20202024
.withEasyScoreCalculatorClass(TestdataMixedEntityEasyScoreCalculator.class);
20212025

0 commit comments

Comments
 (0)