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. The ONLY_UP trend 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_DOWN requires 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>
Copy to Clipboard Toggle word wrap

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>
Copy to Clipboard Toggle word wrap
Red Hat logoGithubredditYoutubeTwitter

Learn

Try, buy, & sell

Communities

About Red Hat Documentation

We help Red Hat users innovate and achieve their goals with our products and services with content they can trust. Explore our recent updates.

Making open source more inclusive

Red Hat is committed to replacing problematic language in our code, documentation, and web properties. For more details, see the Red Hat Blog.

About Red Hat

We deliver hardened solutions that make it easier for enterprises to work across platforms and environments, from the core datacenter to the network edge.

Theme

© 2026 Red Hat
Back to top