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
others
867
TimefoldAI
zepfred
@@ -75,9 +75,24 @@ $ git clone {quickstarts-clone-url} To complete this guide, you need: +[tabs] +==== +Java / Kotlin:: ++ +-- * https://adoptopenjdk.net/[JDK] {java-version}+ with `JAVA_HOME` configured appropriately * https://maven.apache.org/download.html[Apache Maven] {maven-version}+ or https://gradle.org/i...
```suggestion * An IDE, such as https://www.jetbrains.com/pycharm/[IntelliJ PyCharm], https://code.visualstudio.com[VSCode] or https://www.eclipse.org[Eclipse] ```
timefold-solver
github_2023
others
841
TimefoldAI
zepfred
@@ -0,0 +1,200 @@ +[#loadBalancingAndFairness] += Load balancing and fairness +:doctype: book +:sectnums: +:icons: font + +Load balancing is a common constraint for many Timefold Solver use cases. +Especially when scheduling employees, the workload needs to be spread out fairly; +there may even be legal requirements to...
```suggestion == What is fair? ```
timefold-solver
github_2023
java
841
TimefoldAI
Christopher-Chianelli
@@ -0,0 +1,62 @@ +package ai.timefold.solver.core.impl.score.stream.collector; + +import java.math.BigDecimal; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Objects; + +public final class LoadBalanceCalculator implements ObjectCalculator<Object, BigDecimal> {
So, if I am reading this correctly, this does `sqrt(sum(count^2))`? This has the consequence that a "fair" schedule result increases as the number of shifts increases: Assume two employees, and a perfectly fair schedule, a perfectly fair schedule that is off by one, and a completely unfair schedule. Then these wil...
timefold-solver
github_2023
java
841
TimefoldAI
Christopher-Chianelli
@@ -0,0 +1,62 @@ +package ai.timefold.solver.core.impl.score.stream.collector; + +import java.math.BigDecimal; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Objects; + +public final class LoadBalanceCalculator implements ObjectCalculator<Object, BigDecimal> { + + private final Map<Object,...
How does this handle "load balance by minutes worked"?
timefold-solver
github_2023
java
831
TimefoldAI
triceo
@@ -86,10 +86,6 @@ public final void retractLeft(LeftTuple_ tuple) { return; } TupleState state = outTuple.state; - if (!state.isActive()) { - throw new IllegalStateException("Impossible state: The tuple (" + outTuple.state + ") in node (" + this - + "...
Let's keep the condition, but return from it. Keep a comment explaining the situation where this happens. Dtto. below.
timefold-solver
github_2023
java
830
TimefoldAI
zepfred
@@ -73,11 +71,11 @@ public Result_ result() { if (propertyToItemCountMap.isEmpty()) { return null; } - return isMin ? getFirstKey(propertyToItemCountMap.firstEntry().getValue()) - : getFirstKey(propertyToItemCountMap.lastEntry().getValue()); + var itemCount = ...
Nice!
timefold-solver
github_2023
java
830
TimefoldAI
zepfred
@@ -1,22 +1,21 @@ package ai.timefold.solver.core.impl.score.stream.collector; import java.util.Comparator; -import java.util.LinkedHashMap; -import java.util.Map; import java.util.NavigableMap; import java.util.TreeMap; import java.util.function.Function; import ai.timefold.solver.core.impl.util.ConstantLamb...
Do we have tests covering this class?
timefold-solver
github_2023
others
809
TimefoldAI
triceo
@@ -140,6 +140,43 @@ public class Lesson { ---- +==== + +''' + +=== Upgrade from 1.9.0 to 1.10.0
This doesn't belong here, it's already above.
timefold-solver
github_2023
java
800
TimefoldAI
triceo
@@ -1955,6 +1957,263 @@ public static <A, ResultContainer_, Result_> UniConstraintCollector<A, ResultCon return InnerQuadConstraintCollectors.toConsecutiveSequences(resultMap, indexMap); } + // ***************************************************************** + // concurrentUsage + // *********...
Looking at the example, shouldn't the `to` rather be exclusive? Java APIs concerning ranges typically follow conventions `[min, max)`.
timefold-solver
github_2023
java
800
TimefoldAI
triceo
@@ -1,11 +1,15 @@ -package ai.timefold.solver.examples.common.experimental.api; +package ai.timefold.solver.core.api.score.stream.common; -public interface IntervalCluster<Interval_, Point_ extends Comparable<Point_>, Difference_ extends Comparable<Difference_>> +public interface ConcurrentUsage<Interval_, Point_ ext...
The first method speak of overlap. The other two methods speak of concurrent usage. We should standardize this; personally, `minimumOverlap` is more self-explanatory to me.
timefold-solver
github_2023
java
800
TimefoldAI
triceo
@@ -0,0 +1,16 @@ +package ai.timefold.solver.core.api.score.stream.common; + +public interface ConcurrentUsageInfo<Interval_, Point_ extends Comparable<Point_>, Difference_ extends Comparable<Difference_>> { + + /** + * @return never null, an iterable that iterates through the interval clusters + * c...
This, in my opinion, is another place where the new name "concurrent usage" doesn't really work. "get concurrent usages" sounds to me a bit like something a non-native speaker would produce. Overlapping intervals probably wasn't ideal either. How about overlapping ranges?
timefold-solver
github_2023
java
800
TimefoldAI
triceo
@@ -0,0 +1,16 @@ +package ai.timefold.solver.core.api.score.stream.common; + +public interface ConcurrentUsageInfo<Interval_, Point_ extends Comparable<Point_>, Difference_ extends Comparable<Difference_>> { + + /** + * @return never null, an iterable that iterates through the interval clusters + * c...
Just out of curiosity... can you think of a term for a "break" inbetween two ranges of numbers? I'm thinking maybe maths has a term for this.
timefold-solver
github_2023
java
800
TimefoldAI
triceo
@@ -11,21 +11,21 @@ public interface IntervalBreak<Interval_, Point_ extends Comparable<Point_>, Dif /** * @return never null, the interval cluster leading directly into this */ - IntervalCluster<Interval_, Point_, Difference_> getPreviousIntervalCluster(); + ConcurrentUsage<Interval_, Point_, Di...
getPreviousRange?
timefold-solver
github_2023
java
800
TimefoldAI
triceo
@@ -11,21 +11,21 @@ public interface IntervalBreak<Interval_, Point_ extends Comparable<Point_>, Dif /** * @return never null, the interval cluster leading directly into this */ - IntervalCluster<Interval_, Point_, Difference_> getPreviousIntervalCluster(); + ConcurrentUsage<Interval_, Point_, Di...
If we're changing the difference function to be `[start, end)`, we should consider changing this too.
timefold-solver
github_2023
java
800
TimefoldAI
triceo
@@ -0,0 +1,49 @@ +package ai.timefold.solver.core.impl.score.stream.collector.bi; + +import java.util.Objects; +import java.util.function.BiFunction; +import java.util.function.Function; +import java.util.function.Supplier; + +import ai.timefold.solver.core.api.score.stream.common.ConcurrentUsageInfo; +import ai.timefo...
Let's start learning the "new" equals... return o instanceof ConcurrentUsageBiConstraintCollector<?, ?, ?, ?, ?> that && Objects.equals(startMap, that.startMap) && ... People have started showing that the JVM doesn't really like the way everyone typically does equals.
timefold-solver
github_2023
java
800
TimefoldAI
triceo
@@ -1,24 +1,29 @@ -package ai.timefold.solver.examples.common.experimental.impl; +package ai.timefold.solver.core.impl.score.stream.collector.connectedRanges;
I'd go for just `ranges` - we generally don't do camel case in package names.
timefold-solver
github_2023
java
800
TimefoldAI
triceo
@@ -1955,6 +1957,263 @@ public static <A, ResultContainer_, Result_> UniConstraintCollector<A, ResultCon return InnerQuadConstraintCollectors.toConsecutiveSequences(resultMap, indexMap); } + // ***************************************************************** + // toConnectedRanges + // *******...
```suggestion toConnectedTemporalRanges(Function<A, PointType_> startMap, Function<A, PointType_> endMap) { ``` Reads better to me.
timefold-solver
github_2023
java
800
TimefoldAI
triceo
@@ -235,20 +239,39 @@ void removeInterval(Interval<Interval_, Point_> interval) { } @Override - public Iterable<IntervalCluster<Interval_, Point_, Difference_>> getIntervalClusters() { + public Iterable<ConnectedRange<Interval_, Point_, Difference_>> getConnectedRanges() { return (Iterable) c...
Please fix naming. Possibly in the entire PR; speaks of clusters, but there no longer is any such class.
timefold-solver
github_2023
java
800
TimefoldAI
triceo
@@ -0,0 +1,212 @@ +package ai.timefold.solver.core.impl.score.stream.collector.connected_ranges; + +import java.util.Iterator; +import java.util.NavigableSet; +import java.util.Objects; +import java.util.function.BiFunction; + +import ai.timefold.solver.core.api.score.stream.common.ConnectedRange; + +final class Connec...
For the sake of bravity, I'd prefer this.startSplitPoint = Objects.requireNonNull(start, "start");
timefold-solver
github_2023
java
800
TimefoldAI
triceo
@@ -3,24 +3,24 @@ import ai.timefold.solver.core.api.score.stream.common.ConnectedRange; import ai.timefold.solver.core.api.score.stream.common.RangeGap; -final class RangeGapImpl<Interval_, Point_ extends Comparable<Point_>, Difference_ extends Comparable<Difference_>> +final class RangeGapImpl<Range_, Point_ exte...
Still clusters throughout this file.
timefold-solver
github_2023
java
786
TimefoldAI
Christopher-Chianelli
@@ -81,17 +38,17 @@ public LookUpStrategyResolver(DescriptorPolicy descriptorPolicy, LookUpStrategyT */ public LookUpStrategy determineLookUpStrategy(Object object) { return decisionCache.computeIfAbsent(object.getClass(), objectClass -> { - if (objectClass.isEnum()) { + if (De...
I think value ranges that return arrays are rare, but probably not impossible. Arrays are mutable though, and may contain reference to mutable values (i.e. PlanningEntities).
timefold-solver
github_2023
java
779
TimefoldAI
zepfred
@@ -28,31 +29,44 @@ * @param <Solution_> the solution type, the class with the {@link PlanningSolution} annotation */ public class SolverScope<Solution_> { - protected Set<SolverMetric> solverMetricSet; - protected Tags monitoringTags; - protected int startingSolverCount; - protected Random workingRand...
It seems off to have a method before the variable definitions. I suggest to move it after the constructor.
timefold-solver
github_2023
others
772
TimefoldAI
rsynek
@@ -29,22 +29,24 @@ jobs: # Clone timefold-quickstarts # Need to check for stale repo, since Github is not aware of the build chain and therefore doesn't automate it. - - name: Find the proper timefold-quickstarts repo and branch - env: - CHAIN_USER: ${{ github.actor }} - C...
Perhaps: ```suggestion - name: Checkout timefold-quickstarts (development) # Checkout the development branch if the PR branch does not exist ```
timefold-solver
github_2023
java
767
TimefoldAI
zepfred
@@ -0,0 +1,180 @@ +package ai.timefold.solver.core.config.heuristic.selector.move; + +import java.util.Random; + +import ai.timefold.solver.core.config.heuristic.selector.common.nearby.NearbySelectionConfig; +import ai.timefold.solver.core.config.heuristic.selector.entity.EntitySelectorConfig; +import ai.timefold.solve...
```suggestion ```
timefold-solver
github_2023
java
767
TimefoldAI
zepfred
@@ -0,0 +1,180 @@ +package ai.timefold.solver.core.config.heuristic.selector.move; + +import java.util.Random; + +import ai.timefold.solver.core.config.heuristic.selector.common.nearby.NearbySelectionConfig; +import ai.timefold.solver.core.config.heuristic.selector.entity.EntitySelectorConfig; +import ai.timefold.solve...
```suggestion return nearbyConfig.withEntitySelectorConfig(entityConfig) ```
timefold-solver
github_2023
java
767
TimefoldAI
zepfred
@@ -0,0 +1,180 @@ +package ai.timefold.solver.core.config.heuristic.selector.move; + +import java.util.Random; + +import ai.timefold.solver.core.config.heuristic.selector.common.nearby.NearbySelectionConfig; +import ai.timefold.solver.core.config.heuristic.selector.entity.EntitySelectorConfig; +import ai.timefold.solve...
Let's inline the returning operation for the existing methods.
timefold-solver
github_2023
java
767
TimefoldAI
zepfred
@@ -0,0 +1,19 @@ +package ai.timefold.solver.core.config.heuristic.selector.move; + +import java.util.Random; + +import ai.timefold.solver.core.impl.heuristic.selector.common.nearby.NearbyDistanceMeter; + +/** + * General superclass for move selectors that support Nearby Selection autoconfiguration in construction heur...
I'm unsure if it is a good idea for this interface to extend `NearbyAutoConfigurationMoveSelectorConfig`. I am aware that multiple inheritance is not supported, so I suggest converting the classes `NearbyConstructionHeuristicAutoConfigurationMoveSelectorConfig` and `NearbyAutoConfigurationMoveSelectorConfig` into inter...
timefold-solver
github_2023
java
767
TimefoldAI
zepfred
@@ -56,6 +56,13 @@ public ConstructionHeuristicPhase<Solution_> buildPhase(int phaseIndex, Heuristi ValueSorterManner valueSorterManner = Objects.requireNonNullElse(
Maybe remove valueSorterManner from your construction heuristics settings?
timefold-solver
github_2023
java
766
TimefoldAI
triceo
@@ -330,6 +331,21 @@ Some solver configs (%s) don't specify a %s class, yet there are multiple availa assertTargetClasses(targetList, DotNames.PLANNING_SOLUTION); } + private void assertNodeSharingDisabled(Map<String, SolverConfig> solverConfigMap) { + for (var entry : solverConfigMap.entrySet...
You probably wanted to get the string on a single line, but I don't think it's necessary. In fact, the suggestion typically follows on the second line; in which case, you can use the raw string and can avoid the parens and the concat.
timefold-solver
github_2023
java
758
TimefoldAI
triceo
@@ -176,28 +189,28 @@ private void assertJustification(String message, ConstraintJustification... just throw new AssertionError(assertionMessage); } - List<Object> noneMatchedList = new LinkedList<>(); - List<Object> invalidMatchList = new LinkedList<>(); + List<Object> expe...
Let's use `ArrayList` exclusively. `LinkedList` theoretically has some advantages, but practically, it has none. This doesn't exactly match our use case, but it does a good job of explaining why the reasons people like LinkedList are actually kinda false: https://kjellkod.wordpress.com/2012/02/25/why-you-should-n...
timefold-solver
github_2023
java
761
TimefoldAI
triceo
@@ -204,6 +204,20 @@ public static <T> List<T> inheritMergeableListProperty(List<T> originalList, Lis } } + public static <T> List<T> inheritUniqueMergeableListProperty(List<T> originalList, List<T> inheritedList) { + if (inheritedList == null) { + return originalList; + } el...
I think it'd read easier if it were instead: Set<T> mergedSet = new LinkedHashSet<>(originalList); mergedSet.addAll(inheritedList); return new ArrayList<>(mergedSet); Maintains insertion order, doesn't need to use any streams, and absolute efficiency is not required here.
timefold-solver
github_2023
java
759
TimefoldAI
zepfred
@@ -52,39 +52,45 @@ public boolean isEntityIndependent() { @Override public ValueRange<?> extractValueRange(Solution_ solution, Object entity) { - List<CountableValueRange<?>> childValueRangeList = new ArrayList<>(childValueRangeDescriptorList.size()); - for (ValueRangeDescriptor<Solution_> va...
Do we have tests to validate the changes?
timefold-solver
github_2023
java
755
TimefoldAI
zepfred
@@ -29,14 +30,35 @@ public abstract class AbstractPhaseScope<Solution_> { protected int bestSolutionStepIndex; - public AbstractPhaseScope(SolverScope<Solution_> solverScope) { + /** + * As defined by #AbstractPhaseScope(SolverScope, boolean), + * with the phaseSendsBestSolutionEvents parameter s...
Should we use the default nomenclature `isPhaseSendsBestSolutionEvents`?
timefold-solver
github_2023
java
755
TimefoldAI
zepfred
@@ -8,20 +8,19 @@ import ai.timefold.solver.core.impl.solver.scope.SolverScope; import ai.timefold.solver.core.impl.solver.thread.ChildThreadType; -public class BestScoreFeasibleTermination<Solution_> extends AbstractTermination<Solution_> { +public final class BestScoreFeasibleTermination<Solution_> extends Abstra...
```suggestion "The timeGradientWeightNumbers (%s)'s length (%d) is not 1 less than the feasibleLevelsSize (%d)." ```
timefold-solver
github_2023
java
755
TimefoldAI
zepfred
@@ -56,7 +56,7 @@ public double calculatePhaseTimeGradient(AbstractPhaseScope<Solution_> phaseScop return calculateTimeGradient(phaseTimeMillisSpent); } - protected double calculateTimeGradient(long timeMillisSpent) { + private double calculateTimeGradient(long timeMillisSpent) {
Let's use the `var` keyword as we did in other classes.
timefold-solver
github_2023
java
755
TimefoldAI
zepfred
@@ -36,7 +32,7 @@ public boolean isPhaseTerminated(AbstractPhaseScope<Solution_> phaseScope) { return unimprovedStepCount >= unimprovedStepCountLimit; } - protected int calculateUnimprovedStepCount(AbstractPhaseScope<Solution_> phaseScope) { + private static int calculateUnimprovedStepCount(Abstra...
Let's use the `var` keyword as we did in other classes.
timefold-solver
github_2023
java
755
TimefoldAI
zepfred
@@ -127,18 +139,24 @@ protected boolean isTerminated(long safeTimeMillis) { @Override public double calculateSolverTimeGradient(SolverScope<Solution_> solverScope) { + if (!currentPhaseSendsBestSolutionEvents) { + return 0.0; + } return calculateTimeGradient(solverSafeTimeM...
```suggestion private double calculateTimeGradient(long safeTimeMillis) { if (!currentPhaseSendsBestSolutionEvents) { return 0.0; } ```
timefold-solver
github_2023
java
755
TimefoldAI
zepfred
@@ -127,18 +139,24 @@ protected boolean isTerminated(long safeTimeMillis) { @Override public double calculateSolverTimeGradient(SolverScope<Solution_> solverScope) { + if (!currentPhaseSendsBestSolutionEvents) {
```suggestion ```
timefold-solver
github_2023
java
755
TimefoldAI
zepfred
@@ -127,18 +139,24 @@ protected boolean isTerminated(long safeTimeMillis) { @Override public double calculateSolverTimeGradient(SolverScope<Solution_> solverScope) { + if (!currentPhaseSendsBestSolutionEvents) { + return 0.0; + } return calculateTimeGradient(solverSafeTimeM...
```suggestion ```
timefold-solver
github_2023
java
755
TimefoldAI
zepfred
@@ -127,18 +139,24 @@ protected boolean isTerminated(long safeTimeMillis) { @Override public double calculateSolverTimeGradient(SolverScope<Solution_> solverScope) { + if (!currentPhaseSendsBestSolutionEvents) { + return 0.0;
```suggestion ```
timefold-solver
github_2023
java
755
TimefoldAI
zepfred
@@ -127,18 +139,24 @@ protected boolean isTerminated(long safeTimeMillis) { @Override public double calculateSolverTimeGradient(SolverScope<Solution_> solverScope) { + if (!currentPhaseSendsBestSolutionEvents) { + return 0.0; + }
```suggestion ```
timefold-solver
github_2023
java
755
TimefoldAI
zepfred
@@ -29,26 +31,50 @@ public long getUnimprovedTimeMillisSpentLimit() { return unimprovedTimeMillisSpentLimit; } + @Override + public void phaseStarted(AbstractPhaseScope<Solution_> phaseScope) { + /* + * Construction heuristics and similar phases only trigger best solution events at ...
```suggestion if (!currentPhaseSendsBestSolutionEvents) { return false; } return getUnimprovedTimeMillisSpent(bestSolutionTimeMillis) >= unimprovedTimeMillisSpentLimit; ```
timefold-solver
github_2023
java
755
TimefoldAI
zepfred
@@ -29,26 +31,50 @@ public long getUnimprovedTimeMillisSpentLimit() { return unimprovedTimeMillisSpentLimit; } + @Override + public void phaseStarted(AbstractPhaseScope<Solution_> phaseScope) { + /* + * Construction heuristics and similar phases only trigger best solution events at ...
```suggestion ```
timefold-solver
github_2023
java
755
TimefoldAI
zepfred
@@ -29,26 +31,50 @@ public long getUnimprovedTimeMillisSpentLimit() { return unimprovedTimeMillisSpentLimit; } + @Override + public void phaseStarted(AbstractPhaseScope<Solution_> phaseScope) { + /* + * Construction heuristics and similar phases only trigger best solution events at ...
```suggestion ```
timefold-solver
github_2023
java
755
TimefoldAI
zepfred
@@ -29,26 +31,50 @@ public long getUnimprovedTimeMillisSpentLimit() { return unimprovedTimeMillisSpentLimit; } + @Override + public void phaseStarted(AbstractPhaseScope<Solution_> phaseScope) { + /* + * Construction heuristics and similar phases only trigger best solution events at ...
```suggestion ```
timefold-solver
github_2023
java
755
TimefoldAI
zepfred
@@ -29,26 +31,50 @@ public long getUnimprovedTimeMillisSpentLimit() { return unimprovedTimeMillisSpentLimit; } + @Override + public void phaseStarted(AbstractPhaseScope<Solution_> phaseScope) { + /* + * Construction heuristics and similar phases only trigger best solution events at ...
```suggestion ```
timefold-solver
github_2023
java
755
TimefoldAI
zepfred
@@ -29,26 +31,50 @@ public long getUnimprovedTimeMillisSpentLimit() { return unimprovedTimeMillisSpentLimit; } + @Override + public void phaseStarted(AbstractPhaseScope<Solution_> phaseScope) { + /* + * Construction heuristics and similar phases only trigger best solution events at ...
```suggestion ```
timefold-solver
github_2023
java
755
TimefoldAI
zepfred
@@ -29,26 +31,50 @@ public long getUnimprovedTimeMillisSpentLimit() { return unimprovedTimeMillisSpentLimit; } + @Override + public void phaseStarted(AbstractPhaseScope<Solution_> phaseScope) { + /* + * Construction heuristics and similar phases only trigger best solution events at ...
```suggestion ```
timefold-solver
github_2023
java
755
TimefoldAI
zepfred
@@ -104,20 +110,26 @@ public void stepEnded(AbstractStepScope<Solution_> stepScope) { @Override public boolean isSolverTerminated(SolverScope<Solution_> solverScope) { + if (!currentPhaseSendsBestSolutionEvents) { + return false; + } return isTerminated(solverSafeTimeMillis...
```suggestion if (!currentPhaseSendsBestSolutionEvents) { return false; } var now = clock.millis(); ```
timefold-solver
github_2023
java
755
TimefoldAI
zepfred
@@ -104,20 +110,26 @@ public void stepEnded(AbstractStepScope<Solution_> stepScope) { @Override public boolean isSolverTerminated(SolverScope<Solution_> solverScope) { + if (!currentPhaseSendsBestSolutionEvents) {
```suggestion ```
timefold-solver
github_2023
java
755
TimefoldAI
zepfred
@@ -104,20 +110,26 @@ public void stepEnded(AbstractStepScope<Solution_> stepScope) { @Override public boolean isSolverTerminated(SolverScope<Solution_> solverScope) { + if (!currentPhaseSendsBestSolutionEvents) { + return false;
```suggestion ```
timefold-solver
github_2023
java
755
TimefoldAI
zepfred
@@ -104,20 +110,26 @@ public void stepEnded(AbstractStepScope<Solution_> stepScope) { @Override public boolean isSolverTerminated(SolverScope<Solution_> solverScope) { + if (!currentPhaseSendsBestSolutionEvents) { + return false; + }
```suggestion ```
timefold-solver
github_2023
java
755
TimefoldAI
zepfred
@@ -104,20 +110,26 @@ public void stepEnded(AbstractStepScope<Solution_> stepScope) { @Override public boolean isSolverTerminated(SolverScope<Solution_> solverScope) { + if (!currentPhaseSendsBestSolutionEvents) { + return false; + } return isTerminated(solverSafeTimeMillis...
```suggestion ```
timefold-solver
github_2023
java
755
TimefoldAI
zepfred
@@ -104,20 +110,26 @@ public void stepEnded(AbstractStepScope<Solution_> stepScope) { @Override public boolean isSolverTerminated(SolverScope<Solution_> solverScope) { + if (!currentPhaseSendsBestSolutionEvents) { + return false; + } return isTerminated(solverSafeTimeMillis...
```suggestion ```
timefold-solver
github_2023
java
755
TimefoldAI
zepfred
@@ -104,20 +110,26 @@ public void stepEnded(AbstractStepScope<Solution_> stepScope) { @Override public boolean isSolverTerminated(SolverScope<Solution_> solverScope) { + if (!currentPhaseSendsBestSolutionEvents) { + return false; + } return isTerminated(solverSafeTimeMillis...
```suggestion ```
timefold-solver
github_2023
java
755
TimefoldAI
zepfred
@@ -130,13 +120,124 @@ void scoreImprovesTooLate_terminates() { assertThat(termination.calculateSolverTimeGradient(solverScope)).isEqualTo(1.0, withPrecision(0.0)); // third step - score has improved beyond the threshold, but too late - when(clock.millis()).thenReturn(START_TIME_MILLIS + 1001...
Let's also check the condition the time runs out
timefold-solver
github_2023
java
755
TimefoldAI
zepfred
@@ -130,13 +120,124 @@ void scoreImprovesTooLate_terminates() { assertThat(termination.calculateSolverTimeGradient(solverScope)).isEqualTo(1.0, withPrecision(0.0)); // third step - score has improved beyond the threshold, but too late - when(clock.millis()).thenReturn(START_TIME_MILLIS + 1001...
Same as above
timefold-solver
github_2023
java
755
TimefoldAI
zepfred
@@ -25,37 +28,107 @@ void forNegativeUnimprovedTimeMillis_exceptionIsThrown() { @Test void solverTermination() { - SolverScope<TestdataSolution> solverScope = mock(SolverScope.class); + SolverScope<TestdataSolution> solverScope = spy(new SolverScope<>()); + AbstractPhaseScope<TestdataSo...
Nice tests!
timefold-solver
github_2023
others
755
TimefoldAI
zepfred
@@ -459,6 +459,13 @@ Just like <<timeMillisSpentTermination,time spent termination>>, combinations ar It is preffered to configure this termination on a specific `Phase` (such as ``<localSearch>``) instead of on the `Solver` itself. +Several phases, such as construction heuristics, do not count towards this termin...
```suggestion If such a phase is encountered, the termination is disabled and when the next phase is started, ```
timefold-solver
github_2023
java
714
TimefoldAI
triceo
@@ -173,7 +187,7 @@ public void writeToFile(Path parentFolder) { } public static final class Builder<X extends Number & Comparable<X>, Y extends Number & Comparable<Y>> { - + private static final int MAX_CHART_WIDTH = 1280;
Seems low, no? I'd increase it up to 4K width, which is 3840.
timefold-solver
github_2023
java
714
TimefoldAI
triceo
@@ -209,25 +223,35 @@ public LineChart<X, Y> build(String fileName, String title, String xLabel, Strin * This allows Chart.js to only draw the absolute minimum necessary points. */ data.values().forEach(map -> { - List<Map.Entry<X, Y>> entries = map.entrySet().str...
I'd really like us to start using `var` for these generic-heavy things. The declaration brings no additional context here. You already know it's a list (`toList()`) and you already know it is an entry (`entrySet()`).
timefold-solver
github_2023
java
714
TimefoldAI
triceo
@@ -209,25 +223,35 @@ public LineChart<X, Y> build(String fileName, String title, String xLabel, Strin * This allows Chart.js to only draw the absolute minimum necessary points. */ data.values().forEach(map -> { - List<Map.Entry<X, Y>> entries = map.entrySet().str...
Another great place for `var`. Makes the code much more readable. In fact, I'd go as far as saying that we should make `var` the default, and use the full type if we have a reason to do that.
timefold-solver
github_2023
others
714
TimefoldAI
triceo
@@ -34,7 +31,7 @@ var ${chartId} = new Chart(document.getElementById('${chartId}'), { borderWidth: 1 </#if>, data: [ - <#list dataset.data() as datum><#if datum??>${datum?cn}</#if><#sep>, </#sep></#list> + <#list chart.poin...
If I may recommend - don't touch the format of JS files. I spent days tweaking chart.js to avoid all of its bugs and quirks. Sometimes it required weird choices in data set format. Unless you want to manually check every single supported chart, including tooltips, scaling and different browsers, I recommend not touc...
timefold-solver
github_2023
others
714
TimefoldAI
triceo
@@ -0,0 +1 @@ +18479.00/-529067.00,18751.00/-528929.00,19215.00/-528612.00,19303.00/-528321.00,19953.00/-527645.00,20260.00/-527138.00,20713.00/-525693.00,21012.00/-525142.00,21256.00/-524264.00,21775.00/-523486.00,22214.00/-523138.00,22572.00/-522136.00,23041.00/-521110.00,23762.00/-519091.00,24210.00/-518093.00,24754...
Ideally this file would have the same format as the input files. And all those input files would be called not `.txt`, but `.csv`, because that is what they are - comma-separated values.
timefold-solver
github_2023
java
673
TimefoldAI
triceo
@@ -191,18 +198,112 @@ private UnionMoveSelectorConfig determineDefaultMoveSelectorConfig(HeuristicConf .filter(variableDescriptor -> !variableDescriptor.isListVariable()) .distinct() .toList(); + var hasChainedVariable = basicVariableDescriptorList.stream() + ...
I'm asking myself... if we're adding this move, why only for nearby? Does it make sense to add it for both?
timefold-solver
github_2023
java
673
TimefoldAI
triceo
@@ -191,18 +198,112 @@ private UnionMoveSelectorConfig determineDefaultMoveSelectorConfig(HeuristicConf .filter(variableDescriptor -> !variableDescriptor.isListVariable()) .distinct() .toList(); + var hasChainedVariable = basicVariableDescriptorList.stream() + ...
Same question here.
timefold-solver
github_2023
java
673
TimefoldAI
triceo
@@ -191,18 +198,112 @@ private UnionMoveSelectorConfig determineDefaultMoveSelectorConfig(HeuristicConf .filter(variableDescriptor -> !variableDescriptor.isListVariable()) .distinct() .toList(); + var hasChainedVariable = basicVariableDescriptorList.stream() + ...
How can this even happen? List and basic vars are mutually incompatible - so shouldn't this `else` branch fail fast instead? Or is there a place where this actually works?
timefold-solver
github_2023
java
673
TimefoldAI
triceo
@@ -191,18 +198,112 @@ private UnionMoveSelectorConfig determineDefaultMoveSelectorConfig(HeuristicConf .filter(variableDescriptor -> !variableDescriptor.isListVariable()) .distinct() .toList(); + var hasChainedVariable = basicVariableDescriptorList.stream() + ...
I'm thinking... I don't remember the specific behavior, but aren't these supposed to be unique? Maybe we want to generate the selector names with some randomness? `changeMoveSelector-f4edab` or something like that.
timefold-solver
github_2023
java
673
TimefoldAI
triceo
@@ -191,21 +199,137 @@ private UnionMoveSelectorConfig determineDefaultMoveSelectorConfig(HeuristicConf .filter(variableDescriptor -> !variableDescriptor.isListVariable()) .distinct() .toList(); + var hasChainedVariable = basicVariableDescriptorList.stream() + ...
```suggestion """ The configuration contains both basic and list variables, which makes it incompatible with using a top-level nearbyDistanceMeterClass (%s). Specify move selectors manually or remove the top-level nearbyDistanceMeterClass from y...
timefold-solver
github_2023
java
673
TimefoldAI
triceo
@@ -191,21 +199,137 @@ private UnionMoveSelectorConfig determineDefaultMoveSelectorConfig(HeuristicConf .filter(variableDescriptor -> !variableDescriptor.isListVariable()) .distinct() .toList(); + var hasChainedVariable = basicVariableDescriptorList.stream() + ...
I recommend turning the code for randomness into its own method - it is repeated far too often. Something like `addRandomSuffix(...)`. Also, any chance we could make this randomness deterministic, sharing a pre-determined random seed across all the invocations?
timefold-solver
github_2023
java
673
TimefoldAI
triceo
@@ -191,21 +199,137 @@ private UnionMoveSelectorConfig determineDefaultMoveSelectorConfig(HeuristicConf .filter(variableDescriptor -> !variableDescriptor.isListVariable()) .distinct() .toList(); + var hasChainedVariable = basicVariableDescriptorList.stream() + ...
The method is getting crazy long. I suggest we split it into parts - perhaps each of these inner-most branches gets its own method?
timefold-solver
github_2023
others
596
TimefoldAI
triceo
@@ -0,0 +1,52 @@ +//// +Quarkus and Spring Boot support the same configuration properties.
Good idea. One thing that's not entirely obvious to me is the `<solverName>` part. You explain it in another section, and that is fine. But do you ever mention that this is optional? That `<solverName>` can be exluded if you only ever inject one thing? I think this needs to be described in more detail, to give mo...
timefold-solver
github_2023
others
596
TimefoldAI
triceo
@@ -0,0 +1,52 @@ +//// +Quarkus and Spring Boot support the same configuration properties. +All the properties are in this file, which can then be included multiple times. +The {property_prefix} attribute is used for Quarkus properties. +//// + +{property_prefix}timefold.solver.<solverName>.solver-config-xml:: +A class...
What do you mean "optional"? If the property is not specified, but the file `solverConfig.xml` is still found, will it be used? And if the file is not found/not used, where do the defaults come frome? (I'm not saying we should _change_ existing behavior, but we should _describe_ it.)
timefold-solver
github_2023
others
596
TimefoldAI
triceo
@@ -0,0 +1,52 @@ +//// +Quarkus and Spring Boot support the same configuration properties. +All the properties are in this file, which can then be included multiple times. +The {property_prefix} attribute is used for Quarkus properties. +//// + +{property_prefix}timefold.solver.<solverName>.solver-config-xml:: +A class...
Could use a link to the chapter discussing those.
timefold-solver
github_2023
others
596
TimefoldAI
triceo
@@ -0,0 +1,52 @@ +//// +Quarkus and Spring Boot support the same configuration properties. +All the properties are in this file, which can then be included multiple times. +The {property_prefix} attribute is used for Quarkus properties. +//// + +{property_prefix}timefold.solver.<solverName>.solver-config-xml:: +A class...
Add a link to a chapter on solver configuration.
timefold-solver
github_2023
others
596
TimefoldAI
triceo
@@ -0,0 +1,52 @@ +//// +Quarkus and Spring Boot support the same configuration properties. +All the properties are in this file, which can then be included multiple times. +The {property_prefix} attribute is used for Quarkus properties. +//// + +{property_prefix}timefold.solver.<solverName>.solver-config-xml:: +A class...
Since this is for Spring Boot, I recommend adding a note on Gizmo limitations outside of Quarkus. If we have this in the docs already, a link will be enough. Otherwise we really should explain how GIZMO - for some minor performance benefits - requires you to open your domain model, making fields public.
timefold-solver
github_2023
others
596
TimefoldAI
triceo
@@ -0,0 +1,52 @@ +//// +Quarkus and Spring Boot support the same configuration properties. +All the properties are in this file, which can then be included multiple times. +The {property_prefix} attribute is used for Quarkus properties. +//// + +{property_prefix}timefold.solver.<solverName>.solver-config-xml:: +A class...
I am not entirely sure, but don't we support the ISO duration format [1] here? If so, we might as well provide a link. [1] https://www.digi.com/resources/documentation/digidocs/90001488-13/reference/r_iso_8601_duration_format.htm
timefold-solver
github_2023
others
596
TimefoldAI
triceo
@@ -0,0 +1,52 @@ +//// +Quarkus and Spring Boot support the same configuration properties. +All the properties are in this file, which can then be included multiple times. +The {property_prefix} attribute is used for Quarkus properties. +//// + +{property_prefix}timefold.solver.<solverName>.solver-config-xml:: +A class...
Dtto.
timefold-solver
github_2023
others
596
TimefoldAI
triceo
@@ -0,0 +1,52 @@ +//// +Quarkus and Spring Boot support the same configuration properties. +All the properties are in this file, which can then be included multiple times. +The {property_prefix} attribute is used for Quarkus properties. +//// + +{property_prefix}timefold.solver.<solverName>.solver-config-xml:: +A class...
I'd say "when a specific score (or better) has been reached".
timefold-solver
github_2023
others
596
TimefoldAI
triceo
@@ -0,0 +1,52 @@ +//// +Quarkus and Spring Boot support the same configuration properties. +All the properties are in this file, which can then be included multiple times. +The {property_prefix} attribute is used for Quarkus properties. +//// + +{property_prefix}timefold.solver.<solverName>.solver-config-xml:: +A class...
Is this true? Wow, I didn't know. Cool.
timefold-solver
github_2023
others
596
TimefoldAI
triceo
@@ -271,22 +271,743 @@ To use Timefold Solver with Quarkus, read the xref:quickstart/quarkus/quarkus-qu If you are starting a new project, visit the https://code.quarkus.io/[code.quarkus.io] and select the _Timefold AI constraint solver_ extension before generating your application. +=== Timefold configuration prop...
I'd call this "injecting managed resources".
timefold-solver
github_2023
others
596
TimefoldAI
triceo
@@ -271,22 +271,743 @@ To use Timefold Solver with Quarkus, read the xref:quickstart/quarkus/quarkus-qu If you are starting a new project, visit the https://code.quarkus.io/[code.quarkus.io] and select the _Timefold AI constraint solver_ extension before generating your application. +=== Timefold configuration prop...
Don't we have a list of score types elsewhere in the docs? If so, I'd just reference that. No point in duplicating content.
timefold-solver
github_2023
others
596
TimefoldAI
triceo
@@ -271,22 +271,743 @@ To use Timefold Solver with Quarkus, read the xref:quickstart/quarkus/quarkus-qu If you are starting a new project, visit the https://code.quarkus.io/[code.quarkus.io] and select the _Timefold AI constraint solver_ extension before generating your application. +=== Timefold configuration prop...
```suggestion (solution, entities, and constraint classes) and customized properties (`spent-limit`, `domain-access-type` etc.) for the ```
timefold-solver
github_2023
others
596
TimefoldAI
triceo
@@ -271,22 +271,743 @@ To use Timefold Solver with Quarkus, read the xref:quickstart/quarkus/quarkus-qu If you are starting a new project, visit the https://code.quarkus.io/[code.quarkus.io] and select the _Timefold AI constraint solver_ extension before generating your application. +=== Timefold configuration prop...
I am not entirely sure why we're selling this as multi-stage planning. This feature can be used for other uses as well. It is a generic feature. Personally, I'd remove references to multi-stage, turn it into a generic chapter on injecting multiple instances of `SolverManager`, and maybe mention in a note that this f...
timefold-solver
github_2023
others
596
TimefoldAI
triceo
@@ -271,22 +271,743 @@ To use Timefold Solver with Quarkus, read the xref:quickstart/quarkus/quarkus-qu If you are starting a new project, visit the https://code.quarkus.io/[code.quarkus.io] and select the _Timefold AI constraint solver_ extension before generating your application. +=== Timefold configuration prop...
```suggestion The different solver settings are configured in the `application.properties` file. For example, two different time settings for `spent-limit` are defined as follows: ```
timefold-solver
github_2023
others
596
TimefoldAI
triceo
@@ -271,22 +271,743 @@ To use Timefold Solver with Quarkus, read the xref:quickstart/quarkus/quarkus-qu If you are starting a new project, visit the https://code.quarkus.io/[code.quarkus.io] and select the _Timefold AI constraint solver_ extension before generating your application. +=== Timefold configuration prop...
```suggestion === Available configuration properties ``` This is the Timefold documentation. No need to repeat the name over and over; and even if that were necessary, it'd be `Timefold Solver`, not `Timefold`.
timefold-solver
github_2023
others
596
TimefoldAI
triceo
@@ -271,22 +271,743 @@ To use Timefold Solver with Quarkus, read the xref:quickstart/quarkus/quarkus-qu If you are starting a new project, visit the https://code.quarkus.io/[code.quarkus.io] and select the _Timefold AI constraint solver_ extension before generating your application. +=== Timefold configuration prop...
This is what I mean with the multi-stage planning. It's irrelevant to this comment - no matter if you use multi-stage or not, when injecting multiple `@Named` instances, you can only use the `SolverManager`.
timefold-solver
github_2023
others
596
TimefoldAI
triceo
@@ -271,22 +271,743 @@ To use Timefold Solver with Quarkus, read the xref:quickstart/quarkus/quarkus-qu If you are starting a new project, visit the https://code.quarkus.io/[code.quarkus.io] and select the _Timefold AI constraint solver_ extension before generating your application. +=== Timefold configuration prop...
I think you brought in the multi-stage planning because you needed a good use case for this feature. However, I think the example you ended up with may cause more confusion. I don't think we should be telling people to have two constraint providers, one for every part of a problem. (Even though a minority of users will...
timefold-solver
github_2023
others
596
TimefoldAI
triceo
@@ -271,22 +271,708 @@ To use Timefold Solver with Quarkus, read the xref:quickstart/quarkus/quarkus-qu If you are starting a new project, visit the https://code.quarkus.io/[code.quarkus.io] and select the _Timefold AI constraint solver_ extension before generating your application. +[#integrationWithQuarkusPropert...
Please change the ref to match the title.
timefold-solver
github_2023
others
596
TimefoldAI
triceo
@@ -0,0 +1,61 @@ +//// +Quarkus and Spring Boot support the same configuration properties. +All the properties are in this file, which can then be included multiple times. +The {property_prefix} attribute is used for Quarkus properties. +//// + +{property_prefix}timefold.solver.<solverName>.solver-config-xml::
I'm thinking... this is content duplication with the `config-properties.adoc` file. Can we somehow define a property (just like we do `property_prefix`) which will only inject `<solverName>.` when necessary by the context? That way, we'll be able to use the same file for all three places where it's used.
timefold-solver
github_2023
others
596
TimefoldAI
triceo
@@ -271,22 +271,708 @@ To use Timefold Solver with Quarkus, read the xref:quickstart/quarkus/quarkus-qu If you are starting a new project, visit the https://code.quarkus.io/[code.quarkus.io] and select the _Timefold AI constraint solver_ extension before generating your application. +[#integrationWithQuarkusPropert...
```suggestion Multi-stage planning can also be accomplished by using a separate solver configuration for each optimization stage. ```
timefold-solver
github_2023
java
564
TimefoldAI
triceo
@@ -0,0 +1,312 @@ +package ai.timefold.solver.quarkus; + +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.assertNotSame; +import static...
`ScoreManager` is deprecated. We need not and should not support it in this new feature. Also, aren't we missing the `SolverManager` here?
timefold-solver
github_2023
java
564
TimefoldAI
triceo
@@ -0,0 +1,312 @@ +package ai.timefold.solver.quarkus; + +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.assertNotSame; +import static...
Are the `Config`/`Factory`/`Manager` suffixes necessary? They are boilerplate; we need to find a way for this to work with simple names and no such restrictive rules.
timefold-solver
github_2023
java
564
TimefoldAI
triceo
@@ -66,11 +63,35 @@ void registerAdditionalBeans(BuildProducer<AdditionalBeanBuildItem> additionalBe } else { benchmarkConfig = null; } - syntheticBeans.produce(SyntheticBeanBuildItem.configure(PlannerBenchmarkConfig.class) - .supplier(recorder.benchmarkConfigSupplie...
This seems like a defensive comment. You're justifying why you did it like this, as if someone was going to say you've done it wrong. In my opinion, after this code is merged, this comment no longer has any value. We should remove it.
timefold-solver
github_2023
java
564
TimefoldAI
triceo
@@ -18,37 +17,40 @@ * See also {@link SolverRuntimeConfig} */ @ConfigGroup -public class SolverBuildTimeConfig { +public interface SolverBuildTimeConfig {
Have you made sure none of the pre-existing behavior have changed? (In other words: is this 100 % backwards compatible?) Have you ensured that for the single instance, the config is still properly overriden when using the config XML as well as these properties? Have you ensured the same with the benchmark config?
timefold-solver
github_2023
java
564
TimefoldAI
triceo
@@ -1,24 +1,39 @@ package ai.timefold.solver.quarkus.config; +import java.util.Map; +import java.util.Optional; + import ai.timefold.solver.core.config.solver.SolverConfig; import ai.timefold.solver.core.config.solver.SolverManagerConfig; -import io.quarkus.runtime.annotations.ConfigItem; import io.quarkus.runt...
```suggestion * During run time, this is translated into Timefold's {@link SolverConfig} runtime properties per solver. * If a solver name is not explicitly specified, the solver name will default to {@link #DEFAULT_SOLVER_NAME}. ```
timefold-solver
github_2023
java
564
TimefoldAI
triceo
@@ -40,16 +40,20 @@ HotDeploymentWatchedFileBuildItem watchSolverBenchmarkConfigXml() { } @BuildStep - @Record(ExecutionTime.STATIC_INIT) - void registerAdditionalBeans(BuildProducer<AdditionalBeanBuildItem> additionalBeans, - BuildProducer<SyntheticBeanBuildItem> syntheticBeans, + Bench...
```suggestion throw new ConfigurationException("When defining multiple solvers, the benchmark feature is not enabled. " + "Consider using separate <solverBenchmark> instances for evaluating different solver configurations."); ``` I wouldn't go so far as to recommend specific sectio...
timefold-solver
github_2023
java
564
TimefoldAI
triceo
@@ -18,37 +19,53 @@ * See also {@link SolverRuntimeConfig} */ @ConfigGroup -public class SolverBuildTimeConfig { +public interface SolverBuildTimeConfig { + + /** + * A classpath resource to read the specific solver configuration XML. + * + * If this property isn't specified, that solverConfig.xml i...
Any chance to not include the deprecated field for the new config, only keep it for the old way? (If it's too hard to split the two, or requires code duplication, forget about it.)
timefold-solver
github_2023
java
564
TimefoldAI
triceo
@@ -1,32 +1,47 @@ package ai.timefold.solver.quarkus.deployment.config; +import java.util.Map; import java.util.Optional; import ai.timefold.solver.core.config.solver.SolverConfig; -import io.quarkus.runtime.annotations.ConfigItem; +import io.quarkus.runtime.annotations.ConfigPhase; import io.quarkus.runtime....
```suggestion * Configuration properties that overwrite the {@link SolverConfig} per Solver. * If a solver name is not explicitly specified, the solver name will default to {@link #DEFAULT_SOLVER_NAME}. ``` When writing about Timefold, please remember: - Timefold is the company. - Timefold Solver i...
timefold-solver
github_2023
java
564
TimefoldAI
triceo
@@ -0,0 +1,115 @@ +package ai.timefold.solver.quarkus; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import java.time.Duration; + +import jakarta.inject.Inject; + +import ai.ti...
This test - a test for the old behavior - should still test the deprecated `ScoreManager`. It's only the new `@Named` behavior where we don't support it.