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 Deprecated Methods Modifier and Type Method Description ScoregetNewBestScore()Returns theScoreof thegetNewBestSolution().Solution_getNewBestSolution()Note that: In real-time planning, not allProblemChanges might be processed: checkisEveryProblemFactChangeProcessed(). thisPlanningSolutionmight be uninitialized: checkScore.isSolutionInitialized(). thisPlanningSolutionmight be infeasible: checkScore.isFeasible().longgetTimeMillisSpent()booleanisEveryProblemChangeProcessed()booleanisEveryProblemFactChangeProcessed()Deprecated, for removal: This API element is subject to removal in a future version.in favor ofisEveryProblemChangeProcessed().-
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
ProblemChanges 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
@Deprecated(forRemoval=true) public boolean isEveryProblemFactChangeProcessed()
Deprecated, for removal: This API element is subject to removal in a future version.in favor ofisEveryProblemChangeProcessed().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()
-
-