signature: public class ScoreCalculationSpeedProblemStatistic { @ Override public void writeGraphFiles ( BenchmarkReport benchmarkReport ) { } }

implementation:
Locale locale = benchmarkReport . getLocale ( ) ; NumberAxis xAxis = new NumberAxis ( "Time spent" ) ; xAxis . setNumberFormatOverride ( new MillisecondsSpentNumberFormat ( locale ) ) ; NumberAxis yAxis = new NumberAxis ( "Score calculation speed per second" ) ; yAxis . setNumberFormatOverride ( NumberFormat . getInstance ( locale ) ) ; yAxis . setAutoRangeIncludesZero ( false ) ; XYPlot plot = new XYPlot ( null , xAxis , yAxis , null ) ; plot . setOrientation ( PlotOrientation . VERTICAL ) ; int seriesIndex = 0 ; for ( SingleBenchmarkResult singleBenchmarkResult : problemBenchmarkResult . getSingleBenchmarkResultList ( ) ) { XYSeries series = new XYSeries ( singleBenchmarkResult . getSolverBenchmarkResult ( ) . getNameWithFavoriteSuffix ( ) ) ; XYItemRenderer renderer = new XYLineAndShapeRenderer ( ) ; if ( singleBenchmarkResult . hasAllSuccess ( ) ) { ScoreCalculationSpeedSubSingleStatistic subSingleStatistic = ( ScoreCalculationSpeedSubSingleStatistic ) singleBenchmarkResult . getSubSingleStatistic ( problemStatisticType ) ; List < ScoreCalculationSpeedStatisticPoint > points = subSingleStatistic . getPointList ( ) ; for ( ScoreCalculationSpeedStatisticPoint point : points ) { long timeMillisSpent = point . getTimeMillisSpent ( ) ; long scoreCalculationSpeed = point . getScoreCalculationSpeed ( ) ; series . add ( timeMillisSpent , scoreCalculationSpeed ) ; } } plot . setDataset ( seriesIndex , new XYSeriesCollection ( series ) ) ; if ( singleBenchmarkResult . getSolverBenchmarkResult ( ) . isFavorite ( ) ) { // Make the favorite more obvious
renderer . setSeriesStroke ( 0 , new BasicStroke ( 2.0f ) ) ; } plot . setRenderer ( seriesIndex , renderer ) ; seriesIndex ++ ; } JFreeChart chart = new JFreeChart ( problemBenchmarkResult . getName ( ) + " score calculation speed statistic" , JFreeChart . DEFAULT_TITLE_FONT , plot , true ) ; graphFile = writeChartToImageFile ( chart , problemBenchmarkResult . getName ( ) + "ScoreCalculationSpeedStatistic" ) ;


signature: public class InvestmentIncrementalScoreCalculator { @ Override public void resetWorkingSolution ( InvestmentSolution solution ) { } }

implementation: this . solution = solution ; squaredStandardDeviationFemtosMaximum = solution . getParametrization ( ) . calculateSquaredStandardDeviationFemtosMaximum ( ) ; squaredStandardDeviationFemtos = 0L ; List < Region > regionList = solution . getRegionList ( ) ; regionQuantityTotalMap = new HashMap < > ( ) ; for ( Region region : regionList ) { regionQuantityTotalMap . put ( region , 0L ) ; } List < Sector > sectorList = solution . getSectorList ( ) ; sectorQuantityTotalMap = new HashMap < > ( sectorList . size ( ) ) ; for ( Sector sector : sectorList ) { sectorQuantityTotalMap . put ( sector , 0L ) ; } hardScore = 0L ; softScore = 0L ; for ( AssetClassAllocation allocation : solution . getAssetClassAllocationList ( ) ) { insertQuantityMillis ( allocation , true ) ; }


signature: public class InvestmentIncrementalScoreCalculator { private void insertQuantityMillis ( AssetClassAllocation allocation , boolean reset ) { } }

implementation:
// Standard deviation maximum
if ( squaredStandardDeviationFemtos > squaredStandardDeviationFemtosMaximum ) { hardScore += squaredStandardDeviationFemtos - squaredStandardDeviationFemtosMaximum ; } squaredStandardDeviationFemtos += calculateStandardDeviationSquaredFemtosDelta ( allocation , reset ) ; if ( squaredStandardDeviationFemtos > squaredStandardDeviationFemtosMaximum ) { hardScore -= squaredStandardDeviationFemtos - squaredStandardDeviationFemtosMaximum ; } Long quantityMillis = allocation . getQuantityMillis ( ) ; if ( quantityMillis != null ) { // Region quantity maximum
Region region = allocation . getRegion ( ) ; long regionQuantityMaximum = region . getQuantityMillisMaximum ( ) ; long oldRegionQuantity = regionQuantityTotalMap . get ( region ) ; long oldRegionAvailable = regionQuantityMaximum - oldRegionQuantity ; long newRegionQuantity = oldRegionQuantity + quantityMillis ; long newRegionAvailable = regionQuantityMaximum - newRegionQuantity ; hardScore += Math . min ( newRegionAvailable , 0L ) - Math . min ( oldRegionAvailable , 0L ) ; regionQuantityTotalMap . put ( region , newRegionQuantity ) ; // Sector quantity maximum
Sector sector = allocation . getSector ( ) ; long sectorQuantityMaximum = sector . getQuantityMillisMaximum ( ) ; long oldSectorQuantity = sectorQuantityTotalMap . get ( sector ) ; long oldSectorAvailable = sectorQuantityMaximum - oldSectorQuantity ; long newSectorQuantity = oldSectorQuantity + quantityMillis ; long newSectorAvailable = sectorQuantityMaximum - newSectorQuantity ; hardScore += Math . min ( newSectorAvailable , 0L ) - Math . min ( oldSectorAvailable , 0L ) ; sectorQuantityTotalMap . put ( sector , newSectorQuantity ) ; } // Maximize expected return
softScore += allocation . getQuantifiedExpectedReturnMicros ( ) ;


signature:
public class BasicPlumbingTermination { /** * If this returns true , then the problemFactChangeQueue is definitely not empty .
 * Concurrency note : Blocks until { @ link # problemFactChangeQueue } is not empty or { @ link # terminatedEarly } is true .
 * @ return true if the solver needs to be restarted */
public synchronized boolean waitForRestartSolverDecision ( ) { } }

implementation: if ( ! daemon ) { return ! problemFactChangeQueue . isEmpty ( ) && ! terminatedEarly ; } else { while ( problemFactChangeQueue . isEmpty ( ) && ! terminatedEarly ) { try { wait ( ) ; } catch ( InterruptedException e ) { Thread . currentThread ( ) . interrupt ( ) ; throw new IllegalStateException ( "Solver thread was interrupted during Object.wait()." , e ) ; } } return ! terminatedEarly ; }


signature:
public class BasicPlumbingTermination { /** * Concurrency note : unblocks { @ link # waitForRestartSolverDecision ( ) } .
 * @ param problemFactChange never null
 * @ return as specified by { @ link Collection # add } */
public synchronized < Solution_ > boolean addProblemFactChange ( ProblemFactChange < Solution_ > problemFactChange ) { } }

implementation: boolean added = problemFactChangeQueue . add ( problemFactChange ) ; notifyAll ( ) ; return added ;


signature:
public class BasicPlumbingTermination { /** * Concurrency note : unblocks { @ link # waitForRestartSolverDecision ( ) } .
 * @ param problemFactChangeList never null
 * @ return as specified by { @ link Collection # add } */
public synchronized < Solution_ > boolean addProblemFactChanges ( List < ProblemFactChange < Solution_ > > problemFactChangeList ) { } }

implementation: boolean added = problemFactChangeQueue . addAll ( problemFactChangeList ) ; notifyAll ( ) ; return added ;


signature: public class BasicPlumbingTermination { @ Override public synchronized boolean isSolverTerminated ( DefaultSolverScope solverScope ) { } }

implementation:
// Destroying a thread pool with solver threads will only cause it to interrupt those solver threads ,
// it won ' t call Solver . terminateEarly ( )
if ( Thread . currentThread ( ) . isInterrupted ( ) // Does not clear the interrupted flag
// Avoid duplicate log message because this method is called twice :
// - in the phase step loop ( every phase termination bridges to the solver termination )
// - in the solver ' s phase loop
&& ! terminatedEarly ) { logger . info ( "The solver thread got interrupted, so this solver is terminating early." ) ; terminatedEarly = true ; } return terminatedEarly || ! problemFactChangeQueue . isEmpty ( ) ;


signature:
public class MrMachineTransientUsage { /** * Used by the GUI to sort the { @ link ConstraintMatch } list
 * by { @ link ConstraintMatch # getJustificationList ( ) } .
 * @ param other never null
 * @ return comparison */
@ Override public int compareTo ( MrMachineTransientUsage other ) { } }

implementation: return new CompareToBuilder ( ) . append ( machineCapacity , other . machineCapacity ) . append ( usage , other . usage ) . toComparison ( ) ;


signature: public class HillClimbingAcceptor { @ Override public boolean isAccepted ( LocalSearchMoveScope moveScope ) { } }

implementation: Score moveScore = moveScope . getScore ( ) ; Score lastStepScore = moveScope . getStepScope ( ) . getPhaseScope ( ) . getLastCompletedStepScope ( ) . getScore ( ) ; return moveScore . compareTo ( lastStepScore ) >= 0 ;


signature:
public class BendableScore { /** * Creates a new { @ link BendableScore } .
 * @ param hardLevelsSize at least 0
 * @ param softLevelsSize at least 0
 * @ param hardLevel at least 0 , less than hardLevelsSize
 * @ param hardScore any
 * @ return never null */
public static BendableScore ofHard ( int hardLevelsSize , int softLevelsSize , int hardLevel , int hardScore ) { } }

implementation: int [ ] hardScores = new int [ hardLevelsSize ] ; hardScores [ hardLevel ] = hardScore ; return new BendableScore ( 0 , hardScores , new int [ softLevelsSize ] ) ;


signature:
public class BendableScore { /** * Creates a new { @ link BendableScore } .
 * @ param hardLevelsSize at least 0
 * @ param softLevelsSize at least 0
 * @ param softLevel at least 0 , less than softLevelsSize
 * @ param softScore any
 * @ return never null */
public static BendableScore ofSoft ( int hardLevelsSize , int softLevelsSize , int softLevel , int softScore ) { } }

implementation: int [ ] softScores = new int [ softLevelsSize ] ; softScores [ softLevel ] = softScore ; return new BendableScore ( 0 , new int [ hardLevelsSize ] , softScores ) ;


signature: public class UnionMoveSelectorConfig { @ Override public MoveSelector buildBaseMoveSelector ( HeuristicConfigPolicy configPolicy , SelectionCacheType minimumCacheType , boolean randomSelection ) { } }

implementation:
List < MoveSelector > moveSelectorList = new ArrayList < > ( moveSelectorConfigList . size ( ) ) ; for ( MoveSelectorConfig moveSelectorConfig : moveSelectorConfigList ) { moveSelectorList . add ( moveSelectorConfig . buildMoveSelector ( configPolicy , minimumCacheType , SelectionOrder . fromRandomSelectionBoolean ( randomSelection ) ) ) ; } SelectionProbabilityWeightFactory selectorProbabilityWeightFactory ; if ( selectorProbabilityWeightFactoryClass != null ) { if ( ! randomSelection ) { throw new IllegalArgumentException ( "The moveSelectorConfig (" + this + ") with selectorProbabilityWeightFactoryClass (" + selectorProbabilityWeightFactoryClass + ") has non-random randomSelection (" + randomSelection + ")." ) ; } selectorProbabilityWeightFactory = ConfigUtils . newInstance ( this , "selectorProbabilityWeightFactoryClass" , selectorProbabilityWeightFactoryClass ) ; } else if ( randomSelection ) { Map < MoveSelector , Double > fixedProbabilityWeightMap = new HashMap < > ( moveSelectorConfigList . size ( ) ) ; for ( int i = 0 ; i < moveSelectorConfigList . size ( ) ; i ++ ) { MoveSelectorConfig moveSelectorConfig = moveSelectorConfigList . get ( i ) ; MoveSelector moveSelector = moveSelectorList . get ( i ) ; Double fixedProbabilityWeight = moveSelectorConfig . getFixedProbabilityWeight ( ) ; if ( fixedProbabilityWeight == null ) { // Default to equal probability for each move type = > unequal probability for each move instance
fixedProbabilityWeight = 1.0 ; } fixedProbabilityWeightMap . put ( moveSelector , fixedProbabilityWeight ) ; } selectorProbabilityWeightFactory = new FixedSelectorProbabilityWeightFactory ( fixedProbabilityWeightMap ) ; } else { selectorProbabilityWeightFactory = null ; } return new UnionMoveSelector ( moveSelectorList , randomSelection , selectorProbabilityWeightFactory ) ;


signature: public class DefaultLocalSearchPhase { @ Override public void solve ( DefaultSolverScope < Solution_ > solverScope ) { } }

implementation:
LocalSearchPhaseScope < Solution_ > phaseScope = new LocalSearchPhaseScope < > ( solverScope ) ; phaseStarted ( phaseScope ) ; while ( ! termination . isPhaseTerminated ( phaseScope ) ) { LocalSearchStepScope < Solution_ > stepScope = new LocalSearchStepScope < > ( phaseScope ) ; stepScope . setTimeGradient ( termination . calculatePhaseTimeGradient ( phaseScope ) ) ; stepStarted ( stepScope ) ; decider . decideNextStep ( stepScope ) ; if ( stepScope . getStep ( ) == null ) { if ( termination . isPhaseTerminated ( phaseScope ) ) { logger . trace ( "{}    Step index ({}), time spent ({}) terminated without picking a nextStep." , logIndentation , stepScope . getStepIndex ( ) , stepScope . getPhaseScope ( ) . calculateSolverTimeMillisSpentUpToNow ( ) ) ; } else if ( stepScope . getSelectedMoveCount ( ) == 0L ) { logger . warn ( "{}    No doable selected move at step index ({}), time spent ({})." + " Terminating phase early." , logIndentation , stepScope . getStepIndex ( ) , stepScope . getPhaseScope ( ) . calculateSolverTimeMillisSpentUpToNow ( ) ) ; } else { throw new IllegalStateException ( "The step index (" + stepScope . getStepIndex ( ) + ") has accepted/selected move count (" + stepScope . getAcceptedMoveCount ( ) + "/" + stepScope . getSelectedMoveCount ( ) + ") but failed to pick a nextStep (" + stepScope . getStep ( ) + ")." ) ; } // Although stepStarted has been called , stepEnded is not called for this step
break ; } doStep ( stepScope ) ; stepEnded ( stepScope ) ; phaseScope . setLastCompletedStepScope ( stepScope ) ; } phaseEnded ( phaseScope ) ;


signature: public class SubSingleBenchmarkRunner { @ Override public SubSingleBenchmarkRunner < Solution_ > call ( ) { } }

implementation:
MDC . put ( NAME_MDC , subSingleBenchmarkResult . getName ( ) ) ; Runtime runtime = Runtime . getRuntime ( ) ; ProblemBenchmarkResult < Solution_ > problemBenchmarkResult = subSingleBenchmarkResult . getSingleBenchmarkResult ( ) . getProblemBenchmarkResult ( ) ; Solution_ problem = problemBenchmarkResult . readProblem ( ) ; if ( ! problemBenchmarkResult . getPlannerBenchmarkResult ( ) . hasMultipleParallelBenchmarks ( ) ) { runtime . gc ( ) ; subSingleBenchmarkResult . setUsedMemoryAfterInputSolution ( runtime . totalMemory ( ) - runtime . freeMemory ( ) ) ; } logger . trace ( "Benchmark problem has been read for subSingleBenchmarkResult ({})." , subSingleBenchmarkResult ) ; SolverConfig solverConfig = subSingleBenchmarkResult . getSingleBenchmarkResult ( ) . getSolverBenchmarkResult ( ) . getSolverConfig ( ) ; if ( subSingleBenchmarkResult . getSingleBenchmarkResult ( ) . getSubSingleCount ( ) > 1 ) { solverConfig = new SolverConfig ( solverConfig ) ; solverConfig . offerRandomSeedFromSubSingleIndex ( ( long ) subSingleBenchmarkResult . getSubSingleBenchmarkIndex ( ) ) ; } // Intentionally create a fresh solver for every SingleBenchmarkResult to reset Random , tabu lists , . . .
Solver < Solution_ > solver = solverConfig . buildSolver ( solverConfigContext ) ; for ( SubSingleStatistic subSingleStatistic : subSingleBenchmarkResult . getEffectiveSubSingleStatisticMap ( ) . values ( ) ) { subSingleStatistic . open ( solver ) ; subSingleStatistic . initPointList ( ) ; } Solution_ solution = solver . solve ( problem ) ; long timeMillisSpent = solver . getTimeMillisSpent ( ) ; DefaultSolverScope < Solution_ > solverScope = ( ( DefaultSolver < Solution_ > ) solver ) . getSolverScope ( ) ; SolutionDescriptor < Solution_ > solutionDescriptor = solverScope . getSolutionDescriptor ( ) ; problemBenchmarkResult . registerScale ( solutionDescriptor . getEntityCount ( solution ) , solutionDescriptor . getGenuineVariableCount ( solution ) , solutionDescriptor . getMaximumValueCount ( solution ) , solutionDescriptor . getProblemScale ( solution ) ) ; subSingleBenchmarkResult . setScore ( solutionDescriptor . getScore ( solution ) ) ; subSingleBenchmarkResult . setTimeMillisSpent ( timeMillisSpent ) ; subSingleBenchmarkResult . setScoreCalculationCount ( solverScope . getScoreCalculationCount ( ) ) ; for ( SubSingleStatistic subSingleStatistic : subSingleBenchmarkResult . getEffectiveSubSingleStatisticMap ( ) . values ( ) ) { subSingleStatistic . close ( solver ) ; subSingleStatistic . hibernatePointList ( ) ; } if ( ! warmUp ) { problemBenchmarkResult . writeSolution ( subSingleBenchmarkResult , solution ) ; } MDC . remove ( NAME_MDC ) ; return this ;


signature: public class MoveIteratorFactoryConfig { @ Override public MoveSelector buildBaseMoveSelector ( HeuristicConfigPolicy configPolicy , SelectionCacheType minimumCacheType , boolean randomSelection ) { } }

implementation: if ( moveIteratorFactoryClass == null ) { throw new IllegalArgumentException ( "The moveIteratorFactoryConfig (" + this + ") lacks a moveListFactoryClass (" + moveIteratorFactoryClass + ")." ) ; } MoveIteratorFactory moveIteratorFactory = ConfigUtils . newInstance ( this , "moveIteratorFactoryClass" , moveIteratorFactoryClass ) ; ConfigUtils . applyCustomProperties ( moveIteratorFactory , "moveIteratorFactoryClass" , moveIteratorFactoryCustomProperties , "moveIteratorFactoryCustomProperties" ) ; return new MoveIteratorFactoryToMoveSelectorBridge ( moveIteratorFactory , randomSelection ) ;


signature:
public class DroolsScoreDirector { /** * public void beforeEntityAdded ( EntityDescriptor entityDescriptor , Object entity ) / / Do nothing */
@ Override public void afterEntityAdded ( EntityDescriptor < Solution_ > entityDescriptor , Object entity ) { } }

implementation: if ( entity == null ) { throw new IllegalArgumentException ( "The entity (" + entity + ") cannot be added to the ScoreDirector." ) ; } if ( ! getSolutionDescriptor ( ) . hasEntityDescriptor ( entity . getClass ( ) ) ) { throw new IllegalArgumentException ( "The entity (" + entity + ") of class (" + entity . getClass ( ) + ") is not a configured @PlanningEntity." ) ; } if ( kieSession . getFactHandle ( entity ) != null ) { throw new IllegalArgumentException ( "The entity (" + entity + ") was already added to this ScoreDirector." + " Usually the cause is that that specific instance was already in your Solution's entities" + " and you probably want to use before/afterVariableChanged() instead." ) ; } kieSession . insert ( entity ) ; super . afterEntityAdded ( entityDescriptor , entity ) ;


signature:
public class DroolsScoreDirector { /** * public void beforeVariableChanged ( VariableDescriptor variableDescriptor , Object entity ) / / Do nothing */
@ Override public void afterVariableChanged ( VariableDescriptor variableDescriptor , Object entity ) { } }

implementation: update ( entity , variableDescriptor . getVariableName ( ) ) ; super . afterVariableChanged ( variableDescriptor , entity ) ;


signature:
public class DroolsScoreDirector { /** * public void beforeEntityRemoved ( EntityDescriptor entityDescriptor , Object entity ) / / Do nothing */
@ Override public void afterEntityRemoved ( EntityDescriptor < Solution_ > entityDescriptor , Object entity ) { } }

implementation: FactHandle factHandle = kieSession . getFactHandle ( entity ) ; if ( factHandle == null ) { throw new IllegalArgumentException ( "The entity (" + entity + ") was never added to this ScoreDirector.\n" + "Maybe that specific instance is not in the return values of the " + PlanningSolution . class . getSimpleName ( ) + "'s entity members (" + getSolutionDescriptor ( ) . getEntityMemberAndEntityCollectionMemberNames ( ) + ")." ) ; } kieSession . delete ( factHandle ) ; super . afterEntityRemoved ( entityDescriptor , entity ) ;


signature:
public class DroolsScoreDirector { /** * public void beforeProblemFactAdded ( Object problemFact ) / / Do nothing */
@ Override public void afterProblemFactAdded ( Object problemFact ) { } }

implementation: if ( kieSession . getFactHandle ( problemFact ) != null ) { throw new IllegalArgumentException ( "The problemFact (" + problemFact + ") was already added to this ScoreDirector.\n" + "Maybe that specific instance is already in the " + PlanningSolution . class . getSimpleName ( ) + "'s problem fact members (" + getSolutionDescriptor ( ) . getProblemFactMemberAndProblemFactCollectionMemberNames ( ) + ").\n" + "Maybe use before/afterProblemPropertyChanged() instead of before/afterProblemFactAdded()." ) ; } kieSession . insert ( problemFact ) ; super . afterProblemFactAdded ( problemFact ) ;


signature:
public class DroolsScoreDirector { /** * public void beforeProblemPropertyChanged ( Object problemFactOrEntity ) / / Do nothing */
@ Override public void afterProblemPropertyChanged ( Object problemFactOrEntity ) { } }

implementation: FactHandle factHandle = kieSession . getFactHandle ( problemFactOrEntity ) ; if ( factHandle == null ) { throw new IllegalArgumentException ( "The problemFact (" + problemFactOrEntity + ") was never added to this ScoreDirector.\n" + "Maybe that specific instance is not in the " + PlanningSolution . class . getSimpleName ( ) + "'s problem fact members (" + getSolutionDescriptor ( ) . getProblemFactMemberAndProblemFactCollectionMemberNames ( ) + ").\n" + "Maybe first translate that external instance to the workingSolution's instance" + " with " + ScoreDirector . class . getSimpleName ( ) + ".lookUpWorkingObject()." ) ; } kieSession . update ( factHandle , problemFactOrEntity ) ; super . afterProblemPropertyChanged ( problemFactOrEntity ) ;


signature:
public class DroolsScoreDirector { /** * public void beforeProblemFactRemoved ( Object problemFact ) / / Do nothing */
@ Override public void afterProblemFactRemoved ( Object problemFact ) { } }

implementation: FactHandle factHandle = kieSession . getFactHandle ( problemFact ) ; if ( factHandle == null ) { throw new IllegalArgumentException ( "The problemFact (" + problemFact + ") was never added to this ScoreDirector.\n" + "Maybe that specific instance is not in the " + PlanningSolution . class . getSimpleName ( ) + "'s problem fact members (" + getSolutionDescriptor ( ) . getProblemFactMemberAndProblemFactCollectionMemberNames ( ) + ").\n" + "Maybe first translate that external instance to the workingSolution's instance" + " with " + ScoreDirector . class . getSimpleName ( ) + ".lookUpWorkingObject()." ) ; } kieSession . delete ( factHandle ) ; super . afterProblemFactRemoved ( problemFact ) ;


signature:
public class PlannerBenchmarkFactory { /** * See { @ link # createFromXmlResource ( String ) } .
 * @ param benchmarkConfigResource never null , a classpath resource
 * as defined by { @ link ClassLoader # getResource ( String ) }
 * @ param classLoader sometimes null , the { @ link ClassLoader } to use for loading all resources and { @ link Class } es ,
 * null to use the default { @ link ClassLoader }
 * @ return never null */
public static PlannerBenchmarkFactory createFromXmlResource ( String benchmarkConfigResource , ClassLoader classLoader ) { } }

implementation: return new XStreamXmlPlannerBenchmarkFactory ( new SolverConfigContext ( classLoader ) ) . configure ( benchmarkConfigResource ) ;


signature: public class BenchmarkReportConfig { public BenchmarkReport buildBenchmarkReport ( PlannerBenchmarkResult plannerBenchmark ) { } }

implementation: BenchmarkReport benchmarkReport = new BenchmarkReport ( plannerBenchmark ) ; benchmarkReport . setLocale ( determineLocale ( ) ) ; benchmarkReport . setTimezoneId ( ZoneId . systemDefault ( ) ) ; supplySolverRanking ( benchmarkReport ) ; return benchmarkReport ;


signature: public class ExhaustiveSearchPhaseConfig { @ Override public ExhaustiveSearchPhase buildPhase ( int phaseIndex , HeuristicConfigPolicy solverConfigPolicy , BestSolutionRecaller bestSolutionRecaller , Termination solverTermination ) { } }

implementation:
HeuristicConfigPolicy phaseConfigPolicy = solverConfigPolicy . createPhaseConfigPolicy ( ) ; phaseConfigPolicy . setReinitializeVariableFilterEnabled ( true ) ; phaseConfigPolicy . setInitializedChainedValueFilterEnabled ( true ) ; ExhaustiveSearchType exhaustiveSearchType_ = exhaustiveSearchType == null ? ExhaustiveSearchType . BRANCH_AND_BOUND : exhaustiveSearchType ; phaseConfigPolicy . setEntitySorterManner ( entitySorterManner != null ? entitySorterManner : exhaustiveSearchType_ . getDefaultEntitySorterManner ( ) ) ; phaseConfigPolicy . setValueSorterManner ( valueSorterManner != null ? valueSorterManner : exhaustiveSearchType_ . getDefaultValueSorterManner ( ) ) ; DefaultExhaustiveSearchPhase phase = new DefaultExhaustiveSearchPhase ( phaseIndex , solverConfigPolicy . getLogIndentation ( ) , bestSolutionRecaller , buildPhaseTermination ( phaseConfigPolicy , solverTermination ) ) ; boolean scoreBounderEnabled = exhaustiveSearchType_ . isScoreBounderEnabled ( ) ; NodeExplorationType nodeExplorationType_ ; if ( exhaustiveSearchType_ == ExhaustiveSearchType . BRUTE_FORCE ) { nodeExplorationType_ = defaultIfNull ( nodeExplorationType , NodeExplorationType . ORIGINAL_ORDER ) ; if ( nodeExplorationType_ != NodeExplorationType . ORIGINAL_ORDER ) { throw new IllegalArgumentException ( "The phaseConfig (" + this + ") has an nodeExplorationType (" + nodeExplorationType + ") which is not compatible with its exhaustiveSearchType (" + exhaustiveSearchType + ")." ) ; } } else { nodeExplorationType_ = defaultIfNull ( nodeExplorationType , NodeExplorationType . DEPTH_FIRST ) ; } phase . setNodeComparator ( nodeExplorationType_ . buildNodeComparator ( scoreBounderEnabled ) ) ; EntitySelectorConfig entitySelectorConfig_ = buildEntitySelectorConfig ( phaseConfigPolicy ) ; EntitySelector entitySelector = entitySelectorConfig_ . buildEntitySelector ( phaseConfigPolicy , SelectionCacheType . PHASE , SelectionOrder . ORIGINAL ) ; phase . setEntitySelector ( entitySelector ) ; phase . setDecider ( buildDecider ( phaseConfigPolicy , entitySelector , bestSolutionRecaller , phase . getTermination ( ) , scoreBounderEnabled ) ) ; EnvironmentMode environmentMode = phaseConfigPolicy . getEnvironmentMode ( ) ; if ( environmentMode . isNonIntrusiveFullAsserted ( ) ) { phase . setAssertWorkingSolutionScoreFromScratch ( true ) ; phase . setAssertStepScoreFromScratch ( true ) ; // Does nothing because ES doesn ' t use predictStepScore ( )
} if ( environmentMode . isIntrusiveFastAsserted ( ) ) { phase . setAssertExpectedWorkingSolutionScore ( true ) ; phase . setAssertExpectedStepScore ( true ) ; // Does nothing because ES doesn ' t use predictStepScore ( )
phase . setAssertShadowVariablesAreNotStaleAfterStep ( true ) ; // Does nothing because ES doesn ' t use predictStepScore ( )
} return phase ;


signature: public class ConstraintConfigurationDescriptor { public void processAnnotations ( DescriptorPolicy descriptorPolicy , ScoreDefinition scoreDefinition ) { } }

implementation:
processPackAnnotation ( descriptorPolicy ) ; ArrayList < Method > potentiallyOverwritingMethodList = new ArrayList < > ( ) ; // Iterate inherited members too ( unlike for EntityDescriptor where each one is declared )
// to make sure each one is registered
for ( Class < ? > lineageClass : ConfigUtils . getAllAnnotatedLineageClasses ( constraintConfigurationClass , ConstraintConfiguration . class ) ) { List < Member > memberList = ConfigUtils . getDeclaredMembers ( lineageClass ) ; for ( Member member : memberList ) { if ( member instanceof Method && potentiallyOverwritingMethodList . stream ( ) . anyMatch ( m -> member . getName ( ) . equals ( m . getName ( ) ) // Short cut to discard negatives faster
&& ReflectionHelper . isMethodOverwritten ( ( Method ) member , m . getDeclaringClass ( ) ) ) ) { // Ignore member because it is an overwritten method
continue ; } processParameterAnnotation ( descriptorPolicy , member , scoreDefinition ) ; } potentiallyOverwritingMethodList . ensureCapacity ( potentiallyOverwritingMethodList . size ( ) + memberList . size ( ) ) ; memberList . stream ( ) . filter ( member -> member instanceof Method ) . forEach ( member -> potentiallyOverwritingMethodList . add ( ( Method ) member ) ) ; } if ( constraintWeightDescriptorMap . isEmpty ( ) ) { throw new IllegalStateException ( "The constraintConfigurationClass (" + constraintConfigurationClass + ") must have at least 1 member with a " + ConstraintWeight . class . getSimpleName ( ) + " annotation." ) ; }


signature: public class ProblemBenchmarkResult { public void accumulateResults ( BenchmarkReport benchmarkReport ) { } }

implementation: for ( SingleBenchmarkResult singleBenchmarkResult : singleBenchmarkResultList ) { singleBenchmarkResult . accumulateResults ( benchmarkReport ) ; } determineTotalsAndAveragesAndRanking ( ) ; determineWinningScoreDifference ( ) ; for ( ProblemStatistic problemStatistic : problemStatisticList ) { problemStatistic . accumulateResults ( benchmarkReport ) ; }


signature:
public class ProblemBenchmarkResult { /** * HACK to avoid loading the problem just to extract its problemScale .
 * Called multiple times , for every { @ link SingleBenchmarkResult } of this { @ link ProblemBenchmarkResult } .
 * @ param registeringEntityCount { @ code > = 0}
 * @ param registeringVariableCount { @ code > = 0}
 * @ param registeringProblemScale { @ code > = 0} */
public void registerScale ( long registeringEntityCount , long registeringVariableCount , long registeringMaximumValueCount , long registeringProblemScale ) { } }

implementation:
if ( entityCount == null ) { entityCount = registeringEntityCount ; } else if ( entityCount . longValue ( ) != registeringEntityCount ) { logger . warn ( "The problemBenchmarkResult ({}) has different entityCount values ([{},{}]).\n" + "This is normally impossible for 1 inputSolutionFile." , getName ( ) , entityCount , registeringEntityCount ) ; // The entityCount is not unknown ( null ) , but known to be ambiguous
entityCount = - 1L ; } if ( variableCount == null ) { variableCount = registeringVariableCount ; } else if ( variableCount . longValue ( ) != registeringVariableCount ) { logger . warn ( "The problemBenchmarkResult ({}) has different variableCount values ([{},{}]).\n" + "This is normally impossible for 1 inputSolutionFile." , getName ( ) , variableCount , registeringVariableCount ) ; // The variableCount is not unknown ( null ) , but known to be ambiguous
variableCount = - 1L ; } if ( maximumValueCount == null ) { maximumValueCount = registeringMaximumValueCount ; } else if ( maximumValueCount . longValue ( ) != registeringMaximumValueCount ) { logger . warn ( "The problemBenchmarkResult ({}) has different maximumValueCount values ([{},{}]).\n" + "This is normally impossible for 1 inputSolutionFile." , getName ( ) , maximumValueCount , registeringMaximumValueCount ) ; // The maximumValueCount is not unknown ( null ) , but known to be ambiguous
maximumValueCount = - 1L ; } if ( problemScale == null ) { problemScale = registeringProblemScale ; } else if ( problemScale . longValue ( ) != registeringProblemScale ) { logger . warn ( "The problemBenchmarkResult ({}) has different problemScale values ([{},{}]).\n" + "This is normally impossible for 1 inputSolutionFile." , getName ( ) , problemScale , registeringProblemScale ) ; // The problemScale is not unknown ( null ) , but known to be ambiguous
problemScale = - 1L ; }


signature: public class ProblemBenchmarkResult { protected static < Solution_ > Map < ProblemBenchmarkResult , ProblemBenchmarkResult > createMergeMap ( PlannerBenchmarkResult newPlannerBenchmarkResult , List < SingleBenchmarkResult > singleBenchmarkResultList ) { } }

implementation:
// IdentityHashMap but despite that different ProblemBenchmarkResult instances are merged
Map < ProblemBenchmarkResult , ProblemBenchmarkResult > mergeMap = new IdentityHashMap < > ( ) ; Map < ProblemProvider < Solution_ > , ProblemBenchmarkResult > problemProviderToNewResultMap = new HashMap < > ( ) ; for ( SingleBenchmarkResult singleBenchmarkResult : singleBenchmarkResultList ) { ProblemBenchmarkResult < Solution_ > oldResult = singleBenchmarkResult . getProblemBenchmarkResult ( ) ; if ( ! mergeMap . containsKey ( oldResult ) ) { ProblemBenchmarkResult < Solution_ > newResult ; if ( ! problemProviderToNewResultMap . containsKey ( oldResult . problemProvider ) ) { newResult = new ProblemBenchmarkResult < > ( newPlannerBenchmarkResult ) ; newResult . name = oldResult . name ; newResult . problemProvider = oldResult . problemProvider ; // Skip oldResult . problemReportDirectory
newResult . problemStatisticList = new ArrayList < > ( oldResult . problemStatisticList . size ( ) ) ; for ( ProblemStatistic oldProblemStatistic : oldResult . problemStatisticList ) { newResult . problemStatisticList . add ( oldProblemStatistic . getProblemStatisticType ( ) . buildProblemStatistic ( newResult ) ) ; } newResult . singleBenchmarkResultList = new ArrayList < > ( oldResult . singleBenchmarkResultList . size ( ) ) ; newResult . entityCount = oldResult . entityCount ; newResult . variableCount = oldResult . variableCount ; newResult . maximumValueCount = oldResult . maximumValueCount ; newResult . problemScale = oldResult . problemScale ; problemProviderToNewResultMap . put ( oldResult . problemProvider , newResult ) ; newPlannerBenchmarkResult . getUnifiedProblemBenchmarkResultList ( ) . add ( newResult ) ; } else { newResult = problemProviderToNewResultMap . get ( oldResult . problemProvider ) ; if ( ! Objects . equals ( oldResult . name , newResult . name ) ) { throw new IllegalStateException ( "The oldResult (" + oldResult + ") and newResult (" + newResult + ") should have the same name, because they have the same problemProvider (" + oldResult . problemProvider + ")." ) ; } newResult . problemStatisticList . removeIf ( newStatistic -> ! oldResult . hasProblemStatisticType ( newStatistic . getProblemStatisticType ( ) ) ) ; newResult . entityCount = ConfigUtils . meldProperty ( oldResult . entityCount , newResult . entityCount ) ; newResult . variableCount = ConfigUtils . meldProperty ( oldResult . variableCount , newResult . variableCount ) ; newResult . maximumValueCount = ConfigUtils . meldProperty ( oldResult . maximumValueCount , newResult . maximumValueCount ) ; newResult . problemScale = ConfigUtils . meldProperty ( oldResult . problemScale , newResult . problemScale ) ; } mergeMap . put ( oldResult , newResult ) ; } } return mergeMap ;


signature:
public class ValueRangeFactory { /** * Build a { @ link CountableValueRange } of a subset of { @ code int } values between 2 bounds .
 * @ param from inclusive minimum
 * @ param to exclusive maximum , { @ code > = from }
 * @ param incrementUnit { @ code > 0}
 * @ return never null */
public static CountableValueRange < Integer > createIntValueRange ( int from , int to , int incrementUnit ) { } }

implementation: return new IntValueRange ( from , to , incrementUnit ) ;


signature:
public class ValueRangeFactory { /** * Build a { @ link CountableValueRange } of a subset of { @ code long } values between 2 bounds .
 * @ param from inclusive minimum
 * @ param to exclusive maximum , { @ code > = from }
 * @ param incrementUnit { @ code > 0}
 * @ return never null */
public static CountableValueRange < Long > createLongValueRange ( long from , long to , long incrementUnit ) { } }

implementation: return new LongValueRange ( from , to , incrementUnit ) ;


signature:
public class ValueRangeFactory { /** * Build a { @ link CountableValueRange } of all { @ link BigInteger } values between 2 bounds .
 * @ param from inclusive minimum
 * @ param to exclusive maximum , { @ code > = from }
 * @ return never null */
public static CountableValueRange < BigInteger > createBigIntegerValueRange ( BigInteger from , BigInteger to ) { } }

implementation: return new BigIntegerValueRange ( from , to ) ;


signature:
public class ValueRangeFactory { /** * Build a { @ link CountableValueRange } of all { @ link BigDecimal } values ( of a specific scale ) between 2 bounds .
 * All parameters must have the same { @ link BigDecimal # scale ( ) } .
 * @ param from inclusive minimum
 * @ param to exclusive maximum , { @ code > = from }
 * @ return never null */
public static CountableValueRange < BigDecimal > createBigDecimalValueRange ( BigDecimal from , BigDecimal to ) { } }

implementation: return new BigDecimalValueRange ( from , to ) ;


signature:
public class ValueRangeFactory { /** * Build a { @ link CountableValueRange } of a subset of { @ link LocalDate } values between 2 bounds .
 * Facade for { @ link # createTemporalValueRange ( Temporal , Temporal , long , TemporalUnit ) } .
 * @ param from never null , inclusive minimum
 * @ param to never null , exclusive maximum , { @ code > = from }
 * @ param incrementUnitAmount { @ code > 0}
 * @ param incrementUnitType never null , must be { @ link LocalDate # isSupported ( TemporalUnit ) supported } */
public static CountableValueRange < LocalDate > createLocalDateValueRange ( LocalDate from , LocalDate to , long incrementUnitAmount , TemporalUnit incrementUnitType ) { } }

implementation: return createTemporalValueRange ( from , to , incrementUnitAmount , incrementUnitType ) ;


signature:
public class ValueRangeFactory { /** * Build a { @ link CountableValueRange } of a subset of { @ link LocalTime } values between 2 bounds .
 * Facade for { @ link # createTemporalValueRange ( Temporal , Temporal , long , TemporalUnit ) } .
 * @ param from never null , inclusive minimum
 * @ param to never null , exclusive maximum , { @ code > = from }
 * @ param incrementUnitAmount { @ code > 0}
 * @ param incrementUnitType never null , must be { @ link LocalTime # isSupported ( TemporalUnit ) supported } */
public static CountableValueRange < LocalTime > createLocalTimeValueRange ( LocalTime from , LocalTime to , long incrementUnitAmount , TemporalUnit incrementUnitType ) { } }


signature:
public class ValueRangeFactory { /** * Build a { @ link CountableValueRange } of a subset of { @ link LocalDateTime } values between 2 bounds .
 * Facade for { @ link # createTemporalValueRange ( Temporal , Temporal , long , TemporalUnit ) } .
 * @ param from never null , inclusive minimum
 * @ param to never null , exclusive maximum , { @ code > = from }
 * @ param incrementUnitAmount { @ code > 0}
 * @ param incrementUnitType never null , must be { @ link LocalDateTime # isSupported ( TemporalUnit ) supported } */
public static CountableValueRange < LocalDateTime > createLocalDateTimeValueRange ( LocalDateTime from , LocalDateTime to , long incrementUnitAmount , TemporalUnit incrementUnitType ) { } }


signature:
public class ValueRangeFactory { /** * Build a { @ link CountableValueRange } of a subset of { @ link Temporal } values ( such as { @ link LocalDate } or { @ link LocalDateTime } ) between 2 bounds .
 * All parameters must have the same { @ link TemporalUnit } .
 * @ param from never null , inclusive minimum
 * @ param to never null , exclusive maximum , { @ code > = from }
 * @ param incrementUnitAmount { @ code > 0}
 * @ param incrementUnitType never null , must be { @ link Temporal # isSupported ( TemporalUnit ) supported } by { @ code from } and { @ code to } */
public static < Temporal_ extends Temporal & Comparable < ? super Temporal_ > > CountableValueRange < Temporal_ > createTemporalValueRange ( Temporal_ from , Temporal_ to , long incrementUnitAmount , TemporalUnit incrementUnitType ) { } }

implementation: return new TemporalValueRange < > ( from , to , incrementUnitAmount , incrementUnitType ) ;


signature: public class DefaultCustomPhase { @ Override public void solve ( DefaultSolverScope < Solution_ > solverScope ) { } }

implementation: CustomPhaseScope < Solution_ > phaseScope = new CustomPhaseScope < > ( solverScope ) ; phaseStarted ( phaseScope ) ; CustomStepScope < Solution_ > stepScope = new CustomStepScope < > ( phaseScope ) ; for ( CustomPhaseCommand < Solution_ > customPhaseCommand : customPhaseCommandList ) { solverScope . checkYielding ( ) ; if ( termination . isPhaseTerminated ( phaseScope ) ) { break ; } stepStarted ( stepScope ) ; doStep ( stepScope , customPhaseCommand ) ; stepEnded ( stepScope ) ; phaseScope . setLastCompletedStepScope ( stepScope ) ; stepScope = new CustomStepScope < > ( phaseScope ) ; } phaseEnded ( phaseScope ) ;


signature: public class MoveCountPerStepProblemStatistic { @ Override public void writeGraphFiles ( BenchmarkReport benchmarkReport ) { } }

implementation:
Locale locale = benchmarkReport . getLocale ( ) ; NumberAxis xAxis = new NumberAxis ( "Time spent" ) ; xAxis . setNumberFormatOverride ( new MillisecondsSpentNumberFormat ( locale ) ) ; NumberAxis yAxis = new NumberAxis ( "Accepted/selected moves per step" ) ; yAxis . setNumberFormatOverride ( NumberFormat . getInstance ( locale ) ) ; XYPlot plot = new XYPlot ( null , xAxis , yAxis , null ) ; DrawingSupplier drawingSupplier = new DefaultDrawingSupplier ( ) ; plot . setOrientation ( PlotOrientation . VERTICAL ) ; int seriesIndex = 0 ; for ( SingleBenchmarkResult singleBenchmarkResult : problemBenchmarkResult . getSingleBenchmarkResultList ( ) ) { XYSeries acceptedSeries = new XYSeries ( singleBenchmarkResult . getSolverBenchmarkResult ( ) . getNameWithFavoriteSuffix ( ) + " accepted" ) ; XYSeries selectedSeries = new XYSeries ( singleBenchmarkResult . getSolverBenchmarkResult ( ) . getNameWithFavoriteSuffix ( ) + " selected" ) ; XYItemRenderer renderer = new XYLineAndShapeRenderer ( true , false ) ; if ( singleBenchmarkResult . hasAllSuccess ( ) ) { MoveCountPerStepSubSingleStatistic subSingleStatistic = ( MoveCountPerStepSubSingleStatistic ) singleBenchmarkResult . getSubSingleStatistic ( problemStatisticType ) ; List < MoveCountPerStepStatisticPoint > list = subSingleStatistic . getPointList ( ) ; for ( MoveCountPerStepStatisticPoint point : list ) { long timeMillisSpent = point . getTimeMillisSpent ( ) ; long acceptedMoveCount = point . getMoveCountPerStepMeasurement ( ) . getAcceptedMoveCount ( ) ; long selectedMoveCount = point . getMoveCountPerStepMeasurement ( ) . getSelectedMoveCount ( ) ; acceptedSeries . add ( timeMillisSpent , acceptedMoveCount ) ; selectedSeries . add ( timeMillisSpent , selectedMoveCount ) ; } } XYSeriesCollection seriesCollection = new XYSeriesCollection ( ) ; seriesCollection . addSeries ( acceptedSeries ) ; seriesCollection . addSeries ( selectedSeries ) ; plot . setDataset ( seriesIndex , seriesCollection ) ; if ( singleBenchmarkResult . getSolverBenchmarkResult ( ) . isFavorite ( ) ) { // Make the favorite more obvious
renderer . setSeriesStroke ( 0 , new BasicStroke ( 2.0f ) ) ; // Dashed line for selected move count
renderer . setSeriesStroke ( 1 , new BasicStroke ( 2.0f , BasicStroke . CAP_ROUND , BasicStroke . JOIN_ROUND , 1.0f , new float [ ] { 2.0f , 6.0f } , 0.0f ) ) ; } else { // Dashed line for selected move count
renderer . setSeriesStroke ( 1 , new BasicStroke ( 1.0f , BasicStroke . CAP_ROUND , BasicStroke . JOIN_ROUND , 1.0f , new float [ ] { 2.0f , 6.0f } , 0.0f ) ) ; } // Render both lines in the same color
Paint linePaint = drawingSupplier . getNextPaint ( ) ; renderer . setSeriesPaint ( 0 , linePaint ) ; renderer . setSeriesPaint ( 1 , linePaint ) ; plot . setRenderer ( seriesIndex , renderer ) ; seriesIndex ++ ; } JFreeChart chart = new JFreeChart ( problemBenchmarkResult . getName ( ) + " move count per step statistic" , JFreeChart . DEFAULT_TITLE_FONT , plot , true ) ; graphFile = writeChartToImageFile ( chart , problemBenchmarkResult . getName ( ) + "MoveCountPerStepStatistic" ) ;


signature: public class AbstractValueRangeDescriptor { @ Override public boolean mightContainEntity ( ) { } }

implementation: SolutionDescriptor < Solution_ > solutionDescriptor = variableDescriptor . getEntityDescriptor ( ) . getSolutionDescriptor ( ) ; Class < ? > variablePropertyType = variableDescriptor . getVariablePropertyType ( ) ; for ( Class < ? > entityClass : solutionDescriptor . getEntityClassSet ( ) ) { if ( variablePropertyType . isAssignableFrom ( entityClass ) ) { return true ; } } return false ;


signature:
public class MrServiceMovedProcessesCount { /** * Used by the GUI to sort the { @ link ConstraintMatch } list
 * by { @ link ConstraintMatch # getJustificationList ( ) } .
 * @ param other never null
 * @ return comparison */
@ Override public int compareTo ( MrServiceMovedProcessesCount other ) { } }

implementation: return new CompareToBuilder ( ) . append ( service , other . service ) . append ( movedProcessesCount , other . movedProcessesCount ) . toComparison ( ) ;


signature: public class AbstractMove { protected static < E > List < E > rebaseList ( List < E > externalObjectList , ScoreDirector < ? > destinationScoreDirector ) { } }

implementation: List < E > rebasedObjectList = new ArrayList < > ( externalObjectList . size ( ) ) ; for ( E entity : externalObjectList ) { rebasedObjectList . add ( destinationScoreDirector . lookUpWorkingObject ( entity ) ) ; } return rebasedObjectList ;


signature: public class DefaultPartitionedSearchPhase { @ Override public void solve ( DefaultSolverScope < Solution_ > solverScope ) { } }

implementation:
PartitionedSearchPhaseScope < Solution_ > phaseScope = new PartitionedSearchPhaseScope < > ( solverScope ) ; List < Solution_ > partList = solutionPartitioner . splitWorkingSolution ( solverScope . getScoreDirector ( ) , runnablePartThreadLimit ) ; int partCount = partList . size ( ) ; phaseScope . setPartCount ( partCount ) ; phaseStarted ( phaseScope ) ; ExecutorService executor = createThreadPoolExecutor ( partCount ) ; ChildThreadPlumbingTermination childThreadPlumbingTermination = new ChildThreadPlumbingTermination ( ) ; PartitionQueue < Solution_ > partitionQueue = new PartitionQueue < > ( partCount ) ; Semaphore runnablePartThreadSemaphore = runnablePartThreadLimit == null ? null : new Semaphore ( runnablePartThreadLimit , true ) ; try { for ( ListIterator < Solution_ > it = partList . listIterator ( ) ; it . hasNext ( ) ; ) { int partIndex = it . nextIndex ( ) ; Solution_ part = it . next ( ) ; PartitionSolver < Solution_ > partitionSolver = buildPartitionSolver ( childThreadPlumbingTermination , runnablePartThreadSemaphore , solverScope ) ; partitionSolver . addEventListener ( event -> { InnerScoreDirector < Solution_ > childScoreDirector = partitionSolver . solverScope . getScoreDirector ( ) ; PartitionChangeMove < Solution_ > move = PartitionChangeMove . createMove ( childScoreDirector , partIndex ) ; InnerScoreDirector < Solution_ > parentScoreDirector = solverScope . getScoreDirector ( ) ; move = move . rebase ( parentScoreDirector ) ; partitionQueue . addMove ( partIndex , move ) ; } ) ; executor . submit ( ( ) -> { try { partitionSolver . solve ( part ) ; long partCalculationCount = partitionSolver . getScoreCalculationCount ( ) ; partitionQueue . addFinish ( partIndex , partCalculationCount ) ; } catch ( Throwable throwable ) { // Any Exception or even Error that happens here ( on a partition thread ) must be stored
// in the partitionQueue in order to be propagated to the solver thread .
logger . trace ( "{}            Part thread ({}) exception that will be propagated to the solver thread." , logIndentation , partIndex , throwable ) ; partitionQueue . addExceptionThrown ( partIndex , throwable ) ; } } ) ; } for ( PartitionChangeMove < Solution_ > step : partitionQueue ) { PartitionedSearchStepScope < Solution_ > stepScope = new PartitionedSearchStepScope < > ( phaseScope ) ; stepStarted ( stepScope ) ; stepScope . setStep ( step ) ; if ( logger . isDebugEnabled ( ) ) { stepScope . setStepString ( step . toString ( ) ) ; } doStep ( stepScope ) ; stepEnded ( stepScope ) ; phaseScope . setLastCompletedStepScope ( stepScope ) ; } phaseScope . addChildThreadsScoreCalculationCount ( partitionQueue . getPartsCalculationCount ( ) ) ; } finally { // In case one of the partition threads threw an Exception , it is propagated here
// but the other partition threads are not aware of the failure and may continue solving for a long time ,
// so we need to ask them to terminate . In case no exception was thrown , this does nothing .
childThreadPlumbingTermination . terminateChildren ( ) ; ThreadUtils . shutdownAwaitOrKill ( executor , logIndentation , "Partitioned Search" ) ; } phaseEnded ( phaseScope ) ;


signature:
public class DefaultSolverScope { /** * Similar to { @ link Thread # yield ( ) } , but allows capping the number of active solver threads
 * at less than the CPU processor count , so other threads ( for example servlet threads that handle REST calls )
 * and other processes ( such as SSH ) have access to uncontested CPUs and don ' t suffer any latency .
 * Needs to be called < b > before < / b > { @ link Termination # isPhaseTerminated ( AbstractPhaseScope ) } ,
 * so the decision to start a new iteration is after any yield waiting time has been consumed
 * ( so { @ link Solver # terminateEarly ( ) } reacts immediately ) . */
public void checkYielding ( ) { } }

implementation:
if ( runnableThreadSemaphore != null ) { runnableThreadSemaphore . release ( ) ; try { runnableThreadSemaphore . acquire ( ) ; } catch ( InterruptedException e ) { // The BasicPlumbingTermination will terminate the solver .
Thread . currentThread ( ) . interrupt ( ) ; } }


signature: public class PillarChangeMoveSelectorConfig { @ Override public MoveSelector buildBaseMoveSelector ( HeuristicConfigPolicy configPolicy , SelectionCacheType minimumCacheType , boolean randomSelection ) { } }

implementation: PillarSelectorConfig pillarSelectorConfig_ = pillarSelectorConfig == null ? new PillarSelectorConfig ( ) : pillarSelectorConfig ; List < String > variableNameIncludeList = valueSelectorConfig == null ? null : valueSelectorConfig . getVariableName ( ) == null ? null : Collections . singletonList ( valueSelectorConfig . getVariableName ( ) ) ; PillarSelector pillarSelector = pillarSelectorConfig_ . buildPillarSelector ( configPolicy , minimumCacheType , SelectionOrder . fromRandomSelectionBoolean ( randomSelection ) , variableNameIncludeList ) ; ValueSelectorConfig valueSelectorConfig_ = valueSelectorConfig == null ? new ValueSelectorConfig ( ) : valueSelectorConfig ; ValueSelector valueSelector = valueSelectorConfig_ . buildValueSelector ( configPolicy , pillarSelector . getEntityDescriptor ( ) , minimumCacheType , SelectionOrder . fromRandomSelectionBoolean ( randomSelection ) ) ; return new PillarChangeMoveSelector ( pillarSelector , valueSelector , randomSelection ) ;


signature:
public class GenuineVariableDescriptor { /** * A { @ link PlanningVariable # nullable ( ) } value is always considered initialized , but it can still be reinitialized
 * with { @ link PlanningVariable # reinitializeVariableEntityFilter ( ) } .
 * @ param entity never null
 * @ return true if the variable on that entity is initialized */
public boolean isInitialized ( Object entity ) { } }

implementation: if ( nullable ) { return true ; } Object variable = getValue ( entity ) ; return variable != null ;


signature:
public class Flight { /** * TODO return overlapping time to avoid score trap ? */
public boolean overlaps ( Flight other ) { } }

implementation: return departureUTCDateTime . compareTo ( other . arrivalUTCDateTime ) < 0 && other . departureUTCDateTime . compareTo ( arrivalUTCDateTime ) < 0 ;


signature: public class ProbabilityEntitySelector { @ Override public void constructCache ( DefaultSolverScope solverScope ) { } }

implementation: cachedEntityMap = new TreeMap < > ( ) ; ScoreDirector scoreDirector = solverScope . getScoreDirector ( ) ; double probabilityWeightOffset = 0L ; for ( Object entity : childEntitySelector ) { double probabilityWeight = probabilityWeightFactory . createProbabilityWeight ( scoreDirector , entity ) ; cachedEntityMap . put ( probabilityWeightOffset , entity ) ; probabilityWeightOffset += probabilityWeight ; } probabilityWeightTotal = probabilityWeightOffset ;


signature: public class TimeTablePanel { public void defineColumnHeaderByKey ( HeaderColumnKey xObject ) { } }

implementation: int x = layout . addColumn ( ) ; xMap . put ( xObject , x ) ;


signature: public class TimeTablePanel { public void addCornerHeader ( HeaderColumnKey xObject , HeaderRowKey yObject , JComponent component ) { } }

implementation: int x = xMap . get ( xObject ) ; int y = yMap . get ( yObject ) ; add ( component , new TimeTableLayoutConstraints ( x , y , true ) ) ;


signature: public class Task { public int getMissingSkillCount ( ) { } }

implementation: if ( employee == null ) { return 0 ; } int count = 0 ; for ( Skill skill : taskType . getRequiredSkillList ( ) ) { if ( ! employee . getSkillSet ( ) . contains ( skill ) ) { count ++ ; } } return count ;


signature: public class DefaultConstructionHeuristicPhase { @ Override public void solve ( DefaultSolverScope < Solution_ > solverScope ) { } }

implementation:
ConstructionHeuristicPhaseScope < Solution_ > phaseScope = new ConstructionHeuristicPhaseScope < > ( solverScope ) ; phaseStarted ( phaseScope ) ; for ( Placement placement : entityPlacer ) { ConstructionHeuristicStepScope < Solution_ > stepScope = new ConstructionHeuristicStepScope < > ( phaseScope ) ; stepStarted ( stepScope ) ; decider . decideNextStep ( stepScope , placement ) ; if ( stepScope . getStep ( ) == null ) { if ( termination . isPhaseTerminated ( phaseScope ) ) { logger . trace ( "{}    Step index ({}), time spent ({}) terminated without picking a nextStep." , logIndentation , stepScope . getStepIndex ( ) , stepScope . getPhaseScope ( ) . calculateSolverTimeMillisSpentUpToNow ( ) ) ; } else if ( stepScope . getSelectedMoveCount ( ) == 0L ) { logger . warn ( "{}    No doable selected move at step index ({}), time spent ({})." + " Terminating phase early." , logIndentation , stepScope . getStepIndex ( ) , stepScope . getPhaseScope ( ) . calculateSolverTimeMillisSpentUpToNow ( ) ) ; } else { throw new IllegalStateException ( "The step index (" + stepScope . getStepIndex ( ) + ") has selected move count (" + stepScope . getSelectedMoveCount ( ) + ") but failed to pick a nextStep (" + stepScope . getStep ( ) + ")." ) ; } // Although stepStarted has been called , stepEnded is not called for this step
break ; } doStep ( stepScope ) ; stepEnded ( stepScope ) ; phaseScope . setLastCompletedStepScope ( stepScope ) ; if ( termination . isPhaseTerminated ( phaseScope ) ) { break ; } } phaseEnded ( phaseScope ) ;


signature: public class CustomPhaseConfig { @ Override public CustomPhase buildPhase ( int phaseIndex , HeuristicConfigPolicy solverConfigPolicy , BestSolutionRecaller bestSolutionRecaller , Termination solverTermination ) { } }

implementation: HeuristicConfigPolicy phaseConfigPolicy = solverConfigPolicy . createPhaseConfigPolicy ( ) ; DefaultCustomPhase phase = new DefaultCustomPhase ( phaseIndex , solverConfigPolicy . getLogIndentation ( ) , bestSolutionRecaller , buildPhaseTermination ( phaseConfigPolicy , solverTermination ) ) ; if ( ConfigUtils . isEmptyCollection ( customPhaseCommandClassList ) ) { throw new IllegalArgumentException ( "Configure at least 1 <customPhaseCommandClass> in the <customPhase> configuration." ) ; } List < CustomPhaseCommand > customPhaseCommandList = new ArrayList < > ( customPhaseCommandClassList . size ( ) ) ; for ( Class < ? extends CustomPhaseCommand > customPhaseCommandClass : customPhaseCommandClassList ) { CustomPhaseCommand customPhaseCommand = ConfigUtils . newInstance ( this , "customPhaseCommandClass" , customPhaseCommandClass ) ; ConfigUtils . applyCustomProperties ( customPhaseCommand , "customPhaseCommandClass" , customProperties , "customProperties" ) ; customPhaseCommandList . add ( customPhaseCommand ) ; } phase . setCustomPhaseCommandList ( customPhaseCommandList ) ; phase . setForceUpdateBestSolution ( forceUpdateBestSolution == null ? false : forceUpdateBestSolution ) ; EnvironmentMode environmentMode = phaseConfigPolicy . getEnvironmentMode ( ) ; if ( environmentMode . isNonIntrusiveFullAsserted ( ) ) { phase . setAssertStepScoreFromScratch ( true ) ; } return phase ;


signature: public class HardSoftScoreHolder { @ Override public void configureConstraintWeight ( Rule rule , HardSoftScore constraintWeight ) { } }

implementation: super . configureConstraintWeight ( rule , constraintWeight ) ; BiConsumer < RuleContext , Integer > matchExecutor ; if ( constraintWeight . equals ( HardSoftScore . ZERO ) ) { matchExecutor = ( RuleContext kcontext , Integer matchWeight ) -> { } ; } else if ( constraintWeight . getSoftScore ( ) == 0 ) { matchExecutor = ( RuleContext kcontext , Integer matchWeight ) -> addHardConstraintMatch ( kcontext , constraintWeight . getHardScore ( ) * matchWeight ) ; } else if ( constraintWeight . getHardScore ( ) == 0 ) { matchExecutor = ( RuleContext kcontext , Integer matchWeight ) -> addSoftConstraintMatch ( kcontext , constraintWeight . getSoftScore ( ) * matchWeight ) ; } else { matchExecutor = ( RuleContext kcontext , Integer matchWeight ) -> addMultiConstraintMatch ( kcontext , constraintWeight . getHardScore ( ) * matchWeight , constraintWeight . getSoftScore ( ) * matchWeight ) ; } matchExecutorByNumberMap . put ( rule , matchExecutor ) ; matchExecutorByScoreMap . put ( rule , ( RuleContext kcontext , HardSoftScore weightMultiplier ) -> addMultiConstraintMatch ( kcontext , constraintWeight . getHardScore ( ) * weightMultiplier . getHardScore ( ) , constraintWeight . getSoftScore ( ) * weightMultiplier . getSoftScore ( ) ) ) ;


signature:
public class LookUpStrategyResolver { /** * This method is thread - safe .
 * @ param object never null
 * @ return never null */
public LookUpStrategy determineLookUpStrategy ( Object object ) { } }

implementation: Class < ? > objectClass = object . getClass ( ) ; return decisionCache . computeIfAbsent ( objectClass , key -> { if ( object . getClass ( ) . isEnum ( ) ) { return new ImmutableLookUpStrategy ( ) ; } switch ( lookUpStrategyType ) { case PLANNING_ID_OR_NONE : MemberAccessor memberAccessor1 = ConfigUtils . findPlanningIdMemberAccessor ( objectClass ) ; if ( memberAccessor1 == null ) { return new NoneLookUpStrategy ( ) ; } return new PlanningIdLookUpStrategy ( memberAccessor1 ) ; case PLANNING_ID_OR_FAIL_FAST : MemberAccessor memberAccessor2 = ConfigUtils . findPlanningIdMemberAccessor ( objectClass ) ; if ( memberAccessor2 == null ) { throw new IllegalArgumentException ( "The class (" + objectClass + ") does not have a " + PlanningId . class . getSimpleName ( ) + " annotation," + " but the lookUpStrategyType (" + lookUpStrategyType + ") requires it.\n" + "Maybe add the " + PlanningId . class . getSimpleName ( ) + " annotation" + " or change the " + PlanningSolution . class . getSimpleName ( ) + " annotation's " + LookUpStrategyType . class . getSimpleName ( ) + "." ) ; } return new PlanningIdLookUpStrategy ( memberAccessor2 ) ; case EQUALITY : Method equalsMethod ; Method hashCodeMethod ; try { equalsMethod = object . getClass ( ) . getMethod ( "equals" , Object . class ) ; hashCodeMethod = object . getClass ( ) . getMethod ( "hashCode" ) ; } catch ( NoSuchMethodException e ) { throw new IllegalStateException ( "Impossible state because equals() and hashCode() always exist." , e ) ; } if ( equalsMethod . getDeclaringClass ( ) . equals ( Object . class ) ) { throw new IllegalArgumentException ( "The class (" + object . getClass ( ) . getSimpleName ( ) + ") doesn't override the equals() method, neither does any superclass." ) ; } if ( hashCodeMethod . getDeclaringClass ( ) . equals ( Object . class ) ) { throw new IllegalArgumentException ( "The class (" + object . getClass ( ) . getSimpleName ( ) + ") overrides equals() but neither it nor any superclass" + " overrides the hashCode() method." ) ; } return new EqualsLookUpStrategy ( ) ; case NONE : return new NoneLookUpStrategy ( ) ; default : throw new IllegalStateException ( "The lookUpStrategyType (" + lookUpStrategyType + ") is not implemented." ) ; } } ) ;


signature: public class FromSolutionEntitySelector { @ Override public void phaseStarted ( AbstractPhaseScope phaseScope ) { } }

implementation: super . phaseStarted ( phaseScope ) ; InnerScoreDirector scoreDirector = phaseScope . getScoreDirector ( ) ; cachedEntityList = entityDescriptor . extractEntities ( scoreDirector . getWorkingSolution ( ) ) ; cachedEntityListRevision = scoreDirector . getWorkingEntityListRevision ( ) ; cachedEntityListIsDirty = false ;


signature: public class AbstractScoreDirector { @ Override public void setWorkingSolution ( Solution_ workingSolution ) { } }

implementation: this . workingSolution = workingSolution ; SolutionDescriptor < Solution_ > solutionDescriptor = getSolutionDescriptor ( ) ; workingInitScore = - solutionDescriptor . countUninitializedVariables ( workingSolution ) ; if ( lookUpEnabled ) { lookUpManager . resetWorkingObjects ( solutionDescriptor . getAllFacts ( workingSolution ) ) ; } variableListenerSupport . resetWorkingSolution ( ) ; setWorkingEntityListDirty ( ) ;


signature: public class AbstractScoreDirector { @ Override public final void beforeEntityAdded ( Object entity ) { } }

implementation: beforeEntityAdded ( getSolutionDescriptor ( ) . findEntityDescriptorOrFail ( entity . getClass ( ) ) , entity ) ;


signature: public class AbstractScoreDirector { @ Override public void assertExpectedWorkingScore ( Score expectedWorkingScore , Object completedAction ) { } }

implementation: Score workingScore = calculateScore ( ) ; if ( ! expectedWorkingScore . equals ( workingScore ) ) { throw new IllegalStateException ( "Score corruption (" + expectedWorkingScore . subtract ( workingScore ) . toShortString ( ) + "): the expectedWorkingScore (" + expectedWorkingScore + ") is not the workingScore (" + workingScore + ") after completedAction (" + completedAction + ")." ) ; }


signature: public class SubChainSwapMoveSelectorConfig { @ Override public MoveSelector buildBaseMoveSelector ( HeuristicConfigPolicy configPolicy , SelectionCacheType minimumCacheType , boolean randomSelection ) { } }

implementation: EntityDescriptor entityDescriptor = deduceEntityDescriptor ( configPolicy . getSolutionDescriptor ( ) , entityClass ) ; SubChainSelectorConfig subChainSelectorConfig_ = subChainSelectorConfig == null ? new SubChainSelectorConfig ( ) : subChainSelectorConfig ; SubChainSelector leftSubChainSelector = subChainSelectorConfig_ . buildSubChainSelector ( configPolicy , entityDescriptor , minimumCacheType , SelectionOrder . fromRandomSelectionBoolean ( randomSelection ) ) ; SubChainSelectorConfig rightSubChainSelectorConfig = defaultIfNull ( secondarySubChainSelectorConfig , subChainSelectorConfig_ ) ; SubChainSelector rightSubChainSelector = rightSubChainSelectorConfig . buildSubChainSelector ( configPolicy , entityDescriptor , minimumCacheType , SelectionOrder . fromRandomSelectionBoolean ( randomSelection ) ) ; return new SubChainSwapMoveSelector ( leftSubChainSelector , rightSubChainSelector , randomSelection , defaultIfNull ( selectReversingMoveToo , true ) ) ;


signature: public class KOptMoveSelector { @ Override public boolean isCountable ( ) { } }

implementation: if ( ! entitySelector . isCountable ( ) ) { return false ; } for ( ValueSelector valueSelector : valueSelectors ) { if ( ! valueSelector . isCountable ( ) ) { return false ; } } return true ;


signature: public class StepCountingHillClimbingAcceptor { @ Override public void phaseStarted ( LocalSearchPhaseScope phaseScope ) { } }

implementation: super . phaseStarted ( phaseScope ) ; thresholdScore = phaseScope . getBestScore ( ) ; count = 0 ;


signature: public class ChainedChangeMove { @ Override public boolean isMoveDoable ( ScoreDirector < Solution_ > scoreDirector ) { } }

implementation: return super . isMoveDoable ( scoreDirector ) && ! Objects . equals ( entity , toPlanningValue ) ;


signature: public class SelectorConfig { protected void validateCacheTypeVersusSelectionOrder ( SelectionCacheType resolvedCacheType , SelectionOrder resolvedSelectionOrder ) { } }

implementation: switch ( resolvedSelectionOrder ) { case INHERIT : throw new IllegalArgumentException ( "The moveSelectorConfig (" + this + ") has a resolvedSelectionOrder (" + resolvedSelectionOrder + ") which should have been resolved by now." ) ; case ORIGINAL : case RANDOM : break ; case SORTED : case SHUFFLED : case PROBABILISTIC : if ( resolvedCacheType . isNotCached ( ) ) { throw new IllegalArgumentException ( "The moveSelectorConfig (" + this + ") has a resolvedSelectionOrder (" + resolvedSelectionOrder + ") which does not support the resolvedCacheType (" + resolvedCacheType + ")." ) ; } break ; default : throw new IllegalStateException ( "The resolvedSelectionOrder (" + resolvedSelectionOrder + ") is not implemented." ) ; }


signature: public class ChangeMoveSelectorConfig { @ Override public MoveSelector buildBaseMoveSelector ( HeuristicConfigPolicy configPolicy , SelectionCacheType minimumCacheType , boolean randomSelection ) { } }

implementation: if ( entitySelectorConfig == null ) { throw new IllegalStateException ( "The entitySelectorConfig (" + entitySelectorConfig + ") should haven been initialized during unfolding." ) ; } EntitySelector entitySelector = entitySelectorConfig . buildEntitySelector ( configPolicy , minimumCacheType , SelectionOrder . fromRandomSelectionBoolean ( randomSelection ) ) ; if ( valueSelectorConfig == null ) { throw new IllegalStateException ( "The valueSelectorConfig (" + valueSelectorConfig + ") should haven been initialized during unfolding." ) ; } ValueSelector valueSelector = valueSelectorConfig . buildValueSelector ( configPolicy , entitySelector . getEntityDescriptor ( ) , minimumCacheType , SelectionOrder . fromRandomSelectionBoolean ( randomSelection ) ) ; return new ChangeMoveSelector ( entitySelector , valueSelector , randomSelection ) ;


signature: public class TailChainSwapMove { @ Override public boolean isMoveDoable ( ScoreDirector < Solution_ > scoreDirector ) { } }

implementation:
if ( Objects . equals ( leftValue , rightValue ) || Objects . equals ( leftEntity , rightValue ) || Objects . equals ( rightEntity , leftValue ) ) { return false ; } if ( rightEntity == null ) { // TODO Currently unsupported because we fail to create a valid undoMove . . . even though doMove supports it
if ( leftAnchor == rightAnchor ) { return false ; } } if ( ! variableDescriptor . isValueRangeEntityIndependent ( ) ) { ValueRangeDescriptor < Solution_ > valueRangeDescriptor = variableDescriptor . getValueRangeDescriptor ( ) ; Solution_ workingSolution = scoreDirector . getWorkingSolution ( ) ; if ( rightEntity != null ) { ValueRange rightValueRange = valueRangeDescriptor . extractValueRange ( workingSolution , rightEntity ) ; if ( ! rightValueRange . contains ( leftValue ) ) { return false ; } } ValueRange leftValueRange = valueRangeDescriptor . extractValueRange ( workingSolution , leftEntity ) ; if ( ! leftValueRange . contains ( rightValue ) ) { return false ; } } return true ;


signature: public class DefaultSubChainSelector { @ Override public void constructCache ( DefaultSolverScope solverScope ) { } }

implementation:
InnerScoreDirector scoreDirector = solverScope . getScoreDirector ( ) ; GenuineVariableDescriptor variableDescriptor = valueSelector . getVariableDescriptor ( ) ; long valueSize = valueSelector . getSize ( ) ; // Fail - fast when anchorTrailingChainList . size ( ) could ever be too big
if ( valueSize > ( long ) Integer . MAX_VALUE ) { throw new IllegalStateException ( "The selector (" + this + ") has a valueSelector (" + valueSelector + ") with valueSize (" + valueSize + ") which is higher than Integer.MAX_VALUE." ) ; } List < Object > anchorList = new ArrayList < > ( ) ; for ( Object value : valueSelector ) { if ( variableDescriptor . isValuePotentialAnchor ( value ) ) { anchorList . add ( value ) ; } } int anchorListSize = Math . max ( anchorList . size ( ) , 1 ) ; anchorTrailingChainList = new ArrayList < > ( anchorListSize ) ; int anchorChainInitialCapacity = ( ( int ) valueSize / anchorListSize ) + 1 ; for ( Object anchor : anchorList ) { List < Object > anchorChain = new ArrayList < > ( anchorChainInitialCapacity ) ; Object trailingEntity = inverseVariableSupply . getInverseSingleton ( anchor ) ; while ( trailingEntity != null ) { anchorChain . add ( trailingEntity ) ; trailingEntity = inverseVariableSupply . getInverseSingleton ( trailingEntity ) ; } if ( anchorChain . size ( ) >= minimumSubChainSize ) { anchorTrailingChainList . add ( new SubChain ( anchorChain ) ) ; } }


signature: public class SimulatedAnnealingAcceptor { @ Override public void phaseStarted ( LocalSearchPhaseScope phaseScope ) { } }

implementation: super . phaseStarted ( phaseScope ) ; for ( double startingTemperatureLevel : ScoreUtils . extractLevelDoubles ( startingTemperature ) ) { if ( startingTemperatureLevel < 0.0 ) { throw new IllegalArgumentException ( "The startingTemperature (" + startingTemperature + ") cannot have negative level (" + startingTemperatureLevel + ")." ) ; } } startingTemperatureLevels = ScoreUtils . extractLevelDoubles ( startingTemperature ) ; temperatureLevels = startingTemperatureLevels ; levelsLength = startingTemperatureLevels . length ;


signature: public class FromSolutionPropertyValueSelector { @ Override public void phaseStarted ( AbstractPhaseScope phaseScope ) { } }

implementation: super . phaseStarted ( phaseScope ) ; InnerScoreDirector scoreDirector = phaseScope . getScoreDirector ( ) ; cachedValueRange = ( ValueRange < Object > ) valueRangeDescriptor . extractValueRange ( scoreDirector . getWorkingSolution ( ) ) ; if ( valueRangeMightContainEntity ) { cachedEntityListRevision = scoreDirector . getWorkingEntityListRevision ( ) ; cachedEntityListIsDirty = false ; }


signature:
public class StatisticUtils { /** * Calculates standard deviation of { @ link BenchmarkResult # getAverageScore ( ) } s from { @ code averageScore } .
 * @ param averageScore not null
 * @ return standard deviation double values */
public static double [ ] determineStandardDeviationDoubles ( List < ? extends BenchmarkResult > benchmarkResultList , Score averageScore , int successCount ) { } }

implementation:
if ( successCount <= 0 ) { return null ; } if ( averageScore == null ) { throw new IllegalArgumentException ( "Average score (" + averageScore + ") cannot be null." ) ; } // averageScore can no longer be null
double [ ] differenceSquaredTotalDoubles = null ; for ( BenchmarkResult benchmarkResult : benchmarkResultList ) { if ( benchmarkResult . hasAllSuccess ( ) ) { Score difference = benchmarkResult . getAverageScore ( ) . subtract ( averageScore ) ; // Calculations done on doubles to avoid common overflow when executing with an int score > 500 000
double [ ] differenceDoubles = ScoreUtils . extractLevelDoubles ( difference ) ; if ( differenceSquaredTotalDoubles == null ) { differenceSquaredTotalDoubles = new double [ differenceDoubles . length ] ; } for ( int i = 0 ; i < differenceDoubles . length ; i ++ ) { differenceSquaredTotalDoubles [ i ] += Math . pow ( differenceDoubles [ i ] , 2.0 ) ; } } } double [ ] standardDeviationDoubles = new double [ differenceSquaredTotalDoubles . length ] ; for ( int i = 0 ; i < differenceSquaredTotalDoubles . length ; i ++ ) { standardDeviationDoubles [ i ] = Math . pow ( differenceSquaredTotalDoubles [ i ] / successCount , 0.5 ) ; } return standardDeviationDoubles ;


signature:
public class StatisticUtils { /** * TODO Do the locale formatting in benchmarkReport . html . ftl - https : / / issues . jboss . org / browse / PLANNER - 169 */
public static String getStandardDeviationString ( double [ ] standardDeviationDoubles ) { } }

implementation:
if ( standardDeviationDoubles == null ) { return null ; } StringBuilder standardDeviationString = new StringBuilder ( standardDeviationDoubles . length * 9 ) ; // Abbreviate to 2 decimals
// We don ' t use a local sensitive DecimalFormat , because other Scores don ' t use it either ( see PLANNER - 169)
DecimalFormatSymbols decimalFormatSymbols = new DecimalFormatSymbols ( Locale . US ) ; DecimalFormat exponentialFormat = new DecimalFormat ( "0.0#E0" , decimalFormatSymbols ) ; DecimalFormat decimalFormat = new DecimalFormat ( "0.0#" , decimalFormatSymbols ) ; boolean first = true ; for ( double standardDeviationDouble : standardDeviationDoubles ) { if ( first ) { first = false ; } else { standardDeviationString . append ( "/" ) ; } // See http : / / docs . oracle . com / javase / 7 / docs / api / java / lang / Double . html # toString % 28double % 29
String abbreviated ; if ( 0.001 <= standardDeviationDouble && standardDeviationDouble <= 10000000.0 ) { abbreviated = decimalFormat . format ( standardDeviationDouble ) ; } else { abbreviated = exponentialFormat . format ( standardDeviationDouble ) ; } standardDeviationString . append ( abbreviated ) ; } return standardDeviationString . toString ( ) ;


signature: public class EasyScoreDirectorFactory { @ Override public EasyScoreDirector < Solution_ > buildScoreDirector ( boolean lookUpEnabled , boolean constraintMatchEnabledPreference ) { } }

implementation: return new EasyScoreDirector < > ( this , lookUpEnabled , constraintMatchEnabledPreference , easyScoreCalculator ) ;


signature: public class MachineReassignment { @ ProblemFactCollectionProperty private List < MrServiceDependency > getServiceDependencyList ( ) { } }

implementation: List < MrServiceDependency > serviceDependencyList = new ArrayList < > ( serviceList . size ( ) * 5 ) ; for ( MrService service : serviceList ) { for ( MrService toService : service . getToDependencyServiceList ( ) ) { MrServiceDependency serviceDependency = new MrServiceDependency ( ) ; serviceDependency . setFromService ( service ) ; serviceDependency . setToService ( toService ) ; serviceDependencyList . add ( serviceDependency ) ; } } return serviceDependencyList ;


signature: public class TerminationConfig { public Termination buildTermination ( HeuristicConfigPolicy configPolicy , Termination chainedTermination ) { } }

implementation: Termination termination = buildTermination ( configPolicy ) ; if ( termination == null ) { return chainedTermination ; } return new OrCompositeTermination ( chainedTermination , termination ) ;


signature:
public class Match { /** * The normal methods { @ link # equals ( Object ) } and { @ link # hashCode ( ) } cannot be used
 * because the rule engine already requires them ( for performance in their original state ) .
 * @ see # solutionHashCode ( ) */
public boolean solutionEquals ( Object o ) { } }

implementation: if ( this == o ) { return true ; } else if ( o instanceof Match ) { Match other = ( Match ) o ; return new EqualsBuilder ( ) . append ( id , other . id ) . append ( homeTeam , other . homeTeam ) . append ( awayTeam , other . awayTeam ) . append ( day , other . day ) . isEquals ( ) ; } else { return false ; }


signature:
public class Match { /** * The normal methods { @ link # equals ( Object ) } and { @ link # hashCode ( ) } cannot be used
 * because the rule engine already requires them ( for performance in their original state ) .
 * @ see # solutionEquals ( Object ) */
public int solutionHashCode ( ) { } }

implementation: return new HashCodeBuilder ( ) . append ( id ) . append ( homeTeam ) . append ( awayTeam ) . append ( day ) . toHashCode ( ) ;


signature: public class QueuedEntityPlacerConfig { @ Override public QueuedEntityPlacer buildEntityPlacer ( HeuristicConfigPolicy configPolicy ) { } }

implementation:
EntitySelectorConfig entitySelectorConfig_ = buildEntitySelectorConfig ( configPolicy ) ; EntitySelector entitySelector = entitySelectorConfig_ . buildEntitySelector ( configPolicy , SelectionCacheType . PHASE , SelectionOrder . ORIGINAL ) ; List < MoveSelectorConfig > moveSelectorConfigList_ ; if ( ConfigUtils . isEmptyCollection ( moveSelectorConfigList ) ) { EntityDescriptor entityDescriptor = entitySelector . getEntityDescriptor ( ) ; Collection < GenuineVariableDescriptor > variableDescriptors = entityDescriptor . getGenuineVariableDescriptors ( ) ; List < MoveSelectorConfig > subMoveSelectorConfigList = new ArrayList < > ( variableDescriptors . size ( ) ) ; for ( GenuineVariableDescriptor variableDescriptor : variableDescriptors ) { subMoveSelectorConfigList . add ( buildChangeMoveSelectorConfig ( configPolicy , entitySelectorConfig_ . getId ( ) , variableDescriptor ) ) ; } MoveSelectorConfig subMoveSelectorConfig ; if ( subMoveSelectorConfigList . size ( ) > 1 ) { // Default to cartesian product ( not a queue ) of planning variables .
subMoveSelectorConfig = new CartesianProductMoveSelectorConfig ( subMoveSelectorConfigList ) ; } else { subMoveSelectorConfig = subMoveSelectorConfigList . get ( 0 ) ; } moveSelectorConfigList_ = Collections . singletonList ( subMoveSelectorConfig ) ; } else { moveSelectorConfigList_ = moveSelectorConfigList ; } List < MoveSelector > moveSelectorList = new ArrayList < > ( moveSelectorConfigList_ . size ( ) ) ; for ( MoveSelectorConfig moveSelectorConfig : moveSelectorConfigList_ ) { moveSelectorList . add ( moveSelectorConfig . buildMoveSelector ( configPolicy , SelectionCacheType . JUST_IN_TIME , SelectionOrder . ORIGINAL ) ) ; } return new QueuedEntityPlacer ( entitySelector , moveSelectorList ) ;


signature: public class BenchmarkReport { public String getRelativePathToBenchmarkReportDirectory ( File file ) { } }

implementation: String benchmarkReportDirectoryPath = plannerBenchmarkResult . getBenchmarkReportDirectory ( ) . getAbsoluteFile ( ) . toURI ( ) . getPath ( ) ; String filePath = file . getAbsoluteFile ( ) . toURI ( ) . getPath ( ) ; if ( ! filePath . startsWith ( benchmarkReportDirectoryPath ) ) { throw new IllegalArgumentException ( "The filePath (" + filePath + ") does not start with the benchmarkReportDirectoryPath (" + benchmarkReportDirectoryPath + ")." ) ; } String relativePath = filePath . substring ( benchmarkReportDirectoryPath . length ( ) ) ; if ( relativePath . startsWith ( "/" ) ) { relativePath = relativePath . substring ( 1 ) ; } return relativePath ;


signature: public class BenchmarkReport { public void writeReport ( ) { } }

implementation: logger . info ( "Generating benchmark report..." ) ; summaryDirectory = new File ( plannerBenchmarkResult . getBenchmarkReportDirectory ( ) , "summary" ) ; summaryDirectory . mkdir ( ) ; plannerBenchmarkResult . accumulateResults ( this ) ; fillWarningList ( ) ; writeBestScoreSummaryChart ( ) ; writeBestScoreScalabilitySummaryChart ( ) ; writeWinningScoreDifferenceSummaryChart ( ) ; writeWorstScoreDifferencePercentageSummaryChart ( ) ; writeBestScoreDistributionSummaryChart ( ) ; writeScoreCalculationSpeedSummaryChart ( ) ; writeWorstScoreCalculationSpeedDifferencePercentageSummaryChart ( ) ; writeTimeSpentSummaryChart ( ) ; writeTimeSpentScalabilitySummaryChart ( ) ; writeBestScorePerTimeSpentSummaryChart ( ) ; for ( ProblemBenchmarkResult < Object > problemBenchmarkResult : plannerBenchmarkResult . getUnifiedProblemBenchmarkResultList ( ) ) { for ( SingleBenchmarkResult singleBenchmarkResult : problemBenchmarkResult . getSingleBenchmarkResultList ( ) ) { for ( SubSingleBenchmarkResult subSingleBenchmarkResult : singleBenchmarkResult . getSubSingleBenchmarkResultList ( ) ) { if ( ! subSingleBenchmarkResult . hasAllSuccess ( ) ) { continue ; } for ( SubSingleStatistic subSingleStatistic : subSingleBenchmarkResult . getEffectiveSubSingleStatisticMap ( ) . values ( ) ) { try { subSingleStatistic . unhibernatePointList ( ) ; } catch ( IllegalStateException e ) { if ( ! plannerBenchmarkResult . getAggregation ( ) ) { throw new IllegalStateException ( "Failed to unhibernate point list of SubSingleStatistic (" + subSingleStatistic + ") of SubSingleBenchmark (" + subSingleBenchmarkResult + ")." , e ) ; } logger . trace ( "This is expected, aggregator doesn't copy CSV files. Could not read CSV file " + "({}) of sub single statistic ({})." , subSingleStatistic . getCsvFile ( ) . getAbsolutePath ( ) , subSingleStatistic ) ; } } } } } for ( ProblemBenchmarkResult < Object > problemBenchmarkResult : plannerBenchmarkResult . getUnifiedProblemBenchmarkResultList ( ) ) { if ( problemBenchmarkResult . hasAnySuccess ( ) ) { for ( ProblemStatistic problemStatistic : problemBenchmarkResult . getProblemStatisticList ( ) ) { problemStatistic . writeGraphFiles ( this ) ; } for ( SingleBenchmarkResult singleBenchmarkResult : problemBenchmarkResult . getSingleBenchmarkResultList ( ) ) { if ( singleBenchmarkResult . hasAllSuccess ( ) ) { for ( PureSubSingleStatistic pureSubSingleStatistic : singleBenchmarkResult . getMedian ( ) . getPureSubSingleStatisticList ( ) ) { pureSubSingleStatistic . writeGraphFiles ( this ) ; } } } } } for ( ProblemBenchmarkResult < Object > problemBenchmarkResult : plannerBenchmarkResult . getUnifiedProblemBenchmarkResultList ( ) ) { for ( SingleBenchmarkResult singleBenchmarkResult : problemBenchmarkResult . getSingleBenchmarkResultList ( ) ) { for ( SubSingleBenchmarkResult subSingleBenchmarkResult : singleBenchmarkResult . getSubSingleBenchmarkResultList ( ) ) { if ( ! subSingleBenchmarkResult . hasAllSuccess ( ) ) { continue ; } for ( SubSingleStatistic subSingleStatistic : subSingleBenchmarkResult . getEffectiveSubSingleStatisticMap ( ) . values ( ) ) { if ( plannerBenchmarkResult . getAggregation ( ) ) { subSingleStatistic . setPointList ( null ) ; } else { subSingleStatistic . hibernatePointList ( ) ; } } } } } determineDefaultShownScoreLevelIndex ( ) ; writeHtmlOverviewFile ( ) ;


signature: public class BenchmarkReport { private CategoryPlot createBarChartPlot ( DefaultCategoryDataset dataset , String yAxisLabel , NumberFormat yAxisNumberFormat ) { } }

implementation: CategoryAxis xAxis = new CategoryAxis ( "Data" ) ; xAxis . setCategoryMargin ( 0.40 ) ; NumberAxis yAxis = new NumberAxis ( yAxisLabel ) ; yAxis . setNumberFormatOverride ( yAxisNumberFormat ) ; BarRenderer renderer = createBarChartRenderer ( yAxisNumberFormat ) ; CategoryPlot plot = new CategoryPlot ( dataset , xAxis , yAxis , renderer ) ; plot . setOrientation ( PlotOrientation . VERTICAL ) ; return plot ;


signature: public class ChainedSwapMove { @ Override public ChainedSwapMove < Solution_ > createUndoMove ( ScoreDirector < Solution_ > scoreDirector ) { } }

implementation: return new ChainedSwapMove < > ( variableDescriptorList , rightEntity , leftEntity , oldLeftTrailingEntityList , oldRightTrailingEntityList ) ;


signature:
public class OrCompositeTermination { /** * Calculates the maximum timeGradient of all Terminations .
 * Not supported timeGradients ( - 1.0 ) are ignored .
 * @ param solverScope never null
 * @ return the maximum timeGradient of the Terminations . */
@ Override public double calculateSolverTimeGradient ( DefaultSolverScope solverScope ) { } }

implementation: double timeGradient = 0.0 ; for ( Termination termination : terminationList ) { double nextTimeGradient = termination . calculateSolverTimeGradient ( solverScope ) ; if ( nextTimeGradient >= 0.0 ) { timeGradient = Math . max ( timeGradient , nextTimeGradient ) ; } } return timeGradient ;


signature:
public class OrCompositeTermination { /** * Calculates the maximum timeGradient of all Terminations .
 * Not supported timeGradients ( - 1.0 ) are ignored .
 * @ param phaseScope never null
 * @ return the maximum timeGradient of the Terminations . */
@ Override public double calculatePhaseTimeGradient ( AbstractPhaseScope phaseScope ) { } }

implementation: double timeGradient = 0.0 ; for ( Termination termination : terminationList ) { double nextTimeGradient = termination . calculatePhaseTimeGradient ( phaseScope ) ; if ( nextTimeGradient >= 0.0 ) { timeGradient = Math . max ( timeGradient , nextTimeGradient ) ; } } return timeGradient ;


signature: public class OrCompositeTermination { @ Override public OrCompositeTermination createChildThreadTermination ( DefaultSolverScope solverScope , ChildThreadType childThreadType ) { } }

implementation: return new OrCompositeTermination ( createChildThreadTerminationList ( solverScope , childThreadType ) ) ;


signature: public class HardMediumSoftScoreHolder { @ Override public void configureConstraintWeight ( Rule rule , HardMediumSoftScore constraintWeight ) { } }

implementation: super . configureConstraintWeight ( rule , constraintWeight ) ; BiConsumer < RuleContext , Integer > matchExecutor ; if ( constraintWeight . equals ( HardMediumSoftScore . ZERO ) ) { matchExecutor = ( RuleContext kcontext , Integer weightMultiplier ) -> { } ; } else if ( constraintWeight . getMediumScore ( ) == 0 && constraintWeight . getSoftScore ( ) == 0 ) { matchExecutor = ( RuleContext kcontext , Integer weightMultiplier ) -> addHardConstraintMatch ( kcontext , constraintWeight . getHardScore ( ) * weightMultiplier ) ; } else if ( constraintWeight . getHardScore ( ) == 0 && constraintWeight . getSoftScore ( ) == 0 ) { matchExecutor = ( RuleContext kcontext , Integer weightMultiplier ) -> addMediumConstraintMatch ( kcontext , constraintWeight . getMediumScore ( ) * weightMultiplier ) ; } else if ( constraintWeight . getHardScore ( ) == 0 && constraintWeight . getMediumScore ( ) == 0 ) { matchExecutor = ( RuleContext kcontext , Integer weightMultiplier ) -> addSoftConstraintMatch ( kcontext , constraintWeight . getSoftScore ( ) * weightMultiplier ) ; } else { matchExecutor = ( RuleContext kcontext , Integer weightMultiplier ) -> addMultiConstraintMatch ( kcontext , constraintWeight . getHardScore ( ) * weightMultiplier , constraintWeight . getMediumScore ( ) * weightMultiplier , constraintWeight . getSoftScore ( ) * weightMultiplier ) ; } matchExecutorByNumberMap . put ( rule , matchExecutor ) ; matchExecutorByScoreMap . put ( rule , ( RuleContext kcontext , HardMediumSoftScore weightMultiplier ) -> addMultiConstraintMatch ( kcontext , constraintWeight . getHardScore ( ) * weightMultiplier . getHardScore ( ) , constraintWeight . getMediumScore ( ) * weightMultiplier . getMediumScore ( ) , constraintWeight . getSoftScore ( ) * weightMultiplier . getSoftScore ( ) ) ) ;


signature:
public class HardMediumSoftScoreHolder { /** * Penalize a match by the { @ link ConstraintWeight } negated and multiplied with the specific weightMultiplier per score level .
 * Slower than { @ link # penalize ( RuleContext , int ) } .
 * @ param kcontext never null , the magic variable in DRL
 * @ param hardWeightMultiplier at least 0
 * @ param mediumWeightMultiplier at least 0
 * @ param softWeightMultiplier at least 0 */
public void penalize ( RuleContext kcontext , int hardWeightMultiplier , int mediumWeightMultiplier , int softWeightMultiplier ) { } }

implementation: reward ( kcontext , - hardWeightMultiplier , - mediumWeightMultiplier , - softWeightMultiplier ) ;


signature: public class TaskAssignment { @ ValueRangeProvider ( id = "startPeriodRange" ) public CountableValueRange < Integer > getStartPeriodRange ( ) { } }

implementation: return ValueRangeFactory . createIntValueRange ( task . getStartPeriodRangeFrom ( ) , task . getStartPeriodRangeTo ( ) ) ;


signature: public class CheapTimeIncrementalScoreCalculator { @ Override public void resetWorkingSolution ( CheapTimeSolution solution ) { } }

implementation:
this . cheapTimeSolution = solution ; hardScore = 0L ; mediumScore = 0L ; softScore = 0L ; if ( solution . getGlobalPeriodRangeFrom ( ) != 0 ) { throw new IllegalStateException ( "The globalPeriodRangeFrom (" + solution . getGlobalPeriodRangeFrom ( ) + ") should be 0." ) ; } resourceListSize = solution . getResourceList ( ) . size ( ) ; globalPeriodRangeTo = solution . getGlobalPeriodRangeTo ( ) ; List < Machine > machineList = solution . getMachineList ( ) ; List < PeriodPowerPrice > periodPowerPriceList = solution . getPeriodPowerPriceList ( ) ; machineToMachinePeriodListMap = new MachinePeriodPart [ machineList . size ( ) ] [ ] ; for ( Machine machine : machineList ) { MachinePeriodPart [ ] machinePeriodList = new MachinePeriodPart [ globalPeriodRangeTo ] ; for ( int period = 0 ; period < globalPeriodRangeTo ; period ++ ) { machinePeriodList [ period ] = new MachinePeriodPart ( machine , periodPowerPriceList . get ( period ) ) ; } machineToMachinePeriodListMap [ machine . getIndex ( ) ] = machinePeriodList ; } unassignedMachinePeriodList = new MachinePeriodPart [ globalPeriodRangeTo ] ; for ( int period = 0 ; period < globalPeriodRangeTo ; period ++ ) { unassignedMachinePeriodList [ period ] = new MachinePeriodPart ( null , periodPowerPriceList . get ( period ) ) ; } for ( TaskAssignment taskAssignment : solution . getTaskAssignmentList ( ) ) { // Do not do modifyMachine ( taskAssignment , null , taskAssignment . getMachine ( ) ) ;
// because modifyStartPeriod does all its effects too
modifyStartPeriod ( taskAssignment , null , taskAssignment . getStartPeriod ( ) ) ; }


signature: public class CheapTimeIncrementalScoreCalculator { private void modifyMachine ( TaskAssignment taskAssignment , Machine oldMachine , Machine newMachine ) { } }

implementation: if ( Objects . equals ( oldMachine , newMachine ) ) { return ; } Integer startPeriod = taskAssignment . getStartPeriod ( ) ; if ( startPeriod == null ) { return ; } Integer endPeriod = taskAssignment . getEndPeriod ( ) ; if ( oldMachine != null ) { MachinePeriodPart [ ] machinePeriodList = machineToMachinePeriodListMap [ oldMachine . getIndex ( ) ] ; retractRange ( taskAssignment , machinePeriodList , startPeriod , endPeriod , false ) ; } if ( newMachine != null ) { MachinePeriodPart [ ] machinePeriodList = machineToMachinePeriodListMap [ newMachine . getIndex ( ) ] ; insertRange ( taskAssignment , machinePeriodList , startPeriod , endPeriod , false ) ; }


signature: public class AbstractTabuAcceptor { @ Override public void phaseStarted ( LocalSearchPhaseScope phaseScope ) { } }

implementation:
super . phaseStarted ( phaseScope ) ; LocalSearchStepScope lastCompletedStepScope = phaseScope . getLastCompletedStepScope ( ) ; // Tabu sizes do not change during stepStarted ( ) , because they must be in sync with the tabuSequenceList . size ( )
workingTabuSize = tabuSizeStrategy == null ? 0 : tabuSizeStrategy . determineTabuSize ( lastCompletedStepScope ) ; workingFadingTabuSize = fadingTabuSizeStrategy == null ? 0 : fadingTabuSizeStrategy . determineTabuSize ( lastCompletedStepScope ) ; int totalTabuListSize = workingTabuSize + workingFadingTabuSize ; // is at least 1
tabuToStepIndexMap = new HashMap < > ( totalTabuListSize ) ; tabuSequenceDeque = new ArrayDeque < > ( ) ;


signature: public class TailChainSwapMoveSelectorConfig { @ Override public MoveSelector buildBaseMoveSelector ( HeuristicConfigPolicy configPolicy , SelectionCacheType minimumCacheType , boolean randomSelection ) { } }

implementation: EntitySelectorConfig entitySelectorConfig_ = entitySelectorConfig == null ? new EntitySelectorConfig ( ) : entitySelectorConfig ; EntitySelector entitySelector = entitySelectorConfig_ . buildEntitySelector ( configPolicy , minimumCacheType , SelectionOrder . fromRandomSelectionBoolean ( randomSelection ) ) ; ValueSelectorConfig valueSelectorConfig_ = valueSelectorConfig == null ? new ValueSelectorConfig ( ) : valueSelectorConfig ; ValueSelector valueSelector = valueSelectorConfig_ . buildValueSelector ( configPolicy , entitySelector . getEntityDescriptor ( ) , minimumCacheType , SelectionOrder . fromRandomSelectionBoolean ( randomSelection ) ) ; return new TailChainSwapMoveSelector ( entitySelector , valueSelector , randomSelection ) ;


signature: public class ValueSelectorConfig { public GenuineVariableDescriptor extractVariableDescriptor ( HeuristicConfigPolicy configPolicy , EntityDescriptor entityDescriptor ) { } }

implementation: entityDescriptor = downcastEntityDescriptor ( configPolicy , entityDescriptor ) ; if ( variableName != null ) { GenuineVariableDescriptor variableDescriptor = entityDescriptor . getGenuineVariableDescriptor ( variableName ) ; if ( variableDescriptor == null ) { throw new IllegalArgumentException ( "The selectorConfig (" + this + ") has a variableName (" + variableName + ") which is not a valid planning variable on entityClass (" + entityDescriptor . getEntityClass ( ) + ").\n" + entityDescriptor . buildInvalidVariableNameExceptionMessage ( variableName ) ) ; } return variableDescriptor ; } else if ( mimicSelectorRef != null ) { return configPolicy . getValueMimicRecorder ( mimicSelectorRef ) . getVariableDescriptor ( ) ; } else { return null ; }


signature: public class BestSolutionRecallerConfig { public < Solution_ > BestSolutionRecaller < Solution_ > buildBestSolutionRecaller ( EnvironmentMode environmentMode ) { } }

implementation: BestSolutionRecaller < Solution_ > bestSolutionRecaller = new BestSolutionRecaller < > ( ) ; if ( environmentMode . isNonIntrusiveFullAsserted ( ) ) { bestSolutionRecaller . setAssertInitialScoreFromScratch ( true ) ; bestSolutionRecaller . setAssertShadowVariablesAreNotStale ( true ) ; bestSolutionRecaller . setAssertBestScoreIsUnmodified ( true ) ; } return bestSolutionRecaller ;


signature:
public class FieldAccessingSolutionCloner { /** * This method is thread - safe .
 * @ param clazz never null
 * @ param < C > type
 * @ return never null */
@ SuppressWarnings ( "unchecked" ) protected < C > Constructor < C > retrieveCachedConstructor ( Class < C > clazz ) { } }

implementation: return ( Constructor < C > ) constructorMemoization . computeIfAbsent ( clazz , key -> { Constructor < C > constructor ; try { constructor = clazz . getDeclaredConstructor ( ) ; } catch ( ReflectiveOperationException e ) { throw new IllegalStateException ( "The class (" + clazz + ") should have a no-arg constructor to create a planning clone." , e ) ; } constructor . setAccessible ( true ) ; return constructor ; } ) ;


signature:
public class FieldAccessingSolutionCloner { /** * This method is thread - safe .
 * @ param clazz never null
 * @ param < C > type
 * @ return never null */
protected < C > List < Field > retrieveCachedFields ( Class < C > clazz ) { } }

implementation: return fieldListMemoization . computeIfAbsent ( clazz , key -> { Field [ ] fields = clazz . getDeclaredFields ( ) ; List < Field > fieldList = new ArrayList < > ( fields . length ) ; for ( Field field : fields ) { if ( ! Modifier . isStatic ( field . getModifiers ( ) ) ) { field . setAccessible ( true ) ; fieldList . add ( field ) ; } } return fieldList ; } ) ;


signature:
public class FieldAccessingSolutionCloner { /** * This method is thread - safe .
 * @ param field never null
 * @ param fieldInstanceClass never null
 * @ param actualValueClass never null
 * @ return never null */
protected boolean retrieveDeepCloneDecision ( Field field , Class < ? > fieldInstanceClass , Class < ? > actualValueClass ) { } }

implementation: Pair < Field , Class < ? > > pair = Pair . of ( field , fieldInstanceClass ) ; Boolean deepCloneDecision = fieldDeepClonedMemoization . computeIfAbsent ( pair , key -> isFieldDeepCloned ( field , fieldInstanceClass ) ) ; return deepCloneDecision || retrieveDeepCloneDecisionForActualValueClass ( actualValueClass ) ;


signature:
public class ReflectionsWorkaroundClasspathHelper { /** * Returns an array of class Loaders initialized from the specified array .
 * If the input is null or empty , it defaults to both { @ link # contextClassLoader ( ) } and { @ link # staticClassLoader ( ) }
 * @ return the array of class loaders , not null */
public static ClassLoader [ ] classLoaders ( ClassLoader ... classLoaders ) { } }

implementation: if ( classLoaders != null && classLoaders . length != 0 ) { return classLoaders ; } else { ClassLoader contextClassLoader = contextClassLoader ( ) , staticClassLoader = staticClassLoader ( ) ; return contextClassLoader != null ? staticClassLoader != null && contextClassLoader != staticClassLoader ? new ClassLoader [ ] { contextClassLoader , staticClassLoader } : new ClassLoader [ ] { contextClassLoader } : new ClassLoader [ ] { } ; }


signature:
public class ReflectionsWorkaroundClasspathHelper { /** * Returns a distinct collection of URLs based on a package name .
 * This searches for the package name as a resource , using { @ link ClassLoader # getResources ( String ) } .
 * For example , { @ code forPackage ( org . reflections ) } effectively returns URLs from the
 * classpath containing packages starting with { @ code org . reflections } .
 * If the optional { @ link ClassLoader } s are not specified , then both { @ link # contextClassLoader ( ) }
 * and { @ link # staticClassLoader ( ) } are used for { @ link ClassLoader # getResources ( String ) } .
 * The returned URLs retains the order of the given { @ code classLoaders } .
 * @ return the collection of URLs , not null */
public static Collection < URL > forPackage ( String name , ClassLoader ... classLoaders ) { } }

implementation: return forResource ( resourceName ( name ) , classLoaders ) ;


signature:
public class ReflectionsWorkaroundClasspathHelper { /** * Returns a distinct collection of URLs based on a resource .
 * This searches for the resource name , using { @ link ClassLoader # getResources ( String ) } .
 * For example , { @ code forResource ( test . properties ) } effectively returns URLs from the
 * classpath containing files of that name .
 * If the optional { @ link ClassLoader } s are not specified , then both { @ link # contextClassLoader ( ) }
 * and { @ link # staticClassLoader ( ) } are used for { @ link ClassLoader # getResources ( String ) } .
 * The returned URLs retains the order of the given { @ code classLoaders } .
 * @ return the collection of URLs , not null */
public static Collection < URL > forResource ( String resourceName , ClassLoader ... classLoaders ) { } }

implementation:
final List < URL > result = new ArrayList < > ( ) ; final ClassLoader [ ] loaders = classLoaders ( classLoaders ) ; for ( ClassLoader classLoader : loaders ) { try { final Enumeration < URL > urls = classLoader . getResources ( resourceName ) ; while ( urls . hasMoreElements ( ) ) { final URL url = urls . nextElement ( ) ; int index = url . toExternalForm ( ) . lastIndexOf ( resourceName ) ; if ( index != - 1 ) { String newUrlString = url . toExternalForm ( ) . substring ( 0 , index ) ; // Use old url as context to support exotic url handlers
result . add ( new URL ( url , newUrlString ) ) ; } else { result . add ( url ) ; } } } catch ( IOException e ) { if ( Reflections . log != null ) { Reflections . log . error ( "error getting resources for " + resourceName , e ) ; } } } return distinctUrls ( result ) ;


signature:
public class ReflectionsWorkaroundClasspathHelper { /** * http : / / michaelscharf . blogspot . co . il / 2006/11 / javaneturlequals - and - hashcode - make . html */
private static Collection < URL > distinctUrls ( Collection < URL > urls ) { } }

implementation: Map < String , URL > distinct = new HashMap < > ( urls . size ( ) ) ; for ( URL url : urls ) { distinct . put ( url . toExternalForm ( ) , url ) ; } return distinct . values ( ) ;


signature: public class AbstractScoreHolder { @ Override public void configureConstraintWeight ( Rule rule , Score_ constraintWeight ) { } }

implementation: if ( constraintWeight . getInitScore ( ) != 0 ) { throw new IllegalStateException ( "The initScore (" + constraintWeight . getInitScore ( ) + ") must be 0." ) ; } if ( constraintMatchEnabled ) { String constraintPackage = rule . getPackageName ( ) ; String constraintName = rule . getName ( ) ; String constraintId = constraintPackage + "/" + constraintName ; constraintMatchTotalMap . put ( constraintId , new ConstraintMatchTotal ( constraintPackage , constraintName , constraintWeight , zeroScore ) ) ; }


signature: public class PartitionSolver { @ Override public Solution_ solve ( Solution_ problem ) { } }

implementation: solverScope . initializeYielding ( ) ; try { solverScope . setBestSolution ( problem ) ; solvingStarted ( solverScope ) ; runPhases ( solverScope ) ; solvingEnded ( solverScope ) ; return solverScope . getBestSolution ( ) ; } finally { solverScope . destroyYielding ( ) ; }