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

Potential polymorphism bug: EntityDescriptor.getGenuineVariableDescriptors() used when declared but not effective descriptors wanted

XMLWordPrintable

    • NEW
    • NEW

      In:

      org.optaplanner.core.config.heuristic.selector.move.generic.ChangeMoveSelectorConfig#buildUnfoldedMoveSelectorConfig(org.optaplanner.core.config.heuristic.policy.HeuristicConfigPolicy)

      This code is potentially bad:

          @Override
          protected MoveSelectorConfig buildUnfoldedMoveSelectorConfig(HeuristicConfigPolicy configPolicy) {
              ...
                  entityDescriptors = configPolicy.getSolutionDescriptor().getGenuineEntityDescriptors();
              ...
              for (EntityDescriptor entityDescriptor : entityDescriptors) {
                  ...
                  } else {
                      variableDescriptorList.addAll(entityDescriptor.getGenuineVariableDescriptors()); // Should be declared only? Now its effective.
                  }...
          }
      

      if Cat extends Animal and Animal has a genuine planning variable "foo" and both Cat and Animal are a genuine planning entity, then "foo" is added twice I think.

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

                Created:
                Updated: