Chapter 11. The InitializingScoreTrend class
You can add the InitializingScoreTrend class to optimization algorithms to specify how the score changes when additional variables are initialized and the already-initialized variables do not change. Some optimization algorithms, such Construction Heuristics and Exhaustive Search, run faster when this information is available.
You can specify one of the following trends for the score or each score level separately:
-
ANY(default): Initializing an extra variable can change the score positively or negatively. This trend does not provide a performance gain. ONLY_UP(rare): Initializing an extra variable can only change the score positively. TheONLY_UPtrend requires the following conditions:- There are only positive constraints.
- Initializing the next variable cannot unmatch a positive constraint that was matched by a previous initialized variable.
ONLY_DOWN: Initializing an additional variable can only change the score negatively.ONLY_DOWNrequires the following conditions:- There are only negative constraints.
- Initializing the next variable cannot unmatch a negative constraint that was matched by a previous initialized variable.
Most use cases have only negative constraints. Many of those use cases have an InitializingScoreTrend class that only goes down, as shown in the following example:
<scoreDirectorFactory>
<constraintProviderClass>org.optaplanner.examples.cloudbalancing.score.CloudBalancingConstraintProvider</constraintProviderClass>
<initializingScoreTrend>ONLY_DOWN</initializingScoreTrend>
</scoreDirectorFactory>Alternatively, you can also specify the trend for each score level separately, as shown in the following example:
<scoreDirectorFactory>
<constraintProviderClass>org.optaplanner.examples.cloudbalancing.score.CloudBalancingConstraintProvider</constraintProviderClass>
<initializingScoreTrend>ONLY_DOWN/ONLY_DOWN</initializingScoreTrend>
</scoreDirectorFactory>