OptaPlanner logo
  • Download
  • Learn
    • Documentation
    • Videos

    • Use cases
    • Compatibility
    • Testimonials and case studies
  • Get help
  • Blog
  • Source
  • Team
  • Services
  • Star
  • T
  • L
  • F
  • YT
Fork me on GitHub

Visualize the score and the constraints

Mon 13 March 2017
Avatar Geoffrey De Smet
Geoffrey De Smet

Twitter LinkedIn GitHub

OptaPlanner creator

So we solved the planning problem and found a best solution which has a score of 0hard/-123soft. Why -123soft? Where does that penalty come from? Which constraints are broken? Let’s see how we can break down the score and visualize the pain points in a UI.

Let’s approach this problem from two sides on the course scheduling example:

Break down score per constraint type

In the top-down approach, we split up the score per constraint type (so per score rule):

Constraint type Score impact

Room capacity

-100soft

Room stability

-40soft

Curriculum compactness

-3soft

Total

-123soft

The room capacity constraint is broken the most: it causes for 81% (100/123) of the score loss. Maybe the school should invest in more classrooms?

Heat map with score impact per planning entity

In the bottom-up approach, we visualize the score impact per lecture:

  • Red lectures impact hard constraints.

  • Orange lectures impact only soft constraints. The higher the impact, the heavier the color.

  • White lectures don’t impact the score.

Solution Normal view Indictment heat map Score

Initialized

courseScheduling0Initialized
courseScheduling0IndictmentInitialized

-4hard/-18soft

Feasible

courseScheduling1Feasible
courseScheduling1IndictmentFeasible

0hard/-68soft

Near optimal

courseScheduling2NearOptimal
courseScheduling2IndictmentNearOptimal

0hard/-1soft (*)

Optimal

courseScheduling3Optimal
courseScheduling3IndictmentOptimal

0hard/0soft

As OptaPlanner finds better and better solutions, there is less and less orange on the heat map. Looks like the history courses are particularly hard to schedule. Maybe the school should look for an additional history teacher?

(*) Notice that -1soft is shared by multiple lectures: 3 lectures break the room stability constraint together because two of them use a different room than the other one.

Show me the API

OptaPlanner 7 provides this information out of the box through the ConstraintMatch API:

scoreVisualization

First build a ScoreDirector with Solver.getScoreDirectorFactory() and then:

  • Break down the score per constraint type with ScoreDirector.getConstraintMatchTotals(). Each ConstraintMatchTotal represents one score rule and has its total score.

  • Determine the score impact per planning entity with ScoreDirector.getIndictmentMap(). Each Indictment holds the total score impact of one planning entity. Use that score to create the heat map in your UI.

Try it out

  1. Download OptaPlanner 7.0.0.CR1 or higher.

  2. Run an example and load a dataset.

  3. Click on the flame button at the bottom left.

  4. Click the solve button.

Conclusion

Help the user make sense of the resulting score. Visualize which constraints and planning entities cause most harm.


Permalink
 tagged as feature howto school timetabling

Comments

Visit our forum to comment
AtomNews feed
Don’t want to miss a single blog post?
Follow us on
  • T
  • L
  • F
Blog archive
Latest release
  • 8.35.0.Final released
    Fri 3 March 2023
Upcoming events
    Add event / Archive
Latest blog posts
  • OptaPlanner 9 is coming
    Tue 21 February 2023
    Lukáš Petrovický
  • Farewell - a new lead
    Tue 15 November 2022
    Geoffrey De Smet
  • Run OptaPlanner workloads on OpenShift, part II
    Wed 9 November 2022
    Radovan Synek
  • Bavet - A faster score engine for OptaPlanner
    Tue 6 September 2022
    Geoffrey De Smet
  • Run OptaPlanner workloads on OpenShift, part I.
    Thu 9 June 2022
    Radovan Synek
  • OptaPlanner deprecates score DRL
    Thu 26 May 2022
    Lukáš Petrovický
  • Real-time planning meets SolverManager
    Mon 7 March 2022
    Radovan Synek
  • Blog archive
Latest videos
  • The Vehicle Routing Problem
    Fri 23 September 2022
    Geoffrey De Smet
  • Introduction to OptaPlanner AI constraint solver
    Thu 25 August 2022
    Anna Dupliak
  • On schedule: Artificial Intelligence plans that meet expectations
    Sat 23 July 2022
    Geoffrey De Smet
  • Host your OptaPlanner app on OpenShift (Kubernetes)
    Mon 7 February 2022
    Geoffrey De Smet
  • OptaPlanner - A fast, easy-to-use, open source AI constraint solver for software developers
    Mon 31 January 2022
  • Order picking planning with OptaPlanner
    Fri 31 December 2021
    Anna Dupliak
  • AI lesson scheduling on Quarkus with OptaPlanner
    Thu 18 November 2021
    Geoffrey De Smet
  • Video archive

OptaPlanner is open. All dependencies of this project are available under the Apache Software License 2.0 or a compatible license. OptaPlanner is trademarked.

This website was built with JBake and is open source.

Community

  • Blog
  • Get Help
  • Team
  • Governance
  • Academic research

Code

  • Build from source
  • Issue tracker
  • Release notes
  • Upgrade recipes
  • Logo and branding
CC by 3.0 | Privacy Policy
Sponsored by Red Hat