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

ScoreVerifier: simplify usage by relying on @ConstraintWeight

    XMLWordPrintable

Details

    • Feature Request
    • Resolution: Won't Do
    • Major
    • None
    • None
    • optaplanner-test
    • 2018 Week 45-47
    • 8
    • NEW
    • NEW

    Description

      Currently ScoreVerifier is used like this:

          private HardMediumSoftScoreVerifier<MeetingSchedule> scoreVerifier = new HardMediumSoftScoreVerifier<>(
                  SolverFactory.createFromXmlResource(MeetingSchedulingApp.SOLVER_CONFIG));
      ...
      
              MeetingAssignment ma1 = solution.getMeetingAssignmentList().get(1);
              ma1.setStartingTimeGrain(solution.getTimeGrainList().get(2));
              ma1.setRoom(solution.getRoomList().get(1));
      
              scoreVerifier.assertSoftWeight("Room stability", -7 * constraintConfiguration.getRoomStability().getSoftScore(), solution);
      

      That use of constraintConfiguration and the need to specify "soft" is no longer needed, now that we have @ConstraintWeight.

      That last line should look more like this:

          ...
              scoreVerifier.assertPenalty("Room stability", 7, solution);
      

      Requirements:

      • Unignore ConferenceSchedulingScoreHardConstraintTest and ConferenceSchedulingScoreSoftConstraintTest
      • There should be both an assertPenalty and assertReward method
      • Regardless of the default constraintWeight for "Room stability", it overwrites that to weight to 1soft and verifies that the result is indeed -7soft.
      • The constrainstWeight of all other constraints are set to score ZERO, to make the unit tests faster.
      • Notice how the testing code is now indepent of score level or score weight of the default ConstraintConfiguration.

      TODO:

      • Design ScoreVerifier API additions by writing strawmans, present to Geoffrey/Radovan/Jiri
      • Adjust all examples that could benefit from this
      • Write docs (extend existing section)
      • Add in upgrade recipe and release notes
      • Make a separate jira to take advantage of this to simplify the test xlsx work of conference scheduling for the user (no need to specify a score per sheet, but a penalty/reward instead)

      Attachments

        Activity

          People

            gdesmet@redhat.com Geoffrey De Smet (Inactive)
            gdesmet@redhat.com Geoffrey De Smet (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: