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
1,009
TimefoldAI
triceo
@@ -18,31 +18,33 @@ import ai.timefold.solver.core.impl.score.constraint.DefaultConstraintMatchTotal; import ai.timefold.solver.core.impl.util.CollectionUtils; +import org.jspecify.annotations.NonNull; +import org.jspecify.annotations.Nullable; + /** * Note: Users should never create instances of this type direc...
No particular reason. I guess I just don't like to throw an NPE, but I agree that this might as well be one.
timefold-solver
github_2023
java
1,009
TimefoldAI
triceo
@@ -46,22 +44,22 @@ public static BendableBigDecimalScore parseScore(String scoreString) { * Creates a new {@link BendableBigDecimalScore}. * * @param initScore see {@link Score#initScore()} - * @param hardScores never null, never change that array afterwards: it must be immutable - * @param s...
Not sure what you mean. If the question is whether the array contents can be null, than the answer is no - but I'm not sure you can state that using these annotations.
timefold-solver
github_2023
java
1,009
TimefoldAI
triceo
@@ -138,9 +131,9 @@ public int initScore() { } /** - * @return not null, array copy because this class is immutable + * @return array copy because this class is immutable */ - public long[] hardScores() { + public long @NonNull [] hardScores() {
For my edification, as I haven't seen this before... is this how you have to annotate array types? My brain would find `@NonNull long[]` much more natural.
timefold-solver
github_2023
java
1,009
TimefoldAI
triceo
@@ -53,15 +55,18 @@ public static HardMediumSoftBigDecimalScore parseScore(String scoreString) { return ofUninitialized(initScore, hardScore, mediumScore, softScore); } - public static HardMediumSoftBigDecimalScore ofUninitialized(int initScore, BigDecimal hardScore, BigDecimal mediumScore, + publ...
IMO yes. Let's make sure we propagate this to the other `BigDecimal` score types as well.
timefold-solver
github_2023
java
1,009
TimefoldAI
triceo
@@ -132,6 +137,7 @@ public static HardMediumSoftBigDecimalScore ofSoft(BigDecimal softScore) { * timefold-solver-jpa, timefold-solver-jackson, timefold-solver-jaxb, ... */ @SuppressWarnings("unused") + // TODO: params default or null?
Well spotted. In the interest of getting rid of null, default values (`BigDecimal.ZERO`) would be preferred.
timefold-solver
github_2023
java
1,009
TimefoldAI
triceo
@@ -155,6 +161,7 @@ public int initScore() { * * @return higher is better, usually negative, 0 if no hard constraints are broken/fulfilled */ + // TODO: nonnull?
Based on the above, yes.
timefold-solver
github_2023
java
1,009
TimefoldAI
triceo
@@ -694,6 +696,7 @@ or uncorrupted constraintMatchEnabled (%s) is disabled. uncorruptedAnalysis.constraintMap().forEach((constraintRef, uncorruptedConstraintAnalysis) -> { var corruptedConstraintAnalysis = corruptedAnalysis.constraintMap() .get(constraintRef); + // ...
Keep the warning there, please. I'll take a look at all new warnings after this is merged, and decide if the code needs changing or if the annotation needs adjusting.
timefold-solver
github_2023
java
1,009
TimefoldAI
triceo
@@ -117,16 +111,15 @@ public static BendableScore ofSoft(int hardLevelsSize, int softLevelsSize, int s * timefold-solver-jpa, timefold-solver-jackson, timefold-solver-jaxb, ... */ @SuppressWarnings("unused") + // TODO: suppress warnings here or use empty array? Also in related classes (bendable)
Yes.
timefold-solver
github_2023
java
1,009
TimefoldAI
triceo
@@ -66,6 +67,7 @@ * * @return {@link NullSolutionCloner} when it is null (workaround for annotation limitation) */ + // TODO: return @NonNull?
This is really just an annotations hack. I would avoid marking annotations.
timefold-solver
github_2023
java
1,009
TimefoldAI
triceo
@@ -19,33 +21,32 @@ public interface IncrementalScoreCalculator<Solution_, Score_ extends Score<Scor /** * There are no {@link #beforeEntityAdded(Object)} and {@link #afterEntityAdded(Object)} calls * for entities that are already present in the workingSolution. - * - * @param workingSolution n...
Correct.
timefold-solver
github_2023
java
1,107
TimefoldAI
zepfred
@@ -0,0 +1,110 @@ +package ai.timefold.solver.core.api.domain.metamodel; + +import java.util.List; + +import ai.timefold.solver.core.api.domain.solution.PlanningSolution; +import ai.timefold.solver.core.api.domain.variable.PlanningListVariable; +import ai.timefold.solver.core.api.domain.variable.PlanningVariable; + +/*...
Should we use the "formatted" instead?
timefold-solver
github_2023
java
1,107
TimefoldAI
zepfred
@@ -0,0 +1,70 @@ +package ai.timefold.solver.core.api.domain.metamodel; + +import java.util.List; + +import ai.timefold.solver.core.api.domain.entity.PlanningEntity; +import ai.timefold.solver.core.api.domain.solution.PlanningSolution; + +/** + * Represents the meta-model of a {@link PlanningSolution}. + * Allows acces...
Let's use String::formatted
timefold-solver
github_2023
java
1,107
TimefoldAI
zepfred
@@ -0,0 +1,51 @@ +package ai.timefold.solver.core.api.domain.metamodel; + +import ai.timefold.solver.core.api.domain.variable.PlanningVariable; + +/** + * A {@link VariableMetaModel} that represents a @{@link PlanningVariable basic planning variable}. + * + * <p> + * <strong>This package and all of its contents are par...
I wonder if `allowsUnassigned` should be part of `VariableMetaModel`. If we need to cast variable models to check this, perhaps we could avoid that by adding it to the parent class.
timefold-solver
github_2023
java
1,107
TimefoldAI
zepfred
@@ -0,0 +1,51 @@ +package ai.timefold.solver.core.api.domain.metamodel; + +import ai.timefold.solver.core.api.domain.variable.PlanningVariable; + +/** + * A {@link VariableMetaModel} that represents a @{@link PlanningVariable basic planning variable}. + * + * <p> + * <strong>This package and all of its contents are par...
Same as above
timefold-solver
github_2023
java
1,107
TimefoldAI
zepfred
@@ -0,0 +1,37 @@ +package ai.timefold.solver.core.api.domain.metamodel; + +/** + * A {@link VariableMetaModel} that represents a shadow planning variable.
Custom shadow variables can be modified by user code
timefold-solver
github_2023
java
1,107
TimefoldAI
zepfred
@@ -0,0 +1,11 @@ +package ai.timefold.solver.core.api.domain.metamodel; + +record DefaultUnassignedLocation() implements UnassignedLocation {
I understand your strategy, but I suggest a different approach. What if `DefaultUnassignedLocation` extends `DefaultLocationInList` and throws exceptions for `DefaultUnassignedLocation::entity()` or `DefaultUnassignedLocation::index()`? We still fail fast, and there will be no need to cast values in the internal class...
timefold-solver
github_2023
java
1,107
TimefoldAI
zepfred
@@ -0,0 +1,138 @@ +package ai.timefold.solver.core.api.move; + +import java.util.Collection; +import java.util.HashSet; +import java.util.LinkedHashSet; +import java.util.List; + +import ai.timefold.solver.core.api.domain.entity.PlanningEntity; +import ai.timefold.solver.core.api.domain.lookup.PlanningId; +import ai.ti...
Are there any move implementations that do not provide these methods? Does it make sense to have them for any move? Depending on the answers, why not transfer these tabu-related operations to a specific tabu-move interface, such as `TabuMove extends Move`? Next to that, the TB logic should use `TabuMove` instead of ...
timefold-solver
github_2023
java
1,107
TimefoldAI
zepfred
@@ -0,0 +1,80 @@ +package ai.timefold.solver.core.api.move; + +import ai.timefold.solver.core.api.domain.metamodel.PlanningListVariableMetaModel; +import ai.timefold.solver.core.api.domain.metamodel.PlanningVariableMetaModel; +import ai.timefold.solver.core.api.domain.solution.PlanningSolution; +import ai.timefold.solv...
What about the unassign operation?
timefold-solver
github_2023
java
1,107
TimefoldAI
zepfred
@@ -0,0 +1,64 @@ +package ai.timefold.solver.core.impl.domain.solution.descriptor; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Objects; + +import ai.timefold.solver.core.api.domain.metamodel.PlanningEntityMetaModel; +import ai.timefold.solver.core.api.domain.m...
Let's use "formatted"
timefold-solver
github_2023
java
1,107
TimefoldAI
zepfred
@@ -0,0 +1,67 @@ +package ai.timefold.solver.core.impl.domain.solution.descriptor; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Objects; + +import ai.timefold.solver.core.api.domain.metamodel.PlanningEntityMetaModel; +import ai.timefold.solver.core.api.domain.m...
Let's use "formatted"
timefold-solver
github_2023
java
1,107
TimefoldAI
zepfred
@@ -0,0 +1,36 @@ +package ai.timefold.solver.core.impl.domain.solution.descriptor; + +import ai.timefold.solver.core.api.domain.metamodel.PlanningEntityMetaModel; +import ai.timefold.solver.core.api.domain.metamodel.ShadowVariableMetaModel; +import ai.timefold.solver.core.impl.domain.variable.descriptor.ShadowVariableD...
Do we need this method?
timefold-solver
github_2023
java
1,107
TimefoldAI
zepfred
@@ -0,0 +1,10 @@ +package ai.timefold.solver.core.impl.domain.solution.descriptor; + +import ai.timefold.solver.core.impl.domain.variable.descriptor.VariableDescriptor; + +public sealed interface InnerVariableMetaModel<Solution_>
Why not move this interface to the public API and return a generic type? Alternatively, we could add the method to `VariableMetaModel`, as it appears to be a common method for all its child classes.
timefold-solver
github_2023
java
1,107
TimefoldAI
zepfred
@@ -4,16 +4,16 @@ import java.util.Map; import java.util.Objects; +import ai.timefold.solver.core.api.domain.metamodel.ElementLocation; +import ai.timefold.solver.core.api.domain.metamodel.LocationInList; import ai.timefold.solver.core.api.score.director.ScoreDirector; import ai.timefold.solver.core.impl.domain.v...
Here is one of the places we could enhance the experience by modifying the default contract so that `ExternalizedListVariableStateSupply::getLocationInList` returns `LocationInList`. I'm uncertain whether calling `ensureAssigned()` would disrupt existing code, but if not, it would be logical to apply this validation wh...
timefold-solver
github_2023
java
1,107
TimefoldAI
zepfred
@@ -7,26 +7,24 @@ import ai.timefold.solver.core.api.domain.solution.PlanningSolution; import ai.timefold.solver.core.api.score.director.ScoreDirector; +import ai.timefold.solver.core.impl.move.director.VariableChangeRecordingScoreDirector; /** * Abstract superclass for {@link Move}, requiring implementation o...
I'm unsure if the comment makes sense. It looks like we will always use `VariableChangeRecordingScoreDirector`.
timefold-solver
github_2023
java
1,107
TimefoldAI
zepfred
@@ -10,20 +11,20 @@ * therefore removing the need to implement the undo move. * * @param <Solution_> + * @deprecated In favor of {@link AbstractMove}, which no longer requires undo moves to be implemented either. */ +@Deprecated(forRemoval = true, since = "1.16.0") public abstract class AbstractSimplifiedMove<...
ditto
timefold-solver
github_2023
java
1,107
TimefoldAI
zepfred
@@ -0,0 +1,24 @@ +package ai.timefold.solver.core.impl.heuristic.selector.move.factory; + +import java.util.Iterator; + +import ai.timefold.solver.core.api.move.Move; + +final class LegacyIteratorAdapter<Solution_> implements Iterator<Move<Solution_>> { + + private final Iterator<ai.timefold.solver.core.impl.heurist...
Is there a reason for not importing the class?
timefold-solver
github_2023
java
1,107
TimefoldAI
zepfred
@@ -68,19 +68,13 @@ public boolean isMoveDoable(ScoreDirector<Solution_> scoreDirector) { return !Objects.equals(oldFirstValue, toPlanningValue); } - @Override - public SubChainChangeMove<Solution_> createUndoMove(ScoreDirector<Solution_> scoreDirector) { - Object oldFirstValue = variableDe...
Let's make it consistent and rename the var to `castScoreDirector`
timefold-solver
github_2023
java
1,107
TimefoldAI
zepfred
@@ -67,34 +69,27 @@ public boolean isMoveDoable(ScoreDirector<Solution_> scoreDirector) { return !SubChainSwapMove.containsAnyOf(rightSubChain, leftSubChain); } - @Override - public SubChainReversingSwapMove<Solution_> createUndoMove(ScoreDirector<Solution_> scoreDirector) { - return new Su...
Let's rename it to `castScoreDirector`
timefold-solver
github_2023
java
1,107
TimefoldAI
zepfred
@@ -188,68 +188,43 @@ public boolean isMoveDoable(ScoreDirector<Solution_> scoreDirector) { return true; } - @Override - public TailChainSwapMove<Solution_> createUndoMove(ScoreDirector<Solution_> scoreDirector) { - if (!sameAnchor) { - return new TailChainSwapMove<>(variableDesc...
This method seems similar to `SubChainReversingChangeMove::reverseChain`
timefold-solver
github_2023
java
1,107
TimefoldAI
zepfred
@@ -71,7 +71,8 @@ public <Node_> Node_ successor(Node_ object, ListVariableStateSupply<?> listVari @SuppressWarnings("unchecked") public <Node_> Node_ predecessor(Node_ object, ListVariableStateSupply<?> listVariableStateSupply) { var listVariableDescriptor = listVariableStateSupply.getSourceVariable...
Let's apply `var` to all possible places.
timefold-solver
github_2023
java
1,107
TimefoldAI
zepfred
@@ -86,9 +87,12 @@ public <Node_> Node_ predecessor(Node_ object, ListVariableStateSupply<?> listVa } public <Node_> boolean between(Node_ start, Node_ middle, Node_ end, ListVariableStateSupply<?> listVariableStateSupply) { - var startElementLocation = (LocationInList) listVariableStateSupply.getLoc...
ditto
timefold-solver
github_2023
java
1,107
TimefoldAI
zepfred
@@ -376,8 +377,10 @@ int getShortestCycleIdentifier(EntityOrderInfo entityOrderInfo, Object[] removeE private int getSegmentSize(EntityOrderInfo entityOrderInfo, Object from, Object to) { var entityToEntityIndex = entityOrderInfo.entityToEntityIndex(); - var startElementLocation = (LocationInList...
Let's apply `var` to all possible places.
timefold-solver
github_2023
java
1,107
TimefoldAI
zepfred
@@ -70,7 +70,7 @@ public void applyChangesFromCopy(MultipleDelegateList<?> copy) { public int getIndexOfValue(ListVariableStateSupply<?> listVariableStateSupply, Object value) { var elementLocation = listVariableStateSupply.getLocationInList(value); - if (elementLocation instanceof LocationInList...
This is kind of casting operation we can avoid by changing the `ListVariableStateSupply` contract. See my suggestions related to `LocationInList`.
timefold-solver
github_2023
java
1,107
TimefoldAI
zepfred
@@ -120,11 +109,11 @@ protected void doMoveOnGenuineVariables(ScoreDirector<Solution_> scoreDirector) } private void doTailSwap(ScoreDirector<Solution_> scoreDirector) { - InnerScoreDirector<Solution_, ?> innerScoreDirector = (InnerScoreDirector<Solution_, ?>) scoreDirector; - List<Object> fir...
Let's rename it to `castScoreDirector`
timefold-solver
github_2023
java
1,107
TimefoldAI
zepfred
@@ -153,8 +142,8 @@ private void doTailSwap(ScoreDirector<Solution_> scoreDirector) { } private void doSublistReversal(ScoreDirector<Solution_> scoreDirector) { - InnerScoreDirector<Solution_, ?> innerScoreDirector = (InnerScoreDirector<Solution_, ?>) scoreDirector; - List<Object> listVariable...
ditto
timefold-solver
github_2023
java
1,107
TimefoldAI
zepfred
@@ -133,12 +122,12 @@ private void doTailSwap(ScoreDirector<Solution_> scoreDirector) { secondEdgeEndpoint, secondOriginalSize); - List<Object> firstListVariableTail = firstListVariable.subList(firstEdgeEndpoint, firstOriginalSize); - List<Object> secondListVariableTail...
Let's apply `var` to all possible places.
timefold-solver
github_2023
java
1,107
TimefoldAI
zepfred
@@ -84,11 +81,23 @@ protected void doMoveOnGenuineVariables(ScoreDirector<Solution_> scoreDirector) constructionHeuristicPhase.solvingEnded(solverScope); scoreDirector.triggerVariableListeners(); + var entityToInsertedValuesMap = CollectionUtils.<Object, List<Object>> newIdentityHashMap(0); +...
Is the call to `recordingScoreDirector.afterListVariableChanged` no longer necessary?
timefold-solver
github_2023
java
1,107
TimefoldAI
zepfred
@@ -119,20 +119,15 @@ public boolean isMoveDoable(ScoreDirector<Solution_> scoreDirector) { return !(rightEntity == leftEntity && leftIndex == rightIndex); } - @Override - public ListSwapMove<Solution_> createUndoMove(ScoreDirector<Solution_> scoreDirector) { - return new ListSwapMove<>(var...
Let's rename it to `castScoreDirector`
timefold-solver
github_2023
java
1,107
TimefoldAI
zepfred
@@ -88,23 +87,17 @@ public boolean isMoveDoable(ScoreDirector<Solution_> scoreDirector) { } } - @Override - protected AbstractMove<Solution_> createUndoMove(ScoreDirector<Solution_> scoreDirector) { - return new SubListChangeMove<>(variableDescriptor, destinationEntity, destinationIndex, le...
Let's rename it to `castScoreDirector`
timefold-solver
github_2023
java
1,107
TimefoldAI
zepfred
@@ -48,15 +48,9 @@ public boolean isMoveDoable(ScoreDirector<Solution_> scoreDirector) { return !Objects.equals(oldValue, toPlanningValue); } - @Override - public ChangeMove<Solution_> createUndoMove(ScoreDirector<Solution_> scoreDirector) { - Object oldValue = variableDescriptor.getValue(e...
Let's rename it to `castScoreDirector`
timefold-solver
github_2023
java
1,107
TimefoldAI
zepfred
@@ -81,10 +76,10 @@ public SwapMove<Solution_> rebase(ScoreDirector<Solution_> destinationScoreDirec @Override protected void doMoveOnGenuineVariables(ScoreDirector<Solution_> scoreDirector) { - InnerScoreDirector<Solution_, ?> innerScoreDirector = (InnerScoreDirector<Solution_, ?>) scoreDirector; - ...
Let's rename it to `castScoreDirector`
timefold-solver
github_2023
java
1,107
TimefoldAI
zepfred
@@ -0,0 +1,48 @@ +package ai.timefold.solver.core.impl.move.director; + +import ai.timefold.solver.core.api.domain.metamodel.ElementLocation; +import ai.timefold.solver.core.api.domain.metamodel.PlanningListVariableMetaModel; +import ai.timefold.solver.core.api.move.Move; +import ai.timefold.solver.core.impl.score.dire...
Cool!
timefold-solver
github_2023
java
1,107
TimefoldAI
zepfred
@@ -0,0 +1,20 @@ +package ai.timefold.solver.core.impl.move.director; + +import ai.timefold.solver.core.api.move.Rebaser; +import ai.timefold.solver.core.impl.domain.variable.descriptor.ListVariableDescriptor; +import ai.timefold.solver.core.impl.score.director.VariableDescriptorAwareScoreDirector; + +record ListVariab...
No actions here?
timefold-solver
github_2023
java
1,107
TimefoldAI
zepfred
@@ -0,0 +1,20 @@ +package ai.timefold.solver.core.impl.move.director; + +import ai.timefold.solver.core.api.move.Rebaser; +import ai.timefold.solver.core.impl.domain.variable.descriptor.ListVariableDescriptor; +import ai.timefold.solver.core.impl.score.director.VariableDescriptorAwareScoreDirector; + +record ListVariab...
ditto
timefold-solver
github_2023
java
1,107
TimefoldAI
zepfred
@@ -0,0 +1,133 @@ +package ai.timefold.solver.core.impl.move.director; + +import java.util.Objects; + +import ai.timefold.solver.core.api.domain.metamodel.ElementLocation; +import ai.timefold.solver.core.api.domain.metamodel.PlanningListVariableMetaModel; +import ai.timefold.solver.core.api.domain.metamodel.PlanningVar...
Cool!
timefold-solver
github_2023
java
1,107
TimefoldAI
zepfred
@@ -11,176 +11,145 @@ import ai.timefold.solver.core.impl.domain.variable.descriptor.GenuineVariableDescriptor; import ai.timefold.solver.core.impl.domain.variable.inverserelation.SingletonInverseVariableSupply; import ai.timefold.solver.core.impl.heuristic.selector.SelectorTestUtils; +import ai.timefold.solver.core...
This comment applies to all places where we are removing the undo validation. I understand the move logic has changed, but I am still concerned about removing the undo validation entirely. I wonder how much effort it would take to use the ephemeral director while maintaining the undo validations.
timefold-solver
github_2023
others
1,107
TimefoldAI
zepfred
@@ -1842,20 +1842,7 @@ A move that is currently not doable can become doable when the working solution otherwise we probably shouldn't have created it in the first place. Each move has an __undo move__: a move (normally of the same type) which does the exact opposite.
Is the phrase "normally of the same type" still applicable?
timefold-solver
github_2023
others
1,107
TimefoldAI
zepfred
@@ -30,7 +30,23 @@ Those documented `impl` classes are reliable and safe to use (unless explicitly but we're just not entirely comfortable yet to write their signatures in stone. ==== -[NOTE] -==== -The Python Solver is currently in beta and its API is subject to change. -==== \ No newline at end of file +[#preview...
```suggestion Timefold Solver may include components that are only available as preview features. Currently available are: ```
timefold-solver
github_2023
java
1,107
TimefoldAI
zepfred
@@ -3,22 +3,16 @@ import java.util.Collection; import java.util.Collections; -import ai.timefold.solver.core.impl.heuristic.move.Move; +import ai.timefold.solver.core.api.move.Move; import ai.timefold.solver.core.impl.localsearch.scope.LocalSearchMoveScope; import ai.timefold.solver.core.impl.localsearch.scope.Lo...
Will removing the TS undo moves affect any existing code?
timefold-solver
github_2023
others
1,151
TimefoldAI
lee-carlon
@@ -0,0 +1,29 @@ +[#introduction] +:page-aliases: ../index.adoc +:doctype: book +:sectnums: +:icons: font + +[#whatIsTimefold] += What is Timefold Solver? + +Every organization faces planning problems: providing products or services with a limited set of _constrained_ resources (employees, assets, time and money). +Tim...
```suggestion Timefold Solver’s xref:planning-ai-concepts.adoc[PlanningAI] optimizes these problems to do more business with fewer resources using Constraint Satisfaction Programming. ``` Minor change: resources are a countable noun so we should use fewer.
timefold-solver
github_2023
others
1,151
TimefoldAI
lee-carlon
@@ -0,0 +1,29 @@ +[#introduction] +:page-aliases: ../index.adoc +:doctype: book +:sectnums: +:icons: font + +[#whatIsTimefold] += What is Timefold Solver? + +Every organization faces planning problems: providing products or services with a limited set of _constrained_ resources (employees, assets, time and money).
```suggestion Every organization faces planning problems: providing products or services with a limited set of _constrained_ resources (employees, assets, time, and money). ``` US English generally prefers the serial comma :)
timefold-solver
github_2023
others
1,151
TimefoldAI
lee-carlon
@@ -0,0 +1,29 @@ +[#introduction] +:page-aliases: ../index.adoc +:doctype: book +:sectnums: +:icons: font + +[#whatIsTimefold] += What is Timefold Solver? + +Every organization faces planning problems: providing products or services with a limited set of _constrained_ resources (employees, assets, time and money). +Tim...
```suggestion It xref:integration/integration.adoc#integration[integrates very easily] with other Java^TM^, Python, and other technologies. ```
timefold-solver
github_2023
others
1,151
TimefoldAI
triceo
@@ -1,287 +0,0 @@ -[#introduction] -= Introduction -:page-aliases: ../index.adoc -:doctype: book -:sectnums: -:icons: font - -[#whatIsTimefold] -== What is Timefold Solver? - -Every organization faces planning problems: providing products or services with a limited set of _constrained_ resources (employees, assets, tim...
It this gone now?
timefold-solver
github_2023
others
1,151
TimefoldAI
triceo
@@ -1,287 +0,0 @@ -[#introduction] -= Introduction -:page-aliases: ../index.adoc -:doctype: book -:sectnums: -:icons: font - -[#whatIsTimefold] -== What is Timefold Solver? - -Every organization faces planning problems: providing products or services with a limited set of _constrained_ resources (employees, assets, tim...
The PR description mentions that this will be re-introduced as an image. In my opinion, information should not be presented exclusively as images - text is important. For discoverability and accessibility, among other reasons.
timefold-solver
github_2023
java
1,136
TimefoldAI
zepfred
@@ -137,10 +137,122 @@ default ScoreAnalysis<Score_> analyze(Solution_ solution, ScoreAnalysisFetchPoli ScoreAnalysis<Score_> analyze(Solution_ solution, ScoreAnalysisFetchPolicy fetchPolicy, SolutionUpdatePolicy solutionUpdatePolicy); + /** + * As defined by {@link #recommendAssignment(Objec...
Very informative!
timefold-solver
github_2023
java
1,136
TimefoldAI
zepfred
@@ -137,10 +137,122 @@ default ScoreAnalysis<Score_> analyze(Solution_ solution, ScoreAnalysisFetchPoli ScoreAnalysis<Score_> analyze(Solution_ solution, ScoreAnalysisFetchPolicy fetchPolicy, SolutionUpdatePolicy solutionUpdatePolicy); + /** + * As defined by {@link #recommendAssignment(Objec...
This param explanation is unclear to me. Can we explicitly state the difference between an initialized and uninitialized solution?
timefold-solver
github_2023
java
1,136
TimefoldAI
zepfred
@@ -5,45 +5,47 @@ import java.util.function.Function; import ai.timefold.solver.core.api.score.Score; -import ai.timefold.solver.core.api.solver.RecommendedFit; import ai.timefold.solver.core.api.solver.ScoreAnalysisFetchPolicy; import ai.timefold.solver.core.impl.score.director.InnerScoreDirector; -final class...
Should we also mention the fully initialized solution?
timefold-solver
github_2023
java
1,136
TimefoldAI
zepfred
@@ -0,0 +1,158 @@ +package ai.timefold.solver.core.impl.solver; + +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import java.util.Random; +import java.util.function.Function; + +import ai.timefold.solver.core.api.score.Score; +import ai.timefold.solver.core.api.score.analysis.ScoreAnal...
I'm worried that this action will not be undone. We can unassign the element, but I can't find the corresponding undo action. Could this lead to an inconsistent state?
timefold-solver
github_2023
java
1,136
TimefoldAI
zepfred
@@ -0,0 +1,158 @@ +package ai.timefold.solver.core.impl.solver; + +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import java.util.Random; +import java.util.function.Function; + +import ai.timefold.solver.core.api.score.Score; +import ai.timefold.solver.core.api.score.analysis.ScoreAnal...
I understand what the logic is doing here and have some questions: 1. Wouldn't this create a capturing lambda? 2. We will return `DefaultRecommendedAssignment` or `DefaultRecommendedFit`. What is the advantage of using the lambda instead of just instantiating the default implementations?
timefold-solver
github_2023
java
1,136
TimefoldAI
zepfred
@@ -338,7 +338,7 @@ void analyzeWithUninitializedSolution(SolutionManagerSource SolutionManagerSourc @ParameterizedTest @EnumSource(SolutionManagerSource.class) - void recommendFit(SolutionManagerSource SolutionManagerSource) { + void recommendAssignment(SolutionManagerSource SolutionManagerSource) {
Maybe we should create a separate test for that. Even though `recommendFit` is deprecated now, we still should test it to ensure no regressions are introduced.
timefold-solver
github_2023
java
1,136
TimefoldAI
zepfred
@@ -386,22 +387,71 @@ void recommendFit(SolutionManagerSource SolutionManagerSource) { @ParameterizedTest @EnumSource(SolutionManagerSource.class) - void recommendFitUninitializedSolution(SolutionManagerSource SolutionManagerSource) { + void recommendAssignmentAlreadyAssigned(SolutionManagerSource Sol...
ditto
timefold-solver
github_2023
java
1,136
TimefoldAI
zepfred
@@ -475,7 +581,7 @@ void recommendFitUninitializedSolutionWithUnassigned(SolutionManagerSource Solut @ParameterizedTest @EnumSource(SolutionManagerSource.class) - void recommendFitMultivar(SolutionManagerSource SolutionManagerSource) { + void recommendAssignmentMultivar(SolutionManagerSource SolutionM...
ditto
timefold-solver
github_2023
java
1,136
TimefoldAI
zepfred
@@ -578,7 +778,7 @@ void recommendFitUninitializedSolutionWithMultivar(SolutionManagerSource Solutio solution.setMultiVarEntityList(List.of(uninitializedEntity, secondUninitializedEntity)); var solutionManager = SolutionManagerSource.createSolutionManager(SOLVER_FACTORY_MULTIVAR); - assertTha...
ditto
timefold-solver
github_2023
java
1,136
TimefoldAI
zepfred
@@ -604,7 +804,8 @@ void recommendFitChained(SolutionManagerSource SolutionManagerSource) { var solutionManager = SolutionManagerSource.createSolutionManager(SOLVER_FACTORY_CHAINED); var recommendationList = - solutionManager.recommendFit(solution, uninitializedEntity, TestdataShadowi...
ditto
timefold-solver
github_2023
java
1,136
TimefoldAI
zepfred
@@ -672,14 +940,14 @@ void recommendFitTwoUninitializedEntityWithChained(SolutionManagerSource Solutio uninitializedSolution.setChainedEntityList(Arrays.asList(b1, c1, c2, uninitializedEntity, uninitializedEntity2)); var solutionManager = SolutionManagerSource.createSolutionManager(SOLVER_FACTORY_CH...
The suggestion to continue testing the `recommendFit` test applies to all instances where we are changing it to `recommendAssignment`.
timefold-solver
github_2023
java
1,136
TimefoldAI
zepfred
@@ -386,22 +387,71 @@ void recommendFit(SolutionManagerSource SolutionManagerSource) { @ParameterizedTest @EnumSource(SolutionManagerSource.class) - void recommendFitUninitializedSolution(SolutionManagerSource SolutionManagerSource) { + void recommendAssignmentAlreadyAssigned(SolutionManagerSource Sol...
My comment in the `AssignmentProcessor` class relates to this validation. Please verify if I'm overlooking anything.
timefold-solver
github_2023
java
1,136
TimefoldAI
zepfred
@@ -386,22 +387,71 @@ void recommendFit(SolutionManagerSource SolutionManagerSource) { @ParameterizedTest @EnumSource(SolutionManagerSource.class) - void recommendFitUninitializedSolution(SolutionManagerSource SolutionManagerSource) { + void recommendAssignmentAlreadyAssigned(SolutionManagerSource Sol...
Is there a reason to set the value?
timefold-solver
github_2023
java
1,136
TimefoldAI
zepfred
@@ -459,14 +509,70 @@ void recommendFitWithUnassigned(SolutionManagerSource SolutionManagerSource) { @ParameterizedTest @EnumSource(SolutionManagerSource.class) - void recommendFitUninitializedSolutionWithUnassigned(SolutionManagerSource SolutionManagerSource) { + void recommendAssignmentWithAllAssign...
How will this unassigned recommendation work if we already unassign it at the beginning of the `AssignmentProcessor` logic?
timefold-solver
github_2023
java
1,136
TimefoldAI
zepfred
@@ -764,13 +1101,33 @@ void recommendFitTwoUninitializedEntityWithList(SolutionManagerSource SolutionMa var solutionManager = SolutionManagerSource.createSolutionManager(SOLVER_FACTORY_LIST); var recommendationList = - solutionManager.recommendFit(solution, uninitializedValue, v -> ne...
Should this test fail as per the validation in `Assigner#apply`?
timefold-solver
github_2023
java
1,136
TimefoldAI
zepfred
@@ -113,12 +116,20 @@ public ScoreAnalysis<Score_> analyze(Solution_ solution, ScoreAnalysisFetchPolic return analysis; } + @Override + public <In_, Out_> List<RecommendedAssignment<Out_, Score_>> recommendAssignment(Solution_ solution,
I believe we need to add a new overloaded method without `fetchPolicy` param as we are using such a method in the documentation.
timefold-solver
github_2023
java
1,136
TimefoldAI
zepfred
@@ -174,15 +174,15 @@ private static String getSerializedScoreAnalysis() { } @Test - void recommendationFit() throws JsonProcessingException { + void recommendedAssignment() throws JsonProcessingException {
The same comment about continuing to test the deprecated stuff applies here.
timefold-solver
github_2023
java
1,123
TimefoldAI
zepfred
@@ -15,24 +13,14 @@ final class RuinRecreateConstructionHeuristicPhase<Solution_> super(builder); } - @Override - protected void collectMetrics(AbstractStepScope<Solution_> stepScope) { - // Nested phase doesn't collect metrics. - } - @Override protected ConstructionHeuristicPh...
What was the problem with this logic?
timefold-solver
github_2023
java
1,072
TimefoldAI
triceo
@@ -91,6 +91,8 @@ protected List<SolverMetric> getSolverMetrics(ProblemBenchmarksConfig config) { .orElseGet(ProblemStatisticType::defaultList)) { if (problemStatisticType == ProblemStatisticType.SCORE_CALCULATION_SPEED) { out.add(SolverMetric.SCORE_CALCULATION_COUNT); + ...
Question: does "move calculation" make sense? Move's aren't calculated. Arguably "move execution" would be more correct here. Any other ideas?
timefold-solver
github_2023
java
1,072
TimefoldAI
triceo
@@ -0,0 +1,56 @@ +package ai.timefold.solver.benchmark.impl.statistic.movecalculationspeed; + +import static java.util.Collections.singletonList; + +import java.util.List; + +import ai.timefold.solver.benchmark.config.statistic.ProblemStatisticType; +import ai.timefold.solver.benchmark.impl.report.BenchmarkReport; +imp...
For new code, I'd generally go with `var`.
timefold-solver
github_2023
java
1,072
TimefoldAI
triceo
@@ -0,0 +1,91 @@ +package ai.timefold.solver.benchmark.impl.statistic.movecalculationspeed; + +import java.util.List; +import java.util.concurrent.atomic.AtomicLong; +import java.util.function.Consumer; + +import ai.timefold.solver.benchmark.config.statistic.ProblemStatisticType; +import ai.timefold.solver.benchmark.im...
We already have this code elsewhere. It's a bit of a fishy logic, we should extract it to a method and reuse.
timefold-solver
github_2023
java
1,072
TimefoldAI
triceo
@@ -0,0 +1,22 @@ +package ai.timefold.solver.core.impl.heuristic.move; + +import ai.timefold.solver.core.api.domain.solution.PlanningSolution; + +/** + * Abstract superclass for {@link Move} which includes the ability to enable or disable the move metric collection. + * + * @param <Solution_> the solution type, the cla...
Please think of a different way of doing this. `Move` is something that people extend; we don't want them to think about metrics as they do so. Moves should not have to understand if they're being measured or not. Also, this makes the move even more mutable than it already was before. I don't like this at all.
timefold-solver
github_2023
java
1,072
TimefoldAI
Christopher-Chianelli
@@ -515,13 +515,15 @@ void testScoreCalculationCountForFinishedJob() throws ExecutionException, Interr solverJob.getFinalBestSolution(); assertThat(solverJob.getScoreCalculationCount()).isEqualTo(5L); + assertThat(solverJob.getMoveEvaluationCount()).isEqualTo(4L);
Why is it 4 and not 5? It only use Swap/Change moves?
timefold-solver
github_2023
others
1,072
TimefoldAI
triceo
@@ -596,6 +596,27 @@ Useful for comparing different score calculators and/or constraint implementatio Also useful to measure the scalability cost of an extra constraint. +[#benchmarkReportMoveEvaluationSpeedSummary] +=== Move evaluation speed summary (graph And table)
```suggestion === Move evaluation speed summary (graph and table) ```
timefold-solver
github_2023
others
1,072
TimefoldAI
triceo
@@ -33,6 +33,18 @@ and still compare it with the original's calculation speed. Comparing the best score with the original's best score is pointless: it's comparing apples and oranges. ==== +The solver usually calculates the score for each move it evaluates. +This means a direct relationship exists between the score...
```suggestion making this ratio `N:1`. ```
timefold-solver
github_2023
others
1,072
TimefoldAI
triceo
@@ -33,6 +33,18 @@ and still compare it with the original's calculation speed. Comparing the best score with the original's best score is pointless: it's comparing apples and oranges. ==== +The solver usually calculates the score for each move it evaluates. +This means a direct relationship exists between the score...
```suggestion as the move count will stay stable no matter how many score calculations the moves perform. ```
timefold-solver
github_2023
others
1,072
TimefoldAI
triceo
@@ -596,6 +596,27 @@ Useful for comparing different score calculators and/or constraint implementatio Also useful to measure the scalability cost of an extra constraint. +[#benchmarkReportMoveEvaluationSpeedSummary] +=== Move evaluation speed summary (graph And table) + +Shows the move evaluation speed: a count pe...
This note arguably applies to score calculation count, but is irrelevant in move count, no? Move counts are the same regardless of what moves are used. (It is true that RnR is slow and therefore will decrease move count, but you can say that about any slow move. This is not specific to RnR.)
timefold-solver
github_2023
others
1,072
TimefoldAI
triceo
@@ -753,6 +774,34 @@ After those few seconds of initialization, the calculation speed is relatively s ==== +[#benchmarkReportMoveEvaluationSpeedOverTimeStatistic] +=== Move evaluation speed over time statistic (graph and CSV) + +To see how fast the moves are evaluated, add: + +[source,xml,options="nowrap"] +---- +...
```suggestion After the construction heuristic phase, the evaluation speed is relatively stable, ``` Let's not promise seconds. :-) We've seen it can be minutes, hours.
timefold-solver
github_2023
java
1,072
TimefoldAI
triceo
@@ -217,6 +226,16 @@ public Long getScoreCalculationSpeed() { return scoreCalculationCount * 1000L / timeMillisSpent; } + @SuppressWarnings("unused") // Used by FreeMarker. + public Long getMoveEvaluationSpeed() { + long timeSpent = this.timeMillisSpent; + if (timeSpent == 0L) { + ...
Consider sharing this method statically; it's used in more than one place, and likely also for score calculation speed.
timefold-solver
github_2023
java
1,072
TimefoldAI
triceo
@@ -58,6 +58,7 @@ public EntityPlacer<Solution_> getEntityPlacer() { @Override public DefaultConstructionHeuristicPhase<Solution_> build() { + this.setEnableCollectMetrics(false);
Arguably, if this is only used in one place and the default is true, this should rather be called `disableMetricCollection()`, inverting the logic.
timefold-solver
github_2023
java
1,072
TimefoldAI
triceo
@@ -130,7 +130,9 @@ public void stepStarted(LocalSearchStepScope<Solution_> stepScope) { public void stepEnded(LocalSearchStepScope<Solution_> stepScope) { super.stepEnded(stepScope); decider.stepEnded(stepScope); - collectMetrics(stepScope); + if (stepScope.isPhaseEnableCollectMetr...
Why would metrics collection ever be disabled in Local Search? What changed that the metric collection is now conditional? Also, let's change the method. Arguably, this belongs on the phase scope, and then it can be called `isMetricCollectionEnabled()`. If we need it, that is.
timefold-solver
github_2023
java
1,072
TimefoldAI
triceo
@@ -44,10 +46,23 @@ public void setBestScoreImproved(Boolean bestScoreImproved) { this.bestScoreImproved = bestScoreImproved; } + public void incrementMoveEvaluationCount(Move<?> move) { + if (isPhaseEnableCollectMetrics()) { + getPhaseScope().getSolverScope().addMoveEvaluationCount...
Ah, I see, it _is_ on the phase, you just make it available on the step like this. I wouldn't - it increases amount of code in one place (here) to decrease amount of code later (at call time). But arguably, it adds more code than it removes.
timefold-solver
github_2023
java
1,072
TimefoldAI
triceo
@@ -355,4 +381,17 @@ public void destroyYielding() { } } + public void incrementMoveEvaluationCountPerType(Move<?> move) { + addMoveEvaluationCountPerType(move.getSimpleMoveTypeDescription(), 1L); + } + + public void addMoveEvaluationCountPerType(String moveType, long count) {
Why is this method public, if we already have the one above?
timefold-solver
github_2023
java
1,072
TimefoldAI
triceo
@@ -62,6 +67,11 @@ public class SolverScope<Solution_> { */ private final Map<Tags, List<AtomicReference<Number>>> stepScoreMap = new ConcurrentHashMap<>(); + /** + * Used for tracking move count per move type + */ + private final Map<String, AtomicLong> moveEvaluationCountPerTypeMap = new Co...
If the map is already concurrent, do you need the `AtomicLong`? Wouldn't locking the entire write operation be a much better guarantee of atomicity?
timefold-solver
github_2023
others
1,072
TimefoldAI
triceo
@@ -4,35 +4,44 @@ [#scoreCalculationPerformanceTricksOverview] == Overview -The `Solver` will normally spend most of its execution time running score calculation, +The `Solver` will normally spend most of its execution time evaluating moves and running score calculation, which is called in its deepest loops. -Fast...
In this case, we are arguably talking about faster score calculation. That is the deciding factor for speed, if everything else is equal. Move evaluation speed is _determined_ by score calculation speed.
timefold-solver
github_2023
others
1,072
TimefoldAI
triceo
@@ -4,35 +4,44 @@ [#scoreCalculationPerformanceTricksOverview] == Overview -The `Solver` will normally spend most of its execution time running score calculation, +The `Solver` will normally spend most of its execution time evaluating moves and running score calculation, which is called in its deepest loops. -Fast...
See, I don't agree with this statement. To improve your performance, you have to increase your score calculation speed - if you focus on move evaluation speed, it means you start removing slow moves, and that is counter-productive. You need to increase the score calculation speed while _keeping_ the existing moves.
timefold-solver
github_2023
others
1,072
TimefoldAI
triceo
@@ -4,35 +4,44 @@ [#scoreCalculationPerformanceTricksOverview] == Overview -The `Solver` will normally spend most of its execution time running score calculation, +The `Solver` will normally spend most of its execution time evaluating moves and running score calculation, which is called in its deepest loops. -Fast...
Have you checked all the references to this? Antora has a habit of failing when refs don't exist. Also, I'd call this section "Move evaluation and score calculation speed".
timefold-solver
github_2023
others
1,072
TimefoldAI
triceo
@@ -458,5 +467,7 @@ For example, move multiple items from the same container to another container. == `stepLimit` benchmark Not all score constraints have the same performance cost. -Sometimes one score constraint can kill the score calculation performance outright. -Use the xref:using-timefold-solver/benchmarking-...
```suggestion Sometimes one score constraint can performance outright. ```
timefold-solver
github_2023
others
1,072
TimefoldAI
triceo
@@ -595,6 +595,27 @@ Useful for comparing different score calculators and/or constraint implementatio (presuming that the solver configurations do not differ otherwise). Also useful to measure the scalability cost of an extra constraint. +[IMPORTANT] +==== +When improving your score speed, +it's important to note t...
```suggestion When improving your score calculation speed, comparing a configuration that uses xref:optimization-algorithms/move-selector-reference.adoc#ruinRecreateMoveSelector[Ruin and Recreate] moves ```
timefold-solver
github_2023
others
1,072
TimefoldAI
triceo
@@ -753,6 +774,50 @@ After those few seconds of initialization, the calculation speed is relatively s ==== +[#benchmarkReportMoveEvaluationSpeedOverTimeStatistic] +=== Move evaluation speed over time statistic (graph and CSV) + +To see how fast the moves are evaluated, add: + +[source,xml,options="nowrap"] +---- +...
```suggestion The initial high evaluation speed is typical during solution initialization: ```
timefold-solver
github_2023
others
1,072
TimefoldAI
triceo
@@ -287,7 +287,7 @@ but not for slow stepping algorithms (such as Tabu Search). Both cause congestion in xref:enterprise-edition/enterprise-edition.adoc#multithreadedSolving[multi-threaded solving] with most appenders, see below. -In Eclipse, `debug` logging to the console tends to cause congestion with a score ca...
```suggestion In Eclipse, `debug` logging to the console tends to cause congestion with move evaluation speeds above 10 000 per second. ```
timefold-solver
github_2023
java
1,072
TimefoldAI
triceo
@@ -44,10 +46,18 @@ public void setBestScoreImproved(Boolean bestScoreImproved) { this.bestScoreImproved = bestScoreImproved; } + public void incrementMoveEvaluationCount(Move<?> move) { + if (getPhaseScope().isEnableCollectMetrics()) {
Let's change the name; 'isMetricCollectionEnabled()', better English. Also, it would be nice if the method were documented - why do we ever need to disable metrics?
timefold-solver
github_2023
java
1,072
TimefoldAI
triceo
@@ -93,7 +93,12 @@ public void setBestSolutionStepIndex(int bestSolutionStepIndex) { public abstract AbstractStepScope<Solution_> getLastCompletedStepScope(); - public boolean isEnableCollectMetrics() { + /** + * @return true, if the metrics collection, such as + * {@link ai.timefold.solv...
```suggestion * @return true, if the metrics collection, such as * {@link ai.timefold.solver.core.config.solver.monitoring.SolverMetric#MOVE_COUNT_PER_TYPE MOVE_COUNT_PER_TYPE}, * is enabled. * This is disabled for nested phases, such as Construction heuristics in Ruin an...
timefold-solver
github_2023
java
1,108
TimefoldAI
zepfred
@@ -20,12 +21,26 @@ default Constraint asConstraint(String constraintName) { /** * Builds a {@link Constraint} from the constraint stream. * The {@link ConstraintRef#packageName() constraint package} defaults to the package of the {@link PlanningSolution} class. + * The constraint will be placed in...
The regex is using `\p{So}`, which means we will accept other symbols.
timefold-solver
github_2023
java
1,108
TimefoldAI
zepfred
@@ -35,54 +32,6 @@ protected TestConstraint<Solution_, Score_> buildConstraint(Score_ constraintWei abstract protected AbstractScoreInliner<Score_> buildScoreInliner(Map<Constraint, Score_> constraintWeightMap, boolean constraintMatchEnabled); - public static final class TestConstraintFactory<Sol...
```suggestion ```
timefold-solver
github_2023
java
1,108
TimefoldAI
zepfred
@@ -0,0 +1,35 @@ +package ai.timefold.solver.quarkus; + +import jakarta.inject.Inject; + +import ai.timefold.solver.core.api.score.stream.ConstraintMetaModel; +import ai.timefold.solver.quarkus.testdata.normal.constraints.TestdataQuarkusConstraintProvider; +import ai.timefold.solver.quarkus.testdata.normal.domain.Testd...
Please also update `TimefoldProcessorSolverResourcesTest`