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

Nearby selector drops the first entity/value instead of the origin entity

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • Minor
    • 8.37.0.Final
    • 7.0.0.Final, 7.38.0.Final
    • optaplanner-core
    • None
    • 2023 Week 03-05 (from Jan 16), 2023 Week 06-08 (from Feb 6), 2023 Week 09-11 (from Feb 27), 2023 Week 12-14 (from Mar 20)
    • Hide

      1. Apply first.diff to 7.38.0.Final
      2. Run the vehicle routing example with any problem (I recommend cvrp-32customers.xml as it uses all vehicles normally)
      => the first vehicle is not assigned

      1. Apply second.diff to 7.38.0.Final
      2.. Run the vehicle routing example on cvrp-reproducer.xml
      => The problem remains uninitialized as the only vehicle had been filtered out

      Show
      1. Apply first.diff to 7.38.0.Final 2. Run the vehicle routing example with any problem (I recommend cvrp-32customers.xml as it uses all vehicles normally) => the first vehicle is not assigned 1. Apply second.diff to 7.38.0.Final 2.. Run the vehicle routing example on cvrp-reproducer.xml => The problem remains uninitialized as the only vehicle had been filtered out
    • NEW
    • NEW

    Description

      The NearbyEntityValueSelector drops the first (nearest) value if the value class.isAssignableFrom(entity class) is true. I guess the purpose of this behavior is to remove the origin entity itself from the values.
      The problem is if a NearbyDistanceMeter returns 0 for values other than the origin entity, the order of the values depends on the order of valueRangeProviderRefs, and the first value is not guaranteed to be the origin entity. This could result some values may remain unused, for example when every move is nearby selected.
      I attached two reproducers for the vehicle routing example. Both has a CH with nearby selection, the first is an example problem with a customer and a vehicle at the same location, the second is a slightly modified distance meter which ruins any problem.
      The easiest workaround is to change the order of the valueRangeProviderRefs on previousStandstill.

      Attachments

        1. first.diff
          3 kB
        2. second.diff
          3 kB

        Activity

          People

            jlocker Jiří Locker
            firesharker Balint Fabry (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: