Class BestSolutionChangedEvent<Solution_>
java.lang.Object
java.util.EventObject
ai.timefold.solver.core.api.solver.event.BestSolutionChangedEvent<Solution_>
- Type Parameters:
Solution_- the solution type, the class with thePlanningSolutionannotation
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
DefaultBestSolutionChangedEvent
Delivered when the
best solution changes during solving.
Delivered in the solver thread (which is the thread that calls Solver.solve(Solution_)).- See Also:
-
Field Summary
Fields inherited from class java.util.EventObject
source -
Constructor Summary
ConstructorsConstructorDescriptionBestSolutionChangedEvent(@NonNull Solver<Solution_> solver, long timeMillisSpent, @NonNull Solution_ newBestSolution, @NonNull Score newBestScore) Deprecated, for removal: This API element is subject to removal in a future version.Users should not manually construct instances of this event.BestSolutionChangedEvent(@NonNull Solver<Solution_> solver, long timeMillisSpent, @NonNull Solution_ newBestSolution, @NonNull Score newBestScore, boolean isNewBestSolutionInitialized) Deprecated, for removal: This API element is subject to removal in a future version.Users should not manually construct instances of this event. -
Method Summary
Modifier and TypeMethodDescription@NonNull ScoreReturns theScoreof thegetNewBestSolution().@NonNull Solution_Note that: In real-time planning, not allProblemChanges might be processed: checkisEveryProblemFactChangeProcessed(). thisPlanningSolutionmight be uninitialized: checkisNewBestSolutionInitialized(). thisPlanningSolutionmight be infeasible: checkScore.isFeasible().longbooleanbooleanDeprecated, for removal: This API element is subject to removal in a future version.PreferisEveryProblemChangeProcessed().booleanMethods inherited from class java.util.EventObject
getSource, toString
-
Constructor Details
-
BestSolutionChangedEvent
@Deprecated(forRemoval=true, since="1.22.0") public BestSolutionChangedEvent(@NonNull Solver<Solution_> solver, long timeMillisSpent, @NonNull Solution_ newBestSolution, @NonNull Score newBestScore) Deprecated, for removal: This API element is subject to removal in a future version.Users should not manually construct instances of this event.- Parameters:
timeMillisSpent->= 0L
-
BestSolutionChangedEvent
@Deprecated(forRemoval=true, since="1.23.0") public BestSolutionChangedEvent(@NonNull Solver<Solution_> solver, long timeMillisSpent, @NonNull Solution_ newBestSolution, @NonNull Score newBestScore, boolean isNewBestSolutionInitialized) Deprecated, for removal: This API element is subject to removal in a future version.Users should not manually construct instances of this event.- Parameters:
timeMillisSpent->= 0L
-
-
Method Details
-
getTimeMillisSpent
public long getTimeMillisSpent()- Returns:
>= 0, the amount of millis spent since theSolverstarted untilgetNewBestSolution()was found
-
getNewBestSolution
Note that:- In real-time planning, not all
ProblemChanges might be processed: checkisEveryProblemFactChangeProcessed(). - this
PlanningSolutionmight be uninitialized: checkisNewBestSolutionInitialized(). - this
PlanningSolutionmight be infeasible: checkScore.isFeasible().
- In real-time planning, not all
-
getNewBestScore
Returns theScoreof thegetNewBestSolution().This is useful for generic code, which doesn't know the type of the
PlanningSolutionto retrieve theScorefrom thegetNewBestSolution()easily. -
isNewBestSolutionInitialized
public boolean isNewBestSolutionInitialized()- Returns:
- True if
getNewBestSolution()is initialized.
-
isEveryProblemFactChangeProcessed
Deprecated, for removal: This API element is subject to removal in a future version.PreferisEveryProblemChangeProcessed().This method is deprecated.- Returns:
- As defined by
Solver.isEveryProblemFactChangeProcessed() - See Also:
-
isEveryProblemChangeProcessed
public boolean isEveryProblemChangeProcessed()- Returns:
- As defined by
Solver.isEveryProblemChangeProcessed() - See Also:
-