signature:
public class XStreamXmlSolverFactory { /** * Builds the { @ link XStream } setup which is used to read / write { @ link SolverConfig solver configs } and benchmark configs .
 * It should never be used to read / write { @ link PlanningSolution solutions } .
 * Use XStreamSolutionFileIO for that instead .
 * @ return never null . */
public static XStream buildXStream ( ) { } }

implementation: XStream xStream = new XStream ( ) ; xStream . setMode ( XStream . ID_REFERENCES ) ; xStream . aliasSystemAttribute ( "xStreamId" , "id" ) ; xStream . aliasSystemAttribute ( "xStreamRef" , "reference" ) ; xStream . processAnnotations ( SolverConfig . class ) ; XStream . setupDefaultSecurity ( xStream ) ; xStream . allowTypesByRegExp ( new String [ ] { "org\\.optaplanner\\.\\w+\\.config\\..*" } ) ; return xStream ;


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

implementation: return new CompareToBuilder ( ) . append ( getClass ( ) . getName ( ) , other . getClass ( ) . getName ( ) ) . append ( id , other . id ) . toComparison ( ) ;


signature: public class AbstractSolver { public void solvingStarted ( DefaultSolverScope < Solution_ > solverScope ) { } }

implementation: solverScope . setWorkingSolutionFromBestSolution ( ) ; bestSolutionRecaller . solvingStarted ( solverScope ) ; termination . solvingStarted ( solverScope ) ; phaseLifecycleSupport . fireSolvingStarted ( solverScope ) ; for ( Phase < Solution_ > phase : phaseList ) { phase . solvingStarted ( solverScope ) ; }


signature: public class ConstructionHeuristicForagerConfig { public ConstructionHeuristicForager buildForager ( HeuristicConfigPolicy configPolicy ) { } }

implementation: ConstructionHeuristicPickEarlyType pickEarlyType_ ; if ( pickEarlyType == null ) { pickEarlyType_ = configPolicy . getScoreDirectorFactory ( ) . getInitializingScoreTrend ( ) . isOnlyDown ( ) ? ConstructionHeuristicPickEarlyType . FIRST_NON_DETERIORATING_SCORE : ConstructionHeuristicPickEarlyType . NEVER ; } else { if ( ( pickEarlyType == ConstructionHeuristicPickEarlyType . FIRST_FEASIBLE_SCORE || pickEarlyType == ConstructionHeuristicPickEarlyType . FIRST_FEASIBLE_SCORE_OR_NON_DETERIORATING_HARD ) && ! ( configPolicy . getScoreDefinition ( ) instanceof FeasibilityScoreDefinition ) ) { throw new IllegalArgumentException ( "The pickEarlyType (" + pickEarlyType + ") is not compatible with the scoreDefinition (" + configPolicy . getScoreDefinition ( ) + ")." ) ; } pickEarlyType_ = pickEarlyType ; } return new DefaultConstructionHeuristicForager ( pickEarlyType_ ) ;


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

implementation: long entitySize = entitySelector . getSize ( ) ; if ( entitySize > ( long ) Integer . MAX_VALUE ) { throw new IllegalStateException ( "The selector (" + this + ") has an entitySelector (" + entitySelector + ") with entitySize (" + entitySize + ") which is higher than Integer.MAX_VALUE." ) ; } Map < List < Object > , List < Object > > valueStateToPillarMap = new LinkedHashMap < > ( ( int ) entitySize ) ; for ( Object entity : entitySelector ) { List < Object > valueState = new ArrayList < > ( variableDescriptors . size ( ) ) ; for ( GenuineVariableDescriptor variableDescriptor : variableDescriptors ) { Object value = variableDescriptor . getValue ( entity ) ; valueState . add ( value ) ; } List < Object > pillar = valueStateToPillarMap . computeIfAbsent ( valueState , key -> new ArrayList < > ( ) ) ; pillar . add ( entity ) ; } cachedBasePillarList = new ArrayList < > ( valueStateToPillarMap . values ( ) ) ;


signature: public class SingleBenchmarkResult { protected static SingleBenchmarkResult createMerge ( SolverBenchmarkResult solverBenchmarkResult , ProblemBenchmarkResult problemBenchmarkResult , SingleBenchmarkResult oldResult ) { } }

implementation: SingleBenchmarkResult newResult = new SingleBenchmarkResult ( solverBenchmarkResult , problemBenchmarkResult ) ; newResult . subSingleBenchmarkResultList = new ArrayList < > ( oldResult . getSubSingleBenchmarkResultList ( ) . size ( ) ) ; int subSingleBenchmarkIndex = 0 ; for ( SubSingleBenchmarkResult oldSubResult : oldResult . subSingleBenchmarkResultList ) { SubSingleBenchmarkResult . createMerge ( newResult , oldSubResult , subSingleBenchmarkIndex ) ; subSingleBenchmarkIndex ++ ; } newResult . median = oldResult . median ; newResult . best = oldResult . best ; newResult . worst = oldResult . worst ; solverBenchmarkResult . getSingleBenchmarkResultList ( ) . add ( newResult ) ; problemBenchmarkResult . getSingleBenchmarkResultList ( ) . add ( newResult ) ; return newResult ;


signature: public class SwapMove { @ Override public String getSimpleMoveTypeDescription ( ) { } }

implementation: StringBuilder moveTypeDescription = new StringBuilder ( 20 * ( variableDescriptorList . size ( ) + 1 ) ) ; moveTypeDescription . append ( getClass ( ) . getSimpleName ( ) ) . append ( "(" ) ; String delimiter = "" ; for ( GenuineVariableDescriptor < Solution_ > variableDescriptor : variableDescriptorList ) { moveTypeDescription . append ( delimiter ) . append ( variableDescriptor . getSimpleEntityAndVariableName ( ) ) ; delimiter = ", " ; } moveTypeDescription . append ( ")" ) ; return moveTypeDescription . toString ( ) ;


signature: public class AbstractPhaseScope { public void reset ( ) { } }

implementation:
bestSolutionStepIndex = - 1 ; // TODO Usage of solverScope . getBestScore ( ) would be better performance wise but is null with a uninitialized score
startingScore = solverScope . calculateScore ( ) ; if ( getLastCompletedStepScope ( ) . getStepIndex ( ) < 0 ) { getLastCompletedStepScope ( ) . setScore ( startingScore ) ; }


signature: public class CourseSchedule { @ ProblemFactCollectionProperty private List < CourseConflict > calculateCourseConflictList ( ) { } }

implementation: List < CourseConflict > courseConflictList = new ArrayList < > ( ) ; for ( Course leftCourse : courseList ) { for ( Course rightCourse : courseList ) { if ( leftCourse . getId ( ) < rightCourse . getId ( ) ) { int conflictCount = 0 ; if ( leftCourse . getTeacher ( ) . equals ( rightCourse . getTeacher ( ) ) ) { conflictCount ++ ; } for ( Curriculum curriculum : leftCourse . getCurriculumList ( ) ) { if ( rightCourse . getCurriculumList ( ) . contains ( curriculum ) ) { conflictCount ++ ; } } if ( conflictCount > 0 ) { courseConflictList . add ( new CourseConflict ( leftCourse , rightCourse , conflictCount ) ) ; } } } } return courseConflictList ;


signature:
public class ConcurrentMemoization { /** * An overridden implementation that heavily favors read access over write access speed .
 * This is thread - safe .
 * { @ inheritDoc } */
@ Override public V computeIfAbsent ( K key , Function < ? super K , ? extends V > mappingFunction ) { } }

implementation:
// This might look like a Double Checked Idiom ( which is broken ) , but it is not
// because value is not a global variable
V value = get ( key ) ; if ( value != null ) { return value ; } return super . computeIfAbsent ( key , mappingFunction ) ;


signature: public class ConstraintMatchTotal { public ConstraintMatch addConstraintMatch ( List < Object > justificationList , Score score ) { } }

implementation: this . score = this . score . add ( score ) ; ConstraintMatch constraintMatch = new ConstraintMatch ( constraintPackage , constraintName , justificationList , score ) ; boolean added = constraintMatchSet . add ( constraintMatch ) ; if ( ! added ) { throw new IllegalStateException ( "The constraintMatchTotal (" + this + ") could not add constraintMatch (" + constraintMatch + ") to its constraintMatchSet (" + constraintMatchSet + ")." ) ; } return constraintMatch ;


signature: public class BestScoreTermination { @ Override public double calculateSolverTimeGradient ( DefaultSolverScope solverScope ) { } }

implementation: Score startingInitializedScore = solverScope . getStartingInitializedScore ( ) ; Score bestScore = solverScope . getBestScore ( ) ; return calculateTimeGradient ( startingInitializedScore , bestScoreLimit , bestScore ) ;


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

implementation:
// TODO FIXME through some sort of solverlistener and async behaviour . . .
throw new UnsupportedOperationException ( "This terminationClass (" + getClass ( ) + ") does not yet support being used in child threads of type (" + childThreadType + ")." ) ;


signature:
public class BendableLongScore { /** * Creates a new { @ link BendableLongScore } .
 * @ 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 BendableLongScore ofHard ( int hardLevelsSize , int softLevelsSize , int hardLevel , long hardScore ) { } }

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


signature:
public class BendableLongScore { /** * Creates a new { @ link BendableLongScore } .
 * @ 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 BendableLongScore ofSoft ( int hardLevelsSize , int softLevelsSize , int softLevel , long softScore ) { } }

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


signature:
public class CloudBalancingGenerator { /** * in gigabyte per hour */
public static void main ( String [ ] args ) { } }

implementation:
CloudBalancingGenerator generator = new CloudBalancingGenerator ( ) ; generator . writeCloudBalance ( 2 , 6 ) ; generator . writeCloudBalance ( 3 , 9 ) ; generator . writeCloudBalance ( 4 , 12 ) ; // generator . writeCloudBalance ( 5 , 15 ) ;
// generator . writeCloudBalance ( 6 , 18 ) ;
// generator . writeCloudBalance ( 7 , 21 ) ;
// generator . writeCloudBalance ( 8 , 24 ) ;
// generator . writeCloudBalance ( 9 , 27 ) ;
// generator . writeCloudBalance ( 10 , 30 ) ;
// generator . writeCloudBalance ( 11 , 33 ) ;
// generator . writeCloudBalance ( 12 , 36 ) ;
// generator . writeCloudBalance ( 13 , 39 ) ;
// generator . writeCloudBalance ( 14 , 42 ) ;
// generator . writeCloudBalance ( 15 , 45 ) ;
// generator . writeCloudBalance ( 16 , 48 ) ;
// generator . writeCloudBalance ( 17 , 51 ) ;
// generator . writeCloudBalance ( 18 , 54 ) ;
// generator . writeCloudBalance ( 19 , 57 ) ;
// generator . writeCloudBalance ( 20 , 60 ) ;
generator . writeCloudBalance ( 100 , 300 ) ; generator . writeCloudBalance ( 200 , 600 ) ; generator . writeCloudBalance ( 400 , 1200 ) ; generator . writeCloudBalance ( 800 , 2400 ) ; generator . writeCloudBalance ( 1600 , 4800 ) ;


signature: public class UnionMoveSelector { @ Override public boolean isNeverEnding ( ) { } }

implementation:
if ( randomSelection ) { for ( MoveSelector moveSelector : childMoveSelectorList ) { if ( moveSelector . isNeverEnding ( ) ) { return true ; } } // The UnionMoveSelector is special : it can be randomSelection true and still neverEnding false
return false ; } else { // Only the last childMoveSelector can be neverEnding
if ( ! childMoveSelectorList . isEmpty ( ) && childMoveSelectorList . get ( childMoveSelectorList . size ( ) - 1 ) . isNeverEnding ( ) ) { return true ; } return false ; }


signature: public class AcceptorConfig { public Acceptor buildAcceptor ( HeuristicConfigPolicy configPolicy ) { } }

implementation:
EnvironmentMode environmentMode = configPolicy . getEnvironmentMode ( ) ; List < Acceptor > acceptorList = new ArrayList < > ( ) ; if ( acceptorClassList != null ) { for ( Class < ? extends Acceptor > acceptorClass : acceptorClassList ) { Acceptor acceptor = ConfigUtils . newInstance ( this , "acceptorClass" , acceptorClass ) ; acceptorList . add ( acceptor ) ; } } if ( acceptorTypeList != null && acceptorTypeList . contains ( AcceptorType . HILL_CLIMBING ) ) { HillClimbingAcceptor acceptor = new HillClimbingAcceptor ( ) ; acceptorList . add ( acceptor ) ; } if ( ( acceptorTypeList != null && acceptorTypeList . contains ( AcceptorType . ENTITY_TABU ) ) || entityTabuSize != null || entityTabuRatio != null || fadingEntityTabuSize != null || fadingEntityTabuRatio != null ) { EntityTabuAcceptor acceptor = new EntityTabuAcceptor ( configPolicy . getLogIndentation ( ) ) ; if ( entityTabuSize != null ) { if ( entityTabuRatio != null ) { throw new IllegalArgumentException ( "The acceptor cannot have both entityTabuSize (" + entityTabuSize + ") and entityTabuRatio (" + entityTabuRatio + ")." ) ; } acceptor . setTabuSizeStrategy ( new FixedTabuSizeStrategy ( entityTabuSize ) ) ; } else if ( entityTabuRatio != null ) { acceptor . setTabuSizeStrategy ( new EntityRatioTabuSizeStrategy ( entityTabuRatio ) ) ; } else if ( fadingEntityTabuSize == null && fadingEntityTabuRatio == null ) { acceptor . setTabuSizeStrategy ( new EntityRatioTabuSizeStrategy ( 0.1 ) ) ; } if ( fadingEntityTabuSize != null ) { if ( fadingEntityTabuRatio != null ) { throw new IllegalArgumentException ( "The acceptor cannot have both fadingEntityTabuSize (" + fadingEntityTabuSize + ") and fadingEntityTabuRatio (" + fadingEntityTabuRatio + ")." ) ; } acceptor . setFadingTabuSizeStrategy ( new FixedTabuSizeStrategy ( fadingEntityTabuSize ) ) ; } else if ( fadingEntityTabuRatio != null ) { acceptor . setFadingTabuSizeStrategy ( new EntityRatioTabuSizeStrategy ( fadingEntityTabuRatio ) ) ; } if ( environmentMode . isNonIntrusiveFullAsserted ( ) ) { acceptor . setAssertTabuHashCodeCorrectness ( true ) ; } acceptorList . add ( acceptor ) ; } if ( ( acceptorTypeList != null && acceptorTypeList . contains ( AcceptorType . VALUE_TABU ) ) || valueTabuSize != null || valueTabuRatio != null || fadingValueTabuSize != null || fadingValueTabuRatio != null ) { ValueTabuAcceptor acceptor = new ValueTabuAcceptor ( configPolicy . getLogIndentation ( ) ) ; if ( valueTabuSize != null ) { if ( valueTabuRatio != null ) { throw new IllegalArgumentException ( "The acceptor cannot have both valueTabuSize (" + valueTabuSize + ") and valueTabuRatio (" + valueTabuRatio + ")." ) ; } acceptor . setTabuSizeStrategy ( new FixedTabuSizeStrategy ( valueTabuSize ) ) ; } else if ( valueTabuRatio != null ) { acceptor . setTabuSizeStrategy ( new ValueRatioTabuSizeStrategy ( valueTabuRatio ) ) ; } if ( fadingValueTabuSize != null ) { if ( fadingValueTabuRatio != null ) { throw new IllegalArgumentException ( "The acceptor cannot have both fadingValueTabuSize (" + fadingValueTabuSize + ") and fadingValueTabuRatio (" + fadingValueTabuRatio + ")." ) ; } acceptor . setFadingTabuSizeStrategy ( new FixedTabuSizeStrategy ( fadingValueTabuSize ) ) ; } else if ( fadingValueTabuRatio != null ) { acceptor . setFadingTabuSizeStrategy ( new ValueRatioTabuSizeStrategy ( fadingValueTabuRatio ) ) ; } if ( valueTabuSize != null ) { acceptor . setTabuSizeStrategy ( new FixedTabuSizeStrategy ( valueTabuSize ) ) ; } if ( fadingValueTabuSize != null ) { acceptor . setFadingTabuSizeStrategy ( new FixedTabuSizeStrategy ( fadingValueTabuSize ) ) ; } if ( environmentMode . isNonIntrusiveFullAsserted ( ) ) { acceptor . setAssertTabuHashCodeCorrectness ( true ) ; } acceptorList . add ( acceptor ) ; } if ( ( acceptorTypeList != null && acceptorTypeList . contains ( AcceptorType . MOVE_TABU ) ) || moveTabuSize != null || fadingMoveTabuSize != null ) { MoveTabuAcceptor acceptor = new MoveTabuAcceptor ( configPolicy . getLogIndentation ( ) ) ; acceptor . setUseUndoMoveAsTabuMove ( false ) ; if ( moveTabuSize != null ) { acceptor . setTabuSizeStrategy ( new FixedTabuSizeStrategy ( moveTabuSize ) ) ; } if ( fadingMoveTabuSize != null ) { acceptor . setFadingTabuSizeStrategy ( new FixedTabuSizeStrategy ( fadingMoveTabuSize ) ) ; } if ( environmentMode . isNonIntrusiveFullAsserted ( ) ) { acceptor . setAssertTabuHashCodeCorrectness ( true ) ; } acceptorList . add ( acceptor ) ; } if ( ( acceptorTypeList != null && acceptorTypeList . contains ( AcceptorType . UNDO_MOVE_TABU ) ) || undoMoveTabuSize != null || fadingUndoMoveTabuSize != null ) { MoveTabuAcceptor acceptor = new MoveTabuAcceptor ( configPolicy . getLogIndentation ( ) ) ; acceptor . setUseUndoMoveAsTabuMove ( true ) ; if ( undoMoveTabuSize != null ) { acceptor . setTabuSizeStrategy ( new FixedTabuSizeStrategy ( undoMoveTabuSize ) ) ; } if ( fadingUndoMoveTabuSize != null ) { acceptor . setFadingTabuSizeStrategy ( new FixedTabuSizeStrategy ( fadingUndoMoveTabuSize ) ) ; } if ( environmentMode . isNonIntrusiveFullAsserted ( ) ) { acceptor . setAssertTabuHashCodeCorrectness ( true ) ; } acceptorList . add ( acceptor ) ; } if ( ( acceptorTypeList != null && acceptorTypeList . contains ( AcceptorType . SOLUTION_TABU ) ) || solutionTabuSize != null || fadingSolutionTabuSize != null ) { SolutionTabuAcceptor acceptor = new SolutionTabuAcceptor ( configPolicy . getLogIndentation ( ) ) ; if ( solutionTabuSize != null ) { acceptor . setTabuSizeStrategy ( new FixedTabuSizeStrategy ( solutionTabuSize ) ) ; } if ( fadingSolutionTabuSize != null ) { acceptor . setFadingTabuSizeStrategy ( new FixedTabuSizeStrategy ( fadingSolutionTabuSize ) ) ; } if ( environmentMode . isNonIntrusiveFullAsserted ( ) ) { acceptor . setAssertTabuHashCodeCorrectness ( true ) ; } acceptorList . add ( acceptor ) ; } if ( ( acceptorTypeList != null && acceptorTypeList . contains ( AcceptorType . SIMULATED_ANNEALING ) ) || simulatedAnnealingStartingTemperature != null ) { SimulatedAnnealingAcceptor acceptor = new SimulatedAnnealingAcceptor ( ) ; if ( simulatedAnnealingStartingTemperature == null ) { // TODO Support SA without a parameter
throw new IllegalArgumentException ( "The acceptorType (" + AcceptorType . SIMULATED_ANNEALING + ") currently requires a simulatedAnnealingStartingTemperature (" + simulatedAnnealingStartingTemperature + ")." ) ; } acceptor . setStartingTemperature ( configPolicy . getScoreDefinition ( ) . parseScore ( simulatedAnnealingStartingTemperature ) ) ; acceptorList . add ( acceptor ) ; } if ( ( acceptorTypeList != null && acceptorTypeList . contains ( AcceptorType . LATE_ACCEPTANCE ) ) || lateAcceptanceSize != null ) { LateAcceptanceAcceptor acceptor = new LateAcceptanceAcceptor ( ) ; acceptor . setLateAcceptanceSize ( defaultIfNull ( lateAcceptanceSize , 400 ) ) ; acceptorList . add ( acceptor ) ; } if ( ( acceptorTypeList != null && acceptorTypeList . contains ( AcceptorType . STEP_COUNTING_HILL_CLIMBING ) ) || stepCountingHillClimbingSize != null ) { int stepCountingHillClimbingSize_ = defaultIfNull ( stepCountingHillClimbingSize , 400 ) ; StepCountingHillClimbingType stepCountingHillClimbingType_ = defaultIfNull ( stepCountingHillClimbingType , StepCountingHillClimbingType . STEP ) ; StepCountingHillClimbingAcceptor acceptor = new StepCountingHillClimbingAcceptor ( stepCountingHillClimbingSize_ , stepCountingHillClimbingType_ ) ; acceptorList . add ( acceptor ) ; } if ( acceptorList . size ( ) == 1 ) { return acceptorList . get ( 0 ) ; } else if ( acceptorList . size ( ) > 1 ) { return new CompositeAcceptor ( acceptorList ) ; } else { throw new IllegalArgumentException ( "The acceptor does not specify any acceptorType (" + acceptorTypeList + ") or other acceptor property.\n" + "For a good starting values," + " see the docs section \"Which optimization algorithms should I use?\"." ) ; }


signature: public class Indictment { public void addConstraintMatch ( ConstraintMatch constraintMatch ) { } }

implementation: score = score . add ( constraintMatch . getScore ( ) ) ; boolean added = constraintMatchSet . add ( constraintMatch ) ; if ( ! added ) { throw new IllegalStateException ( "The indictment (" + this + ") could not add constraintMatch (" + constraintMatch + ") to its constraintMatchSet (" + constraintMatchSet + ")." ) ; }


signature: public class Indictment { @ Override public int compareTo ( Indictment other ) { } }

implementation: if ( ! ( justification instanceof Comparable ) ) { throw new IllegalStateException ( "The justification (" + justification + ") does not implement " + Comparable . class . getSimpleName ( ) + ", so it cannot be compared with otherJustification (" + other . justification + ")." ) ; } return ( ( Comparable ) justification ) . compareTo ( other . justification ) ;


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

implementation: if ( subChain . getEntityList ( ) . contains ( toPlanningValue ) ) { return false ; } Object oldFirstValue = variableDescriptor . getValue ( subChain . getFirstEntity ( ) ) ; return ! Objects . equals ( oldFirstValue , toPlanningValue ) ;


signature:
public class ReportHelper { /** * Escape illegal HTML element id characters , such as a dot .
 * This escape function guarantees that 2 distinct strings will result into 2 distinct escape strings
 * ( presuming that both have been escaped by this method ) .
 * @ param rawHtmlId never null
 * @ return never null */
public static String escapeHtmlId ( String rawHtmlId ) { } }

implementation:
// Uses unicode numbers to escape , see http : / / unicode - table . com
// Uses ' - ' as the escape character
return rawHtmlId . replaceAll ( " " , "-0020" ) . replaceAll ( "!" , "-0021" ) . replaceAll ( "#" , "-0023" ) . replaceAll ( "\\$" , "-0024" ) . replaceAll ( "," , "-002C" ) . replaceAll ( "-" , "-002D" ) . replaceAll ( "\\." , "-002E" ) . replaceAll ( "\\(" , "-0028" ) . replaceAll ( "\\)" , "-0029" ) . replaceAll ( ":" , "-003A" ) . replaceAll ( ";" , "-003B" ) . replaceAll ( "\\?" , "-003F" ) ;


signature:
public class SolverBenchmarkResult { /** * Does not call { @ link SingleBenchmarkResult # accumulateResults ( BenchmarkReport ) } ,
 * because { @ link PlannerBenchmarkResult # accumulateResults ( BenchmarkReport ) } does that already on
 * { @ link PlannerBenchmarkResult # getUnifiedProblemBenchmarkResultList ( ) } .
 * @ param benchmarkReport never null */
public void accumulateResults ( BenchmarkReport benchmarkReport ) { } }

implementation: determineTotalsAndAverages ( ) ; standardDeviationDoubles = StatisticUtils . determineStandardDeviationDoubles ( singleBenchmarkResultList , averageScore , getSuccessCount ( ) ) ;


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

implementation:
// IdentityHashMap because different SolverBenchmarkResult instances are never merged
Map < SolverBenchmarkResult , SolverBenchmarkResult > mergeMap = new IdentityHashMap < > ( ) ; Map < String , Integer > nameCountMap = new HashMap < > ( ) ; for ( SingleBenchmarkResult singleBenchmarkResult : singleBenchmarkResultList ) { SolverBenchmarkResult oldResult = singleBenchmarkResult . getSolverBenchmarkResult ( ) ; if ( ! mergeMap . containsKey ( oldResult ) ) { SolverBenchmarkResult newResult = new SolverBenchmarkResult ( newPlannerBenchmarkResult ) ; Integer nameCount = nameCountMap . get ( oldResult . name ) ; if ( nameCount == null ) { nameCount = 1 ; } else { nameCount ++ ; } nameCountMap . put ( oldResult . name , nameCount ) ; newResult . subSingleCount = oldResult . subSingleCount ; newResult . solverConfig = oldResult . solverConfig ; newResult . scoreDefinition = oldResult . scoreDefinition ; newResult . singleBenchmarkResultList = new ArrayList < > ( oldResult . singleBenchmarkResultList . size ( ) ) ; mergeMap . put ( oldResult , newResult ) ; newPlannerBenchmarkResult . getSolverBenchmarkResultList ( ) . add ( newResult ) ; } } // Make name unique
for ( Map . Entry < SolverBenchmarkResult , SolverBenchmarkResult > entry : mergeMap . entrySet ( ) ) { SolverBenchmarkResult oldResult = entry . getKey ( ) ; SolverBenchmarkResult newResult = entry . getValue ( ) ; if ( nameCountMap . get ( oldResult . name ) > 1 ) { newResult . name = oldResult . name + " (" + oldResult . getPlannerBenchmarkResult ( ) . getName ( ) + ")" ; } else { newResult . name = oldResult . name ; } } return mergeMap ;


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

implementation: EntitySelectorConfig entitySelectorConfig_ = entitySelectorConfig == null ? new EntitySelectorConfig ( ) : entitySelectorConfig ; EntitySelector leftEntitySelector = entitySelectorConfig_ . buildEntitySelector ( configPolicy , minimumCacheType , SelectionOrder . fromRandomSelectionBoolean ( randomSelection ) ) ; EntitySelectorConfig rightEntitySelectorConfig = defaultIfNull ( secondaryEntitySelectorConfig , entitySelectorConfig_ ) ; EntitySelector rightEntitySelector = rightEntitySelectorConfig . buildEntitySelector ( configPolicy , minimumCacheType , SelectionOrder . fromRandomSelectionBoolean ( randomSelection ) ) ; List < GenuineVariableDescriptor > variableDescriptorList = deduceVariableDescriptorList ( leftEntitySelector . getEntityDescriptor ( ) , variableNameIncludeList ) ; return new SwapMoveSelector ( leftEntitySelector , rightEntitySelector , variableDescriptorList , randomSelection ) ;


signature: public class KOptMoveSelectorConfig { @ 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 [ ] valueSelectors = new ValueSelector [ K - 1 ] ; for ( int i = 0 ; i < valueSelectors . length ; i ++ ) { valueSelectors [ i ] = valueSelectorConfig_ . buildValueSelector ( configPolicy , entitySelector . getEntityDescriptor ( ) , minimumCacheType , SelectionOrder . fromRandomSelectionBoolean ( randomSelection ) ) ; } return new KOptMoveSelector ( entitySelector , valueSelectors , randomSelection ) ;


signature: public class ProblemBenchmarksConfig { public < Solution_ > void buildProblemBenchmarkList ( SolverConfigContext solverConfigContext , SolverBenchmarkResult solverBenchmarkResult , Solution_ [ ] extraProblems ) { } }

implementation:
PlannerBenchmarkResult plannerBenchmarkResult = solverBenchmarkResult . getPlannerBenchmarkResult ( ) ; List < ProblemBenchmarkResult > unifiedProblemBenchmarkResultList = plannerBenchmarkResult . getUnifiedProblemBenchmarkResultList ( ) ; for ( ProblemProvider < Solution_ > problemProvider : buildProblemProviderList ( solverConfigContext , solverBenchmarkResult , extraProblems ) ) { // 2 SolverBenchmarks containing equal ProblemBenchmarks should contain the same instance
ProblemBenchmarkResult < Solution_ > newProblemBenchmarkResult = buildProblemBenchmark ( solverConfigContext , plannerBenchmarkResult , problemProvider ) ; ProblemBenchmarkResult problemBenchmarkResult ; int index = unifiedProblemBenchmarkResultList . indexOf ( newProblemBenchmarkResult ) ; if ( index < 0 ) { problemBenchmarkResult = newProblemBenchmarkResult ; unifiedProblemBenchmarkResultList . add ( problemBenchmarkResult ) ; } else { problemBenchmarkResult = unifiedProblemBenchmarkResultList . get ( index ) ; } buildSingleBenchmark ( solverConfigContext , solverBenchmarkResult , problemBenchmarkResult ) ; }


signature:
public class CloudBalancingEasyScoreCalculator { /** * A very simple implementation . The double loop can easily be removed by using Maps as shown in
 * { @ link CloudBalancingMapBasedEasyScoreCalculator # calculateScore ( CloudBalance ) } . */
@ Override public HardSoftScore calculateScore ( CloudBalance cloudBalance ) { } }

implementation:
int hardScore = 0 ; int softScore = 0 ; for ( CloudComputer computer : cloudBalance . getComputerList ( ) ) { int cpuPowerUsage = 0 ; int memoryUsage = 0 ; int networkBandwidthUsage = 0 ; boolean used = false ; // Calculate usage
for ( CloudProcess process : cloudBalance . getProcessList ( ) ) { if ( computer . equals ( process . getComputer ( ) ) ) { cpuPowerUsage += process . getRequiredCpuPower ( ) ; memoryUsage += process . getRequiredMemory ( ) ; networkBandwidthUsage += process . getRequiredNetworkBandwidth ( ) ; used = true ; } } // Hard constraints
int cpuPowerAvailable = computer . getCpuPower ( ) - cpuPowerUsage ; if ( cpuPowerAvailable < 0 ) { hardScore += cpuPowerAvailable ; } int memoryAvailable = computer . getMemory ( ) - memoryUsage ; if ( memoryAvailable < 0 ) { hardScore += memoryAvailable ; } int networkBandwidthAvailable = computer . getNetworkBandwidth ( ) - networkBandwidthUsage ; if ( networkBandwidthAvailable < 0 ) { hardScore += networkBandwidthAvailable ; } // Soft constraints
if ( used ) { softScore -= computer . getCost ( ) ; } } return HardSoftScore . of ( hardScore , softScore ) ;


signature: public class PlannerBenchmarkResult { public void initBenchmarkReportDirectory ( File benchmarkDirectory ) { } }

implementation: String timestampString = startingTimestamp . format ( DateTimeFormatter . ofPattern ( "yyyy-MM-dd_HHmmss" ) ) ; if ( StringUtils . isEmpty ( name ) ) { name = timestampString ; } if ( ! benchmarkDirectory . mkdirs ( ) ) { if ( ! benchmarkDirectory . isDirectory ( ) ) { throw new IllegalArgumentException ( "The benchmarkDirectory (" + benchmarkDirectory + ") already exists, but is not a directory." ) ; } if ( ! benchmarkDirectory . canWrite ( ) ) { throw new IllegalArgumentException ( "The benchmarkDirectory (" + benchmarkDirectory + ") already exists, but is not writable." ) ; } } int duplicationIndex = 0 ; do { String directoryName = timestampString + ( duplicationIndex == 0 ? "" : "_" + duplicationIndex ) ; duplicationIndex ++ ; benchmarkReportDirectory = new File ( benchmarkDirectory , BooleanUtils . isFalse ( aggregation ) ? directoryName : directoryName + "_aggregation" ) ; } while ( ! benchmarkReportDirectory . mkdir ( ) ) ; for ( ProblemBenchmarkResult problemBenchmarkResult : unifiedProblemBenchmarkResultList ) { problemBenchmarkResult . makeDirs ( ) ; }


signature: public class PlannerBenchmarkResult { public static PlannerBenchmarkResult createMergedResult ( List < SingleBenchmarkResult > singleBenchmarkResultList ) { } }

implementation: PlannerBenchmarkResult mergedResult = createMergeSingleton ( singleBenchmarkResultList ) ; Map < SolverBenchmarkResult , SolverBenchmarkResult > solverMergeMap = SolverBenchmarkResult . createMergeMap ( mergedResult , singleBenchmarkResultList ) ; Map < ProblemBenchmarkResult , ProblemBenchmarkResult > problemMergeMap = ProblemBenchmarkResult . createMergeMap ( mergedResult , singleBenchmarkResultList ) ; for ( SingleBenchmarkResult singleBenchmarkResult : singleBenchmarkResultList ) { SolverBenchmarkResult solverBenchmarkResult = solverMergeMap . get ( singleBenchmarkResult . getSolverBenchmarkResult ( ) ) ; ProblemBenchmarkResult problemBenchmarkResult = problemMergeMap . get ( singleBenchmarkResult . getProblemBenchmarkResult ( ) ) ; SingleBenchmarkResult . createMerge ( solverBenchmarkResult , problemBenchmarkResult , singleBenchmarkResult ) ; } return mergedResult ;


signature: public class QueuedValuePlacerConfig { @ Override public QueuedValuePlacer buildEntityPlacer ( HeuristicConfigPolicy configPolicy ) { } }

implementation:
EntityDescriptor entityDescriptor = deduceEntityDescriptor ( configPolicy . getSolutionDescriptor ( ) , entityClass ) ; boolean reinitializeVariableFilterEnabled = configPolicy . isReinitializeVariableFilterEnabled ( ) ; configPolicy . setReinitializeVariableFilterEnabled ( false ) ; ValueSelectorConfig valueSelectorConfig_ = buildValueSelectorConfig ( configPolicy , entityDescriptor ) ; ValueSelector valueSelector = valueSelectorConfig_ . buildValueSelector ( configPolicy , entityDescriptor , SelectionCacheType . PHASE , SelectionOrder . ORIGINAL ) ; configPolicy . setReinitializeVariableFilterEnabled ( reinitializeVariableFilterEnabled ) ; MoveSelectorConfig moveSelectorConfig ; if ( ConfigUtils . isEmptyCollection ( moveSelectorConfigList ) ) { moveSelectorConfig = buildChangeMoveSelectorConfig ( configPolicy , valueSelectorConfig_ . getId ( ) , valueSelector . getVariableDescriptor ( ) ) ; } else if ( moveSelectorConfigList . size ( ) == 1 ) { moveSelectorConfig = moveSelectorConfigList . get ( 0 ) ; } else { // TODO moveSelectorConfigList is only a List because of XStream limitations .
throw new IllegalArgumentException ( "The moveSelectorConfigList (" + moveSelectorConfigList + ") must be a singleton or empty. Use a single " + UnionMoveSelectorConfig . class . getSimpleName ( ) + " or " + CartesianProductMoveSelectorConfig . class . getSimpleName ( ) + " element to nest multiple MoveSelectors." ) ; } MoveSelector moveSelector = moveSelectorConfig . buildMoveSelector ( configPolicy , SelectionCacheType . JUST_IN_TIME , SelectionOrder . ORIGINAL ) ; if ( ! ( valueSelector instanceof EntityIndependentValueSelector ) ) { throw new IllegalArgumentException ( "The queuedValuePlacer (" + this + ") needs to be based on an EntityIndependentValueSelector (" + valueSelector + ")." + " Check your @" + ValueRangeProvider . class . getSimpleName ( ) + " annotations." ) ; } return new QueuedValuePlacer ( ( EntityIndependentValueSelector ) valueSelector , moveSelector ) ;


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

implementation: super . constructCache ( solverScope ) ; sorter . sort ( solverScope . getScoreDirector ( ) , cachedEntityList ) ; logger . trace ( "    Sorted cachedEntityList: size ({}), entitySelector ({})." , cachedEntityList . size ( ) , this ) ;


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

implementation: HeuristicConfigPolicy phaseConfigPolicy = solverConfigPolicy . createPhaseConfigPolicy ( ) ; ThreadFactory threadFactory ; if ( threadFactoryClass != null ) { threadFactory = ConfigUtils . newInstance ( this , "threadFactoryClass" , threadFactoryClass ) ; } else { threadFactory = solverConfigPolicy . buildThreadFactory ( ChildThreadType . PART_THREAD ) ; } DefaultPartitionedSearchPhase phase = new DefaultPartitionedSearchPhase ( phaseIndex , solverConfigPolicy . getLogIndentation ( ) , bestSolutionRecaller , buildPhaseTermination ( phaseConfigPolicy , solverTermination ) , buildSolutionPartitioner ( ) , threadFactory , resolvedActiveThreadCount ( ) ) ; List < PhaseConfig > phaseConfigList_ = phaseConfigList ; if ( ConfigUtils . isEmptyCollection ( phaseConfigList_ ) ) { phaseConfigList_ = Arrays . asList ( new ConstructionHeuristicPhaseConfig ( ) , new LocalSearchPhaseConfig ( ) ) ; } phase . setPhaseConfigList ( phaseConfigList_ ) ; phase . setConfigPolicy ( phaseConfigPolicy . createChildThreadConfigPolicy ( ChildThreadType . PART_THREAD ) ) ; EnvironmentMode environmentMode = phaseConfigPolicy . getEnvironmentMode ( ) ; if ( environmentMode . isNonIntrusiveFullAsserted ( ) ) { phase . setAssertStepScoreFromScratch ( true ) ; } if ( environmentMode . isIntrusiveFastAsserted ( ) ) { phase . setAssertExpectedStepScore ( true ) ; phase . setAssertShadowVariablesAreNotStaleAfterStep ( true ) ; } return phase ;


signature: public class EntityDescriptor { public void processAnnotations ( DescriptorPolicy descriptorPolicy ) { } }

implementation:
processEntityAnnotations ( descriptorPolicy ) ; declaredGenuineVariableDescriptorMap = new LinkedHashMap < > ( ) ; declaredShadowVariableDescriptorMap = new LinkedHashMap < > ( ) ; declaredPinEntityFilterList = new ArrayList < > ( 2 ) ; // Only iterate declared fields and methods , not inherited members , to avoid registering the same one twice
List < Member > memberList = ConfigUtils . getDeclaredMembers ( entityClass ) ; for ( Member member : memberList ) { processValueRangeProviderAnnotation ( descriptorPolicy , member ) ; processPlanningVariableAnnotation ( descriptorPolicy , member ) ; processPlanningPinAnnotation ( descriptorPolicy , member ) ; } if ( declaredGenuineVariableDescriptorMap . isEmpty ( ) && declaredShadowVariableDescriptorMap . isEmpty ( ) ) { throw new IllegalStateException ( "The entityClass (" + entityClass + ") should have at least 1 getter method or 1 field with a " + PlanningVariable . class . getSimpleName ( ) + " annotation or a shadow variable annotation." ) ; } processVariableAnnotations ( descriptorPolicy ) ;


signature:
public class HardSoftLongScoreHolder { /** * Reward a match by the { @ link ConstraintWeight } multiplied with the weightMultiplier for all score levels .
 * @ param kcontext never null , the magic variable in DRL
 * @ param weightMultiplier at least 0 */
public void reward ( RuleContext kcontext , long weightMultiplier ) { } }

implementation: Rule rule = kcontext . getRule ( ) ; BiConsumer < RuleContext , Long > matchExecutor = matchExecutorByNumberMap . get ( rule ) ; if ( matchExecutor == null ) { throw new IllegalStateException ( "The DRL rule (" + rule . getPackageName ( ) + ":" + rule . getName ( ) + ") does not match a @" + ConstraintWeight . class . getSimpleName ( ) + " on the @" + ConstraintConfiguration . class . getSimpleName ( ) + " annotated class." ) ; } matchExecutor . accept ( kcontext , weightMultiplier ) ;


signature:
public class AbstractSolution { /** * Adds to an existing to { @ link List } to avoid copying the entire list with { @ link List # addAll ( Collection ) } .
 * @ param factList never null
 * @ param instanceClass never null */
private void addProblemFactsFromClass ( List < Object > factList , Class < ? > instanceClass ) { } }

implementation:
if ( instanceClass . equals ( AbstractSolution . class ) ) { // The field score should not be included
return ; } for ( Field field : instanceClass . getDeclaredFields ( ) ) { field . setAccessible ( true ) ; if ( isFieldAPlanningEntityPropertyOrPlanningEntityCollectionProperty ( field , instanceClass ) ) { continue ; } Object value ; try { value = field . get ( this ) ; } catch ( IllegalAccessException e ) { throw new IllegalStateException ( "The class (" + instanceClass + ") has a field (" + field + ") which can not be read to create the problem facts." , e ) ; } if ( value != null ) { if ( value instanceof Collection ) { factList . addAll ( ( Collection ) value ) ; } else if ( value instanceof Map ) { throw new IllegalStateException ( "The class (" + instanceClass + ") has a field (" + field + ") which is a " + Map . class . getSimpleName ( ) + " and that's not yet supported." ) ; } else { factList . add ( value ) ; } } } Class < ? > superclass = instanceClass . getSuperclass ( ) ; if ( superclass != null ) { addProblemFactsFromClass ( factList , superclass ) ; }


signature: public class AnchorVariableDemand { @ Override public AnchorVariableSupply createExternalizedSupply ( InnerScoreDirector scoreDirector ) { } }

implementation: SingletonInverseVariableSupply inverseVariableSupply = scoreDirector . getSupplyManager ( ) . demand ( new SingletonInverseVariableDemand ( sourceVariableDescriptor ) ) ; return new ExternalizedAnchorVariableSupply ( sourceVariableDescriptor , inverseVariableSupply ) ;


signature:
public class ReflectionHelper { /** * Returns the JavaBeans property name of the given member .
 * @ param member never null
 * @ return null if the member is neither a field nor a getter method according to the JavaBeans standard */
public static String getGetterPropertyName ( Member member ) { } }

implementation: if ( member instanceof Field ) { return member . getName ( ) ; } else if ( member instanceof Method ) { String methodName = member . getName ( ) ; for ( String prefix : PROPERTY_ACCESSOR_PREFIXES ) { if ( methodName . startsWith ( prefix ) ) { return decapitalizePropertyName ( methodName . substring ( prefix . length ( ) ) ) ; } } } return null ;


signature:
public class ReflectionHelper { /** * Checks whether the given method is a valid getter method according to the JavaBeans standard .
 * @ param method never null
 * @ return true if the given method is a getter method */
public static boolean isGetterMethod ( Method method ) { } }

implementation: if ( method . getParameterTypes ( ) . length != 0 ) { return false ; } String methodName = method . getName ( ) ; if ( methodName . startsWith ( PROPERTY_ACCESSOR_PREFIX_GET ) && method . getReturnType ( ) != void . class ) { return true ; } else if ( methodName . startsWith ( PROPERTY_ACCESSOR_PREFIX_IS ) && method . getReturnType ( ) == boolean . class ) { return true ; } return false ;


signature: public class CartesianProductMoveSelector { @ Override public boolean isNeverEnding ( ) { } }

implementation:
if ( randomSelection ) { return true ; } else { // Only the last childMoveSelector can be neverEnding
return ! childMoveSelectorList . isEmpty ( ) && childMoveSelectorList . get ( childMoveSelectorList . size ( ) - 1 ) . isNeverEnding ( ) ; }


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

implementation: Object oldValue = variableDescriptor . getValue ( entity ) ; return ! Objects . equals ( oldValue , toPlanningValue ) ;


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

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


signature:
public class HardMediumSoftBigDecimalScoreHolder { /** * Penalize a match by the { @ link ConstraintWeight } negated and multiplied with the specific weightMultiplier per score level .
 * Slower than { @ link # penalize ( RuleContext , BigDecimal ) } .
 * @ 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 , BigDecimal hardWeightMultiplier , BigDecimal mediumWeightMultiplier , BigDecimal softWeightMultiplier ) { } }

implementation: reward ( kcontext , hardWeightMultiplier . negate ( ) , mediumWeightMultiplier . negate ( ) , softWeightMultiplier . negate ( ) ) ;


signature:
public class HardMediumSoftBigDecimalScoreHolder { /** * Reward a match by the { @ link ConstraintWeight } multiplied with the specific weightMultiplier per score level .
 * Slower than { @ link # reward ( RuleContext , BigDecimal ) } .
 * @ 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 reward ( RuleContext kcontext , BigDecimal hardWeightMultiplier , BigDecimal mediumWeightMultiplier , BigDecimal softWeightMultiplier ) { } }

implementation: Rule rule = kcontext . getRule ( ) ; BiConsumer < RuleContext , HardMediumSoftBigDecimalScore > matchExecutor = matchExecutorByScoreMap . get ( rule ) ; if ( matchExecutor == null ) { throw new IllegalStateException ( "The DRL rule (" + rule . getPackageName ( ) + ":" + rule . getName ( ) + ") does not match a @" + ConstraintWeight . class . getSimpleName ( ) + " on the @" + ConstraintConfiguration . class . getSimpleName ( ) + " annotated class." ) ; } matchExecutor . accept ( kcontext , HardMediumSoftBigDecimalScore . of ( hardWeightMultiplier , mediumWeightMultiplier , softWeightMultiplier ) ) ;


signature:
public class HardMediumSoftBigDecimalScoreHolder { /** * Add a hard constraint of specified weighting .
 * This is typically used in Drools scoring to add a hard constraint match ( negative value to indicate an infeasible
 * solution ) .
 * @ param kcontext never null , the magic variable in DRL
 * @ param hardWeight never null , higher is better , negative for a penalty , positive for a reward */
public void addHardConstraintMatch ( RuleContext kcontext , BigDecimal hardWeight ) { } }

implementation: hardScore = hardScore . add ( hardWeight ) ; registerConstraintMatch ( kcontext , ( ) -> hardScore = hardScore . subtract ( hardWeight ) , ( ) -> HardMediumSoftBigDecimalScore . of ( hardWeight , BigDecimal . ZERO , BigDecimal . ZERO ) ) ;


signature:
public class HardMediumSoftBigDecimalScoreHolder { /** * Add a medium level constraint of specified weighting .
 * This is typically used in Drools scoring to add a medium priority constraint match .
 * @ param kcontext never null , the magic variable in DRL
 * @ param mediumWeight never null , higher is better , negative for a penalty , positive for a reward */
public void addMediumConstraintMatch ( RuleContext kcontext , BigDecimal mediumWeight ) { } }

implementation: mediumScore = mediumScore . add ( mediumWeight ) ; registerConstraintMatch ( kcontext , ( ) -> mediumScore = mediumScore . subtract ( mediumWeight ) , ( ) -> HardMediumSoftBigDecimalScore . of ( BigDecimal . ZERO , mediumWeight , BigDecimal . ZERO ) ) ;


signature:
public class HardMediumSoftBigDecimalScoreHolder { /** * Add a soft constraint match of specified weighting .
 * This is typically used in Drools scoring to add a low priority constraint match .
 * @ param kcontext never null , the magic variable in DRL
 * @ param softWeight never null , higher is better , negative for a penalty , positive for a reward */
public void addSoftConstraintMatch ( RuleContext kcontext , BigDecimal softWeight ) { } }

implementation: softScore = softScore . add ( softWeight ) ; registerConstraintMatch ( kcontext , ( ) -> softScore = softScore . subtract ( softWeight ) , ( ) -> HardMediumSoftBigDecimalScore . of ( BigDecimal . ZERO , BigDecimal . ZERO , softWeight ) ) ;


signature: public class ConstraintMatchTotalStepScoreSubSingleStatistic { @ Override public void open ( Solver < Solution_ > solver ) { } }

implementation: DefaultSolver < Solution_ > defaultSolver = ( DefaultSolver < Solution_ > ) solver ; defaultSolver . getSolverScope ( ) . getScoreDirector ( ) . overwriteConstraintMatchEnabledPreference ( true ) ; defaultSolver . addPhaseLifecycleListener ( listener ) ;


signature: public class AbstractCompositeTermination { @ Override public void solvingStarted ( DefaultSolverScope solverScope ) { } }

implementation: for ( Termination termination : terminationList ) { termination . solvingStarted ( solverScope ) ; }


signature: public class AbstractCompositeTermination { protected List < Termination > createChildThreadTerminationList ( DefaultSolverScope solverScope , ChildThreadType childThreadType ) { } }

implementation: List < Termination > childThreadTerminationList = new ArrayList < > ( terminationList . size ( ) ) ; for ( Termination termination : terminationList ) { childThreadTerminationList . add ( termination . createChildThreadTermination ( solverScope , childThreadType ) ) ; } return childThreadTerminationList ;


signature: public class CartesianProductMoveSelectorConfig { @ 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 ) ) ) ; } boolean ignoreEmptyChildIterators_ = defaultIfNull ( ignoreEmptyChildIterators , true ) ; return new CartesianProductMoveSelector ( moveSelectorList , ignoreEmptyChildIterators_ , randomSelection ) ;


signature:
public class OptaPlannerExamplesApp { /** * Supported system properties : { @ link CommonApp # DATA _ DIR _ SYSTEM _ PROPERTY } .
 * @ param args never null */
public static void main ( String [ ] args ) { } }

implementation: CommonApp . prepareSwingEnvironment ( ) ; OptaPlannerExamplesApp optaPlannerExamplesApp = new OptaPlannerExamplesApp ( ) ; optaPlannerExamplesApp . pack ( ) ; optaPlannerExamplesApp . setLocationRelativeTo ( null ) ; optaPlannerExamplesApp . setVisible ( true ) ;


signature: public class MeetingAssignment { public int calculateOverlap ( MeetingAssignment other ) { } }

implementation: if ( startingTimeGrain == null || other . getStartingTimeGrain ( ) == null ) { return 0 ; } int start = startingTimeGrain . getGrainIndex ( ) ; int end = start + meeting . getDurationInGrains ( ) ; int otherStart = other . startingTimeGrain . getGrainIndex ( ) ; int otherEnd = otherStart + other . meeting . getDurationInGrains ( ) ; if ( end < otherStart ) { return 0 ; } else if ( otherEnd < start ) { return 0 ; } return Math . min ( end , otherEnd ) - Math . max ( start , otherStart ) ;


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

implementation:
for ( Object leftEntity : leftSubChain . getEntityList ( ) ) { if ( rightSubChain . getEntityList ( ) . contains ( leftEntity ) ) { return false ; } } // Because leftFirstEntity and rightFirstEntity are unequal , chained guarantees their values are unequal too .
return true ;


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

implementation:
XYPlot plot = createPlot ( benchmarkReport ) ; int seriesIndex = 0 ; for ( SingleBenchmarkResult singleBenchmarkResult : problemBenchmarkResult . getSingleBenchmarkResultList ( ) ) { XYIntervalSeries series = new XYIntervalSeries ( singleBenchmarkResult . getSolverBenchmarkResult ( ) . getNameWithFavoriteSuffix ( ) ) ; XYItemRenderer renderer = new YIntervalRenderer ( ) ; if ( singleBenchmarkResult . hasAllSuccess ( ) ) { BestSolutionMutationSubSingleStatistic subSingleStatistic = ( BestSolutionMutationSubSingleStatistic ) singleBenchmarkResult . getSubSingleStatistic ( problemStatisticType ) ; List < BestSolutionMutationStatisticPoint > points = subSingleStatistic . getPointList ( ) ; for ( BestSolutionMutationStatisticPoint point : points ) { long timeMillisSpent = point . getTimeMillisSpent ( ) ; long mutationCount = point . getMutationCount ( ) ; double yValue = mutationCount ; // In an XYInterval the yLow must be lower than yHigh
series . add ( timeMillisSpent , timeMillisSpent , timeMillisSpent , yValue , ( yValue > 0.0 ) ? 0.0 : yValue , ( yValue > 0.0 ) ? yValue : 0.0 ) ; } } XYIntervalSeriesCollection dataset = new XYIntervalSeriesCollection ( ) ; dataset . addSeries ( series ) ; plot . setDataset ( seriesIndex , dataset ) ; 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 ( ) + " best solution mutation statistic" , JFreeChart . DEFAULT_TITLE_FONT , plot , true ) ; graphFile = writeChartToImageFile ( chart , problemBenchmarkResult . getName ( ) + "BestSolutionMutationStatistic" ) ;


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

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


signature: public class Examination { @ ProblemFactCollectionProperty private List < TopicConflict > calculateTopicConflictList ( ) { } }

implementation: List < TopicConflict > topicConflictList = new ArrayList < > ( ) ; for ( Topic leftTopic : topicList ) { for ( Topic rightTopic : topicList ) { if ( leftTopic . getId ( ) < rightTopic . getId ( ) ) { int studentSize = 0 ; for ( Student student : leftTopic . getStudentList ( ) ) { if ( rightTopic . getStudentList ( ) . contains ( student ) ) { studentSize ++ ; } } if ( studentSize > 0 ) { topicConflictList . add ( new TopicConflict ( leftTopic , rightTopic , studentSize ) ) ; } } } } return topicConflictList ;


signature:
public class PartitionQueue { /** * This method is thread - safe .
 * The previous move ( s ) for this partIndex ( if it hasn ' t been consumed yet ) , will be skipped during iteration .
 * @ param partIndex { @ code 0 < = partIndex < partCount }
 * @ param move never null
 * @ see BlockingQueue # add ( Object ) */
public void addMove ( int partIndex , PartitionChangeMove < Solution_ > move ) { } }

implementation: long eventIndex = nextEventIndexMap . get ( partIndex ) . getAndIncrement ( ) ; PartitionChangedEvent < Solution_ > event = new PartitionChangedEvent < > ( partIndex , eventIndex , move ) ; moveEventMap . put ( event . getPartIndex ( ) , event ) ; queue . add ( event ) ;


signature:
public class PartitionQueue { /** * This method is thread - safe .
 * The previous move for this partIndex ( that haven ' t been consumed yet ) , will still be returned during iteration .
 * @ param partIndex { @ code 0 < = partIndex < partCount }
 * @ param partCalculationCount at least 0
 * @ see BlockingQueue # add ( Object ) */
public void addFinish ( int partIndex , long partCalculationCount ) { } }

implementation: long eventIndex = nextEventIndexMap . get ( partIndex ) . getAndIncrement ( ) ; PartitionChangedEvent < Solution_ > event = new PartitionChangedEvent < > ( partIndex , eventIndex , partCalculationCount ) ; queue . add ( event ) ;


signature:
public class PartitionQueue { /** * This method is thread - safe .
 * The previous move for this partIndex ( if it hasn ' t been consumed yet ) , will still be returned during iteration
 * before the iteration throws an exception .
 * @ param partIndex { @ code 0 < = partIndex < partCount }
 * @ param throwable never null
 * @ see BlockingQueue # add ( Object ) */
public void addExceptionThrown ( int partIndex , Throwable throwable ) { } }

implementation: long eventIndex = nextEventIndexMap . get ( partIndex ) . getAndIncrement ( ) ; PartitionChangedEvent < Solution_ > event = new PartitionChangedEvent < > ( partIndex , eventIndex , throwable ) ; queue . add ( event ) ;


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

implementation: super . setWorkingSolution ( workingSolution ) ; if ( incrementalScoreCalculator instanceof ConstraintMatchAwareIncrementalScoreCalculator ) { ( ( ConstraintMatchAwareIncrementalScoreCalculator < Solution_ > ) incrementalScoreCalculator ) . resetWorkingSolution ( workingSolution , constraintMatchEnabledPreference ) ; } else { incrementalScoreCalculator . resetWorkingSolution ( workingSolution ) ; }


signature: public class IncrementalScoreDirector { @ Override public void beforeEntityAdded ( EntityDescriptor < Solution_ > entityDescriptor , Object entity ) { } }

implementation: incrementalScoreCalculator . beforeEntityAdded ( entity ) ; super . beforeEntityAdded ( entityDescriptor , entity ) ;


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

implementation:
// bestSolutionRecaller . solvingStarted ( . . . ) is called by DefaultSolver
// solverPhaseLifecycleSupport . solvingStarted ( . . . ) is called by DefaultSolver
termination . solvingStarted ( solverScope ) ; phaseLifecycleSupport . fireSolvingStarted ( solverScope ) ;


signature: public class AbstractPhase { protected void assertWorkingSolutionInitialized ( AbstractPhaseScope < Solution_ > phaseScope ) { } }

implementation: if ( ! phaseScope . getStartingScore ( ) . isSolutionInitialized ( ) ) { InnerScoreDirector < Solution_ > scoreDirector = phaseScope . getScoreDirector ( ) ; SolutionDescriptor < Solution_ > solutionDescriptor = scoreDirector . getSolutionDescriptor ( ) ; Solution_ workingSolution = scoreDirector . getWorkingSolution ( ) ; for ( Iterator < Object > it = solutionDescriptor . extractAllEntitiesIterator ( workingSolution ) ; it . hasNext ( ) ; ) { Object entity = it . next ( ) ; EntityDescriptor < Solution_ > entityDescriptor = solutionDescriptor . findEntityDescriptorOrFail ( entity . getClass ( ) ) ; if ( ! entityDescriptor . isEntityInitializedOrImmovable ( scoreDirector , entity ) ) { String variableRef = null ; for ( GenuineVariableDescriptor < Solution_ > variableDescriptor : entityDescriptor . getGenuineVariableDescriptors ( ) ) { if ( ! variableDescriptor . isInitialized ( entity ) ) { variableRef = variableDescriptor . getSimpleEntityAndVariableName ( ) ; break ; } } throw new IllegalStateException ( getPhaseTypeString ( ) + " phase (" + phaseIndex + ") needs to start from an initialized solution, but the planning variable (" + variableRef + ") is uninitialized for the entity (" + entity + ").\n" + "Maybe there is no Construction Heuristic configured before this phase to initialize the solution.\n" + "Or maybe the getter/setters of your planning variables in your domain classes aren't implemented correctly." ) ; } } }


signature: public class ScoreDirectorFactoryConfig { public ScoreDefinition buildDeprecatedScoreDefinition ( ) { } }

implementation: if ( scoreDefinitionType != ScoreDefinitionType . BENDABLE && scoreDefinitionType != ScoreDefinitionType . BENDABLE_LONG && scoreDefinitionType != ScoreDefinitionType . BENDABLE_BIG_DECIMAL && ( bendableHardLevelsSize != null || bendableSoftLevelsSize != null ) ) { throw new IllegalArgumentException ( "A bendableHardLevelsSize (" + bendableHardLevelsSize + ") or bendableSoftLevelsSize (" + bendableSoftLevelsSize + ") needs a scoreDefinitionType (" + scoreDefinitionType + ") that is bendable." ) ; } if ( ( scoreDefinitionType == ScoreDefinitionType . BENDABLE || scoreDefinitionType == ScoreDefinitionType . BENDABLE_LONG || scoreDefinitionType == ScoreDefinitionType . BENDABLE_BIG_DECIMAL ) && ( bendableHardLevelsSize == null || bendableSoftLevelsSize == null ) ) { throw new IllegalArgumentException ( "With scoreDefinitionType (" + scoreDefinitionType + ") there must be a bendableHardLevelsSize (" + bendableHardLevelsSize + ") and a bendableSoftLevelsSize (" + bendableSoftLevelsSize + ")." ) ; } if ( scoreDefinitionClass != null ) { if ( scoreDefinitionType != null ) { throw new IllegalArgumentException ( "With scoreDefinitionClass (" + scoreDefinitionClass + ") there must be no scoreDefinitionType (" + scoreDefinitionType + ")." ) ; } return ConfigUtils . newInstance ( this , "scoreDefinitionClass" , scoreDefinitionClass ) ; } if ( scoreDefinitionType != null ) { switch ( scoreDefinitionType ) { case SIMPLE : return new SimpleScoreDefinition ( ) ; case SIMPLE_LONG : return new SimpleLongScoreDefinition ( ) ; case SIMPLE_DOUBLE : return new SimpleDoubleScoreDefinition ( ) ; case SIMPLE_BIG_DECIMAL : return new SimpleBigDecimalScoreDefinition ( ) ; case HARD_SOFT : return new HardSoftScoreDefinition ( ) ; case HARD_SOFT_LONG : return new HardSoftLongScoreDefinition ( ) ; case HARD_SOFT_DOUBLE : return new HardSoftDoubleScoreDefinition ( ) ; case HARD_SOFT_BIG_DECIMAL : return new HardSoftBigDecimalScoreDefinition ( ) ; case HARD_MEDIUM_SOFT : return new HardMediumSoftScoreDefinition ( ) ; case HARD_MEDIUM_SOFT_LONG : return new HardMediumSoftLongScoreDefinition ( ) ; case BENDABLE : return new BendableScoreDefinition ( bendableHardLevelsSize , bendableSoftLevelsSize ) ; case BENDABLE_LONG : return new BendableLongScoreDefinition ( bendableHardLevelsSize , bendableSoftLevelsSize ) ; case BENDABLE_BIG_DECIMAL : return new BendableBigDecimalScoreDefinition ( bendableHardLevelsSize , bendableSoftLevelsSize ) ; default : throw new IllegalStateException ( "The scoreDefinitionType (" + scoreDefinitionType + ") is not implemented." ) ; } } else { return null ; }


signature: public class SolverBenchmarkConfig { public void buildSolverBenchmark ( SolverConfigContext solverConfigContext , PlannerBenchmarkResult plannerBenchmark , Solution_ [ ] extraProblems ) { } }

implementation: validate ( ) ; SolverBenchmarkResult solverBenchmarkResult = new SolverBenchmarkResult ( plannerBenchmark ) ; solverBenchmarkResult . setName ( name ) ; solverBenchmarkResult . setSubSingleCount ( ConfigUtils . inheritOverwritableProperty ( subSingleCount , 1 ) ) ; solverBenchmarkResult . setSolverConfig ( solverConfig ) ; SolutionDescriptor < Object > solutionDescriptor = solverConfig . buildSolutionDescriptor ( solverConfigContext ) ; for ( Solution_ extraProblem : extraProblems ) { if ( ! solutionDescriptor . getSolutionClass ( ) . isInstance ( extraProblem ) ) { throw new IllegalArgumentException ( "The solverBenchmark name (" + name + ") for solution class (" + solutionDescriptor . getSolutionClass ( ) + ") cannot solve a problem (" + extraProblem + ") of class (" + ( extraProblem == null ? null : extraProblem . getClass ( ) ) + ")." ) ; } } solverBenchmarkResult . setScoreDefinition ( solutionDescriptor . getScoreDefinition ( ) ) ; solverBenchmarkResult . setSingleBenchmarkResultList ( new ArrayList < > ( ) ) ; ProblemBenchmarksConfig problemBenchmarksConfig_ = problemBenchmarksConfig == null ? new ProblemBenchmarksConfig ( ) : problemBenchmarksConfig ; plannerBenchmark . getSolverBenchmarkResultList ( ) . add ( solverBenchmarkResult ) ; problemBenchmarksConfig_ . buildProblemBenchmarkList ( solverConfigContext , solverBenchmarkResult , extraProblems ) ;


signature: public class MoveTabuAcceptor { @ Override protected Collection < ? extends Object > findTabu ( LocalSearchMoveScope moveScope ) { } }

implementation: return Collections . singletonList ( moveScope . getMove ( ) ) ;


signature:
public class NQueensApp { /** * Normal way to create a { @ link Solver } .
 * @ return never null */
protected Solver < NQueens > createSolverByXml ( ) { } }

implementation: SolverFactory < NQueens > solverFactory = SolverFactory . createFromXmlResource ( SOLVER_CONFIG ) ; return solverFactory . buildSolver ( ) ;


signature:
public class NQueensApp { /** * Unused alternative . Abnormal way to create a { @ link Solver } .
 * Not recommended ! It is recommended to use { @ link # createSolverByXml ( ) } instead .
 * @ return never null */
protected Solver < NQueens > createSolverByApi ( ) { } }

implementation: SolverFactory < NQueens > solverFactory = SolverFactory . createEmpty ( ) ; SolverConfig solverConfig = solverFactory . getSolverConfig ( ) ; solverConfig . setSolutionClass ( NQueens . class ) ; solverConfig . setEntityClassList ( Collections . < Class < ? > > singletonList ( Queen . class ) ) ; ScoreDirectorFactoryConfig scoreDirectorFactoryConfig = new ScoreDirectorFactoryConfig ( ) ; scoreDirectorFactoryConfig . setScoreDrlList ( Arrays . asList ( "org/optaplanner/examples/nqueens/solver/nQueensScoreRules.drl" ) ) ; solverConfig . setScoreDirectorFactoryConfig ( scoreDirectorFactoryConfig ) ; solverConfig . setTerminationConfig ( new TerminationConfig ( ) . withBestScoreLimit ( "0" ) ) ; List < PhaseConfig > phaseConfigList = new ArrayList < > ( ) ; ConstructionHeuristicPhaseConfig constructionHeuristicPhaseConfig = new ConstructionHeuristicPhaseConfig ( ) ; constructionHeuristicPhaseConfig . setConstructionHeuristicType ( ConstructionHeuristicType . FIRST_FIT_DECREASING ) ; phaseConfigList . add ( constructionHeuristicPhaseConfig ) ; LocalSearchPhaseConfig localSearchPhaseConfig = new LocalSearchPhaseConfig ( ) ; ChangeMoveSelectorConfig changeMoveSelectorConfig = new ChangeMoveSelectorConfig ( ) ; changeMoveSelectorConfig . setSelectionOrder ( SelectionOrder . ORIGINAL ) ; localSearchPhaseConfig . setMoveSelectorConfig ( changeMoveSelectorConfig ) ; localSearchPhaseConfig . setAcceptorConfig ( new AcceptorConfig ( ) . withEntityTabuSize ( 5 ) ) ; phaseConfigList . add ( localSearchPhaseConfig ) ; solverConfig . setPhaseConfigList ( phaseConfigList ) ; return solverFactory . buildSolver ( ) ;


signature: public class LocalSearchDecider { public void solvingStarted ( DefaultSolverScope < Solution_ > solverScope ) { } }

implementation: moveSelector . solvingStarted ( solverScope ) ; acceptor . solvingStarted ( solverScope ) ; forager . solvingStarted ( solverScope ) ;


signature: public class VariableListenerSupport { public void resetWorkingSolution ( ) { } }

implementation: for ( VariableListenerNotifiable notifiable : notifiableList ) { VariableListener variableListener = notifiable . getVariableListener ( ) ; if ( variableListener instanceof StatefulVariableListener ) { ( ( StatefulVariableListener ) variableListener ) . resetWorkingSolution ( scoreDirector ) ; } }


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

implementation: IncrementalScoreCalculator < Solution_ > incrementalScoreCalculator = ConfigUtils . newInstance ( this , "incrementalScoreCalculatorClass" , incrementalScoreCalculatorClass ) ; ConfigUtils . applyCustomProperties ( incrementalScoreCalculator , "incrementalScoreCalculatorClass" , incrementalScoreCalculatorCustomProperties , "incrementalScoreCalculatorCustomProperties" ) ; return new IncrementalScoreDirector < > ( this , lookUpEnabled , constraintMatchEnabledPreference , incrementalScoreCalculator ) ;


signature: public class SubChainChangeMoveSelectorConfig { @ 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 subChainSelector = subChainSelectorConfig_ . buildSubChainSelector ( configPolicy , entityDescriptor , minimumCacheType , SelectionOrder . fromRandomSelectionBoolean ( randomSelection ) ) ; ValueSelectorConfig valueSelectorConfig_ = valueSelectorConfig == null ? new ValueSelectorConfig ( ) : valueSelectorConfig ; ValueSelector valueSelector = valueSelectorConfig_ . buildValueSelector ( configPolicy , entityDescriptor , minimumCacheType , SelectionOrder . fromRandomSelectionBoolean ( randomSelection ) ) ; if ( ! ( valueSelector instanceof EntityIndependentValueSelector ) ) { throw new IllegalArgumentException ( "The moveSelectorConfig (" + this + ") needs to be based on an EntityIndependentValueSelector (" + valueSelector + ")." + " Check your @" + ValueRangeProvider . class . getSimpleName ( ) + " annotations." ) ; } return new SubChainChangeMoveSelector ( subChainSelector , ( EntityIndependentValueSelector ) valueSelector , randomSelection , defaultIfNull ( selectReversingMoveToo , true ) ) ;


signature: public class SubSingleBenchmarkResult { protected static SubSingleBenchmarkResult createMerge ( SingleBenchmarkResult singleBenchmarkResult , SubSingleBenchmarkResult oldResult , int subSingleBenchmarkIndex ) { } }

implementation:
SubSingleBenchmarkResult newResult = new SubSingleBenchmarkResult ( singleBenchmarkResult , subSingleBenchmarkIndex ) ; newResult . pureSubSingleStatisticList = new ArrayList < > ( oldResult . pureSubSingleStatisticList . size ( ) ) ; for ( PureSubSingleStatistic oldSubSingleStatistic : oldResult . pureSubSingleStatisticList ) { newResult . pureSubSingleStatisticList . add ( oldSubSingleStatistic . getStatisticType ( ) . buildPureSubSingleStatistic ( newResult ) ) ; } newResult . initSubSingleStatisticMap ( ) ; for ( SubSingleStatistic newSubSingleStatistic : newResult . effectiveSubSingleStatisticMap . values ( ) ) { SubSingleStatistic oldSubSingleStatistic = oldResult . getSubSingleStatistic ( newSubSingleStatistic . getStatisticType ( ) ) ; if ( ! oldSubSingleStatistic . getCsvFile ( ) . exists ( ) ) { if ( oldResult . hasAnyFailure ( ) ) { newSubSingleStatistic . initPointList ( ) ; logger . debug ( "Old result ({}) is a failure, skipping merge of its sub single statistic ({})." , oldResult , oldSubSingleStatistic ) ; continue ; } else { throw new IllegalStateException ( "Could not find old result's (" + oldResult + ") sub single statistic's (" + oldSubSingleStatistic + ") CSV file." ) ; } } oldSubSingleStatistic . unhibernatePointList ( ) ; newSubSingleStatistic . setPointList ( oldSubSingleStatistic . getPointList ( ) ) ; oldSubSingleStatistic . hibernatePointList ( ) ; } // Skip oldResult . reportDirectory
// Skip oldResult . usedMemoryAfterInputSolution
newResult . succeeded = oldResult . succeeded ; newResult . score = oldResult . score ; newResult . timeMillisSpent = oldResult . timeMillisSpent ; newResult . scoreCalculationCount = oldResult . scoreCalculationCount ; singleBenchmarkResult . getSubSingleBenchmarkResultList ( ) . add ( newResult ) ; return newResult ;


signature: public class BestSolutionMutationSubSingleStatistic { @ Override public void open ( Solver < Solution_ > solver ) { } }

implementation: InnerScoreDirectorFactory < Solution_ > scoreDirectorFactory = ( InnerScoreDirectorFactory < Solution_ > ) solver . getScoreDirectorFactory ( ) ; SolutionDescriptor < Solution_ > solutionDescriptor = scoreDirectorFactory . getSolutionDescriptor ( ) ; listener . setMutationCounter ( new MutationCounter < > ( solutionDescriptor ) ) ; solver . addEventListener ( listener ) ;


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

implementation:
List < XYPlot > plotList = new ArrayList < > ( BenchmarkReport . CHARTED_SCORE_LEVEL_SIZE ) ; int seriesIndex = 0 ; for ( SingleBenchmarkResult singleBenchmarkResult : problemBenchmarkResult . getSingleBenchmarkResultList ( ) ) { List < XYSeries > seriesList = new ArrayList < > ( BenchmarkReport . CHARTED_SCORE_LEVEL_SIZE ) ; // No direct ascending lines between 2 points , but a stepping line instead
XYItemRenderer renderer = new XYStepRenderer ( ) ; if ( singleBenchmarkResult . hasAllSuccess ( ) ) { BestScoreSubSingleStatistic subSingleStatistic = ( BestScoreSubSingleStatistic ) singleBenchmarkResult . getSubSingleStatistic ( problemStatisticType ) ; List < BestScoreStatisticPoint > points = subSingleStatistic . getPointList ( ) ; for ( BestScoreStatisticPoint point : points ) { if ( ! point . getScore ( ) . isSolutionInitialized ( ) ) { continue ; } long timeMillisSpent = point . getTimeMillisSpent ( ) ; double [ ] levelValues = ScoreUtils . extractLevelDoubles ( point . getScore ( ) ) ; for ( int i = 0 ; i < levelValues . length && i < BenchmarkReport . CHARTED_SCORE_LEVEL_SIZE ; i ++ ) { if ( i >= seriesList . size ( ) ) { seriesList . add ( new XYSeries ( singleBenchmarkResult . getSolverBenchmarkResult ( ) . getNameWithFavoriteSuffix ( ) ) ) ; } seriesList . get ( i ) . add ( timeMillisSpent , levelValues [ i ] ) ; } } // TODO if startingSolution is initialized and no improvement is made , a horizontal line should be shown
// Draw a horizontal line from the last new best step to how long the solver actually ran
long timeMillisSpent = singleBenchmarkResult . getTimeMillisSpent ( ) ; double [ ] bestScoreLevels = ScoreUtils . extractLevelDoubles ( singleBenchmarkResult . getMedian ( ) . getScore ( ) ) ; for ( int i = 0 ; i < bestScoreLevels . length && i < BenchmarkReport . CHARTED_SCORE_LEVEL_SIZE ; i ++ ) { if ( i >= seriesList . size ( ) ) { seriesList . add ( new XYSeries ( singleBenchmarkResult . getSolverBenchmarkResult ( ) . getNameWithFavoriteSuffix ( ) ) ) ; } seriesList . get ( i ) . add ( timeMillisSpent , bestScoreLevels [ i ] ) ; } if ( subSingleStatistic . getPointList ( ) . size ( ) <= 1 ) { // Workaround for https : / / sourceforge . net / tracker / ? func = detail & aid = 3387330 & group _ id = 15494 & atid = 115494
renderer = new StandardXYItemRenderer ( StandardXYItemRenderer . SHAPES_AND_LINES ) ; } } if ( singleBenchmarkResult . getSolverBenchmarkResult ( ) . isFavorite ( ) ) { // Make the favorite more obvious
renderer . setSeriesStroke ( 0 , new BasicStroke ( 2.0f ) ) ; } for ( int i = 0 ; i < seriesList . size ( ) ; i ++ ) { if ( i >= plotList . size ( ) ) { plotList . add ( createPlot ( benchmarkReport , i ) ) ; } plotList . get ( i ) . setDataset ( seriesIndex , new XYSeriesCollection ( seriesList . get ( i ) ) ) ; plotList . get ( i ) . setRenderer ( seriesIndex , renderer ) ; } seriesIndex ++ ; } graphFileList = new ArrayList < > ( plotList . size ( ) ) ; for ( int scoreLevelIndex = 0 ; scoreLevelIndex < plotList . size ( ) ; scoreLevelIndex ++ ) { String scoreLevelLabel = problemBenchmarkResult . findScoreLevelLabel ( scoreLevelIndex ) ; JFreeChart chart = new JFreeChart ( problemBenchmarkResult . getName ( ) + " best " + scoreLevelLabel + " statistic" , JFreeChart . DEFAULT_TITLE_FONT , plotList . get ( scoreLevelIndex ) , true ) ; graphFileList . add ( writeChartToImageFile ( chart , problemBenchmarkResult . getName ( ) + "BestScoreStatisticLevel" + scoreLevelIndex ) ) ; }


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

implementation:
if ( childThreadType == ChildThreadType . PART_THREAD ) { // Remove of the bridge ( which is nested if there ' s a phase termination ) , PhaseConfig will add it again
return solverTermination . createChildThreadTermination ( solverScope , childThreadType ) ; } else { throw new IllegalStateException ( "The childThreadType (" + childThreadType + ") is not implemented." ) ; }


signature: public class EasyScoreDirector { @ Override public Score calculateScore ( ) { } }

implementation: variableListenerSupport . assertNotificationQueuesAreEmpty ( ) ; Score score = easyScoreCalculator . calculateScore ( workingSolution ) ; if ( score == null ) { throw new IllegalStateException ( "The easyScoreCalculator (" + easyScoreCalculator . getClass ( ) + ") must return a non-null score (" + score + ") in the method calculateScore()." ) ; } if ( workingInitScore != 0 ) { score = score . withInitScore ( workingInitScore ) ; } setCalculatedScore ( score ) ; return score ;


signature:
public class EasyScoreDirector { /** * { @ link ConstraintMatch } s are not supported by this { @ link ScoreDirector } implementation .
 * @ throws IllegalStateException always
 * @ return throws { @ link IllegalStateException } */
@ Override public Map < Object , Indictment > getIndictmentMap ( ) { } }

implementation: throw new IllegalStateException ( ConstraintMatch . class . getSimpleName ( ) + " is not supported by " + EasyScoreDirector . class . getSimpleName ( ) + "." ) ;


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

implementation:
List < Map < String , XYIntervalSeries > > moveTypeToSeriesMapList = new ArrayList < > ( BenchmarkReport . CHARTED_SCORE_LEVEL_SIZE ) ; List < PickedMoveTypeStepScoreDiffStatisticPoint > points = getPointList ( ) ; for ( PickedMoveTypeStepScoreDiffStatisticPoint point : points ) { long timeMillisSpent = point . getTimeMillisSpent ( ) ; String moveType = point . getMoveType ( ) ; double [ ] levelValues = ScoreUtils . extractLevelDoubles ( point . getStepScoreDiff ( ) ) ; for ( int i = 0 ; i < levelValues . length && i < BenchmarkReport . CHARTED_SCORE_LEVEL_SIZE ; i ++ ) { if ( i >= moveTypeToSeriesMapList . size ( ) ) { moveTypeToSeriesMapList . add ( new LinkedHashMap < > ( ) ) ; } Map < String , XYIntervalSeries > moveTypeToSeriesMap = moveTypeToSeriesMapList . get ( i ) ; XYIntervalSeries series = moveTypeToSeriesMap . computeIfAbsent ( moveType , k -> new XYIntervalSeries ( moveType ) ) ; double yValue = levelValues [ i ] ; // In an XYInterval the yLow must be lower than yHigh
series . add ( timeMillisSpent , timeMillisSpent , timeMillisSpent , yValue , ( yValue > 0.0 ) ? 0.0 : yValue , ( yValue > 0.0 ) ? yValue : 0.0 ) ; } } graphFileList = new ArrayList < > ( moveTypeToSeriesMapList . size ( ) ) ; for ( int scoreLevelIndex = 0 ; scoreLevelIndex < moveTypeToSeriesMapList . size ( ) ; scoreLevelIndex ++ ) { XYPlot plot = createPlot ( benchmarkReport , scoreLevelIndex ) ; XYItemRenderer renderer = new YIntervalRenderer ( ) ; plot . setRenderer ( renderer ) ; XYIntervalSeriesCollection seriesCollection = new XYIntervalSeriesCollection ( ) ; for ( XYIntervalSeries series : moveTypeToSeriesMapList . get ( scoreLevelIndex ) . values ( ) ) { seriesCollection . addSeries ( series ) ; } plot . setDataset ( seriesCollection ) ; String scoreLevelLabel = subSingleBenchmarkResult . getSingleBenchmarkResult ( ) . getProblemBenchmarkResult ( ) . findScoreLevelLabel ( scoreLevelIndex ) ; JFreeChart chart = new JFreeChart ( subSingleBenchmarkResult . getName ( ) + " picked move type step " + scoreLevelLabel + " diff statistic" , JFreeChart . DEFAULT_TITLE_FONT , plot , true ) ; graphFileList . add ( writeChartToImageFile ( chart , "PickedMoveTypeStepScoreDiffStatisticLevel" + scoreLevelIndex ) ) ; }


signature: public class MemoryUseProblemStatistic { @ 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 ( "Memory (bytes)" ) ; yAxis . setNumberFormatOverride ( NumberFormat . getInstance ( locale ) ) ; XYPlot plot = new XYPlot ( null , xAxis , yAxis , null ) ; plot . setOrientation ( PlotOrientation . VERTICAL ) ; int seriesIndex = 0 ; for ( SingleBenchmarkResult singleBenchmarkResult : problemBenchmarkResult . getSingleBenchmarkResultList ( ) ) { XYSeries usedSeries = new XYSeries ( singleBenchmarkResult . getSolverBenchmarkResult ( ) . getNameWithFavoriteSuffix ( ) + " used" ) ; // TODO enable max memory , but in the same color as used memory , but with a dotted line instead
// XYSeries maxSeries = new XYSeries (
// singleBenchmarkResult . getSolverBenchmarkResult ( ) . getNameWithFavoriteSuffix ( ) + " max " ) ;
XYItemRenderer renderer = new XYLineAndShapeRenderer ( ) ; if ( singleBenchmarkResult . hasAllSuccess ( ) ) { MemoryUseSubSingleStatistic subSingleStatistic = ( MemoryUseSubSingleStatistic ) singleBenchmarkResult . getSubSingleStatistic ( problemStatisticType ) ; List < MemoryUseStatisticPoint > points = subSingleStatistic . getPointList ( ) ; for ( MemoryUseStatisticPoint point : points ) { long timeMillisSpent = point . getTimeMillisSpent ( ) ; MemoryUseMeasurement memoryUseMeasurement = point . getMemoryUseMeasurement ( ) ; usedSeries . add ( timeMillisSpent , memoryUseMeasurement . getUsedMemory ( ) ) ; // maxSeries . add ( timeMillisSpent , memoryUseMeasurement . getMaxMemory ( ) ) ;
} } XYSeriesCollection seriesCollection = new XYSeriesCollection ( ) ; seriesCollection . addSeries ( usedSeries ) ; // seriesCollection . addSeries ( maxSeries ) ;
plot . setDataset ( seriesIndex , seriesCollection ) ; if ( singleBenchmarkResult . getSolverBenchmarkResult ( ) . isFavorite ( ) ) { // Make the favorite more obvious
renderer . setSeriesStroke ( 0 , new BasicStroke ( 2.0f ) ) ; // renderer . setSeriesStroke ( 1 , new BasicStroke ( 2.0f ) ) ;
} plot . setRenderer ( seriesIndex , renderer ) ; seriesIndex ++ ; } JFreeChart chart = new JFreeChart ( problemBenchmarkResult . getName ( ) + " memory use statistic" , JFreeChart . DEFAULT_TITLE_FONT , plot , true ) ; graphFile = writeChartToImageFile ( chart , problemBenchmarkResult . getName ( ) + "MemoryUseStatistic" ) ;


signature:
public class SolverFactory { /** * Uses { @ link KieServices # getKieClasspathContainer ( ) } .
 * @ param solverConfigResource never null , a classpath resource in the { @ link KieContainer }
 * as defined by { @ link ClassLoader # getResource ( String ) }
 * @ return never null */
public static < Solution_ > SolverFactory < Solution_ > createFromKieContainerXmlResource ( String solverConfigResource ) { } }

implementation: KieContainer kieContainer = KieServices . Factory . get ( ) . getKieClasspathContainer ( ) ; return new XStreamXmlSolverFactory < Solution_ > ( new SolverConfigContext ( kieContainer ) ) . configure ( solverConfigResource ) ;


signature:
public class SolverFactory { /** * See { @ link # createFromXmlResource ( String ) } .
 * @ param solverConfigResource 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 < Solution_ > SolverFactory < Solution_ > createFromXmlResource ( String solverConfigResource , ClassLoader classLoader ) { } }

implementation: return new XStreamXmlSolverFactory < Solution_ > ( new SolverConfigContext ( classLoader ) ) . configure ( solverConfigResource ) ;


signature: public class ScoreDifferencePercentage { public ScoreDifferencePercentage add ( ScoreDifferencePercentage addend ) { } }

implementation: if ( percentageLevels . length != addend . getPercentageLevels ( ) . length ) { throw new IllegalStateException ( "The addend (" + addend + ")'s levelsLength (" + addend . getPercentageLevels ( ) . length + ") is different from the base (" + this + ")'s levelsLength (" + percentageLevels . length + ")." ) ; } double [ ] newPercentageLevels = new double [ percentageLevels . length ] ; for ( int i = 0 ; i < percentageLevels . length ; i ++ ) { newPercentageLevels [ i ] = percentageLevels [ i ] + addend . percentageLevels [ i ] ; } return new ScoreDifferencePercentage ( newPercentageLevels ) ;


signature: public class SolverConfig { public EnvironmentMode determineEnvironmentMode ( ) { } }

implementation: if ( environmentMode == EnvironmentMode . PRODUCTION ) { environmentMode = EnvironmentMode . NON_REPRODUCIBLE ; } return defaultIfNull ( environmentMode , EnvironmentMode . REPRODUCIBLE ) ;


signature: public class SolverConfig { public void offerRandomSeedFromSubSingleIndex ( long subSingleIndex ) { } }

implementation: if ( environmentMode == null || environmentMode . isReproducible ( ) ) { if ( randomFactoryClass == null && randomSeed == null ) { randomSeed = subSingleIndex ; } }


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

implementation: super . configureConstraintWeight ( rule , constraintWeight ) ; BiConsumer < RuleContext , Integer > matchExecutor ; if ( constraintWeight . equals ( BendableScore . zero ( hardScores . length , softScores . length ) ) ) { matchExecutor = ( RuleContext kcontext , Integer matchWeight ) -> { } ; } else { Integer singleLevel = null ; Integer singleLevelWeight = null ; for ( int i = 0 ; i < constraintWeight . getLevelsSize ( ) ; i ++ ) { int levelWeight = constraintWeight . getHardOrSoftScore ( i ) ; if ( levelWeight != 0 ) { if ( singleLevel != null ) { singleLevel = null ; singleLevelWeight = null ; break ; } singleLevel = i ; singleLevelWeight = levelWeight ; } } if ( singleLevel != null ) { int levelWeight = singleLevelWeight ; if ( singleLevel < constraintWeight . getHardLevelsSize ( ) ) { int level = singleLevel ; matchExecutor = ( RuleContext kcontext , Integer matchWeight ) -> addHardConstraintMatch ( kcontext , level , levelWeight * matchWeight ) ; } else { int level = singleLevel - constraintWeight . getHardLevelsSize ( ) ; matchExecutor = ( RuleContext kcontext , Integer matchWeight ) -> addSoftConstraintMatch ( kcontext , level , levelWeight * matchWeight ) ; } } else { matchExecutor = ( RuleContext kcontext , Integer matchWeight ) -> { int [ ] hardWeights = new int [ hardScores . length ] ; int [ ] softWeights = new int [ softScores . length ] ; for ( int i = 0 ; i < hardWeights . length ; i ++ ) { hardWeights [ i ] = constraintWeight . getHardScore ( i ) * matchWeight ; } for ( int i = 0 ; i < softWeights . length ; i ++ ) { softWeights [ i ] = constraintWeight . getSoftScore ( i ) * matchWeight ; } addMultiConstraintMatch ( kcontext , hardWeights , softWeights ) ; } ; } } matchExecutorByNumberMap . put ( rule , matchExecutor ) ; matchExecutorByScoreMap . put ( rule , ( RuleContext kcontext , BendableScore weightMultiplier ) -> { int [ ] hardWeights = new int [ hardScores . length ] ; int [ ] softWeights = new int [ softScores . length ] ; for ( int i = 0 ; i < hardWeights . length ; i ++ ) { hardWeights [ i ] = constraintWeight . getHardScore ( i ) * weightMultiplier . getHardScore ( i ) ; } for ( int i = 0 ; i < softWeights . length ; i ++ ) { softWeights [ i ] = constraintWeight . getSoftScore ( i ) * weightMultiplier . getSoftScore ( i ) ; } addMultiConstraintMatch ( kcontext , hardWeights , softWeights ) ; } ) ;


signature:
public class BendableBigDecimalScore { /** * Creates a new { @ link BendableBigDecimalScore } .
 * @ param initScore see { @ link Score # getInitScore ( ) }
 * @ param hardScores never null , never change that array afterwards : it must be immutable
 * @ param softScores never null , never change that array afterwards : it must be immutable
 * @ return never null */
public static BendableBigDecimalScore ofUninitialized ( int initScore , BigDecimal [ ] hardScores , BigDecimal [ ] softScores ) { } }

implementation: return new BendableBigDecimalScore ( initScore , hardScores , softScores ) ;


signature:
public class BendableBigDecimalScore { /** * Creates a new { @ link BendableBigDecimalScore } .
 * @ param hardLevelsSize at least 0
 * @ param softLevelsSize at least 0
 * @ return never null */
public static BendableBigDecimalScore zero ( int hardLevelsSize , int softLevelsSize ) { } }

implementation: BigDecimal [ ] hardScores = new BigDecimal [ hardLevelsSize ] ; Arrays . fill ( hardScores , BigDecimal . ZERO ) ; BigDecimal [ ] softScores = new BigDecimal [ softLevelsSize ] ; Arrays . fill ( softScores , BigDecimal . ZERO ) ; return new BendableBigDecimalScore ( 0 , hardScores , softScores ) ;


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

implementation: BigDecimal [ ] hardScores = new BigDecimal [ hardLevelsSize ] ; Arrays . fill ( hardScores , BigDecimal . ZERO ) ; BigDecimal [ ] softScores = new BigDecimal [ softLevelsSize ] ; Arrays . fill ( softScores , BigDecimal . ZERO ) ; hardScores [ hardLevel ] = hardScore ; return new BendableBigDecimalScore ( 0 , hardScores , softScores ) ;


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

implementation: BigDecimal [ ] hardScores = new BigDecimal [ hardLevelsSize ] ; Arrays . fill ( hardScores , BigDecimal . ZERO ) ; BigDecimal [ ] softScores = new BigDecimal [ softLevelsSize ] ; Arrays . fill ( softScores , BigDecimal . ZERO ) ; softScores [ softLevel ] = softScore ; return new BendableBigDecimalScore ( 0 , hardScores , softScores ) ;


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

implementation: SortedSet < ExhaustiveSearchNode > expandableNodeQueue = new TreeSet < > ( nodeComparator ) ; ExhaustiveSearchPhaseScope < Solution_ > phaseScope = new ExhaustiveSearchPhaseScope < > ( solverScope ) ; phaseScope . setExpandableNodeQueue ( expandableNodeQueue ) ; phaseStarted ( phaseScope ) ; while ( ! expandableNodeQueue . isEmpty ( ) && ! termination . isPhaseTerminated ( phaseScope ) ) { ExhaustiveSearchStepScope < Solution_ > stepScope = new ExhaustiveSearchStepScope < > ( phaseScope ) ; ExhaustiveSearchNode node = expandableNodeQueue . last ( ) ; expandableNodeQueue . remove ( node ) ; stepScope . setExpandingNode ( node ) ; stepStarted ( stepScope ) ; restoreWorkingSolution ( stepScope ) ; decider . expandNode ( stepScope ) ; stepEnded ( stepScope ) ; phaseScope . setLastCompletedStepScope ( stepScope ) ; } phaseEnded ( phaseScope ) ;


signature: public class LocalSearchForagerConfig { public LocalSearchForager buildForager ( HeuristicConfigPolicy configPolicy ) { } }

implementation:
if ( foragerClass != null ) { if ( pickEarlyType != null || acceptedCountLimit != null || finalistPodiumType != null ) { throw new IllegalArgumentException ( "The forager with foragerClass (" + foragerClass + ") must not also have a pickEarlyType (" + pickEarlyType + "), acceptedCountLimit (" + acceptedCountLimit + ") or finalistPodiumType (" + finalistPodiumType + ")." ) ; } return ConfigUtils . newInstance ( this , "foragerClass" , foragerClass ) ; } LocalSearchPickEarlyType pickEarlyType_ = defaultIfNull ( pickEarlyType , LocalSearchPickEarlyType . NEVER ) ; int acceptedCountLimit_ = defaultIfNull ( acceptedCountLimit , Integer . MAX_VALUE ) ; FinalistPodiumType finalistPodiumType_ = defaultIfNull ( finalistPodiumType , FinalistPodiumType . HIGHEST_SCORE ) ; // Breaking ties randomly leads statistically to much better results
boolean breakTieRandomly_ = defaultIfNull ( breakTieRandomly , true ) ; return new AcceptedLocalSearchForager ( finalistPodiumType_ . buildFinalistPodium ( ) , pickEarlyType_ , acceptedCountLimit_ , breakTieRandomly_ ) ;


signature:
public class BendableLongScoreHolder { /** * Penalize a match by the { @ link ConstraintWeight } negated and multiplied with the specific weightMultiplier per score level .
 * Slower than { @ link # penalize ( RuleContext , long ) } .
 * @ param kcontext never null , the magic variable in DRL
 * @ param hardWeightsMultiplier elements at least 0
 * @ param softWeightsMultiplier elements at least 0 */
public void penalize ( RuleContext kcontext , long [ ] hardWeightsMultiplier , long [ ] softWeightsMultiplier ) { } }

implementation: long [ ] negatedHardWeightsMultiplier = new long [ hardScores . length ] ; long [ ] negatedSoftWeightsMultiplier = new long [ softScores . length ] ; for ( int i = 0 ; i < negatedHardWeightsMultiplier . length ; i ++ ) { negatedHardWeightsMultiplier [ i ] = - hardWeightsMultiplier [ i ] ; } for ( int i = 0 ; i < negatedSoftWeightsMultiplier . length ; i ++ ) { negatedSoftWeightsMultiplier [ i ] = - softWeightsMultiplier [ i ] ; } reward ( kcontext , negatedHardWeightsMultiplier , negatedSoftWeightsMultiplier ) ;


signature:
public class BendableLongScoreHolder { /** * Reward a match by the { @ link ConstraintWeight } multiplied with the specific weightMultiplier per score level .
 * Slower than { @ link # reward ( RuleContext , long ) } .
 * @ param kcontext never null , the magic variable in DRL
 * @ param hardWeightsMultiplier elements at least 0
 * @ param softWeightsMultiplier elements at least 0 */
public void reward ( RuleContext kcontext , long [ ] hardWeightsMultiplier , long [ ] softWeightsMultiplier ) { } }

implementation: Rule rule = kcontext . getRule ( ) ; BiConsumer < RuleContext , BendableLongScore > matchExecutor = matchExecutorByScoreMap . get ( rule ) ; if ( matchExecutor == null ) { throw new IllegalStateException ( "The DRL rule (" + rule . getPackageName ( ) + ":" + rule . getName ( ) + ") does not match a @" + ConstraintWeight . class . getSimpleName ( ) + " on the @" + ConstraintConfiguration . class . getSimpleName ( ) + " annotated class." ) ; } matchExecutor . accept ( kcontext , BendableLongScore . of ( hardWeightsMultiplier , softWeightsMultiplier ) ) ;


signature:
public class OrderByMoveIndexBlockingQueue { /** * Not thread - safe . Can only be called from the solver thread .
 * @ param stepIndex at least 0 */
public void startNextStep ( int stepIndex ) { } }

implementation: synchronized ( this ) { if ( filterStepIndex >= stepIndex ) { throw new IllegalStateException ( "The old filterStepIndex (" + filterStepIndex + ") must be less than the stepIndex (" + stepIndex + ")" ) ; } filterStepIndex = stepIndex ; MoveResult < Solution_ > exceptionResult = innerQueue . stream ( ) . filter ( MoveResult :: hasThrownException ) . findFirst ( ) . orElse ( null ) ; if ( exceptionResult != null ) { throw new IllegalStateException ( "The move thread with moveThreadIndex (" + exceptionResult . getMoveThreadIndex ( ) + ") has thrown an exception." + " Relayed here in the parent thread." , exceptionResult . getThrowable ( ) ) ; } innerQueue . clear ( ) ; } nextMoveIndex = 0 ; backlog . clear ( ) ;


signature:
public class OrderByMoveIndexBlockingQueue { /** * This method is thread - safe . It can be called from any move thread .
 * @ param moveThreadIndex { @ code 0 < = moveThreadIndex < moveThreadCount }
 * @ param stepIndex at least 0
 * @ param moveIndex at least 0
 * @ param move never null
 * @ see BlockingQueue # add ( Object ) */
public void addUndoableMove ( int moveThreadIndex , int stepIndex , int moveIndex , Move < Solution_ > move ) { } }

implementation:
MoveResult < Solution_ > result = new MoveResult < > ( moveThreadIndex , stepIndex , moveIndex , move , false , null ) ; synchronized ( this ) { if ( result . getStepIndex ( ) != filterStepIndex ) { // Discard element from previous step
return ; } innerQueue . add ( result ) ; }


signature:
public class OrderByMoveIndexBlockingQueue { /** * This method is thread - safe . It can be called from any move thread .
 * @ param moveThreadIndex { @ code 0 < = moveThreadIndex < moveThreadCount }
 * @ param stepIndex at least 0
 * @ param moveIndex at least 0
 * @ param move never null
 * @ param score never null
 * @ see BlockingQueue # add ( Object ) */
public void addMove ( int moveThreadIndex , int stepIndex , int moveIndex , Move < Solution_ > move , Score score ) { } }

implementation:
MoveResult < Solution_ > result = new MoveResult < > ( moveThreadIndex , stepIndex , moveIndex , move , true , score ) ; synchronized ( this ) { if ( result . getStepIndex ( ) != filterStepIndex ) { // Discard element from previous step
return ; } innerQueue . add ( result ) ; }


signature:
public class OrderByMoveIndexBlockingQueue { /** * This method is thread - safe . It can be called from any move thread .
 * Previous results ( that haven ' t been consumed yet ) , will still be returned during iteration
 * before the iteration throws an exception ,
 * unless there ' s a lower moveIndex that isn ' t in the queue yet .
 * @ param moveThreadIndex { @ code 0 < = moveThreadIndex < moveThreadCount }
 * @ param throwable never null */
public void addExceptionThrown ( int moveThreadIndex , Throwable throwable ) { } }

implementation: MoveResult < Solution_ > result = new MoveResult < > ( moveThreadIndex , throwable ) ; synchronized ( this ) { innerQueue . add ( result ) ; }


signature:
public class OrderByMoveIndexBlockingQueue { /** * Not thread - safe . Can only be called from the solver thread .
 * @ return never null
 * @ throws InterruptedException if interrupted
 * @ see BlockingQueue # take ( ) */
public MoveResult < Solution_ > take ( ) throws InterruptedException { } }

implementation:
int moveIndex = nextMoveIndex ; nextMoveIndex ++ ; if ( ! backlog . isEmpty ( ) ) { MoveResult < Solution_ > result = backlog . remove ( moveIndex ) ; if ( result != null ) { return result ; } } while ( true ) { MoveResult < Solution_ > result = innerQueue . take ( ) ; // If 2 exceptions are added from different threads concurrently , either one could end up first .
// This is a known deviation from 100 % reproducibility , that never occurs in a success scenario .
if ( result . hasThrownException ( ) ) { throw new IllegalStateException ( "The move thread with moveThreadIndex (" + result . getMoveThreadIndex ( ) + ") has thrown an exception." + " Relayed here in the parent thread." , result . getThrowable ( ) ) ; } if ( result . getMoveIndex ( ) == moveIndex ) { return result ; } else { backlog . put ( result . getMoveIndex ( ) , result ) ; } }