repo_name stringlengths 1 62 | dataset stringclasses 1
value | lang stringclasses 11
values | pr_id int64 1 20.1k | owner stringlengths 2 34 | reviewer stringlengths 2 39 | diff_hunk stringlengths 15 262k | code_review_comment stringlengths 1 99.6k |
|---|---|---|---|---|---|---|---|
timefold-solver | github_2023 | java | 564 | TimefoldAI | triceo | @@ -0,0 +1,69 @@
+package ai.timefold.solver.quarkus.rest;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+import ai.timefold.solver.quarkus.testdata.normal.constraints.TestdataQuarkusConstraintProvider;
+import ai.timefold.solver.quarkus.testdata.normal.domain.TestdataQuarkusEntity;
+import ai.timef... | No need to be so verbose. Enough to say that removing public will cause an exception. If someone decides to try even though they've been warned, they'll find out what exception it is. :-) |
timefold-solver | github_2023 | java | 564 | TimefoldAI | triceo | @@ -1,21 +1,32 @@
package ai.timefold.solver.quarkus.rest;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
import ai.timefold.solver.quarkus.testdata.normal.constraints.TestdataQuarkusConstraintProvider;
import ai.timefold.solver.quarkus.testdata.normal.domain.TestdataQuarkusEntity;
import ai.time... | Dtto. I'm even considering if we need to warn about this at all; we typically don't. |
timefold-solver | github_2023 | java | 564 | TimefoldAI | triceo | @@ -0,0 +1,111 @@
+package ai.timefold.solver.quarkus.it.devui;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+import java.util.List;
+
+import jakarta.inject.Inject;
+import jakarta.inject.Named;
+import jakarta.ws.rs.Path;
+
+import ai.timefold.solver.core.api.solver.SolverManager;
+import ai.timefol... | For sake of simplicity, I'd refactor this to avoid the lambda.
Make the assertions be inside a method, have the string as an argument to the method, call the method twice.
The stack trace in case of a failure will be nicer, and more self-explanatory. |
timefold-solver | github_2023 | java | 564 | TimefoldAI | triceo | @@ -0,0 +1,111 @@
+package ai.timefold.solver.quarkus.it.devui;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+import java.util.List;
+
+import jakarta.inject.Inject;
+import jakarta.inject.Named;
+import jakarta.ws.rs.Path;
+
+import ai.timefold.solver.core.api.solver.SolverManager;
+import ai.timefol... | Dtto. |
timefold-solver | github_2023 | java | 564 | TimefoldAI | triceo | @@ -27,11 +28,11 @@ public class TimefoldProcessorHotReloadTest {
@Test
void solverConfigHotReload() { | This test (and its `MultipleSolvers` counterpart) seems to throw a lot of exceptions into the sysout, even though it is passing. Let's fix that. |
timefold-solver | github_2023 | java | 564 | TimefoldAI | triceo | @@ -229,18 +230,27 @@ SolverConfigBuildItem recordAndRegisterBuildTimeBeans(CombinedIndexBuildItem com
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
Map<String, SolverConfig> allSolverConfig = new HashMap<>(); | According to the convention, this would be a `solverConfigMap`. |
timefold-solver | github_2023 | java | 564 | TimefoldAI | triceo | @@ -268,9 +278,79 @@ SolverConfigBuildItem recordAndRegisterBuildTimeBeans(CombinedIndexBuildItem com
return new SolverConfigBuildItem(allSolverConfig, generatedGizmoClasses);
}
- private SolverConfig generateSolverConfig(ClassLoader classLoader, IndexView indexView,
- BuildProducer<Reflec... | `solverConfigWithoutSolutionClassList` |
timefold-solver | github_2023 | java | 564 | TimefoldAI | triceo | @@ -268,9 +278,79 @@ SolverConfigBuildItem recordAndRegisterBuildTimeBeans(CombinedIndexBuildItem com
return new SolverConfigBuildItem(allSolverConfig, generatedGizmoClasses);
}
- private SolverConfig generateSolverConfig(ClassLoader classLoader, IndexView indexView,
- BuildProducer<Reflec... | `solverConfigWithUnusedSolutionClassList` |
timefold-solver | github_2023 | java | 564 | TimefoldAI | triceo | @@ -268,9 +278,79 @@ SolverConfigBuildItem recordAndRegisterBuildTimeBeans(CombinedIndexBuildItem com
return new SolverConfigBuildItem(allSolverConfig, generatedGizmoClasses);
}
- private SolverConfig generateSolverConfig(ClassLoader classLoader, IndexView indexView,
- BuildProducer<Reflec... | What is a target? Nothing in the solver is called a target. The exception should not mention a "target" because the user does not know what that is. |
timefold-solver | github_2023 | java | 564 | TimefoldAI | triceo | @@ -268,9 +278,79 @@ SolverConfigBuildItem recordAndRegisterBuildTimeBeans(CombinedIndexBuildItem com
return new SolverConfigBuildItem(allSolverConfig, generatedGizmoClasses);
}
- private SolverConfig generateSolverConfig(ClassLoader classLoader, IndexView indexView,
- BuildProducer<Reflec... | I'd rephrase the first sentence. "Some solver configs (...) don't specify a @PlanningSolution class, yet there are multiple available (...) on the classpath." |
timefold-solver | github_2023 | java | 564 | TimefoldAI | triceo | @@ -268,9 +278,79 @@ SolverConfigBuildItem recordAndRegisterBuildTimeBeans(CombinedIndexBuildItem com
return new SolverConfigBuildItem(allSolverConfig, generatedGizmoClasses);
}
- private SolverConfig generateSolverConfig(ClassLoader classLoader, IndexView indexView,
- BuildProducer<Reflec... | Targets again. |
timefold-solver | github_2023 | java | 564 | TimefoldAI | triceo | @@ -121,10 +127,17 @@ private static void registerSpi(Class<?> serviceClass, BuildProducer<ServiceProv
}
@BuildStep
- HotDeploymentWatchedFileBuildItem watchSolverConfigXml() {
- String solverConfigXML = timefoldBuildTimeConfig.solverConfigXml
+ void watchSolverConfigXml(BuildProducer<HotDeploy... | Please be consistent; `solverCongigXmlFileSet`. |
timefold-solver | github_2023 | java | 564 | TimefoldAI | triceo | @@ -225,29 +218,330 @@ SolverConfigBuildItem recordAndRegisterBeans(TimefoldRecorder recorder, Recorder
+ "application.properties entries (quarkus.index-dependency.<name>.group-id"
+ " and quarkus.index-dependency.<name>.artifact-id).");
additionalBeans.produce(new... | `solverConfigMap` |
timefold-solver | github_2023 | java | 564 | TimefoldAI | triceo | @@ -225,29 +218,330 @@ SolverConfigBuildItem recordAndRegisterBeans(TimefoldRecorder recorder, Recorder
+ "application.properties entries (quarkus.index-dependency.<name>.group-id"
+ " and quarkus.index-dependency.<name>.artifact-id).");
additionalBeans.produce(new... | Since we started using the raw strings with `%s` patterns, please apply it here as well - the new code needs to be consistent. Over time, the old pattern will be replaced entirely, as we touch more and more of the old code. |
timefold-solver | github_2023 | java | 564 | TimefoldAI | triceo | @@ -225,29 +218,330 @@ SolverConfigBuildItem recordAndRegisterBeans(TimefoldRecorder recorder, Recorder
+ "application.properties entries (quarkus.index-dependency.<name>.group-id"
+ " and quarkus.index-dependency.<name>.artifact-id).");
additionalBeans.produce(new... | And here as well. |
timefold-solver | github_2023 | java | 564 | TimefoldAI | triceo | @@ -225,29 +218,330 @@ SolverConfigBuildItem recordAndRegisterBeans(TimefoldRecorder recorder, Recorder
+ "application.properties entries (quarkus.index-dependency.<name>.group-id"
+ " and quarkus.index-dependency.<name>.artifact-id).");
additionalBeans.produce(new... | ```suggestion
or remove the unnecessary solution classes from the classpath."""
```
Be mindful that, if the `"""` is on a new line, the exception message will include an empty line. You don't want that. |
timefold-solver | github_2023 | java | 564 | TimefoldAI | triceo | @@ -225,29 +218,330 @@ SolverConfigBuildItem recordAndRegisterBeans(TimefoldRecorder recorder, Recorder
+ "application.properties entries (quarkus.index-dependency.<name>.group-id"
+ " and quarkus.index-dependency.<name>.artifact-id).");
additionalBeans.produce(new... | `unusedSolutionClassNameSet`. |
timefold-solver | github_2023 | java | 564 | TimefoldAI | triceo | @@ -225,29 +218,330 @@ SolverConfigBuildItem recordAndRegisterBeans(TimefoldRecorder recorder, Recorder
+ "application.properties entries (quarkus.index-dependency.<name>.group-id"
+ " and quarkus.index-dependency.<name>.artifact-id).");
additionalBeans.produce(new... | Another newline at the end. |
timefold-solver | github_2023 | java | 564 | TimefoldAI | triceo | @@ -563,40 +845,46 @@ private GeneratedGizmoClasses generateDomainAccessors(SolverConfig solverConfig,
membersToGeneratedAccessorsFor.removeIf(this::shouldIgnoreMember);
// Fail fast on auto-discovery.
- var planningSolutionAnnotationInstanceCollection =
+ Collection<An... | `unusedSolutionClassNameSet`. |
timefold-solver | github_2023 | java | 590 | TimefoldAI | triceo | @@ -0,0 +1,115 @@
+package ai.timefold.solver.spring.boot.autoconfigure;
+
+import static java.util.Collections.emptyList;
+
+import java.util.ArrayList;
+import java.util.Comparator;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Optional;
+import java.util.Set;
+import java.util.stream.Collector... | Why was introducing this necessary?
What abstract classes do we need to find? |
timefold-solver | github_2023 | java | 590 | TimefoldAI | triceo | @@ -0,0 +1,115 @@
+package ai.timefold.solver.spring.boot.autoconfigure;
+
+import static java.util.Collections.emptyList;
+
+import java.util.ArrayList;
+import java.util.Comparator;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Optional;
+import java.util.Set;
+import java.util.stream.Collector... | Let's avoid `Optional` if the only purpose of it is to avoid a local `null` check.
I'd argue the following code reads much better:
var implementingClassList = findImplementingClassList(targetClass);
if (implementingClassList == null || implementingClassList.isEmpty()) {
return null;
} else ... |
timefold-solver | github_2023 | java | 590 | TimefoldAI | triceo | @@ -0,0 +1,115 @@
+package ai.timefold.solver.spring.boot.autoconfigure;
+
+import static java.util.Collections.emptyList;
+
+import java.util.ArrayList;
+import java.util.Comparator;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Optional;
+import java.util.Set;
+import java.util.stream.Collector... | `packageSet`. |
timefold-solver | github_2023 | java | 590 | TimefoldAI | triceo | @@ -0,0 +1,115 @@
+package ai.timefold.solver.spring.boot.autoconfigure;
+
+import static java.util.Collections.emptyList;
+
+import java.util.ArrayList;
+import java.util.Comparator;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Optional;
+import java.util.Set;
+import java.util.stream.Collector... | Please apply the new convention to formatting error messages. |
timefold-solver | github_2023 | java | 590 | TimefoldAI | triceo | @@ -0,0 +1,115 @@
+package ai.timefold.solver.spring.boot.autoconfigure;
+
+import static java.util.Collections.emptyList;
+
+import java.util.ArrayList;
+import java.util.Comparator;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Optional;
+import java.util.Set;
+import java.util.stream.Collector... | Dtto. |
timefold-solver | github_2023 | java | 590 | TimefoldAI | triceo | @@ -0,0 +1,115 @@
+package ai.timefold.solver.spring.boot.autoconfigure;
+
+import static java.util.Collections.emptyList;
+
+import java.util.ArrayList;
+import java.util.Comparator;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Optional;
+import java.util.Set;
+import java.util.stream.Collector... | Dtto. |
timefold-solver | github_2023 | java | 590 | TimefoldAI | triceo | @@ -0,0 +1,115 @@
+package ai.timefold.solver.spring.boot.autoconfigure;
+
+import static java.util.Collections.emptyList;
+
+import java.util.ArrayList;
+import java.util.Comparator;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Optional;
+import java.util.Set;
+import java.util.stream.Collector... | Dtto. |
timefold-solver | github_2023 | java | 590 | TimefoldAI | triceo | @@ -64,62 +70,422 @@
@ConditionalOnMissingBean({ SolverConfig.class, SolverFactory.class, ScoreManager.class, SolutionManager.class,
SolverManager.class })
@EnableConfigurationProperties({ TimefoldProperties.class })
-public class TimefoldAutoConfiguration implements BeanClassLoaderAware {
+public class Time... | ```suggestion
// postProcessBeanFactory runs before creating any bean, but we need TimefoldProperties.
// Therefore, we use the Environment to load the properties.
``` |
timefold-solver | github_2023 | java | 590 | TimefoldAI | triceo | @@ -64,62 +70,422 @@
@ConditionalOnMissingBean({ SolverConfig.class, SolverFactory.class, ScoreManager.class, SolutionManager.class,
SolverManager.class })
@EnableConfigurationProperties({ TimefoldProperties.class })
-public class TimefoldAutoConfiguration implements BeanClassLoaderAware {
+public class Time... | I suggest we should have the same behavior in Spring Boot and Quarkus, where possible.
What would be the reasons _not_ to do this here? |
timefold-solver | github_2023 | java | 590 | TimefoldAI | triceo | @@ -64,62 +70,422 @@
@ConditionalOnMissingBean({ SolverConfig.class, SolverFactory.class, ScoreManager.class, SolutionManager.class,
SolverManager.class })
@EnableConfigurationProperties({ TimefoldProperties.class })
-public class TimefoldAutoConfiguration implements BeanClassLoaderAware {
+public class Time... | Why the quote inside the string? |
timefold-solver | github_2023 | java | 590 | TimefoldAI | triceo | @@ -64,62 +70,422 @@
@ConditionalOnMissingBean({ SolverConfig.class, SolverFactory.class, ScoreManager.class, SolutionManager.class,
SolverManager.class })
@EnableConfigurationProperties({ TimefoldProperties.class })
-public class TimefoldAutoConfiguration implements BeanClassLoaderAware {
+public class Time... | Let's not leave the TODO here, let's fix it instead.
What would be the pros and cons?
What does Quarkus do? |
timefold-solver | github_2023 | java | 590 | TimefoldAI | triceo | @@ -1,12 +1,24 @@
package ai.timefold.solver.spring.boot.autoconfigure.config;
+import java.util.Map;
+import java.util.Set;
+
import ai.timefold.solver.core.api.domain.common.DomainAccessType;
import ai.timefold.solver.core.api.score.stream.ConstraintStreamImplType;
import ai.timefold.solver.core.config.solver.E... | It is a good idea to have a constant for this.
However, I'd go further and have constants even for the names themselves - that way, you don't need to repeat them later in this class. |
timefold-solver | github_2023 | others | 687 | TimefoldAI | triceo | @@ -50,6 +50,12 @@ Defaults to `REFLECTION`.
The other possible value is `GIZMO`.
endif::[]
+{property_prefix}timefold.solver.{solver_name_prefix}nearby-distance-meter-class::
+Enable the xref:enterprise-edition/enterprise-edition.adoc#nearbySelection[Nearby Selection] quick configuration.
+If the Nearby Selection ... | ```suggestion
and automatically enables Nearby Selection for the compatible move selectors.
``` |
timefold-solver | github_2023 | java | 687 | TimefoldAI | triceo | @@ -719,6 +720,27 @@ private void applySolverProperties(IndexView indexView, String solverName, Solve
if (solverConfig.getDomainAccessType() == null) {
solverConfig.setDomainAccessType(DomainAccessType.GIZMO);
}
+
+ Optional<String> nearbyDistanceMeterClass =
+ timef... | `Optional` has `ifPresent(...)` for just this use case. |
timefold-solver | github_2023 | java | 687 | TimefoldAI | triceo | @@ -60,6 +60,11 @@ public interface SolverBuildTimeConfig {
*/
TerminationRuntimeConfig termination();
+ /**
+ * Enable the Nearby Selection quick configuration.
+ */
+ Optional<String> nearbyDistanceMeterClass(); | Shouldn't this return `Class<? extends NearbyDistanceMeter>` directly? The other properties also don't return `String`. |
timefold-solver | github_2023 | java | 687 | TimefoldAI | triceo | @@ -52,7 +55,7 @@ void solverProperties() {
assertEquals(DomainAccessType.REFLECTION, solverConfig.getDomainAccessType());
assertEquals(null,
solverConfig.getScoreDirectorFactoryConfig().getConstraintStreamImplType());
-
+ assertNotNull(solverConfig.getNearbyDistanceMeterClass(... | I obviously didn't notice before, but we use AssertJ, not JUnit assertions. |
timefold-solver | github_2023 | java | 687 | TimefoldAI | triceo | @@ -39,30 +40,27 @@ class TimefoldBenchmarkProcessorInheritedSolverBenchmarkTest {
@Test
void inheritClassesFromSolverConfig() {
- Assertions.assertEquals(TestdataQuarkusSolution.class, solverConfig.getSolutionClass());
- Assertions.assertEquals(2, solverConfig.getEntityClassList().size());
- ... | `containsExactly` (and similar methods) is your friend. |
timefold-solver | github_2023 | java | 687 | TimefoldAI | triceo | @@ -39,30 +40,27 @@ class TimefoldBenchmarkProcessorInheritedSolverBenchmarkTest {
@Test
void inheritClassesFromSolverConfig() {
- Assertions.assertEquals(TestdataQuarkusSolution.class, solverConfig.getSolutionClass());
- Assertions.assertEquals(2, solverConfig.getEntityClassList().size());
- ... | Also easier done with `containsExactly`. |
timefold-solver | github_2023 | java | 684 | TimefoldAI | triceo | @@ -280,4 +282,33 @@ private void inheritCommon(MoveSelectorConfig<?> inheritedConfig) {
fixedProbabilityWeight, inheritedConfig.getFixedProbabilityWeight());
}
+ protected String addRandomSuffix(String name, Random random) { | Should be `static`, no? |
timefold-solver | github_2023 | java | 684 | TimefoldAI | triceo | @@ -280,4 +282,33 @@ private void inheritCommon(MoveSelectorConfig<?> inheritedConfig) {
fixedProbabilityWeight, inheritedConfig.getFixedProbabilityWeight());
}
+ protected String addRandomSuffix(String name, Random random) {
+ StringBuilder value = new StringBuilder(name);
+ va... | I'd consider working without this. You can call `enableNearbySelection(...)`, which by default returns the config unchanged.
(I'm driven by eliminating boilerplate code; the selectors already have plenty without adding more.) |
timefold-solver | github_2023 | java | 684 | TimefoldAI | triceo | @@ -280,4 +282,33 @@ private void inheritCommon(MoveSelectorConfig<?> inheritedConfig) {
fixedProbabilityWeight, inheritedConfig.getFixedProbabilityWeight());
}
+ protected String addRandomSuffix(String name, Random random) {
+ StringBuilder value = new StringBuilder(name);
+ va... | Maybe this could return `false` by default, so that you only need to override it when `true` needs to be returned? |
timefold-solver | github_2023 | java | 684 | TimefoldAI | triceo | @@ -154,6 +154,18 @@ public void visitReferencedClasses(Consumer<Class<?>> classVisitor) {
}
}
+ @Override
+ public boolean hasNearbySelectionConfig() {
+ return (subListSelectorConfig != null && ((subListSelectorConfig.getNearbySelectionConfig() != null) | This condition is kinda insane.
Maybe simplify it by introducing boolean variables for its components?
The code will be longer, but people will actually be able to understand what the condition does.
(There are similar conditions elsewhere in this PR.)
|
timefold-solver | github_2023 | java | 684 | TimefoldAI | triceo | @@ -22,8 +23,24 @@ public UnionMoveSelectorFactory(UnionMoveSelectorConfig moveSelectorConfig) {
@Override
protected MoveSelector<Solution_> buildBaseMoveSelector(HeuristicConfigPolicy<Solution_> configPolicy,
SelectionCacheType minimumCacheType, boolean randomSelection) {
- List<MoveSelec... | Maybe explain _why_ in a comment?
The problem with cartesian is that if there are two selectors, it will have A×B moves. So if there are four selectors (2 non-nearby + 2 nearby), it will be A×B×C×D moves.
Whereas union will always be A+B+C+D.
|
timefold-solver | github_2023 | java | 684 | TimefoldAI | triceo | @@ -22,8 +23,24 @@ public UnionMoveSelectorFactory(UnionMoveSelectorConfig moveSelectorConfig) {
@Override
protected MoveSelector<Solution_> buildBaseMoveSelector(HeuristicConfigPolicy<Solution_> configPolicy,
SelectionCacheType minimumCacheType, boolean randomSelection) {
- List<MoveSelec... | Cautious use of `var` wouldn't hurt here, I think.
The name already says `list`. |
timefold-solver | github_2023 | java | 684 | TimefoldAI | triceo | @@ -0,0 +1,355 @@
+package ai.timefold.solver.core.config.heuristic.selector.move;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.a... | We use AssertJ, not JUnit assertions. |
timefold-solver | github_2023 | java | 684 | TimefoldAI | triceo | @@ -162,6 +166,31 @@ public void visitReferencedClasses(Consumer<Class<?>> classVisitor) {
classVisitor.accept(selectorProbabilityWeightFactoryClass);
}
+ @Override
+ public UnionMoveSelectorConfig enableNearbySelection(Class<? extends NearbyDistanceMeter<?, ?>> distanceMeter,
+ Random ... | Id argue that the following would read better, also coincidentally doesn't need to create an extra list or iterate twice:
for (... all configs ...) {
if (not nearby) {
continue;
}
...
}
Also, the `selectorConfig` variable is another nice use of `var` - all the necessar... |
timefold-solver | github_2023 | others | 726 | TimefoldAI | triceo | @@ -10,7 +10,7 @@ Assign each conference talk to a timeslot and a room, after the talks have been
image::use-cases-and-examples/conference-scheduling/conferenceSchedulingMilestonesTimeline.png[align="center"] | I think this entire adoc file can disappear entirely. It is a description of an example which we no longer have. (In fact, I will be removing the entire "use cases and examples" chapter very soon.) |
timefold-solver | github_2023 | java | 659 | TimefoldAI | triceo | @@ -32,7 +32,8 @@ protected TriFunction<A, B, Score_, ConstraintJustification> getJustificationMap
public <ConstraintJustification_ extends ConstraintJustification> BiConstraintBuilder<A, B, Score_> justifyWith(
TriFunction<A, B, Score_, ConstraintJustification_> justificationMapping) {
if (t... | Please convert to the new convention, using multi-line strings and placeholders. |
timefold-solver | github_2023 | java | 659 | TimefoldAI | triceo | @@ -47,7 +48,8 @@ protected BiFunction<A, B, Collection<Object>> getIndictedObjectsMapping() {
@Override
public BiConstraintBuilder<A, B, Score_> indictWith(BiFunction<A, B, Collection<Object>> indictedObjectsMapping) {
if (this.indictedObjectsMapping != null) {
- throw new IllegalStateExc... | Dtto. |
timefold-solver | github_2023 | java | 659 | TimefoldAI | triceo | @@ -32,7 +32,8 @@ protected PentaFunction<A, B, C, D, Score_, ConstraintJustification> getJustific
public <ConstraintJustification_ extends ConstraintJustification> QuadConstraintBuilder<A, B, C, D, Score_> justifyWith(
PentaFunction<A, B, C, D, Score_, ConstraintJustification_> justificationMapping) ... | Please convert to the new convention, using multi-line strings and placeholders. |
timefold-solver | github_2023 | java | 659 | TimefoldAI | triceo | @@ -48,7 +49,8 @@ protected QuadFunction<A, B, C, D, Collection<Object>> getIndictedObjectsMapping
public QuadConstraintBuilder<A, B, C, D, Score_>
indictWith(QuadFunction<A, B, C, D, Collection<Object>> indictedObjectsMapping) {
if (this.indictedObjectsMapping != null) {
- throw n... | Dtto. |
timefold-solver | github_2023 | java | 659 | TimefoldAI | triceo | @@ -32,7 +32,8 @@ protected QuadFunction<A, B, C, Score_, ConstraintJustification> getJustificatio
public <ConstraintJustification_ extends ConstraintJustification> TriConstraintBuilder<A, B, C, Score_> justifyWith(
QuadFunction<A, B, C, Score_, ConstraintJustification_> justificationMapping) {
... | Dtto. |
timefold-solver | github_2023 | java | 659 | TimefoldAI | triceo | @@ -47,7 +48,8 @@ protected TriFunction<A, B, C, Collection<Object>> getIndictedObjectsMapping() {
@Override
public TriConstraintBuilder<A, B, C, Score_> indictWith(TriFunction<A, B, C, Collection<Object>> indictedObjectsMapping) {
if (this.indictedObjectsMapping != null) {
- throw new Ill... | Dtto. |
timefold-solver | github_2023 | java | 659 | TimefoldAI | triceo | @@ -32,7 +32,8 @@ protected BiFunction<A, Score_, ConstraintJustification> getJustificationMapping
public <ConstraintJustification_ extends ConstraintJustification> UniConstraintBuilder<A, Score_> justifyWith(
BiFunction<A, Score_, ConstraintJustification_> justificationMapping) {
if (this.ju... | Dtto. |
timefold-solver | github_2023 | java | 659 | TimefoldAI | triceo | @@ -47,7 +48,8 @@ protected Function<A, Collection<Object>> getIndictedObjectsMapping() {
@Override
public UniConstraintBuilder<A, Score_> indictWith(Function<A, Collection<Object>> indictedObjectsMapping) {
if (this.indictedObjectsMapping != null) {
- throw new IllegalStateException("Indi... | Dtto. |
timefold-solver | github_2023 | java | 659 | TimefoldAI | triceo | @@ -104,6 +125,17 @@ private void validateMatchWeighTotal(Number matchWeightTotal) {
}
}
+ private void validateJustification(ConstraintJustification... justifications) {
+ Objects.requireNonNull(justifications, "The justification must be not null.");
+ }
+
+ private void validateIndictm... | Arguably, this should not be here. What if the user decided to indict with no indictments? We should be able to test for that. |
timefold-solver | github_2023 | java | 659 | TimefoldAI | triceo | @@ -135,6 +167,65 @@ private void assertImpact(ScoreImpactType scoreImpactType, Number matchWeightTot
throw new AssertionError(assertionMessage);
}
+ private void assertJustification(ConstraintJustification justification, String message) {
+ if (constraintJustificationCollection.isEmpty()) {
+... | Hmm, I think I didn't think this through.
A constraint can trigger multiple matches, therefore there may be multiple justifications. Therefore the user must be able to provide _all_ justifications that they expect to be there. So the code constraint verifier `justifiesWith(...)` needs to be a vararg. |
timefold-solver | github_2023 | java | 659 | TimefoldAI | triceo | @@ -32,7 +32,9 @@ protected TriFunction<A, B, Score_, ConstraintJustification> getJustificationMap
public <ConstraintJustification_ extends ConstraintJustification> BiConstraintBuilder<A, B, Score_> justifyWith(
TriFunction<A, B, Score_, ConstraintJustification_> justificationMapping) {
if (t... | ```suggestion
"""
Justification mapping already set (%s).
Maybe the constraint calls justifyWith() twice?"""
```
Java's got cool features now. Use them, please. (Apply in other places in the PR as well.) |
timefold-solver | github_2023 | java | 659 | TimefoldAI | triceo | @@ -0,0 +1,25 @@
+package ai.timefold.solver.test.api.score.stream.testdata.justification;
+
+import ai.timefold.solver.core.api.score.stream.ConstraintJustification;
+
+public class TestSecondComparableJustification | Any particular reason for testing comparable justifications? What specifically is being tested here? |
timefold-solver | github_2023 | java | 659 | TimefoldAI | triceo | @@ -4,9 +4,55 @@
import ai.timefold.solver.core.api.score.buildin.hardsoftlong.HardSoftLongScore;
import ai.timefold.solver.core.api.score.stream.Constraint;
+import ai.timefold.solver.core.api.score.stream.ConstraintJustification;
public interface SingleConstraintAssertion {
+ /**
+ * As defined by {@l... | I'm wondering, for the sake of consistency... the `penalizes(...)` method (and its reward counterparts) has the `message` as second argument. Maybe we deprecate those and introduce new ones where `message` goes first?
It would look silly if some methods have message first, and other have message last. This is going ... |
timefold-solver | github_2023 | java | 659 | TimefoldAI | triceo | @@ -26,6 +29,9 @@ public Constraint[] defineConstraints(ConstraintFactory factory) {
protected Constraint horizontalConflict(ConstraintFactory factory) {
return factory.forEachUniquePair(Queen.class, equal(Queen::getRowIndex))
.penalize(SimpleScore.ONE)
+ .justifyWith((quee... | Isn't this the default if you don't provide any indictments? |
timefold-solver | github_2023 | java | 659 | TimefoldAI | triceo | @@ -39,36 +98,64 @@ default void penalizesBy(int matchWeightTotal) {
* @throws AssertionError when the expected penalty is not observed
*/
default void penalizesBy(long matchWeightTotal) {
- penalizesBy(matchWeightTotal, null);
+ penalizesBy(null, matchWeightTotal);
}
/**
- ... | The next version of Solver is `1.8.0`. Please apply consistently. |
timefold-solver | github_2023 | others | 659 | TimefoldAI | triceo | @@ -0,0 +1,17 @@
+type: specs.openrewrite.org/v1beta/recipe
+name: ai.timefold.solver.migration.ToLatestSingleConstraintAssertion
+displayName: 'Use non-deprecated SingleConstraintAssertion methods'
+description: 'Use `penalizesBy/rewardsWith(String, int)` instead of `penalizesBy/rewardsWith(int, String)` on `SingleCon... | I'd prefer we have a Java class for this. See how I created the `NullableRecipe`.
The main reason is that if we did every such thing as a top-level YML recipe, we would soon have too many of them. I'd like to keep that folder relatively clean. |
timefold-solver | github_2023 | java | 659 | TimefoldAI | triceo | @@ -39,36 +98,64 @@ default void penalizesBy(int matchWeightTotal) {
* @throws AssertionError when the expected penalty is not observed
*/
default void penalizesBy(long matchWeightTotal) {
- penalizesBy(matchWeightTotal, null);
+ penalizesBy(null, matchWeightTotal);
}
/**
- ... | If it starts with a capital letter, it is a sentence and therefore it ends with a `.`. |
timefold-solver | github_2023 | java | 515 | TimefoldAI | zepfred | @@ -213,6 +217,59 @@ void solveGenerics() throws ExecutionException, InterruptedException {
solverJob.getFinalBestSolution();
}
+ @Test
+ void solveWithOverride() throws InterruptedException {
+ CountDownLatch countDownLatch = new CountDownLatch(2);
+ PhaseConfig<?> customPhaseConfig... | Yes, it makes sense. The goal is to ensure the termination time is overridden, but the internal state is not fetchable. I'll try to think of something else. |
timefold-solver | github_2023 | java | 515 | TimefoldAI | zepfred | @@ -0,0 +1,41 @@
+package ai.timefold.solver.core.api.solver;
+
+import java.util.UUID;
+import java.util.function.BiConsumer;
+import java.util.function.Consumer;
+
+import ai.timefold.solver.core.api.domain.solution.PlanningSolution;
+import ai.timefold.solver.core.config.solver.termination.TerminationConfig;
+
+/**
... | Let's wait for the design meeting to define the next steps here. |
timefold-solver | github_2023 | java | 515 | TimefoldAI | zepfred | @@ -0,0 +1,41 @@
+package ai.timefold.solver.core.api.solver;
+
+import java.util.UUID;
+import java.util.function.BiConsumer;
+import java.util.function.Consumer;
+
+import ai.timefold.solver.core.api.domain.solution.PlanningSolution;
+import ai.timefold.solver.core.config.solver.termination.TerminationConfig;
+
+/**
... | Let's wait for the design meeting to define the next steps here. |
timefold-solver | github_2023 | java | 515 | TimefoldAI | zepfred | @@ -0,0 +1,37 @@
+package ai.timefold.solver.core.api.solver;
+
+import java.util.UUID;
+import java.util.function.BiConsumer;
+import java.util.function.Consumer;
+
+import ai.timefold.solver.core.api.domain.solution.PlanningSolution;
+import ai.timefold.solver.core.config.solver.termination.TerminationConfig;
+
+/**
... | Let's wait for the design meeting to define the next steps here. |
timefold-solver | github_2023 | java | 515 | TimefoldAI | zepfred | @@ -268,11 +364,46 @@ default SolverJob<Solution_, ProblemId_> solveAndListen(ProblemId_ problemId,
* If null it defaults to logging the exception as an error.
* @return never null
*/
+ default SolverJob<Solution_, ProblemId_> solveAndListen(ProblemId_ problemId,
+ Function<? supe... | Let's wait for the design meeting to define the next steps here. |
timefold-solver | github_2023 | java | 515 | TimefoldAI | zepfred | @@ -98,6 +99,65 @@ static <Solution_, ProblemId_> SolverManager<Solution_, ProblemId_> create(
return new DefaultSolverManager<>(solverFactory, solverManagerConfig);
}
+ // ************************************************************************
+ // Builder methods
+ // ***********************... | Let's wait for the design meeting to define the next steps here. |
timefold-solver | github_2023 | java | 515 | TimefoldAI | zepfred | @@ -196,10 +264,35 @@ default SolverJob<Solution_, ProblemId_> solve(ProblemId_ problemId,
* If null it defaults to logging the exception as an error.
* @return never null
*/
+ default SolverJob<Solution_, ProblemId_> solve(ProblemId_ problemId,
+ Fu... | Let's wait for the design meeting to define the next steps here. |
timefold-solver | github_2023 | java | 515 | TimefoldAI | zepfred | @@ -0,0 +1,38 @@
+package ai.timefold.solver.core.config.solver;
+
+import ai.timefold.solver.core.api.domain.solution.PlanningSolution;
+import ai.timefold.solver.core.config.solver.termination.TerminationConfig;
+
+/**
+ * Includes settings to override default {@link ai.timefold.solver.core.api.solver.Solver} configu... | > It is questionable if this class belongs in `config` package. As you can see, it caused it to be needlessly inserted in the XSD. I'd move this to `api/solver`, which is where it is primarily used.
>
Yes, I was unsure about how to deal with this XSD auto-generation, and it makes sense to move it to `api/solver.`
... |
timefold-solver | github_2023 | java | 515 | TimefoldAI | zepfred | @@ -0,0 +1,101 @@
+package ai.timefold.solver.core.config.solver;
+
+import java.util.UUID;
+import java.util.function.BiConsumer;
+import java.util.function.Consumer;
+import java.util.function.Function;
+
+import ai.timefold.solver.core.api.domain.solution.PlanningSolution;
+import ai.timefold.solver.core.config.solv... | I removed this class as it had become unused after updating the public API contract. |
timefold-solver | github_2023 | java | 515 | TimefoldAI | zepfred | @@ -0,0 +1,82 @@
+package ai.timefold.solver.core.impl.solver;
+
+import java.util.Objects;
+import java.util.UUID;
+import java.util.function.BiConsumer;
+import java.util.function.Consumer;
+import java.util.function.Function;
+
+import ai.timefold.solver.core.api.domain.solution.PlanningSolution;
+import ai.timefold... | > If you're implementing `SolverJobBuilder`, typically we call the implementation `DefaultSolverJobBuilder`.
Done!
> In this case, it is questionable whether we need the interface at all - why not make this the `SolverJobBuilder` directly? Make the constructors package-private and there are no issues.
The inte... |
timefold-solver | github_2023 | others | 515 | TimefoldAI | zepfred | @@ -1435,6 +1435,18 @@
</xs:complexType>
+ <xs:complexType name="solverConfigOverride"> | Yes, I confirmed that no changes have been made to this file. |
timefold-solver | github_2023 | java | 515 | TimefoldAI | zepfred | @@ -115,6 +116,15 @@ static <Solution_> SolverFactory<Solution_> create(SolverConfig solverConfig) {
*
* @return never null
*/
- Solver<Solution_> buildSolver();
+ default Solver<Solution_> buildSolver() {
+ return this.buildSolver(null);
+ }
+ /**
+ * As defined by {@link #bu... | I have made changes to the logic to ensure that the configOverride is now required. |
timefold-solver | github_2023 | java | 515 | TimefoldAI | zepfred | @@ -0,0 +1,95 @@
+package ai.timefold.solver.core.api.solver;
+
+import java.util.UUID;
+import java.util.function.BiConsumer;
+import java.util.function.Consumer;
+import java.util.function.Function;
+
+import ai.timefold.solver.core.api.domain.solution.PlanningSolution;
+
+/**
+ * Provides a fluid contract that allow... | The only case I can think of is if we want to reuse a builder and update the configuration, which seems an anti-pattern. |
timefold-solver | github_2023 | java | 515 | TimefoldAI | zepfred | @@ -72,7 +72,10 @@ void solve() throws ExecutionException, InterruptedException {
Collections.emptyList(),
HardSoftLongScore.ZERO);
- SolverJob<TestDataKitchenSinkSolution, Long> solverJob = solverManager.solve(1L, problem);
+ SolverJob<TestDataKitchenSinkSolution, Long... | Agreed. Should we keep using the builder or revert changes for this method? |
timefold-solver | github_2023 | others | 623 | TimefoldAI | triceo | @@ -0,0 +1,286 @@
+= Define the constraints and calculate the score
+:imagesdir: ../..
+
+A _score_ represents the quality of a specific solution.
+The higher the better.
+Timefold Solver looks for the best solution, which is the solution with the highest score found in the available time.
+It might be the _optimal_ so... | ```suggestion
For example: _The sum total of travel time._
``` |
timefold-solver | github_2023 | others | 623 | TimefoldAI | triceo | @@ -0,0 +1,286 @@
+= Define the constraints and calculate the score
+:imagesdir: ../..
+
+A _score_ represents the quality of a specific solution.
+The higher the better.
+Timefold Solver looks for the best solution, which is the solution with the highest score found in the available time.
+It might be the _optimal_ so... | ```suggestion
// Max end-time not met
``` |
timefold-solver | github_2023 | others | 623 | TimefoldAI | triceo | @@ -0,0 +1,286 @@
+= Define the constraints and calculate the score
+:imagesdir: ../..
+
+A _score_ represents the quality of a specific solution.
+The higher the better.
+Timefold Solver looks for the best solution, which is the solution with the highest score found in the available time.
+It might be the _optimal_ so... | ```suggestion
// Max end-time not met
``` |
timefold-solver | github_2023 | others | 623 | TimefoldAI | triceo | @@ -0,0 +1,286 @@
+= Define the constraints and calculate the score
+:imagesdir: ../..
+
+A _score_ represents the quality of a specific solution.
+The higher the better.
+Timefold Solver looks for the best solution, which is the solution with the highest score found in the available time.
+It might be the _optimal_ so... | Let's make this an `int`. |
timefold-solver | github_2023 | others | 623 | TimefoldAI | triceo | @@ -0,0 +1,286 @@
+= Define the constraints and calculate the score
+:imagesdir: ../..
+
+A _score_ represents the quality of a specific solution.
+The higher the better.
+Timefold Solver looks for the best solution, which is the solution with the highest score found in the available time.
+It might be the _optimal_ so... | To avoid this. |
timefold-solver | github_2023 | others | 623 | TimefoldAI | triceo | @@ -0,0 +1,286 @@
+= Define the constraints and calculate the score
+:imagesdir: ../..
+
+A _score_ represents the quality of a specific solution.
+The higher the better.
+Timefold Solver looks for the best solution, which is the solution with the highest score found in the available time.
+It might be the _optimal_ so... | `int` please. |
timefold-solver | github_2023 | others | 623 | TimefoldAI | triceo | @@ -0,0 +1,286 @@
+= Define the constraints and calculate the score
+:imagesdir: ../..
+
+A _score_ represents the quality of a specific solution.
+The higher the better.
+Timefold Solver looks for the best solution, which is the solution with the highest score found in the available time.
+It might be the _optimal_ so... | ```suggestion
The `ConstraintProvider` scales much better than the `EasyScoreCalculator`: typically __O__(n) instead of __O__(n²).
``` |
timefold-solver | github_2023 | others | 623 | TimefoldAI | triceo | @@ -0,0 +1,790 @@
+= Model the domain objects
+:imagesdir: ../..
+
+Your goal is to assign each visit to a vehicle.
+You will create these classes:
+
+image::quickstart/vehicle-routing/vehicleRoutingClassDiagramPure.png[]
+
+== Location
+
+The `Location` class is used to represent the destination for deliveries or the ... | Maybe reference planning entity doc? |
timefold-solver | github_2023 | others | 623 | TimefoldAI | triceo | @@ -0,0 +1,790 @@
+= Model the domain objects
+:imagesdir: ../..
+
+Your goal is to assign each visit to a vehicle.
+You will create these classes:
+
+image::quickstart/vehicle-routing/vehicleRoutingClassDiagramPure.png[]
+
+== Location
+
+The `Location` class is used to represent the destination for deliveries or the ... | ```suggestion
Timefold Solver recognizes it as a sequence of connected variables, the field must have an `@PlanningListVariable` annotation.
``` |
timefold-solver | github_2023 | others | 623 | TimefoldAI | triceo | @@ -0,0 +1,790 @@
+= Model the domain objects
+:imagesdir: ../..
+
+Your goal is to assign each visit to a vehicle.
+You will create these classes:
+
+image::quickstart/vehicle-routing/vehicleRoutingClassDiagramPure.png[]
+
+== Location
+
+The `Location` class is used to represent the destination for deliveries or the ... | Aren't we repeating ourselves here? |
timefold-solver | github_2023 | others | 623 | TimefoldAI | triceo | @@ -0,0 +1,790 @@
+= Model the domain objects
+:imagesdir: ../..
+
+Your goal is to assign each visit to a vehicle.
+You will create these classes:
+
+image::quickstart/vehicle-routing/vehicleRoutingClassDiagramPure.png[]
+
+== Location
+
+The `Location` class is used to represent the destination for deliveries or the ... | This paragraph contains more information than the first one regarding the list variable, but I still wonder why does it duplicate some of the information. |
timefold-solver | github_2023 | others | 623 | TimefoldAI | triceo | @@ -0,0 +1,790 @@
+= Model the domain objects
+:imagesdir: ../..
+
+Your goal is to assign each visit to a vehicle.
+You will create these classes:
+
+image::quickstart/vehicle-routing/vehicleRoutingClassDiagramPure.png[]
+
+== Location
+
+The `Location` class is used to represent the destination for deliveries or the ... | Link to section on shadow variables? |
timefold-solver | github_2023 | others | 623 | TimefoldAI | triceo | @@ -0,0 +1,790 @@
+= Model the domain objects
+:imagesdir: ../..
+
+Your goal is to assign each visit to a vehicle.
+You will create these classes:
+
+image::quickstart/vehicle-routing/vehicleRoutingClassDiagramPure.png[]
+
+== Location
+
+The `Location` class is used to represent the destination for deliveries or the ... | ```suggestion
`@NextElementShadowVariable`, respectively. The method returns a reference of the previous and next visit of
``` |
timefold-solver | github_2023 | others | 623 | TimefoldAI | triceo | @@ -0,0 +1,518 @@
+= Gather the domain objects in a planning solution
+:imagesdir: ../..
+
+A `VehicleRoutePlan` wraps all `Vehicle` and `Visit` instances of a single dataset.
+Furthermore, because it contains all vehicles and visits, each with a specific planning variable state,
+it is a _planning solution_ and it has... | Link to planning solution doc. |
timefold-solver | github_2023 | others | 623 | TimefoldAI | triceo | @@ -0,0 +1,518 @@
+= Gather the domain objects in a planning solution
+:imagesdir: ../..
+
+A `VehicleRoutePlan` wraps all `Vehicle` and `Visit` instances of a single dataset.
+Furthermore, because it contains all vehicles and visits, each with a specific planning variable state,
+it is a _planning solution_ and it has... | It is not `null`. The solver fails when list variable is null.
It is an empty list. |
timefold-solver | github_2023 | others | 623 | TimefoldAI | triceo | @@ -0,0 +1,518 @@
+= Gather the domain objects in a planning solution
+:imagesdir: ../..
+
+A `VehicleRoutePlan` wraps all `Vehicle` and `Visit` instances of a single dataset.
+Furthermore, because it contains all vehicles and visits, each with a specific planning variable state,
+it is a _planning solution_ and it has... | ```suggestion
** For each `Vehicle`:
``` |
timefold-solver | github_2023 | others | 623 | TimefoldAI | triceo | @@ -0,0 +1,518 @@
+= Gather the domain objects in a planning solution
+:imagesdir: ../..
+
+A `VehicleRoutePlan` wraps all `Vehicle` and `Visit` instances of a single dataset.
+Furthermore, because it contains all vehicles and visits, each with a specific planning variable state,
+it is a _planning solution_ and it has... | Shadow vars are not optional - if you specify them, they will be filled.
(They are optional in a sense that you don't need to specify them.)
However, with a fresh solution, they are null because the listeners did not run yet. |
timefold-solver | github_2023 | others | 623 | TimefoldAI | triceo | @@ -0,0 +1,518 @@
+= Gather the domain objects in a planning solution
+:imagesdir: ../..
+
+A `VehicleRoutePlan` wraps all `Vehicle` and `Visit` instances of a single dataset.
+Furthermore, because it contains all vehicles and visits, each with a specific planning variable state,
+it is a _planning solution_ and it has... | ```suggestion
Then create an implementation using Haversine method:
``` |
timefold-solver | github_2023 | others | 623 | TimefoldAI | triceo | @@ -0,0 +1,518 @@
+= Gather the domain objects in a planning solution
+:imagesdir: ../..
+
+A `VehicleRoutePlan` wraps all `Vehicle` and `Visit` instances of a single dataset.
+Furthermore, because it contains all vehicles and visits, each with a specific planning variable state,
+it is a _planning solution_ and it has... | ```suggestion
contract for driving time calculation:
``` |
timefold-solver | github_2023 | others | 623 | TimefoldAI | triceo | @@ -0,0 +1,918 @@
+[#quarkusQuickStart]
+= Vehicle Routing Quick Start Guide
+:doctype: book
+:imagesdir: ../..
+:sectnums:
+:icons: font
+include::../../_attributes.adoc[]
+
+// Keep this in sync with the quarkus repo's copy
+// https://github.com/quarkusio/quarkus/blob/main/docs/src/main/asciidoc/timefold.adoc
+// Ke... | Maybe suggest `SDKMAN`? |
timefold-solver | github_2023 | others | 623 | TimefoldAI | triceo | @@ -0,0 +1,918 @@
+[#quarkusQuickStart]
+= Vehicle Routing Quick Start Guide
+:doctype: book
+:imagesdir: ../..
+:sectnums:
+:icons: font
+include::../../_attributes.adoc[]
+
+// Keep this in sync with the quarkus repo's copy
+// https://github.com/quarkusio/quarkus/blob/main/docs/src/main/asciidoc/timefold.adoc
+// Ke... | ```suggestion
when given two visits assigned to the same vehicle, penalizes with a match weight of `20` (exceeded capacity).
``` |
timefold-solver | github_2023 | others | 734 | TimefoldAI | zepfred | @@ -346,17 +346,19 @@ It is not available in the Community Edition.
There are several ways of doing multi-threaded solving:
-* *Multitenancy*: solve different datasets in parallel
-** The `SolverManager` will make it even easier to set this up, in a future version.
+* *<<multithreadedIncrementalSolving,Multi-threa... | This sentence is repeated |
timefold-solver | github_2023 | others | 734 | TimefoldAI | zepfred | @@ -366,89 +368,109 @@ A xref:using-timefold-solver/running-the-solver.adoc#logging[logging level] of `
and slow down the xref:constraints-and-score/performance.adoc#scoreCalculationSpeed[score calculation speed].
====
-[#planningId]
-==== `@PlanningId`
-
-For some functionality (such as multi-threaded solving and ... | ```suggestion
With this feature, the solver can run significantly faster,
getting you the right solution earlier.
``` |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.