@@ -118,33 +118,25 @@ public <Score_ extends Score<Score_>> void processWorkingSolutionDuringMove(Inne
118118
119119 public void updateBestSolutionAndFire (SolverScope <Solution_ > solverScope ) {
120120 updateBestSolutionWithoutFiring (solverScope );
121- // We need to clone the solution again, or we may use the same instance employed by the solver scope,
122- // which is restored between solver phases.
123- // The operation won't block the solving process.
124- solverEventSupport .fireBestSolutionChanged (solverScope , solverScope .cloneBestSolution ());
121+ solverEventSupport .fireBestSolutionChanged (solverScope , solverScope .getBestSolution ());
125122 }
126123
127124 public void updateBestSolutionAndFireIfInitialized (SolverScope <Solution_ > solverScope ) {
128125 updateBestSolutionWithoutFiring (solverScope );
129126 if (solverScope .isBestSolutionInitialized ()) {
130- // We need to clone the solution again, or we may use the same instance employed by the solver scope,
131- // which is restored between solver phases.
132- // The operation won't block the solving process.
133- solverEventSupport .fireBestSolutionChanged (solverScope , solverScope .cloneBestSolution ());
127+ solverEventSupport .fireBestSolutionChanged (solverScope , solverScope .getBestSolution ());
134128 }
135129 }
136130
137131 private void updateBestSolutionAndFire (SolverScope <Solution_ > solverScope , InnerScore <?> bestScore ,
138132 Solution_ bestSolution ) {
139133 updateBestSolutionWithoutFiring (solverScope , bestScore , bestSolution );
140- // We need to clone the solution again, or we may use the same instance employed by the solver scope,
141- // which is restored between solver phases.
142- // The operation won't block the solving process.
143- solverEventSupport .fireBestSolutionChanged (solverScope , solverScope .cloneBestSolution ());
134+ solverEventSupport .fireBestSolutionChanged (solverScope , bestSolution );
144135 }
145136
146137 @ SuppressWarnings ({ "unchecked" , "rawtypes" })
147138 private void updateBestSolutionWithoutFiring (SolverScope <Solution_ > solverScope ) {
139+ // We clone the existing working solution to set it as the best current solution
148140 var newBestSolution = solverScope .getScoreDirector ().cloneWorkingSolution ();
149141 var newBestScore = solverScope .getSolutionDescriptor ().<Score > getScore (newBestSolution );
150142 var innerScore = InnerScore .withUnassignedCount (newBestScore , -solverScope .getScoreDirector ().getWorkingInitScore ());
0 commit comments