Skip to content

Commit 1f3302d

Browse files
committed
feat: enable HGS for basic variables
1 parent b75dc5b commit 1f3302d

39 files changed

Lines changed: 2004 additions & 224 deletions

File tree

core/src/build/revapi-differences.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,17 @@
4444
"old": "field ai.timefold.solver.core.config.heuristic.selector.move.generic.AbstractPillarMoveSelectorConfig<Config_ extends ai.timefold.solver.core.config.heuristic.selector.move.generic.AbstractPillarMoveSelectorConfig<Config_>>.subPillarSequenceComparatorClass",
4545
"new": "field ai.timefold.solver.core.config.heuristic.selector.move.generic.AbstractPillarMoveSelectorConfig<Config_ extends ai.timefold.solver.core.config.heuristic.selector.move.generic.AbstractPillarMoveSelectorConfig<Config_>>.subPillarSequenceComparatorClass",
4646
"justification": "Internal protected fields; safe."
47+
},
48+
{
49+
"ignore": true,
50+
"code": "java.annotation.attributeValueChanged",
51+
"old": "class ai.timefold.solver.core.config.phase.PhaseConfig<Config_ extends ai.timefold.solver.core.config.phase.PhaseConfig<Config_>>",
52+
"new": "class ai.timefold.solver.core.config.phase.PhaseConfig<Config_ extends ai.timefold.solver.core.config.phase.PhaseConfig<Config_>>",
53+
"annotationType": "jakarta.xml.bind.annotation.XmlSeeAlso",
54+
"attribute": "value",
55+
"oldValue": "{ai.timefold.solver.core.config.constructionheuristic.ConstructionHeuristicPhaseConfig.class, ai.timefold.solver.core.config.phase.custom.CustomPhaseConfig.class, ai.timefold.solver.core.config.exhaustivesearch.ExhaustiveSearchPhaseConfig.class, ai.timefold.solver.core.config.localsearch.LocalSearchPhaseConfig.class, ai.timefold.solver.core.config.partitionedsearch.PartitionedSearchPhaseConfig.class}",
56+
"newValue": "{ai.timefold.solver.core.config.constructionheuristic.ConstructionHeuristicPhaseConfig.class, ai.timefold.solver.core.config.phase.custom.CustomPhaseConfig.class, ai.timefold.solver.core.config.exhaustivesearch.ExhaustiveSearchPhaseConfig.class, ai.timefold.solver.core.config.localsearch.LocalSearchPhaseConfig.class, ai.timefold.solver.core.config.evolutionaryalgorithm.EvolutionaryAlgorithmPhaseConfig.class, ai.timefold.solver.core.config.partitionedsearch.PartitionedSearchPhaseConfig.class}",
57+
"justification": "Add new evolutionary config"
4758
}
4859
]
4960
}

core/src/main/java/ai/timefold/solver/core/config/evolutionaryalgorithm/EvolutionaryAlgorithmPhaseConfig.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import org.jspecify.annotations.Nullable;
1212

1313
@XmlType(propOrder = {
14+
"complexProblem",
1415
"populationConfig",
1516
"workerConfig",
1617
})
@@ -19,6 +20,9 @@ public class EvolutionaryAlgorithmPhaseConfig extends PhaseConfig<EvolutionaryAl
1920

2021
public static final String XML_ELEMENT_NAME = "evolutionaryAlgorithm";
2122

23+
@Nullable
24+
private Boolean complexProblem;
25+
2226
@Nullable
2327
private EvolutionaryPopulationConfig populationConfig = null;
2428

@@ -29,6 +33,14 @@ public class EvolutionaryAlgorithmPhaseConfig extends PhaseConfig<EvolutionaryAl
2933
// Constructors and simple getters/setters
3034
// ************************************************************************
3135

36+
public @Nullable Boolean getComplexProblem() {
37+
return complexProblem;
38+
}
39+
40+
public void setComplexProblem(@Nullable Boolean complexProblem) {
41+
this.complexProblem = complexProblem;
42+
}
43+
3244
public @Nullable EvolutionaryPopulationConfig getPopulationConfig() {
3345
return populationConfig;
3446
}
@@ -49,6 +61,11 @@ public void setWorkerConfig(@Nullable EvolutionaryWorkerConfig workerConfig) {
4961
// With methods
5062
// ************************************************************************
5163

64+
public EvolutionaryAlgorithmPhaseConfig withComplexProblem(Boolean complexProblem) {
65+
setComplexProblem(complexProblem);
66+
return this;
67+
}
68+
5269
public EvolutionaryAlgorithmPhaseConfig withPopulationConfig(EvolutionaryPopulationConfig populationConfig) {
5370
setPopulationConfig(populationConfig);
5471
return this;
@@ -62,6 +79,7 @@ public EvolutionaryAlgorithmPhaseConfig withWorkerConfig(EvolutionaryWorkerConfi
6279
@Override
6380
public EvolutionaryAlgorithmPhaseConfig inherit(EvolutionaryAlgorithmPhaseConfig inheritedConfig) {
6481
super.inherit(inheritedConfig);
82+
complexProblem = ConfigUtils.inheritOverwritableProperty(complexProblem, inheritedConfig.getComplexProblem());
6583
populationConfig = ConfigUtils.inheritConfig(populationConfig, inheritedConfig.getPopulationConfig());
6684
workerConfig =
6785
ConfigUtils.inheritConfig(workerConfig, inheritedConfig.getWorkerConfig());

core/src/main/java/ai/timefold/solver/core/config/evolutionaryalgorithm/EvolutionaryCustomPhaseConfig.java renamed to core/src/main/java/ai/timefold/solver/core/config/evolutionaryalgorithm/EvolutionaryIndividualGeneratorConfig.java

Lines changed: 47 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import jakarta.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
1010

1111
import ai.timefold.solver.core.api.solver.phase.PhaseCommand;
12+
import ai.timefold.solver.core.config.constructionheuristic.ConstructionHeuristicPhaseConfig;
1213
import ai.timefold.solver.core.config.phase.PhaseConfig;
1314
import ai.timefold.solver.core.config.util.ConfigUtils;
1415
import ai.timefold.solver.core.impl.io.jaxb.JaxbCustomPropertiesAdapter;
@@ -17,11 +18,16 @@
1718
import org.jspecify.annotations.Nullable;
1819

1920
@XmlType(propOrder = {
21+
"inheritanceRate",
2022
"customPhaseCommandClassList",
2123
"customProperties",
24+
"constructionHeuristic"
2225
})
2326
@NullMarked
24-
public class EvolutionaryCustomPhaseConfig extends PhaseConfig<EvolutionaryCustomPhaseConfig> {
27+
public class EvolutionaryIndividualGeneratorConfig extends PhaseConfig<EvolutionaryIndividualGeneratorConfig> {
28+
29+
@Nullable
30+
private Double inheritanceRate = null;
2531

2632
@XmlElement(name = "customPhaseCommandClass")
2733
@Nullable
@@ -31,10 +37,21 @@ public class EvolutionaryCustomPhaseConfig extends PhaseConfig<EvolutionaryCusto
3137
@Nullable
3238
private Map<String, String> customProperties = null;
3339

40+
@Nullable
41+
private ConstructionHeuristicPhaseConfig constructionHeuristic = null;
42+
3443
// ************************************************************************
3544
// Constructors and simple getters/setters
3645
// ************************************************************************
3746

47+
public @Nullable Double getInheritanceRate() {
48+
return inheritanceRate;
49+
}
50+
51+
public void setInheritanceRate(@Nullable Double inheritanceRate) {
52+
this.inheritanceRate = inheritanceRate;
53+
}
54+
3855
public @Nullable List<Class<? extends PhaseCommand>> getCustomPhaseCommandClassList() {
3956
return customPhaseCommandClassList;
4057
}
@@ -52,39 +69,63 @@ public void setCustomProperties(@Nullable Map<String, String> customProperties)
5269
this.customProperties = customProperties;
5370
}
5471

72+
public @Nullable ConstructionHeuristicPhaseConfig getConstructionHeuristic() {
73+
return constructionHeuristic;
74+
}
75+
76+
public void setConstructionHeuristic(@Nullable ConstructionHeuristicPhaseConfig constructionHeuristic) {
77+
this.constructionHeuristic = constructionHeuristic;
78+
}
79+
5580
// ************************************************************************
5681
// With methods
5782
// ************************************************************************
5883

59-
public EvolutionaryCustomPhaseConfig withCustomPhaseCommandClassList(
84+
public EvolutionaryIndividualGeneratorConfig withInheritanceRate(@Nullable Double inheritanceRate) {
85+
setInheritanceRate(inheritanceRate);
86+
return this;
87+
}
88+
89+
public EvolutionaryIndividualGeneratorConfig withCustomPhaseCommandClassList(
6090
List<Class<? extends PhaseCommand>> customPhaseCommandClassList) {
6191
setCustomPhaseCommandClassList(customPhaseCommandClassList);
6292
return this;
6393
}
6494

65-
public EvolutionaryCustomPhaseConfig withCustomProperties(Map<String, String> customProperties) {
95+
public EvolutionaryIndividualGeneratorConfig withCustomProperties(Map<String, String> customProperties) {
6696
setCustomProperties(customProperties);
6797
return this;
6898
}
6999

100+
public EvolutionaryIndividualGeneratorConfig
101+
withConstructionHeuristic(@Nullable ConstructionHeuristicPhaseConfig constructionHeuristic) {
102+
setConstructionHeuristic(constructionHeuristic);
103+
return this;
104+
}
105+
70106
@Override
71-
public EvolutionaryCustomPhaseConfig inherit(EvolutionaryCustomPhaseConfig inheritedConfig) {
107+
public EvolutionaryIndividualGeneratorConfig inherit(EvolutionaryIndividualGeneratorConfig inheritedConfig) {
72108
super.inherit(inheritedConfig);
109+
inheritanceRate = ConfigUtils.inheritOverwritableProperty(inheritanceRate, inheritedConfig.getInheritanceRate());
73110
customPhaseCommandClassList = ConfigUtils.inheritMergeableListProperty(customPhaseCommandClassList,
74111
inheritedConfig.getCustomPhaseCommandClassList());
75112
customProperties = ConfigUtils.inheritMergeableMapProperty(customProperties, inheritedConfig.getCustomProperties());
113+
constructionHeuristic = ConfigUtils.inheritConfig(constructionHeuristic, inheritedConfig.getConstructionHeuristic());
76114
return this;
77115
}
78116

79117
@Override
80-
public EvolutionaryCustomPhaseConfig copyConfig() {
81-
return new EvolutionaryCustomPhaseConfig().inherit(this);
118+
public EvolutionaryIndividualGeneratorConfig copyConfig() {
119+
return new EvolutionaryIndividualGeneratorConfig().inherit(this);
82120
}
83121

84122
@Override
85123
public void visitReferencedClasses(Consumer<@Nullable Class<?>> classVisitor) {
86124
if (customPhaseCommandClassList != null) {
87125
customPhaseCommandClassList.forEach(classVisitor);
88126
}
127+
if (constructionHeuristic != null) {
128+
constructionHeuristic.visitReferencedClasses(classVisitor);
129+
}
89130
}
90131
}
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
package ai.timefold.solver.core.config.evolutionaryalgorithm;
2+
3+
import java.util.function.Consumer;
4+
5+
import jakarta.xml.bind.annotation.XmlType;
6+
7+
import ai.timefold.solver.core.config.localsearch.LocalSearchPhaseConfig;
8+
import ai.timefold.solver.core.config.phase.PhaseConfig;
9+
import ai.timefold.solver.core.config.util.ConfigUtils;
10+
11+
import org.jspecify.annotations.NullMarked;
12+
import org.jspecify.annotations.Nullable;
13+
14+
@XmlType(propOrder = {
15+
"inheritanceRate",
16+
"localSearch",
17+
})
18+
@NullMarked
19+
public class EvolutionaryLocalSearchConfig extends PhaseConfig<EvolutionaryLocalSearchConfig> {
20+
21+
@Nullable
22+
private Double inheritanceRate = null;
23+
24+
@Nullable
25+
private LocalSearchPhaseConfig localSearch = null;
26+
27+
// ************************************************************************
28+
// Constructors and simple getters/setters
29+
// ************************************************************************
30+
31+
public @Nullable Double getInheritanceRate() {
32+
return inheritanceRate;
33+
}
34+
35+
public void setInheritanceRate(@Nullable Double inheritanceRate) {
36+
this.inheritanceRate = inheritanceRate;
37+
}
38+
39+
public @Nullable LocalSearchPhaseConfig getLocalSearch() {
40+
return localSearch;
41+
}
42+
43+
public void setLocalSearch(@Nullable LocalSearchPhaseConfig localSearch) {
44+
this.localSearch = localSearch;
45+
}
46+
47+
// ************************************************************************
48+
// With methods
49+
// ************************************************************************
50+
51+
public EvolutionaryLocalSearchConfig withInheritanceRate(@Nullable Double inheritanceRate) {
52+
setInheritanceRate(inheritanceRate);
53+
return this;
54+
}
55+
56+
public EvolutionaryLocalSearchConfig withLocalSearch(LocalSearchPhaseConfig localSearch) {
57+
setLocalSearch(localSearch);
58+
return this;
59+
}
60+
61+
@Override
62+
public EvolutionaryLocalSearchConfig inherit(EvolutionaryLocalSearchConfig inheritedConfig) {
63+
super.inherit(inheritedConfig);
64+
inheritanceRate = ConfigUtils.inheritOverwritableProperty(inheritanceRate, inheritedConfig.getInheritanceRate());
65+
localSearch = ConfigUtils.inheritConfig(localSearch, inheritedConfig.getLocalSearch());
66+
return this;
67+
}
68+
69+
@Override
70+
public EvolutionaryLocalSearchConfig copyConfig() {
71+
return new EvolutionaryLocalSearchConfig().inherit(this);
72+
}
73+
74+
@Override
75+
public void visitReferencedClasses(Consumer<@Nullable Class<?>> classVisitor) {
76+
if (localSearch != null) {
77+
localSearch.visitReferencedClasses(classVisitor);
78+
}
79+
}
80+
}

core/src/main/java/ai/timefold/solver/core/config/evolutionaryalgorithm/EvolutionaryWorkerConfig.java

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4,67 +4,66 @@
44

55
import jakarta.xml.bind.annotation.XmlType;
66

7-
import ai.timefold.solver.core.config.localsearch.LocalSearchPhaseConfig;
87
import ai.timefold.solver.core.config.phase.PhaseConfig;
98
import ai.timefold.solver.core.config.util.ConfigUtils;
109

1110
import org.jspecify.annotations.NullMarked;
1211
import org.jspecify.annotations.Nullable;
1312

1413
@XmlType(propOrder = {
15-
"customIndividualPhaseConfig",
16-
"localSearchPhaseConfig",
14+
"individualGeneratorConfig",
15+
"localSearchConfig",
1716
})
1817
@NullMarked
1918
public class EvolutionaryWorkerConfig extends PhaseConfig<EvolutionaryWorkerConfig> {
2019

2120
@Nullable
22-
private EvolutionaryCustomPhaseConfig customIndividualPhaseConfig = null;
21+
private EvolutionaryIndividualGeneratorConfig individualGeneratorConfig = null;
2322

2423
@Nullable
25-
private LocalSearchPhaseConfig localSearchPhaseConfig = null;
24+
private EvolutionaryLocalSearchConfig localSearchConfig = null;
2625

2726
// ************************************************************************
2827
// Constructors and simple getters/setters
2928
// ************************************************************************
3029

31-
public @Nullable EvolutionaryCustomPhaseConfig getCustomIndividualPhaseConfig() {
32-
return customIndividualPhaseConfig;
30+
public @Nullable EvolutionaryIndividualGeneratorConfig getIndividualGeneratorConfig() {
31+
return individualGeneratorConfig;
3332
}
3433

35-
public void setCustomIndividualPhaseConfig(@Nullable EvolutionaryCustomPhaseConfig customIndividualPhaseConfig) {
36-
this.customIndividualPhaseConfig = customIndividualPhaseConfig;
34+
public void setIndividualGeneratorConfig(@Nullable EvolutionaryIndividualGeneratorConfig individualGeneratorConfig) {
35+
this.individualGeneratorConfig = individualGeneratorConfig;
3736
}
3837

39-
public @Nullable LocalSearchPhaseConfig getLocalSearchPhaseConfig() {
40-
return localSearchPhaseConfig;
38+
public @Nullable EvolutionaryLocalSearchConfig getLocalSearchConfig() {
39+
return localSearchConfig;
4140
}
4241

43-
public void setLocalSearchPhaseConfig(@Nullable LocalSearchPhaseConfig localSearchPhaseConfig) {
44-
this.localSearchPhaseConfig = localSearchPhaseConfig;
42+
public void setLocalSearchConfig(@Nullable EvolutionaryLocalSearchConfig localSearchConfig) {
43+
this.localSearchConfig = localSearchConfig;
4544
}
4645

4746
// ************************************************************************
4847
// With methods
4948
// ************************************************************************
5049

5150
public EvolutionaryWorkerConfig
52-
withCustomIndividualPhaseConfig(EvolutionaryCustomPhaseConfig customIndividualPhaseConfig) {
53-
setCustomIndividualPhaseConfig(customIndividualPhaseConfig);
51+
withIndividualGeneratorConfig(EvolutionaryIndividualGeneratorConfig individualGeneratorConfig) {
52+
setIndividualGeneratorConfig(individualGeneratorConfig);
5453
return this;
5554
}
5655

57-
public EvolutionaryWorkerConfig withLocalSearchPhaseConfig(LocalSearchPhaseConfig localSearchPhaseConfig) {
58-
setLocalSearchPhaseConfig(localSearchPhaseConfig);
56+
public EvolutionaryWorkerConfig withLocalSearchConfig(EvolutionaryLocalSearchConfig localSearchConfig) {
57+
setLocalSearchConfig(localSearchConfig);
5958
return this;
6059
}
6160

6261
@Override
6362
public EvolutionaryWorkerConfig inherit(EvolutionaryWorkerConfig inheritedConfig) {
6463
super.inherit(inheritedConfig);
65-
customIndividualPhaseConfig =
66-
ConfigUtils.inheritConfig(customIndividualPhaseConfig, inheritedConfig.getCustomIndividualPhaseConfig());
67-
localSearchPhaseConfig = ConfigUtils.inheritConfig(localSearchPhaseConfig, inheritedConfig.getLocalSearchPhaseConfig());
64+
individualGeneratorConfig =
65+
ConfigUtils.inheritConfig(individualGeneratorConfig, inheritedConfig.getIndividualGeneratorConfig());
66+
localSearchConfig = ConfigUtils.inheritConfig(localSearchConfig, inheritedConfig.getLocalSearchConfig());
6867
return this;
6968
}
7069

@@ -75,11 +74,11 @@ public EvolutionaryWorkerConfig copyConfig() {
7574

7675
@Override
7776
public void visitReferencedClasses(Consumer<@Nullable Class<?>> classVisitor) {
78-
if (customIndividualPhaseConfig != null) {
79-
customIndividualPhaseConfig.visitReferencedClasses(classVisitor);
77+
if (individualGeneratorConfig != null) {
78+
individualGeneratorConfig.visitReferencedClasses(classVisitor);
8079
}
81-
if (localSearchPhaseConfig != null) {
82-
localSearchPhaseConfig.visitReferencedClasses(classVisitor);
80+
if (localSearchConfig != null) {
81+
localSearchConfig.visitReferencedClasses(classVisitor);
8382
}
8483
}
8584
}

0 commit comments

Comments
 (0)