OptaPlanner : ValueSelector can not use ValueRangeType.FROM_PLANNING_ENTITY_PROPERTY

≡放荡痞女 提交于 2019-12-20 06:57:41

问题


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.


回答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.



来源:https://stackoverflow.com/questions/26794063/optaplanner-valueselector-can-not-use-valuerangetype-from-planning-entity-prop

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!