0

I am using MoveSelector configuration in the ConstructionHeuristic Phase. It works fine with configuring filterClass and comparatorClass in EntitySelector.

However, in ValueSelector session, I am not able to use "ValueRangeType.FROM_PLANNING_ENTITY_PROPERTY" planning variable. It throws this exception: java.lang.IllegalArgumentException: The valueSelectorConfig (ValueSelectorConfig(row)) with resolvedCacheType (PHASE) and resolvedSelectionOrder (SORTED) needs to be based on a EntityIndependentValueSelector (FromEntityPropertyValueSelector(row)). Check your @ValueRangeProvider annotations.

Example NQueen Config: ...

<changeMoveSelector>
    <entitySelector mimicSelectorRef="placerEntitySelector">
    </entitySelector>
    <valueSelector>
       <variableName>row</variableName>
       <cacheType>PHASE</cacheType>
       <selectionOrder>SORTED</selectionOrder>
       <sorterComparatorClass>..RowWeightStrength</sorterComparatorClass>
    </valueSelector>
</changeMoveSelector>

....

** I need to use the valueRange depends on my planning Entity in order to use PossibleRowList for each Queen (for the performance sake) Any suggestion please? Thanks in advance.

sky.flyer
  • 91
  • 8
  • "ValueRangeType.FROM_PLANNING_ENTITY_PROPERTY" is optaplanner 6.0 IIRC, you might want to upgrade to 6.1 or 6.2, just follow [the upgrade recipe](https://github.com/droolsjbpm/optaplanner/blob/master/optaplanner-distribution/src/main/assembly/filtered-resources/UpgradeFromPreviousVersionRecipe.txt) – Geoffrey De Smet Nov 07 '14 at 17:05

1 Answers1

1

That valueSelector is SORTED, so it needs to cache (to be able to sort them). But caching with a @ValueRangeProvider per entity is not supported if I recall correctly.

This implies that the CH with a @ValueRangeProvider per entity only supports FIRST_FIT and FIRST_FIT_DECREASING, but not WEAKEST_FIT or STRONGEST_FIT. I believe there's a jira for this already (do link it here if you find it). We need to fix this.

Meanwhile: a workaround would be to not use SORTED, but already sort them in each entity's value range list.

Geoffrey De Smet
  • 26,223
  • 11
  • 73
  • 120