Uploaded image for project: 'OptaPlanner'
  1. OptaPlanner
  2. PLANNER-2744

Difference of zero constraint weight and removal of constraint

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Unresolved
    • Icon: Minor Minor
    • None
    • 8.22.0.Final
    • optaplanner-core
    • NEW
    • NEW

      Related to documentation: PLANNER-2639

      The documentation now states: "Constraints with zero constraint weight are automatically disabled and do not impose any performance penalty."

      Using zero constraint weight I got other score computing speeds than if I comment out that constraints in the constraint provider.

      Related to implementation topics:

      To reproduce I used the FacilityLocation problem of the quickstarts:

      https://github.com/kiegroup/optaplanner-quickstarts (ZIP 8.22.0 as 8.22.1.Final was not selectable as affected version in Jira) or 

      Set the two soft constraints to zero:

      https://github.com/kiegroup/optaplanner-quickstarts/blob/stable/use-cases/facility-location/src/main/java/org/acme/facilitylocation/domain/FacilityLocationConstraintConfiguration.java

      Or commented out the soft constraints in:

      https://github.com/kiegroup/optaplanner-quickstarts/blob/stable/use-cases/facility-location/src/main/java/org/acme/facilitylocation/solver/FacilityLocationConstraintProvider.java

      Score calculation speed with soft constraints set to zero:

      1st run:

      2022-06-22 12:46:03,444 INFO  [org.opt.cor.imp.con.DefaultConstructionHeuristicPhase] (pool-10-thread-1) Construction Heuristic phase (0) ended: time spent (64), best score (0hard/0soft), score calculation speed (30016/sec), step total (60).
      2022-06-22 12:46:33,380 INFO  [org.opt.cor.imp.loc.DefaultLocalSearchPhase] (pool-10-thread-1) Local Search phase (1) ended: time spent (30000), best score (0hard/0soft), score calculation speed (65610/sec), step total (1963975).
      2022-06-22 12:46:33,381 INFO  [org.opt.cor.imp.sol.DefaultSolver] (pool-10-thread-1) Solving ended: time spent (30000), best score (0hard/0soft), score calculation speed (65526/sec), phase total (2), environment mode (REPRODUCIBLE), move thread count (NONE).

       

      2nd run:

      2022-06-22 12:46:50,898 INFO  [org.opt.cor.imp.con.DefaultConstructionHeuristicPhase] (pool-16-thread-1) Construction Heuristic phase (0) ended: time spent (24), best score (0hard/0soft), score calculation speed (81863/sec), step total (60).
      2022-06-22 12:47:20,874 INFO  [org.opt.cor.imp.loc.DefaultLocalSearchPhase] (pool-16-thread-1) Local Search phase (1) ended: time spent (30000), best score (0hard/0soft), score calculation speed (66009/sec), step total (1978632).
      2022-06-22 12:47:20,874 INFO  [org.opt.cor.imp.sol.DefaultSolver] (pool-16-thread-1) Solving ended: time spent (30000), best score (0hard/0soft), score calculation speed (66015/sec), phase total (2), environment mode (REPRODUCIBLE), move thread count (NONE).

      Score calculation speed commented out soft constraints:

      1st run:

      2022-06-22 12:50:09,407 INFO  [org.opt.cor.imp.con.DefaultConstructionHeuristicPhase] (pool-22-thread-1) Construction Heuristic phase (0) ended: time spent (21), best score (0hard/0soft), score calculation speed (100055/sec), step total (60).
      2022-06-22 12:50:39,386 INFO  [org.opt.cor.imp.loc.DefaultLocalSearchPhase] (pool-22-thread-1) Local Search phase (1) ended: time spent (30000), best score (0hard/0soft), score calculation speed (91333/sec), step total (2737956).
      2022-06-22 12:50:39,386 INFO  [org.opt.cor.imp.sol.DefaultSolver] (pool-22-thread-1) Solving ended: time spent (30000), best score (0hard/0soft), score calculation speed (91326/sec), phase total (2), environment mode (REPRODUCIBLE), move thread count (NONE).

      2nd run:

      2022-06-22 12:51:38,782 INFO  [org.opt.cor.imp.con.DefaultConstructionHeuristicPhase] (pool-28-thread-1) Construction Heuristic phase (0) ended: time spent (24), best score (0hard/0soft), score calculation speed (81863/sec), step total (60).
      2022-06-22 12:52:08,757 INFO  [org.opt.cor.imp.loc.DefaultLocalSearchPhase] (pool-28-thread-1) Local Search phase (1) ended: time spent (30000), best score (0hard/0soft), score calculation speed (91576/sec), step total (2744893).
      2022-06-22 12:52:08,757 INFO  [org.opt.cor.imp.sol.DefaultSolver] (pool-28-thread-1) Solving ended: time spent (30000), best score (0hard/0soft), score calculation speed (91557/sec), phase total (2), environment mode (REPRODUCIBLE), move thread count (NONE).

            Unassigned Unassigned
            optazen Simon Tiffert (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: