Class BestSolutionChangedEvent<Solution_>
java.lang.Object
java.util.EventObject
org.optaplanner.core.api.solver.event.BestSolutionChangedEvent<Solution_>
- Type Parameters:
Solution_
- the solution type, the class with thePlanningSolution
annotation
- All Implemented Interfaces:
Serializable
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
ConstructorDescriptionBestSolutionChangedEvent
(Solver<Solution_> solver, long timeMillisSpent, Solution_ newBestSolution, Score newBestScore) -
Method Summary
Modifier and TypeMethodDescriptionReturns theScore
of thegetNewBestSolution()
.Note that: In real-time planning, not allProblemChange
s might be processed: checkisEveryProblemFactChangeProcessed()
. thisPlanningSolution
might be uninitialized: checkScore.isSolutionInitialized()
. thisPlanningSolution
might be infeasible: checkScore.isFeasible()
.long
boolean
boolean
Deprecated, for removal: This API element is subject to removal in a future version.Methods inherited from class java.util.EventObject
getSource, toString
-
Constructor Details
-
Method Details
-
getTimeMillisSpent
public long getTimeMillisSpent()- Returns:
>= 0
, the amount of millis spent since theSolver
started untilgetNewBestSolution()
was found
-
getNewBestSolution
Note that:- In real-time planning, not all
ProblemChange
s might be processed: checkisEveryProblemFactChangeProcessed()
. - this
PlanningSolution
might be uninitialized: checkScore.isSolutionInitialized()
. - this
PlanningSolution
might be infeasible: checkScore.isFeasible()
.
- Returns:
- never null
- In real-time planning, not all
-
getNewBestScore
Returns theScore
of thegetNewBestSolution()
.This is useful for generic code, which doesn't know the type of the
PlanningSolution
to retrieve theScore
from thegetNewBestSolution()
easily.- Returns:
- never null, because at this point it's always already calculated
-
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:
-
isEveryProblemChangeProcessed()
.