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
public class BestSolutionChangedEvent<Solution_> extends EventObject
Delivered when thebest solution
changes during solving. Delivered in the solver thread (which is the thread that callsSolver.solve(Solution_)
).- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class java.util.EventObject
source
-
-
Constructor Summary
Constructors Constructor Description BestSolutionChangedEvent(Solver<Solution_> solver, long timeMillisSpent, Solution_ newBestSolution, Score newBestScore)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description Score
getNewBestScore()
Returns theScore
of thegetNewBestSolution()
.Solution_
getNewBestSolution()
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
getTimeMillisSpent()
boolean
isEveryProblemChangeProcessed()
boolean
isEveryProblemFactChangeProcessed()
Deprecated, for removal: This API element is subject to removal in a future version.PreferisEveryProblemChangeProcessed()
.-
Methods inherited from class java.util.EventObject
getSource, toString
-
-
-
-
Method Detail
-
getTimeMillisSpent
public long getTimeMillisSpent()
- Returns:
>= 0
, the amount of millis spent since theSolver
started untilgetNewBestSolution()
was found
-
getNewBestSolution
public Solution_ 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
public Score 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(forRemoval=true) public boolean 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:
Solver.isEveryProblemFactChangeProcessed()
-
isEveryProblemChangeProcessed
public boolean isEveryProblemChangeProcessed()
- Returns:
- As defined by
Solver.isEveryProblemChangeProcessed()
- See Also:
Solver.isEveryProblemChangeProcessed()
-
-