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 allProblemFactChange
s might be processed: checkisEveryProblemFactChangeProcessed()
. thisPlanningSolution
might be uninitialized: checkScore.isSolutionInitialized()
. thisPlanningSolution
might be infeasible: checkScore.isFeasible()
.long
getTimeMillisSpent()
boolean
isEveryProblemFactChangeProcessed()
boolean
isNewBestSolutionInitialized()
Deprecated.UsegetNewBestScore()
'sScore.isSolutionInitialized()
instead.-
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
ProblemFactChange
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
public boolean isEveryProblemFactChangeProcessed()
- Returns:
- As defined by
Solver.isEveryProblemFactChangeProcessed()
- See Also:
Solver.isEveryProblemFactChangeProcessed()
-
isNewBestSolutionInitialized
@Deprecated public boolean isNewBestSolutionInitialized()
Deprecated.UsegetNewBestScore()
'sScore.isSolutionInitialized()
instead. Will be removed in 8.0.- Returns:
- true if all the planning entities have planning variables that are initialized.
-
-