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
415
TimefoldAI
rsynek
@@ -98,6 +98,10 @@ public double getAngle(Location location) { return Math.atan2(latitudeDifference, longitudeDifference); } + protected static long adjust(double distance) { + return (long) (distance + 0.5); // +0.5 to avoid floating point rounding errors
Is it any different from `Math.round()` ?
timefold-solver
github_2023
java
411
TimefoldAI
rsynek
@@ -179,7 +179,8 @@ private ConstructionHeuristicDecider<Solution_> buildDecider(HeuristicConfigPoli if (moveThreadCount == null) { decider = new ConstructionHeuristicDecider<>(configPolicy.getLogIndentation(), termination, forager); } else { - decider = MultithreadedSolvingEnt...
(soft suggestion) These pairs of a feature and a workaround could be an `enum`.
timefold-solver
github_2023
others
404
TimefoldAI
rsynek
@@ -0,0 +1,707 @@ += Enterprise Edition +:doctype: book +:sectnums: +:icons: font + +Timefold Solver Enterprise Edition is a commercial product that offers additional features, +such as <<nearbySelection,nearby selection>> and <<multithreadedSolving,multi-threaded solving>>. +These features are essential to scale out t...
Should we explicitly say that Enterprise Edition can still be used for an evaluation/development purposes?
timefold-solver
github_2023
java
401
TimefoldAI
triceo
@@ -7,17 +7,138 @@ import ai.timefold.solver.core.api.score.Score; import ai.timefold.solver.core.api.score.stream.ConstraintStream; import ai.timefold.solver.core.config.solver.EnvironmentMode; +import ai.timefold.solver.core.impl.util.Pair; +import ai.timefold.solver.core.impl.util.Quadruple; +import ai.timefold.s...
This confused me at first. - `CollectorA_` et al. are not `...ConstraintCollector` subtypes. (Because that would cause further explosion in the number of interfaces you'd have to create for this.) - `NoKeysThreeCollectorsGroupByBuilder` also doesn't reference constraint collectors. - But then the builder itself is...
timefold-solver
github_2023
java
401
TimefoldAI
triceo
@@ -7,17 +7,138 @@ import ai.timefold.solver.core.api.score.Score; import ai.timefold.solver.core.api.score.stream.ConstraintStream; import ai.timefold.solver.core.config.solver.EnvironmentMode; +import ai.timefold.solver.core.impl.util.Pair; +import ai.timefold.solver.core.impl.util.Quadruple; +import ai.timefold.s...
It appears we no longer need the tuple here. (Which also means we can now replace all declarations of `GroupNodeConstructor` variables with `var`.) Actually, I checked the history and this was the case on `main` already. Please make the changes anyway - it's a good thing to leave the code in a better shape than th...
timefold-solver
github_2023
java
401
TimefoldAI
triceo
@@ -36,6 +157,128 @@ AbstractNode apply(int groupStoreIndex, TupleLifecycle<Tuple_> nextNodesTupleLif } + @FunctionalInterface + interface NoKeysOneCollectorGroupByBuilder<CollectorA_, Tuple_ extends AbstractTuple> { + AbstractNode build(int groupStoreIndex, int undoStoreIndex, + Co...
Let's stay consistent with the node naming and use the `GroupByXMappingYCollectorNodeBuilder` pattern in these names.
timefold-solver
github_2023
java
401
TimefoldAI
triceo
@@ -36,6 +180,128 @@ AbstractNode apply(int groupStoreIndex, TupleLifecycle<Tuple_> nextNodesTupleLif } + @FunctionalInterface + interface GroupBy0Mapping1CollectorNodeBuilder<CollectorA_, Tuple_ extends AbstractTuple> { + AbstractNode build(int groupStoreIndex, int undoStoreIndex, + ...
One thing just crossed my mind... if we don't need `Collector_` to extend `...ConstraintCollector`, do we need `Tuple_` to extend `AbstractTuple`? If not, even more boilerplate to remove right here.
timefold-solver
github_2023
java
392
TimefoldAI
triceo
@@ -80,90 +167,56 @@ public final class ConstraintCollectors { * @return never null */ public static <A> UniConstraintCollector<A, ?, Integer> count() { - return new DefaultUniConstraintCollector<>( - MutableInt::new, - (resultContainer, a) -> innerCount(resultConta...
We didn't do this before, but now that I see it like this, why not make these argless collectors a singleton? Works nicely with the factory idea below.
timefold-solver
github_2023
java
392
TimefoldAI
triceo
@@ -47,23 +40,117 @@ import ai.timefold.solver.core.api.score.stream.tri.TriConstraintCollector; import ai.timefold.solver.core.api.score.stream.uni.UniConstraintCollector; import ai.timefold.solver.core.api.score.stream.uni.UniConstraintStream; -import ai.timefold.solver.core.impl.util.MutableInt; -import ai.timefo...
General comment: please make it so that the collector implementations aren't public. I do not want them to show up in IDEs. If there needs to be a public factory for them, so be it. Let's call it `InnerConstraintCollectors`, to follow the `Inner...` convention we already use elsewhere. You may think it's boilerplate...
timefold-solver
github_2023
java
392
TimefoldAI
triceo
@@ -0,0 +1,9 @@ +package ai.timefold.solver.core.impl.score.stream; + +public interface IntCalculator<Output_> {
Let's start getting used to `sealed` types. Let's seal every interface in the collector impl hierarchy.
timefold-solver
github_2023
java
392
TimefoldAI
triceo
@@ -0,0 +1,33 @@ +package ai.timefold.solver.core.impl.score.stream; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.function.IntFunction; + +public final class CustomCollectionUndoableActionable<Mapped, Result extends Collection<Mapped>>
Let's follow the convention that generic type arguments end with `_`, so that we can easily distinguish them from non-generic ones. I know we didn't do it in `ConstraintCollectors`, because the class already started like that and we kept it internally consistent throughout the years. But now that this is new code, l...
timefold-solver
github_2023
java
392
TimefoldAI
triceo
@@ -1547,14 +1121,14 @@ private static <A, B, C, D, Mapped> QuadConstraintCollector<A, B, C, D, SortedMa * @return never null */ public static <A extends Comparable<A>> UniConstraintCollector<A, ?, SortedSet<A>> toSortedSet() { - return toSortedSet(a -> a); + return toSortedSet(ConstantLa...
No deprecation after all?
timefold-solver
github_2023
java
392
TimefoldAI
triceo
@@ -80,90 +167,56 @@ public final class ConstraintCollectors { * @return never null */ public static <A> UniConstraintCollector<A, ?, Integer> count() { - return new DefaultUniConstraintCollector<>( - MutableInt::new, - (resultContainer, a) -> innerCount(resultConta...
And because these are no longer used and they are not public, we can delete the `Default...` implementations. Nice!
timefold-solver
github_2023
java
392
TimefoldAI
triceo
@@ -0,0 +1,17 @@ +package ai.timefold.solver.core.impl.score.stream; + +public final class IntCounter { + private int count; + + public void increment() { + count++; + } + + public void decrement() { + count--; + } + + public Integer result() {
Since there are no generics here, can we return `int`? Let's return what we have, and deal with boxing elsewhere.
timefold-solver
github_2023
java
392
TimefoldAI
triceo
@@ -0,0 +1,17 @@ +package ai.timefold.solver.core.impl.score.stream; + +public final class LongCounter { + private long count; + + public void increment() { + count++; + } + + public void decrement() { + count--; + } + + public Long result() {
`long` instead of `Long`?
timefold-solver
github_2023
java
392
TimefoldAI
triceo
@@ -0,0 +1,47 @@ +package ai.timefold.solver.core.impl.score.stream; + +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.function.BinaryOperator; +import java.util.stream.Stream; + +public final class ToMapPerKeyCounter<Value_> { + + private final Map<Value_, Long> counts = new LinkedHashMap<...
```suggestion .orElseThrow(() -> new IllegalStateException("Impossible state: Should have had at least one value.")); ``` "Impossible state" seems to be the convention for this.
timefold-solver
github_2023
java
392
TimefoldAI
triceo
@@ -0,0 +1,114 @@ +package ai.timefold.solver.core.impl.score.stream.bi; + +import java.util.Objects; +import java.util.function.Function; +import java.util.function.Supplier; + +import ai.timefold.solver.core.api.function.QuadFunction; +import ai.timefold.solver.core.api.function.TriFunction; +import ai.timefold.solve...
I'd argue we can avoid this craziness with `var`. The type is already on the right-hand side of the assignment, no need to duplicate it. Let's try to apply it consistently.
timefold-solver
github_2023
java
392
TimefoldAI
triceo
@@ -0,0 +1,42 @@ +package ai.timefold.solver.core.impl.score.stream.bi; + +import java.util.function.Function; +import java.util.function.Supplier; + +import ai.timefold.solver.core.api.function.TriFunction; +import ai.timefold.solver.core.api.score.stream.bi.BiConstraintCollector; +import ai.timefold.solver.core.impl....
If you make argless `count...()` a singleton, you get to avoid this, and also needless instances. (Not that it'd ever be a problem.)
timefold-solver
github_2023
java
336
TimefoldAI
rsynek
@@ -0,0 +1,84 @@ +package ai.timefold.solver.core.api.score.constraint; + +import java.util.Objects; + +import ai.timefold.solver.core.api.domain.constraintweight.ConstraintConfiguration; +import ai.timefold.solver.core.api.domain.constraintweight.ConstraintWeight; + +/** + * Represents a unique identifier of a constra...
nitpick: `parseConstraintId` as there is already the method `composeConstraintId`. By using the same name we make sure the user understands it's the same concept.
timefold-solver
github_2023
java
336
TimefoldAI
rsynek
@@ -174,22 +174,40 @@ public boolean isConstraintMatchEnabled() { public final Map<String, ConstraintMatchTotal<Score_>> getConstraintMatchTotalMap() { if (constraintMatchTotalMap == null) { - rebuildConstraintMatchTotalsAndIndictments(); + rebuildConstraintMatchTotals(); ...
nitpick: `constraintIdToConstraintMatchTotalMap` gives an idea what the key is.
timefold-solver
github_2023
java
336
TimefoldAI
rsynek
@@ -2,13 +2,16 @@ import java.util.List; -public class TimefoldDevUIProperties { +import ai.timefold.solver.core.api.score.constraint.ConstraintRef; + +public class TimefoldDevUIProperties { // TODO make record?
Is it a leftover or a suggestion for some next PR (just checking)?
timefold-solver
github_2023
java
336
TimefoldAI
rsynek
@@ -0,0 +1,134 @@ +package ai.timefold.solver.core.api.score.analysis; + +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +import ai.timefold.solver.core.api.score.Score; +import ai.timefold.solver.core.api.score.constraint...
(relevant to all records in this package): Not sure if we should take it that far, but instead of this note, we could expose just interfaces with getters and move these records implementing them to the `impl` package. That way, we make instantiation impossible.
timefold-solver
github_2023
java
336
TimefoldAI
rsynek
@@ -1,19 +1,47 @@ package ai.timefold.solver.core.api.score.stream; +import java.util.UUID; + +import ai.timefold.solver.core.api.score.Score; +import ai.timefold.solver.core.api.score.analysis.MatchAnalysis; +import ai.timefold.solver.core.api.score.analysis.ScoreAnalysis; import ai.timefold.solver.core.api.score....
nitpicking: "random" does not necessarily imply the ID is unique; I would rather use "unique ID"
timefold-solver
github_2023
java
336
TimefoldAI
rsynek
@@ -86,4 +78,85 @@ private <Result_> Result_ callScoreDirector(Solution_ solution, return function.apply(scoreDirector); } } + + @Override + public ScoreExplanation<Solution_, Score_> explain(Solution_ solution, SolutionUpdatePolicy solutionUpdatePolicy) { + var currentScore = (S...
Is there a reason for having this method public on the implementation class?
timefold-solver
github_2023
java
336
TimefoldAI
rsynek
@@ -41,6 +57,126 @@ void polymorphicScore() { .isEqualTo(BendableScore.of(new int[] { -1, -20 }, new int[] { -300, -4000, -50000 })); } + @Test + void scoreAnalysisWithoutMatches() throws JsonProcessingException { + ObjectMapper objectMapper = new ObjectMapper(); + objectMapp...
Can the justification be just any object and it's a list just in this example, or is it always a list?
timefold-solver
github_2023
java
374
TimefoldAI
triceo
@@ -252,4 +252,12 @@ default void expandToQuad() { void impactNegativeBigDecimalCustomJustifications(); + // ************************************************************************
Let's start a new `NodeSharingTest` for this.
timefold-solver
github_2023
java
374
TimefoldAI
triceo
@@ -3000,4 +3008,190 @@ public void joinerEqualsAndSameness() { assertMatch(entity3, entity2)); } + // ************************************************************************ + // Node Sharing + // ************************************************************************ + + @Overrid...
This is needlessly complicated. Since you never need to call those constraint streams, you don't need `buildScoreDirector` or `failureList`. Let's change the test to look like this: Assertions.assertThat(base.join(...)) .as(...) .isSameAs(base.join(...) Maybe you'll need to figure out how...
timefold-solver
github_2023
java
374
TimefoldAI
triceo
@@ -0,0 +1,216 @@ +package ai.timefold.solver.core.impl.util; + +import java.util.Objects; +import java.util.function.BiFunction; +import java.util.function.BiPredicate; +import java.util.function.Function; +import java.util.function.ToIntBiFunction; +import java.util.function.ToIntFunction; + +import ai.timefold.solve...
Let's add a private constructor to prevent instances.
timefold-solver
github_2023
java
374
TimefoldAI
triceo
@@ -0,0 +1,216 @@ +package ai.timefold.solver.core.impl.util; + +import java.util.Objects; +import java.util.function.BiFunction; +import java.util.function.BiPredicate; +import java.util.function.Function; +import java.util.function.ToIntBiFunction; +import java.util.function.ToIntFunction; + +import ai.timefold.solve...
```suggestion * A class that holds common lambdas that are guaranteed to be the same across method calls. In most JDK's, stateless lambdas are ```
timefold-solver
github_2023
java
374
TimefoldAI
triceo
@@ -0,0 +1,216 @@ +package ai.timefold.solver.core.impl.util; + +import java.util.Objects; +import java.util.function.BiFunction; +import java.util.function.BiPredicate; +import java.util.function.Function; +import java.util.function.ToIntBiFunction; +import java.util.function.ToIntFunction; + +import ai.timefold.solve...
Let's have consistent whitespace. Either use newlines, or don't. If you want to separate blocks of lambdas, do so, but do it consistently.
timefold-solver
github_2023
others
379
TimefoldAI
triceo
@@ -66,6 +66,23 @@ $ mvn exec:java This is an open source project, and you are more than welcome to contribute! For more, see link:CONTRIBUTING.adoc[Contributing]. +== Editions + +There are 2 editions of Timefold Solver: + +- Timefold Solver Community Edition (CE) (this repo). +- Timefold Solver Enterprise Edition ...
```suggestion === Key Features of Enterprise Edition (EE) ```
timefold-solver
github_2023
others
379
TimefoldAI
triceo
@@ -66,6 +66,23 @@ $ mvn exec:java This is an open source project, and you are more than welcome to contribute! For more, see link:CONTRIBUTING.adoc[Contributing]. +== Editions + +There are 2 editions of Timefold Solver: + +- Timefold Solver Community Edition (CE) (this repo). +- Timefold Solver Enterprise Edition ...
```suggestion === Licensing and Usage ```
timefold-solver
github_2023
others
379
TimefoldAI
triceo
@@ -66,6 +66,23 @@ $ mvn exec:java This is an open source project, and you are more than welcome to contribute! For more, see link:CONTRIBUTING.adoc[Contributing]. +== Editions + +There are 2 editions of Timefold Solver: + +- Timefold Solver Community Edition (CE) (this repo). +- Timefold Solver Enterprise Edition ...
```suggestion - **Nearby Selection:** Get better solutions quicker, especially with spatial problems. ```
timefold-solver
github_2023
others
379
TimefoldAI
triceo
@@ -66,6 +66,23 @@ $ mvn exec:java This is an open source project, and you are more than welcome to contribute! For more, see link:CONTRIBUTING.adoc[Contributing]. +== Editions + +There are 2 editions of Timefold Solver: + +- Timefold Solver Community Edition (CE) (this repo). +- Timefold Solver Enterprise Edition ...
```suggestion === Key Features of Timefold Solver Enterprise Edition (EE) ```
timefold-solver
github_2023
java
369
TimefoldAI
triceo
@@ -0,0 +1,59 @@ +package ai.timefold.solver.core.impl.util; + +import java.util.Objects; +import java.util.function.BiFunction; +import java.util.function.BiPredicate; +import java.util.function.Function; +import java.util.function.ToIntBiFunction; +import java.util.function.ToIntFunction; + +import ai.timefold.solver...
If these functions are returned via static methods, you can get the casting done inside the methods, as opposed to plaguing the entire codebase with it. Example: public static final <A, B> BiPredicate<A, B> notEquals() { return (BiPredicate<A, B>) NOT_EQUALS; }
timefold-solver
github_2023
others
81
TimefoldAI
rsynek
@@ -0,0 +1,54 @@ +name: Downstream - Timefold Quickstarts + +on: + pull_request: + branches: [main] + paths-ignore: + - 'LICENSE*' + - '.gitignore' + - '**.md' + - '**.adoc' + - '*.txt' + +jobs: + build: + runs-on: ubuntu-latest + concurrency: + group: downstream-quickstarts-...
Can we set the executable flag for the script as a part of this PR instead of doing it each time in the GHA?
timefold-solver
github_2023
others
81
TimefoldAI
rsynek
@@ -0,0 +1,54 @@ +name: Downstream - Timefold Quickstarts + +on: + pull_request: + branches: [main]
We will eventually have also release branches.
timefold-solver
github_2023
others
81
TimefoldAI
rsynek
@@ -0,0 +1,54 @@ +name: Downstream - Timefold Quickstarts + +on: + pull_request:
That's a question. Cloning the PR author repositories without merging with the target repositories does not protected from stale PR, which might, in theory, result in issues only after merging the PR. If we want to cover this corner case, we have to either A) merge the forks with origin repos before the build or B) ...
timefold-solver
github_2023
java
340
TimefoldAI
Christopher-Chianelli
@@ -65,7 +65,7 @@ private static RuntimeException createJustificationException(Constraint constrai private static String factsToString(Object... facts) { return Arrays.stream(facts) - .map(Object::toString) + .map(s -> s == null ? null : s.toString())
Maybe `Objects::toString`? https://docs.oracle.com/javase/8/docs/api/java/util/Objects.html#toString-java.lang.Object-
timefold-solver
github_2023
others
340
TimefoldAI
Christopher-Chianelli
@@ -1514,10 +1514,14 @@ See <<constraintStreamsDealingWithDuplicateTuplesUsingDistinct,`distinct()`>> fo [[constraintStreamsConcat]] ==== Concat -The `concat` building block allows you to create a constraint stream containing tuples of two constraint streams of the same <<constraintStreamsCardinality,cardinality>>....
Inaccurate, since now multiple cardinalities are allowed
timefold-solver
github_2023
java
346
TimefoldAI
triceo
@@ -52,8 +52,11 @@ public class GizmoSolutionClonerImplementor { Object.class); private static final MethodDescriptor PUT_METHOD = MethodDescriptor.ofMethod(Map.class, "put", Object.class, Object.class, Object.class); + private static final String FALLBACK_CLONER = "fallbackCloner"; ...
Let's figure out a different way to pass this information. Static mutable fields are fundamentally wrong, and we've seen it numerous times already. Do we need a Quarkus-specific subtype? So be it. Quarkus-specific constructor? Sure. Just not this, please. In my opinion, the fact that there are ifs for particula...
timefold-solver
github_2023
java
346
TimefoldAI
triceo
@@ -28,7 +28,8 @@ public static <T> SolutionCloner<T> build(SolutionDescriptor<T> solutionDescript ") the classpath or modulepath must contain io.quarkus.gizmo:gizmo.\n" + "Maybe add a dependency to io.quarkus.gizmo:gizmo."); } - return GizmoSolutionClonerImplem...
Why not: ```suggestion return GizmoSolutionClonerImplementor.createClonerFor(solutionDescriptor, ``` Seems like the instance creation is just boilerplate, it can happen internally. People need not know what's happening under the covers.
timefold-solver
github_2023
java
346
TimefoldAI
triceo
@@ -100,14 +101,20 @@ public static Comparator<Class<?>> getInstanceOfComparator(Set<Class<?>> deepClo .thenComparing(Class::getName).reversed(); } + protected void createFields(ClassCreator classCreator) { + classCreator.getFieldCreator(FALLBACK_CLONER, FieldAccessingSolutionCloner.cl...
Could have stayed static.
timefold-solver
github_2023
java
346
TimefoldAI
triceo
@@ -417,6 +419,76 @@ public String generateGizmoBeanFactory(ClassOutput classOutput, Set<Class<?>> be return generatedClassName; } + private static class QuarkusGizmoSolutionClonerImplementor extends GizmoSolutionClonerImplementor {
The class is IMO a big too big to be an inner class. Consider making it a top-level class; it's already static, so you don't need the reference to the outer class.
timefold-solver
github_2023
java
346
TimefoldAI
triceo
@@ -69,7 +69,7 @@ protected <Solution_> SolutionCloner<Solution_> createSolutionCloner(SolutionDes generateGizmoSolutionOrEntityDescriptor(solutionDescriptor, clazz)); }); - GizmoSolutionClonerImplementor.defineClonerFor(classCreator, solutionDescriptor, + n...
Same comment as above; I think it could've been made static and hidden the instance.
timefold-solver
github_2023
java
338
TimefoldAI
triceo
@@ -125,11 +129,26 @@ private Optional<ListVariableDescriptor<?>> findValidListVariableDescriptor( + listVariableDescriptors + ")."); } + ListVariableDescriptor<Solution_> listVariableDescriptor = listVariableDescriptors.get(0); + failIfBasicAndListVariablesAreCombinedOnSin...
I'd argue this needs to happen earlier, before the CH, when the solver config is being processed.
timefold-solver
github_2023
java
338
TimefoldAI
triceo
@@ -125,11 +129,26 @@ private Optional<ListVariableDescriptor<?>> findValidListVariableDescriptor( + listVariableDescriptors + ")."); } + ListVariableDescriptor<Solution_> listVariableDescriptor = listVariableDescriptors.get(0); + failIfBasicAndListVariablesAreCombinedOnSin...
```suggestion throw new UnsupportedOperationException(""" Combining basic variables (%s) with list variables (%) on a single planning entity (%s) is currently not supported. """.formatted(basicVariableDescriptors, listVariableDescriptor, listVariableDescriptor.get...
timefold-solver
github_2023
java
338
TimefoldAI
triceo
@@ -221,6 +224,20 @@ void variableWithPlanningIdIsARecord() { Assertions.assertThatNoException().isThrownBy(() -> solver.solve(solution)); } + @Test + void entityWithMixedBasicAndListPlanningVariables() { + var solverConfig = new SolverConfig() + .withSolutionClass(DummySolut...
This last line shouldn't be necessary. AFAIK phases are auto-configured if not present.
timefold-solver
github_2023
java
338
TimefoldAI
triceo
@@ -549,6 +551,31 @@ private void determineGlobalShadowOrder() { } } + private void validateListVariableDescriptors() { + if (listVariableDescriptors.isEmpty()) { + return; + } + + if (listVariableDescriptors.size() > 1) { + throw new UnsupportedOperationExc...
```suggestion "Combining basic variables (%s) with list variables (%s) on a single planning entity (%s)" + " is currently not supported." ```
timefold-solver
github_2023
java
338
TimefoldAI
triceo
@@ -549,6 +551,31 @@ private void determineGlobalShadowOrder() { } } + private void validateListVariableDescriptors() { + if (listVariableDescriptors.isEmpty()) { + return; + } + + if (listVariableDescriptors.size() > 1) { + throw new UnsupportedOperationExc...
```suggestion listVariableDescriptor.getEntityDescriptor().getEntityClass().getCanonicalName())); ```
timefold-solver
github_2023
others
337
TimefoldAI
triceo
@@ -1030,9 +1030,14 @@ public class StartTimeUpdatingVariableListener implements VariableListener<TaskA ==== Planning value A planning value is a possible value for a genuine planning variable. -Usually, a planning value is a problem fact, but it can also be any object, for example a ``double``. +Usually, a plannin...
```suggestion Usually, a planning value is a problem fact, but it can also be any object, for example an ``Integer``. ```
timefold-solver
github_2023
others
337
TimefoldAI
triceo
@@ -1030,9 +1030,14 @@ public class StartTimeUpdatingVariableListener implements VariableListener<TaskA ==== Planning value A planning value is a possible value for a genuine planning variable. -Usually, a planning value is a problem fact, but it can also be any object, for example a ``double``. +Usually, a plannin...
```suggestion Primitive types (such as ``int``) are not allowed. ```
timefold-solver
github_2023
java
297
TimefoldAI
triceo
@@ -140,6 +141,13 @@ private long determineLayerIndex(AbstractNode node, NodeBuildHelper<Score_> buil var leftParentNode = buildHelper.findParentNode(leftParent); var rightParentNode = buildHelper.findParentNode(rightParent); return Math.max(leftParentNode.getLayerIndex(), rightPa...
Why would concat implement join? The two operations have barely anything in common.
timefold-solver
github_2023
java
297
TimefoldAI
triceo
@@ -359,6 +359,19 @@ public BiConstraintStream<A, B> distinct() { } } + @Override + public BiConstraintStream<A, B> concat(BiConstraintStream<A, B> otherStream) { + var other = (BavetAbstractBiConstraintStream<Solution_, A, B>) otherStream; + var leftBridge = new BavetForeBridgeBiCon...
This is not a join; let's not call it like that.
timefold-solver
github_2023
java
297
TimefoldAI
triceo
@@ -0,0 +1,19 @@ +package ai.timefold.solver.constraint.streams.bavet.bi; + +import ai.timefold.solver.constraint.streams.bavet.common.AbstractConcatNode; +import ai.timefold.solver.constraint.streams.bavet.common.tuple.BiTuple; +import ai.timefold.solver.constraint.streams.bavet.common.tuple.TupleLifecycle; + +public ...
Since concat does not modify the tuples, it doesn't need to create new ones. I'm betting it will be much more efficient if it's rewritten as a pass-through node, without node creation.
timefold-solver
github_2023
java
297
TimefoldAI
triceo
@@ -0,0 +1,103 @@ +package ai.timefold.solver.constraint.streams.bavet.common; + +import static ai.timefold.solver.constraint.streams.bavet.common.tuple.TupleState.ABORTING; +import static ai.timefold.solver.constraint.streams.bavet.common.tuple.TupleState.CREATING; +import static ai.timefold.solver.constraint.streams....
There aren't any indexes.
timefold-solver
github_2023
java
297
TimefoldAI
triceo
@@ -0,0 +1,103 @@ +package ai.timefold.solver.constraint.streams.bavet.common; + +import static ai.timefold.solver.constraint.streams.bavet.common.tuple.TupleState.ABORTING; +import static ai.timefold.solver.constraint.streams.bavet.common.tuple.TupleState.CREATING; +import static ai.timefold.solver.constraint.streams....
These vars need better naming, as there are no indexes and no out tuple list.
timefold-solver
github_2023
java
297
TimefoldAI
triceo
@@ -0,0 +1,103 @@ +package ai.timefold.solver.constraint.streams.bavet.common; + +import static ai.timefold.solver.constraint.streams.bavet.common.tuple.TupleState.ABORTING; +import static ai.timefold.solver.constraint.streams.bavet.common.tuple.TupleState.CREATING; +import static ai.timefold.solver.constraint.streams....
If you store the node-specific tuple state in the store instead of the outtuple, you won't need to create the outtuple just to store the state.
timefold-solver
github_2023
java
297
TimefoldAI
triceo
@@ -0,0 +1,104 @@ +package ai.timefold.solver.constraint.streams.bavet.uni; + +import java.util.Objects; +import java.util.Set; + +import ai.timefold.solver.constraint.streams.bavet.BavetConstraintFactory; +import ai.timefold.solver.constraint.streams.bavet.common.BavetAbstractConstraintStream; +import ai.timefold.solv...
Not a join node. (Same comment also likely in Bi, Tri and Quad.)
timefold-solver
github_2023
java
297
TimefoldAI
triceo
@@ -140,6 +142,13 @@ private long determineLayerIndex(AbstractNode node, NodeBuildHelper<Score_> buil var leftParentNode = buildHelper.findParentNode(leftParent); var rightParentNode = buildHelper.findParentNode(rightParent); return Math.max(leftParentNode.getLayerIndex(), rightPa...
This code seems to repeat a lot now. Maybe we extract it?
timefold-solver
github_2023
others
297
TimefoldAI
triceo
@@ -1511,6 +1511,47 @@ the tuple `(SomePerson, USER)` is sent downstream twice. See <<constraintStreamsDealingWithDuplicateTuplesUsingDistinct,`distinct()`>> for how to deal with duplicate tuples. ==== +[[constraintStreamsConcat]] +==== Concat + +Concat allows you to create a constraint stream containing tuples of ...
```suggestion Unlike union of sets, concatenation of lists repeats duplicated elements. ```
timefold-solver
github_2023
others
297
TimefoldAI
triceo
@@ -1511,6 +1511,47 @@ the tuple `(SomePerson, USER)` is sent downstream twice. See <<constraintStreamsDealingWithDuplicateTuplesUsingDistinct,`distinct()`>> for how to deal with duplicate tuples. ==== +[[constraintStreamsConcat]] +==== Concat + +Concat allows you to create a constraint stream containing tuples of ...
```suggestion If this is undesired, use the <<constraintStreamsDealingWithDuplicateTuplesUsingDistinct,`distinct` building block>>. ```
timefold-solver
github_2023
others
297
TimefoldAI
triceo
@@ -1511,6 +1511,47 @@ the tuple `(SomePerson, USER)` is sent downstream twice. See <<constraintStreamsDealingWithDuplicateTuplesUsingDistinct,`distinct()`>> for how to deal with duplicate tuples. ==== +[[constraintStreamsConcat]] +==== Concat + +Concat allows you to create a constraint stream containing tuples of ...
I am not sure this is a good example. The first question once a smart person sees this is: why not just use a much simple `.filter(hasCat || hasDog)`? Even though you explain that the single filter approach would actually do something different, I have to ask - why? Why would I want the employee there twice? (It was...
timefold-solver
github_2023
others
297
TimefoldAI
triceo
@@ -1511,6 +1511,47 @@ the tuple `(SomePerson, USER)` is sent downstream twice. See <<constraintStreamsDealingWithDuplicateTuplesUsingDistinct,`distinct()`>> for how to deal with duplicate tuples. ==== +[[constraintStreamsConcat]] +==== Concat + +Concat allows you to create a constraint stream containing tuples of ...
```suggestion This correctly counts cats and dogs when an Employee has both a cat and a dog. ```
timefold-solver
github_2023
others
297
TimefoldAI
triceo
@@ -1511,6 +1511,57 @@ the tuple `(SomePerson, USER)` is sent downstream twice. See <<constraintStreamsDealingWithDuplicateTuplesUsingDistinct,`distinct()`>> for how to deal with duplicate tuples. ==== +[[constraintStreamsConcat]] +==== Concat + +Concat allows you to create a constraint stream containing tuples of ...
```suggestion The `concat` building block allows you to create a constraint stream containing tuples of two constraint streams of the same <<constraintStreamsCardinality,cardinality>>. ```
timefold-solver
github_2023
others
297
TimefoldAI
triceo
@@ -1511,6 +1511,57 @@ the tuple `(SomePerson, USER)` is sent downstream twice. See <<constraintStreamsDealingWithDuplicateTuplesUsingDistinct,`distinct()`>> for how to deal with duplicate tuples. ==== +[[constraintStreamsConcat]] +==== Concat + +Concat allows you to create a constraint stream containing tuples of ...
```suggestion If <<constraintStreamsJoin,join>> acts like a cartesian product of two lists, `concat` acts like a concatenation of two lists. ```
timefold-solver
github_2023
others
297
TimefoldAI
triceo
@@ -1511,6 +1511,57 @@ the tuple `(SomePerson, USER)` is sent downstream twice. See <<constraintStreamsDealingWithDuplicateTuplesUsingDistinct,`distinct()`>> for how to deal with duplicate tuples. ==== +[[constraintStreamsConcat]] +==== Concat + +Concat allows you to create a constraint stream containing tuples of ...
```suggestion If the two constraint stream parents share tuples, which happens eg. when the streams being concatenated come from the same source of data, the tuples will be repeated downstream. ```
timefold-solver
github_2023
others
297
TimefoldAI
triceo
@@ -1511,6 +1511,57 @@ the tuple `(SomePerson, USER)` is sent downstream twice. See <<constraintStreamsDealingWithDuplicateTuplesUsingDistinct,`distinct()`>> for how to deal with duplicate tuples. ==== +[[constraintStreamsConcat]] +==== Concat + +Concat allows you to create a constraint stream containing tuples of ...
```suggestion This correctly counts the number of shifts each Employee has, *even when the Employee has no shifts*. ```
timefold-solver
github_2023
others
297
TimefoldAI
triceo
@@ -1511,6 +1511,57 @@ the tuple `(SomePerson, USER)` is sent downstream twice. See <<constraintStreamsDealingWithDuplicateTuplesUsingDistinct,`distinct()`>> for how to deal with duplicate tuples. ==== +[[constraintStreamsConcat]] +==== Concat + +Concat allows you to create a constraint stream containing tuples of ...
```suggestion If it was implemented without `concat` like this: ```
timefold-solver
github_2023
others
297
TimefoldAI
triceo
@@ -1511,6 +1511,57 @@ the tuple `(SomePerson, USER)` is sent downstream twice. See <<constraintStreamsDealingWithDuplicateTuplesUsingDistinct,`distinct()`>> for how to deal with duplicate tuples. ==== +[[constraintStreamsConcat]] +==== Concat + +Concat allows you to create a constraint stream containing tuples of ...
```suggestion An employee with no assigned shifts _will not be penalized because no tuples were passed to the `groupBy` building block_. ```
timefold-solver
github_2023
java
297
TimefoldAI
triceo
@@ -16,4 +16,10 @@ public final class BavetBiConcatNode<A, B> extends AbstractConcatNode<BiTuple<A, protected BiTuple<A, B> getOutTuple(BiTuple<A, B> inTuple) { return new BiTuple<>(inTuple.factA, inTuple.factB, outputStoreSize); } + + @Override + protected void updateOutTuple(BiTuple<A, B> inT...
Tuples have `updateInDifferent(...)` just for this case. Turns out it is a common operation, so it was extracted already.
timefold-solver
github_2023
java
308
TimefoldAI
rsynek
@@ -487,10 +487,28 @@ private static <C> Member getSingleMember(Class<C> clazz, Class<? extends Annota if (memberList.isEmpty()) { return null; } - if (memberList.size() > 1) { - throw new IllegalArgumentException("The class (" + clazz - + ") has " + m...
Is it guaranteed that the second member in the list is the getter and not the field?
timefold-solver
github_2023
others
284
TimefoldAI
triceo
@@ -18,7 +18,7 @@ <!-- Code of integration tests should not be a part of test coverage reports. --> <sonar.coverage.exclusions>**/*</sonar.coverage.exclusions> <!-- Quarkus 2 and 3 use different context roots. --> - <dev.ui.root>/q/dev-v1</dev.ui.root> + <dev.ui.root>/q/dev-ui</dev.ui.root>
Since `main` only uses Quarkus 3, I think we can go back to hardcoding this and removing the comment.
timefold-solver
github_2023
others
284
TimefoldAI
triceo
@@ -651,7 +651,8 @@ <profile> <id>sonarcloud-analysis</id> <properties> - <sonar.coverage.jacoco.xmlReportPaths>${project.reporting.outputDirectory}/jacoco/jacoco.xml</sonar.coverage.jacoco.xmlReportPaths> + <sonar.coverage.jacoco.xmlReportPaths>${project.reporting.outputDirectory}/jaco...
Unrelated change?
timefold-solver
github_2023
java
284
TimefoldAI
triceo
@@ -148,20 +152,48 @@ DetermineIfNativeBuildItem ifNativeBuild() { } @BuildStep(onlyIf = IsDevelopment.class) - public DevConsoleRuntimeTemplateInfoBuildItem getSolverConfig(SolverConfigBuildItem solverConfigBuildItem, - CurateOutcomeBuildItem curateOutcomeBuildItem) { + @Record(STATIC_INIT...
Shall we make it "Timefold Solver"? That way, it'd be consistent with what the project is actually called.
timefold-solver
github_2023
javascript
284
TimefoldAI
triceo
@@ -0,0 +1,61 @@ +import {css, html, LitElement} from 'lit'; +import {JsonRpc} from 'jsonrpc'; +import '@vaadin/icon'; +import '@vaadin/button'; +import {until} from 'lit/directives/until.js'; +import '@vaadin/grid'; +import '@vaadin/grid/vaadin-grid-sort-column.js'; + +export class ConfigComponent extends LitElement {...
Timefold Solver?
timefold-solver
github_2023
javascript
284
TimefoldAI
triceo
@@ -0,0 +1,76 @@ +import {css, html, LitElement} from 'lit'; +import {JsonRpc} from 'jsonrpc'; +import '@vaadin/icon'; +import '@vaadin/button'; +import {until} from 'lit/directives/until.js'; +import '@vaadin/grid'; +import {columnBodyRenderer} from '@vaadin/grid/lit.js'; +import '@vaadin/grid/vaadin-grid-sort-column....
Dtto.
timefold-solver
github_2023
javascript
284
TimefoldAI
triceo
@@ -0,0 +1,104 @@ +import {css, html, LitElement} from 'lit'; +import {JsonRpc} from 'jsonrpc'; +import '@vaadin/icon'; +import '@vaadin/button'; +import {until} from 'lit/directives/until.js'; +import '@vaadin/grid'; +import {columnBodyRenderer} from '@vaadin/grid/lit.js'; +import '@vaadin/grid/vaadin-grid-sort-column...
Dtto.
timefold-solver
github_2023
java
284
TimefoldAI
triceo
@@ -57,51 +46,28 @@ void testSolverConfigPage() throws ParserConfigurationException, SAXException, I } @Test - void testModelPage() throws ParserConfigurationException, SAXException, IOException { - String body = RestAssured.get(getPage("model")) - .then() - .extract(...
I'd use the `class.getCanonicalName()` throughout this test, to make this safe for refactoring.
timefold-solver
github_2023
others
258
TimefoldAI
rsynek
@@ -86,25 +91,13 @@ jobs: out/jreleaser/trace.log out/jreleaser/output.properties + # Pull Request will be created with the changes and a summary of next steps. - name: Set micro snapshot version on the release branch
```suggestion - name: Put back the 999-SNAPSHOT version on the release branch ```
timefold-solver
github_2023
others
258
TimefoldAI
rsynek
@@ -86,25 +91,13 @@ jobs: out/jreleaser/trace.log out/jreleaser/output.properties + # Pull Request will be created with the changes and a summary of next steps. - name: Set micro snapshot version on the release branch run: | git checkout -B ${{ github.event.in...
```suggestion git checkout -B ${{ github.event.inputs.releaseBranch }}-put-back-999-snapshot ```
timefold-solver
github_2023
others
258
TimefoldAI
rsynek
@@ -86,25 +91,13 @@ jobs: out/jreleaser/trace.log out/jreleaser/output.properties + # Pull Request will be created with the changes and a summary of next steps. - name: Set micro snapshot version on the release branch run: | git checkout -B ${{ github.event.in...
```suggestion git push origin ${{ github.event.inputs.releaseBranch }}-put-back-999-snapshot ```
timefold-solver
github_2023
others
258
TimefoldAI
rsynek
@@ -86,25 +91,13 @@ jobs: out/jreleaser/trace.log out/jreleaser/output.properties + # Pull Request will be created with the changes and a summary of next steps. - name: Set micro snapshot version on the release branch run: | git checkout -B ${{ github.event.in...
```suggestion gh pr create --reviewer triceo --base ${{ github.event.inputs.releaseBranch }} --head ${{ github.event.inputs.releaseBranch }}-put-back-999-snapshot --title "build: move back to 999-SNAPSHOT" --body-file .github/workflows/release-pr-body.md ```
timefold-solver
github_2023
java
257
TimefoldAI
rsynek
@@ -15,15 +16,27 @@ public final class ReflectionBeanPropertyMemberAccessor extends AbstractMemberAc private final Class<?> propertyType; private final String propertyName; private final Method getterMethod; + private final MethodHandle getherMethodHandle; private final Method setterMethod; + ...
There is also `unreflectGetter` and `unreflectSetter`, but these operate on `Field` instances, while here we already have the method.
timefold-solver
github_2023
java
254
TimefoldAI
triceo
@@ -42,6 +43,7 @@ public MultipleDelegateList(List<T>... delegates) { } this.totalSize = sizeSoFar; + this.cachedRebaseResult = null;
Maybe add a comment here as to why it's safe to store this here?
timefold-solver
github_2023
java
243
TimefoldAI
rsynek
@@ -525,15 +529,56 @@ private GeneratedGizmoClasses generateDomainAccessors(SolverConfig solverConfig, Set<String> generatedMemberAccessorsClassNameSet = new HashSet<>(); Set<String> gizmoSolutionClonerClassNameSet = new HashSet<>(); + /* + * TODO consistently change the name "entity"...
Nice; sometimes I forget we are already past Java 15.
timefold-solver
github_2023
java
243
TimefoldAI
rsynek
@@ -525,15 +529,56 @@ private GeneratedGizmoClasses generateDomainAccessors(SolverConfig solverConfig, Set<String> generatedMemberAccessorsClassNameSet = new HashSet<>(); Set<String> gizmoSolutionClonerClassNameSet = new HashSet<>(); + /* + * TODO consistently change the name "entity"...
What exactly does it enhance? Only things that may change during solving (solution, genuine and shadow entities) or even facts? Trying to figure out what the name should be.
timefold-solver
github_2023
others
240
TimefoldAI
rsynek
@@ -329,17 +334,6 @@ <newArtifacts> <artifact>${project.groupId}:${project.artifactId}:${project.version}</artifact> </newArtifacts> - <!-- By default revapi will check the oldArtifact against the currently executed build --> - <analysisConfigurationFiles> ...
Is this configuration no longer relevant?
timefold-solver
github_2023
java
240
TimefoldAI
rsynek
@@ -178,7 +178,6 @@ private boolean isScoreCalculationDefined(SolverConfig solverConfig) { } return scoreDirectorFactoryConfig.getEasyScoreCalculatorClass() != null || scoreDirectorFactoryConfig.getIncrementalScoreCalculatorClass() != null || - scoreDirectorFactoryConfi...
Good catch
timefold-solver
github_2023
others
240
TimefoldAI
rsynek
@@ -72,6 +72,12 @@ <plugin> <groupId>org.revapi</groupId> <artifactId>revapi-maven-plugin</artifactId> + <configuration> + <analysisConfigurationFiles> + <file>${project.basedir}/src/build/revapi-filter.json</file> + <file>${project.basedir}/src/build/revap...
Why not define this config in the build parent pom.xml?
timefold-solver
github_2023
javascript
216
TimefoldAI
rsynek
@@ -26,30 +26,69 @@ function replaceTimefoldAutoHeaderFooter() { <div class="me-auto"><a class="text-white" href="https://timefold.ai/product/support/">Support</a></div> </div> </div> + <div id="applicationInfo" class="container text-center"></div> </footer>...
Maybe remove the prefix, see https://github.com/TimefoldAI/timefold-platform/pull/61#discussion_r1294405188
timefold-solver
github_2023
others
206
TimefoldAI
rsynek
@@ -81,4 +81,42 @@ </plugin> </plugins> </build> + + <profiles> + <profile> + <!-- + Benchmarker is not supported in native. + However, Quarkus 3.2.4+ seems to have an issue where the native profile, + if present on another unrelated module, is magically and wrongly inherite...
Good as a temporary workaround, but please at least file an issue to investigate this further. Ideally, this should be reported to Quarkus. If this module is not supposed to work in native, we should not lose time by native compilation in every CI run.
timefold-solver
github_2023
others
193
TimefoldAI
rsynek
@@ -23,7 +23,7 @@ <!--</appender>--> <!-- To override the debug log level from the command line, use the VM option "-Dlogback.level.ai.timefold.solver=trace" --> - <logger name="ai.timefold.solver" level="${logback.level.ai.timefold.solver:-debug}"/> + <logger name="ai.timefold.solver" level="${logback.level....
Intentional?
timefold-solver
github_2023
java
193
TimefoldAI
rsynek
@@ -96,7 +96,22 @@ public T next() { @Override public String toString() { - return "size = " + size; + switch (size) { + case 0 -> { + return "[]"; + } + case 1 -> { + return "[" + first.getElement() + "]"; + } + ...
What is the typical and maximal length of this list?
timefold-solver
github_2023
others
193
TimefoldAI
rsynek
@@ -458,6 +458,55 @@ stream), use <<constraintStreamsConditionalPropagation,ifExists>> instead. It does not create cartesian products and therefore generally performs better. ==== +==== Evaluation of multiple joiners + +When using multiple joiners, there are some important considerations to keep in mind: + +[source...
```suggestion However, both of the key mapping functions are calculated independently of the other, ```
timefold-solver
github_2023
others
193
TimefoldAI
rsynek
@@ -458,6 +458,55 @@ stream), use <<constraintStreamsConditionalPropagation,ifExists>> instead. It does not create cartesian products and therefore generally performs better. ==== +==== Evaluation of multiple joiners + +When using multiple joiners, there are some important considerations to keep in mind: + +[source...
Consistency: ```suggestion When indexing joiners (such as `equal()` and `lessThan()`) check their indexes, ```
timefold-solver
github_2023
java
193
TimefoldAI
rsynek
@@ -0,0 +1,216 @@ +package ai.timefold.solver.constraint.streams.bavet.common; + +import java.util.ArrayList; +import java.util.BitSet; +import java.util.List; +import java.util.function.Consumer; + +import ai.timefold.solver.constraint.streams.bavet.common.AbstractPropagationMetadataCarrier.PropagationType; +import ai...
I think this class (and the Static one, too) is complex enough to deserve unit tests.
timefold-solver
github_2023
java
193
TimefoldAI
rsynek
@@ -0,0 +1,93 @@ +package ai.timefold.solver.constraint.streams.bavet.common; + +import ai.timefold.solver.constraint.streams.bavet.common.tuple.AbstractTuple; +import ai.timefold.solver.constraint.streams.bavet.common.tuple.TupleState; + +final class Group<OutTuple_ extends AbstractTuple, ResultContainer_> + ex...
Perhaps `GroupDataWithKeyAndAccumulate` is more descriptive?
timefold-solver
github_2023
java
193
TimefoldAI
rsynek
@@ -0,0 +1,361 @@ +package ai.timefold.solver.constraint.streams.bavet; + +import static ai.timefold.solver.core.api.score.stream.Joiners.filtering; + +import ai.timefold.solver.constraint.streams.common.AbstractConstraintStreamTest; +import ai.timefold.solver.core.api.score.buildin.simple.SimpleScore; +import ai.timef...
Does this note still apply?
timefold-solver
github_2023
java
193
TimefoldAI
rsynek
@@ -181,82 +184,74 @@ public void update(InTuple_ tuple) { undoAccumulator.run(); } - GroupKey_ oldUserSuppliedGroupKey = extractUserSuppliedKey(oldGroup.groupKey); - GroupKey_ newUserSuppliedGroupKey = hasMultipleGroups ? groupKeyFunction.apply(tuple) : null; + var oldUserS...
Don't we need to set the tuple state to UPDATING anymore?