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 thePlanningSolutionannotation
- All Implemented Interfaces:
Serializable
public class BestSolutionChangedEvent<Solution_> extends EventObject
Delivered when thebest solutionchanges 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 Modifier and Type Method Description ScoregetNewBestScore()Returns theScoreof thegetNewBestSolution().Solution_getNewBestSolution()Note that: In real-time planning, not allProblemFactChanges might be processed: checkisEveryProblemFactChangeProcessed(). thisPlanningSolutionmight be uninitialized: checkScore.isSolutionInitialized(). thisPlanningSolutionmight be infeasible: checkScore.isFeasible().longgetTimeMillisSpent()booleanisEveryProblemFactChangeProcessed()-
Methods inherited from class java.util.EventObject
getSource, toString
-
-
-
-
Method Detail
-
getTimeMillisSpent
public long getTimeMillisSpent()
- Returns:
>= 0, the amount of millis spent since theSolverstarted untilgetNewBestSolution()was found
-
getNewBestSolution
public Solution_ getNewBestSolution()
Note that:- In real-time planning, not all
ProblemFactChanges might be processed: checkisEveryProblemFactChangeProcessed(). - this
PlanningSolutionmight be uninitialized: checkScore.isSolutionInitialized(). - this
PlanningSolutionmight be infeasible: checkScore.isFeasible().
- Returns:
- never null
- In real-time planning, not all
-
getNewBestScore
public Score getNewBestScore()
Returns theScoreof thegetNewBestSolution().This is useful for generic code, which doesn't know the type of the
PlanningSolutionto retrieve theScorefrom thegetNewBestSolution()easily.- Returns:
- never null, because at this point it's always already calculated
-
isEveryProblemFactChangeProcessed
public boolean isEveryProblemFactChangeProcessed()
- Returns:
- As defined by
Solver.isEveryProblemFactChangeProcessed() - See Also:
Solver.isEveryProblemFactChangeProcessed()
-
-